Subject: Re: [PATCH net-next 2/2] lan78xx: update eee code

From: Florian Fainelli <[email-masked]>
Date: Fri, 21 Aug 2015 14:56:35 -0700

On 21/08/15 14:41, [email-masked] wrote:
> Patch to pdate EEE code.

This really deserves a better explanation of what is it that you are
fixing here.

> 
> Signed-off-by: Woojung Huh <[email-masked]>
> ---
>  drivers/net/usb/lan78xx.c | 44 ++++++++++++++++++++++++--------------------
>  drivers/net/usb/lan78xx.h | 22 +++++++++++-----------
>  2 files changed, 35 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 4bcbf28..af102b0 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1296,38 +1296,37 @@ static int lan78xx_get_eee(struct net_device *net, struct ethtool_eee *edata)
>  	if (ret < 0)
>  		return ret;
>  
> +	buf = lan78xx_mmd_read(dev->net, dev->mii.phy_id,
> +			       PHY_MMD_DEV_7, PHY_EEE_ADVERTISEMENT);
> +	adv = mmd_eee_adv_to_ethtool_adv_t(buf);
> +	buf = lan78xx_mmd_read(dev->net, dev->mii.phy_id,
> +			       PHY_MMD_DEV_7, PHY_EEE_LP_ADVERTISEMENT);
> +	lpadv = mmd_eee_adv_to_ethtool_adv_t(buf);

Considering your function signatures, it sounds like you should
implement a libphy driver and you could get things like phy_init_eee()
for free.

[snip]

>  	/* enable PHY interrupts */
>  	ret = lan78xx_read_reg(dev, INT_EP_CTL, &buf);
>  	buf |= INT_ENP_PHY_INT;
> diff --git a/drivers/net/usb/lan78xx.h b/drivers/net/usb/lan78xx.h
> index ae7562e..95e721b 100644
> --- a/drivers/net/usb/lan78xx.h
> +++ b/drivers/net/usb/lan78xx.h
> @@ -1047,23 +1047,23 @@
>  #define PHY_MMD_DEV_3				3
>  
>  #define PHY_EEE_PCS_STATUS			(0x1)
> -#define PHY_EEE_PCS_STATUS_TX_LPI_RCVD_		((WORD)0x0800)
> -#define PHY_EEE_PCS_STATUS_RX_LPI_RCVD_		((WORD)0x0400)
> -#define PHY_EEE_PCS_STATUS_TX_LPI_IND_		((WORD)0x0200)
> -#define PHY_EEE_PCS_STATUS_RX_LPI_IND_		((WORD)0x0100)
> -#define PHY_EEE_PCS_STATUS_PCS_RCV_LNK_STS_	((WORD)0x0004)
> +#define PHY_EEE_PCS_STATUS_TX_LPI_RCVD_		(0x0800)
> +#define PHY_EEE_PCS_STATUS_RX_LPI_RCVD_		(0x0400)
> +#define PHY_EEE_PCS_STATUS_TX_LPI_IND_		(0x0200)
> +#define PHY_EEE_PCS_STATUS_RX_LPI_IND_		(0x0100)
> +#define PHY_EEE_PCS_STATUS_PCS_RCV_LNK_STS_	(0x0004)

Can you look at updating include/uapi/linux/mdio.h with the missing
registers for your use case instead of replicating this in a driver?
-- 
Florian