[RFC 01/11] net: phy: Don't report success if devices weren't found

From: Jeremy Linton
Date: Fri May 22 2020 - 17:32:07 EST


C45 devices are to return 0 for registers they haven't
implemented. This means in theory we can terminate the
device search loop without finding any MMDs. In that
case we want to immediately return indicating that
nothing was found rather than continuing to probe
and falling into the success state at the bottom.

Signed-off-by: Jeremy Linton <jeremy.linton@xxxxxxx>
---
drivers/net/phy/phy_device.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ac2784192472..245899b58a7d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -742,6 +742,12 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
}
}

+ /* no reported devices */
+ if (*devs == 0) {
+ *phy_id = 0xffffffff;
+ return 0;
+ }
+
/* Now probe Device Identifiers for each device present. */
for (i = 1; i < num_ids; i++) {
if (!(c45_ids->devices_in_package & (1 << i)))
--
2.26.2