lkml.org 
[lkml]   [2019]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net] net: phy: Don't assume loopback is supported
From
Date
On 14.03.2019 11:37, Jose Abreu wrote:
> Some PHYs may not support loopback mode so we need to check if register
> is read-only.
>
As I read Clause 22 this is a mandatory feature, the related bit is
specified as R/W. Do you have an actual example of a PHY w/o loopback
mode that doesn't allow to change this bit?

> 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>
> ---
> 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);
>
>

\
 
 \ /
  Last update: 2019-03-16 00:14    [W:0.067 / U:17.880 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site