diff mbox series

[v2,1/4] net: phy: Port set/clear bits from Linux

Message ID 20241120094903.94-1-paul.barker.ct@bp.renesas.com
State New
Delegated to: Marek Vasut
Headers show
Series [v2,1/4] net: phy: Port set/clear bits from Linux | expand

Commit Message

Paul Barker Nov. 20, 2024, 9:49 a.m. UTC
To simply porting phy drivers from Linux to U-Boot, define
phy_set_bits() and phy_clear_bits() functions with a similar API to
those used in Linux.

The U-Boot versions of these functions include the `devad` argument
which is not present in the Linux versions, to keep them aligned with
the other phy functions in U-Boot.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Changes v1->v2:
  - Split out of series adding RZ/G2L Ethernet support [1]
  - Added Marek's Reviewed-by tag

[1]: https://lore.kernel.org/all/20241024152448.102-1-paul.barker.ct@bp.renesas.com/

 include/phy.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Quentin Schulz Nov. 25, 2024, 4:42 p.m. UTC | #1
Hi Paul,

On 11/20/24 10:49 AM, Paul Barker wrote:
> To simply porting phy drivers from Linux to U-Boot, define
> phy_set_bits() and phy_clear_bits() functions with a similar API to
> those used in Linux.
> 
> The U-Boot versions of these functions include the `devad` argument
> which is not present in the Linux versions, to keep them aligned with
> the other phy functions in U-Boot.
> 
> Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Changes v1->v2:
>    - Split out of series adding RZ/G2L Ethernet support [1]
>    - Added Marek's Reviewed-by tag
> 
> [1]: https://lore.kernel.org/all/20241024152448.102-1-paul.barker.ct@bp.renesas.com/
> 
>   include/phy.h | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 
> diff --git a/include/phy.h b/include/phy.h
> index 36785031eeb0..510b0a21831b 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -333,6 +333,28 @@ int gen10g_startup(struct phy_device *phydev);
>   int gen10g_shutdown(struct phy_device *phydev);
>   int gen10g_discover_mmds(struct phy_device *phydev);
>   
> +/**
> + * phy_set_bits - Convenience function for setting bits in a PHY register
> + * @phydev: the phy_device struct

Please document devad parameter here as well?

> + * @regnum: register number to write
> + * @val: bits to set
> + */
> +static inline int phy_set_bits(struct phy_device *phydev, int devad, u32 regnum, u16 val)
> +{
> +	return phy_modify(phydev, devad, regnum, 0, val);
> +}
> +
> +/**
> + * phy_clear_bits - Convenience function for clearing bits in a PHY register
> + * @phydev: the phy_device struct

Please document devad parameter here as well?

> + * @regnum: register number to write
> + * @val: bits to clear
> + */
> +static inline int phy_clear_bits(struct phy_device *phydev, int devad, u32 regnum, u16 val)
> +{

Looking good to me otherwise.

Cheers,
Quentin
Paul Barker Dec. 5, 2024, 6:56 p.m. UTC | #2
On 25/11/2024 16:42, Quentin Schulz wrote:
> Hi Paul,
> 
> On 11/20/24 10:49 AM, Paul Barker wrote:
>> To simply porting phy drivers from Linux to U-Boot, define
>> phy_set_bits() and phy_clear_bits() functions with a similar API to
>> those used in Linux.
>>
>> The U-Boot versions of these functions include the `devad` argument
>> which is not present in the Linux versions, to keep them aligned with
>> the other phy functions in U-Boot.
>>
>> Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
>> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
>> ---
>> Changes v1->v2:
>>    - Split out of series adding RZ/G2L Ethernet support [1]
>>    - Added Marek's Reviewed-by tag
>>
>> [1]: https://lore.kernel.org/all/20241024152448.102-1-paul.barker.ct@bp.renesas.com/
>>
>>   include/phy.h | 22 ++++++++++++++++++++++
>>   1 file changed, 22 insertions(+)
>>
>> diff --git a/include/phy.h b/include/phy.h
>> index 36785031eeb0..510b0a21831b 100644
>> --- a/include/phy.h
>> +++ b/include/phy.h
>> @@ -333,6 +333,28 @@ int gen10g_startup(struct phy_device *phydev);
>>   int gen10g_shutdown(struct phy_device *phydev);
>>   int gen10g_discover_mmds(struct phy_device *phydev);
>>   
>> +/**
>> + * phy_set_bits - Convenience function for setting bits in a PHY register
>> + * @phydev: the phy_device struct
> 
> Please document devad parameter here as well?

Ah, I forgot to add devad to the documentation comment when I added it
to the function signature. I'll do that for v3.

> 
>> + * @regnum: register number to write
>> + * @val: bits to set
>> + */
>> +static inline int phy_set_bits(struct phy_device *phydev, int devad, u32 regnum, u16 val)
>> +{
>> +	return phy_modify(phydev, devad, regnum, 0, val);
>> +}
>> +
>> +/**
>> + * phy_clear_bits - Convenience function for clearing bits in a PHY register
>> + * @phydev: the phy_device struct
> 
> Please document devad parameter here as well?

As above.

Thanks for the review!
diff mbox series

Patch

diff --git a/include/phy.h b/include/phy.h
index 36785031eeb0..510b0a21831b 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -333,6 +333,28 @@  int gen10g_startup(struct phy_device *phydev);
 int gen10g_shutdown(struct phy_device *phydev);
 int gen10g_discover_mmds(struct phy_device *phydev);
 
+/**
+ * phy_set_bits - Convenience function for setting bits in a PHY register
+ * @phydev: the phy_device struct
+ * @regnum: register number to write
+ * @val: bits to set
+ */
+static inline int phy_set_bits(struct phy_device *phydev, int devad, u32 regnum, u16 val)
+{
+	return phy_modify(phydev, devad, regnum, 0, val);
+}
+
+/**
+ * phy_clear_bits - Convenience function for clearing bits in a PHY register
+ * @phydev: the phy_device struct
+ * @regnum: register number to write
+ * @val: bits to clear
+ */
+static inline int phy_clear_bits(struct phy_device *phydev, int devad, u32 regnum, u16 val)
+{
+	return phy_modify(phydev, devad, regnum, val, 0);
+}
+
 /**
  * U_BOOT_PHY_DRIVER() - Declare a new U-Boot driver
  * @__name: name of the driver