[RFC PATCH 2/3] net: phy: Add helper routines to set and clear bits

Michal Simek michal.simek at xilinx.com
Tue Apr 21 10:04:52 CEST 2020


On 20. 04. 20 20:53, Dan Murphy wrote:
> Add phy_set/clear_bit helper routines so that ported drivers from the
> kernel can use these functions.
> 
> Signed-off-by: Dan Murphy <dmurphy at ti.com>
> ---
>  include/phy.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/include/phy.h b/include/phy.h
> index b5de14cbfc29..050c989fa537 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -257,6 +257,44 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
>  	return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val);
>  }
>  

kernel-doc description would be good.

> +static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad,
> +				   u32 regnum, u16 val)
> +{
> +	int value;
> +	int ret;

nit: on one line should be better.

> +
> +	value = phy_read_mmd(phydev, devad, regnum);
> +	if (value < 0)
> +		return value;
> +
> +	value |= val;
> +
> +	ret = phy_write_mmd(phydev, devad, regnum, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,
> +				     u32 regnum, u16 val)
> +{
> +	int value;
> +	int ret;

ditto.

> +
> +	value = phy_read_mmd(phydev, devad, regnum);
> +	if (value < 0)
> +		return value;
> +
> +	value &= ~val;
> +
> +	ret = phy_write_mmd(phydev, devad, regnum, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  #ifdef CONFIG_PHYLIB_10G
>  extern struct phy_driver gen10g_driver;
>  

Thanks,
Michal




More information about the U-Boot mailing list