diff mbox series

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

Message ID 20240218190034.15447-5-ansuelsmth@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: phy: support multi PHY in phy_driver Was: net: phy: detach PHY driver OPs from phy_driver struct | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 957 this patch: 957
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christian Marangi Feb. 18, 2024, 7 p.m. UTC
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@gmail.com>
---
 drivers/net/phy/phy_device.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

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 */