]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: phy: implement fallback mechanism for negative phy adresses
authorHannes Schmelzer <hannes.schmelzer@br-automation.com>
Fri, 29 Mar 2019 08:54:05 +0000 (09:54 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 4 Jun 2019 10:44:49 +0000 (12:44 +0200)
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 <hannes.schmelzer@br-automation.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/phy/phy.c

index ebe07fcaaf12ad275afaec6f6d03d546c2f566ab..7fb83ce7539dfb3202e2f06f9b41cb370fc366df 100644 (file)
@@ -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);