From: Hannes Schmelzer Date: Fri, 29 Mar 2019 08:54:05 +0000 (+0100) Subject: net: phy: implement fallback mechanism for negative phy adresses X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f89b5cc3efc944679ed10ef8c640cb8e2ce65dcc;p=thirdparty%2Fu-boot.git net: phy: implement fallback mechanism for negative phy adresses Negative phy-addresses can occour if the caller function was not able to determine a valid phy address (from device-tree for example). In this case we catch this here and search for ANY phy device on the given mdio- bus. Signed-off-by: Hannes Schmelzer Signed-off-by: Michal Simek --- diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ebe07fcaaf1..7fb83ce7539 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -977,6 +977,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, #endif { struct phy_device *phydev = NULL; + uint mask = (addr > 0) ? (0x1 << addr) : 0xffffffff; #ifdef CONFIG_PHY_FIXED phydev = phy_connect_fixed(bus, dev, interface); @@ -987,7 +988,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, #endif if (!phydev) - phydev = phy_find_by_mask(bus, 1 << addr, interface); + phydev = phy_find_by_mask(bus, mask, interface); if (phydev) phy_connect_dev(phydev, dev);