@@ -212,9 +212,10 @@ EXPORT_SYMBOL(phy_device_create);
* @c45_ids: where to store the c45 ID information.
*
* If the PHY devices-in-package appears to be valid, it and the
- * corresponding identifiers are stored in @c45_ids, zero is stored
- * in @phy_id. Otherwise 0xffffffff is stored in @phy_id. Returns
- * zero on success.
+ * corresponding identifiers are stored in @c45_ids, and the
+ * identifier of the lowest-numbered MMD is stored in @phy_id.
+ * Otherwise 0xffffffff is stored in @phy_id. Returns zero on
+ * success.
*
*/
static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
@@ -240,14 +241,15 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
if (phy_reg < 0)
return -EIO;
c45_ids->devices_in_package |= (phy_reg & 0xffff);
+ }
- /* If mostly Fs, there is no device there,
- * let's get out of here.
- */
- if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) {
- *phy_id = 0xffffffff;
- return 0;
- }
+ /* If all zeroes or mostly Fs, there is no device there, let's get
+ * out of here.
+ */
+ if (c45_ids->devices_in_package == 0 ||
+ (c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) {
+ *phy_id = 0xffffffff;
+ return 0;
}
/* Now probe Device Identifiers for each device present. */
@@ -267,7 +269,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
return -EIO;
c45_ids->device_ids[i] |= (phy_reg & 0xffff);
}
- *phy_id = 0;
+ *phy_id = c45_ids->device_ids[__ffs(c45_ids->devices_in_package)];
return 0;
}