netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Jose Abreu <jose.abreu@synopsys.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Joao Pinto <joao.pinto@synopsys.com>
Subject: Re: [PATCH net] net: phy: Don't assume loopback is supported
Date: Fri, 15 Mar 2019 15:48:41 -0700	[thread overview]
Message-ID: <19c8d2b3-bffe-b3b2-6e91-e878f89e5247@gmail.com> (raw)
In-Reply-To: <eeea080649153eefafef8ff93274733fe8f25b01.1552559796.git.joabreu@synopsys.com>

On 3/14/19 3:37 AM, Jose Abreu wrote:
> Some PHYs may not support loopback mode so we need to check if register
> is read-only.
> 

In that case it may be appropriate to have a specific PHY driver that
implements a set_loopback() method returning -EOPNOTSUPP instead of
changing the generic PHY implementation.

> Fixes: f0f9b4ed2338 ("net: phy: Add phy loopback support in net phy framework")
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Joao Pinto <joao.pinto@synopsys.com>

This looks fine anyway:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> ---
>  drivers/net/phy/phy_device.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 49fdd1ee798e..a749639d98c3 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1918,8 +1918,24 @@ EXPORT_SYMBOL(genphy_resume);
>  
>  int genphy_loopback(struct phy_device *phydev, bool enable)
>  {
> -	return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
> -			  enable ? BMCR_LOOPBACK : 0);
> +	int ret;
> +
> +	ret = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
> +			 enable ? BMCR_LOOPBACK : 0);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = phy_read(phydev, MII_BMCR);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (enable) {
> +		if (ret & BMCR_LOOPBACK)
> +			return 0;
> +		return -EOPNOTSUPP;
> +	}
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL(genphy_loopback);
>  
> 


-- 
Florian

  parent reply	other threads:[~2019-03-15 22:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 10:37 [PATCH net] net: phy: Don't assume loopback is supported Jose Abreu
2019-03-15 22:43 ` David Miller
2019-03-15 22:48 ` Florian Fainelli [this message]
2019-03-17 18:38   ` Andrew Lunn
2019-03-18 12:46     ` Jose Abreu
2019-03-18 14:19       ` Andrew Lunn
2019-03-15 23:14 ` Heiner Kallweit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19c8d2b3-bffe-b3b2-6e91-e878f89e5247@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=joao.pinto@synopsys.com \
    --cc=jose.abreu@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).