[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200522213059.1535892-10-jeremy.linton@arm.com>
Date: Fri, 22 May 2020 16:30:57 -0500
From: Jeremy Linton <jeremy.linton@....com>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, andrew@...n.ch, f.fainelli@...il.com,
hkallweit1@...il.com, linux@...linux.org.uk,
madalin.bucur@....nxp.com, calvin.johnson@....nxp.com,
linux-kernel@...r.kernel.org, Jeremy Linton <jeremy.linton@....com>
Subject: [RFC 09/11] net: phy: Refuse to consider phy_id=0 a valid phy
This is another one of those questionable commits. In this
case a bus tagged C45_FIRST refuses to create phys
where the phy id is invalid. In general this is probably a
good idea, but might cause problems. Another idea might be to
create an additional flag (MDIOBUS_STRICT_ID?) for this case.
Or we just ignore it and accept that the probe logic as it
stands potentially creates bogus phy devices, to avoid the
case where an actual phy exists but isn't responding correctly.
Signed-off-by: Jeremy Linton <jeremy.linton@....com>
---
drivers/net/phy/phy_device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index acdada865864..e74f2ef6f12b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -789,7 +789,9 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
if (!valid_id && c22_present)
return 0;
- *phy_id = 0;
+ if (valid_id || bus->probe_capabilities != MDIOBUS_C45_FIRST)
+ *phy_id = 0;
+
return 0;
}
@@ -853,6 +855,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
if ((phy_id & 0x1fffffff) == 0x1fffffff)
return ERR_PTR(-ENODEV);
+ /* Strict scanning should also ignore phy_id = 0 */
+ if (phy_id == 0 && bus->probe_capabilities == MDIOBUS_C45_FIRST)
+ return ERR_PTR(-ENODEV);
+
return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids);
}
EXPORT_SYMBOL(get_phy_device);
--
2.26.2
Powered by blists - more mailing lists