Skip to content

Commit f4f86d8

Browse files
oleremdavem330
authored andcommitted
net: phy: execute genphy_loopback() per default on all PHYs
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>
1 parent e9377a9 commit f4f86d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,9 @@ int phy_loopback(struct phy_device *phydev, bool enable)
17771777
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
17781778
int ret = 0;
17791779

1780+
if (!phydrv)
1781+
return -ENODEV;
1782+
17801783
mutex_lock(&phydev->lock);
17811784

17821785
if (enable && phydev->loopback_enabled) {
@@ -1789,10 +1792,10 @@ int phy_loopback(struct phy_device *phydev, bool enable)
17891792
goto out;
17901793
}
17911794

1792-
if (phydev->drv && phydrv->set_loopback)
1795+
if (phydrv->set_loopback)
17931796
ret = phydrv->set_loopback(phydev, enable);
17941797
else
1795-
ret = -EOPNOTSUPP;
1798+
ret = genphy_loopback(phydev, enable);
17961799

17971800
if (ret)
17981801
goto out;

0 commit comments

Comments
 (0)