[net-next RFC PATCH 4/6] net: phy: support named mdio_device_id PHY IDs

From: Christian Marangi
Date: Sun Feb 18 2024 - 14:04:03 EST


PHY IDs defined in PHY driver .ids can have a more specific name
defined. If this is the case, overwrite the PHY istance dev name with
the more specific one from the matching dev_id.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
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 60a60f182729..9e359e304f91 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3471,9 +3471,15 @@ static int phy_probe(struct device *dev)
*/
if (phy_driver_match(phydrv, phydev, &dev_id) && dev_id) {
memcpy(phy_dev_id, dev_id, sizeof(*dev_id));
+ /* If defined, overwrite the PHY driver dev name with a
+ * more specific one from the matching dev_id.
+ */
+ if (dev_id->name)
+ drv->name = dev_id->name;
} else {
phy_dev_id->phy_id = phydrv->phy_id;
phy_dev_id->phy_id_mask = phydrv->phy_id_mask;
+ phy_dev_id->name = phydrv->name;
}

/* Fill PHY ID with dev_id if empty and PHY is C45 */
--
2.43.0