]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: phy: execute genphy_loopback() per default on all PHYs
authorOleksij Rempel <o.rempel@pengutronix.de>
Mon, 19 Apr 2021 13:01:01 +0000 (15:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Apr 2021 23:08:02 +0000 (16:08 -0700)
The generic loopback is really generic and is defined by the 802.3
standard, we should just mandate that drivers implement a custom
loopback if the generic one cannot work.

Suggested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c

index 73d29fd5e03dfbe504ebe9a1e1c0ce490079ba78..320a3e5cd10a81914160064f453094f1439a4e2b 100644 (file)
@@ -1777,6 +1777,9 @@ int phy_loopback(struct phy_device *phydev, bool enable)
        struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
        int ret = 0;
 
+       if (!phydrv)
+               return -ENODEV;
+
        mutex_lock(&phydev->lock);
 
        if (enable && phydev->loopback_enabled) {
@@ -1789,10 +1792,10 @@ int phy_loopback(struct phy_device *phydev, bool enable)
                goto out;
        }
 
-       if (phydev->drv && phydrv->set_loopback)
+       if (phydrv->set_loopback)
                ret = phydrv->set_loopback(phydev, enable);
        else
-               ret = -EOPNOTSUPP;
+               ret = genphy_loopback(phydev, enable);
 
        if (ret)
                goto out;