]> git.dujemihanovic.xyz Git - 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)
committerTom Rini <trini@konsulko.com>
Mon, 8 Apr 2019 00:31:16 +0000 (20:31 -0400)
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>
Tested-by: Michal Simek <michal.simek@xilinx.com>
Tested-by: Lukasz Majewski <lukma@denx.de>
drivers/net/phy/phy.c

index 0c8b29dae44a40b56a8b4a02ac91b176268e2bd0..4e8d2943eee1cf1c95c06fcfd60c860a92f85e44 100644 (file)
@@ -922,13 +922,14 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
 #endif
 {
        struct phy_device *phydev = NULL;
+       uint mask = (addr > 0) ? (1 << addr) : 0xffffffff;
 
 #ifdef CONFIG_PHY_FIXED
        phydev = phy_connect_fixed(bus, dev, interface);
 #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);