From 123ca114e07ecf28aa2538748d733e2b22d8b8b5 Mon Sep 17 00:00:00 2001 From: Marek BehĂșn Date: Thu, 7 Apr 2022 00:33:01 +0200 Subject: net: introduce helpers to get PHY interface mode from a device/ofnode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add helpers ofnode_read_phy_mode() and dev_read_phy_mode() to parse the "phy-mode" / "phy-connection-type" property. Add corresponding UT test. Use them treewide. This allows us to inline the phy_get_interface_by_name() into ofnode_read_phy_mode(), since the former is not used anymore. Signed-off-by: Marek BehĂșn Reviewed-by: Ramon Fried Tested-by: Patrice Chotard --- net/mdio-uclass.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'net') diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index bef8280e21..874f59413a 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -15,11 +15,6 @@ #include #include -/* DT node properties for MAC-PHY interface */ -static const char * const phy_mode_str[] = { - "phy-mode", "phy-connection-type" -}; - void dm_mdio_probe_devices(void) { struct udevice *it; @@ -195,26 +190,15 @@ out: /* Connect to a PHY linked in eth DT node */ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) { - const char *if_str; phy_interface_t interface; struct phy_device *phy; - int i; if (!dev_has_ofnode(ethdev)) { debug("%s: supplied eth dev has no DT node!\n", ethdev->name); return NULL; } - interface = PHY_INTERFACE_MODE_NONE; - for (i = 0; i < ARRAY_SIZE(phy_mode_str); i++) { - if_str = dev_read_string(ethdev, phy_mode_str[i]); - if (if_str) { - interface = phy_get_interface_by_name(if_str); - break; - } - } - if (interface < 0) - interface = PHY_INTERFACE_MODE_NONE; + interface = dev_read_phy_mode(ethdev); if (interface == PHY_INTERFACE_MODE_NONE) dev_dbg(ethdev, "can't find interface mode, default to NONE\n"); -- cgit v1.2.3