From 01c926daf58ebd18728ddcd989c5e8f20751ecae Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 16 Oct 2018 12:15:48 -0700 Subject: net: phy: Check phy_mask in get_phy_device() Do not try to probe PHY devices if they are masked in phy_mask. This way we won't try adding devices that are unlikely to be proper PHYs by default. With this change it still remains possible to add such a device explicitly either using "miitool" or calling phy_device_create() explicilty. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- drivers/net/phy/phy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 19d458e07e..b985b75673 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -234,6 +234,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr) u32 phy_id = 0; int r; + /* skip masked out PHY addresses */ + if (bus->phy_mask & BIT(addr)) + return ERR_PTR(-ENODEV); + r = get_phy_id(bus, addr, &phy_id); if (r) return ERR_PTR(r); @@ -440,9 +444,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr, } for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) { - /* skip masked out PHY addresses */ - if (bus->phy_mask & (1 << i)) - continue; phy = mdiobus_scan(bus, i); if (IS_ERR(phy)) -- cgit v1.2.3