From 123ca114e07ecf28aa2538748d733e2b22d8b8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= 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 --- drivers/net/ftgmac100.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/net/ftgmac100.c') diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index aa719d2..626c27d 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -549,17 +549,12 @@ static int ftgmac100_of_to_plat(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); struct ftgmac100_data *priv = dev_get_priv(dev); - const char *phy_mode; pdata->iobase = dev_read_addr(dev); - pdata->phy_interface = -1; - phy_mode = dev_read_string(dev, "phy-mode"); - if (phy_mode) - pdata->phy_interface = phy_get_interface_by_name(phy_mode); - if (pdata->phy_interface == -1) { - dev_err(dev, "Invalid PHY interface '%s'\n", phy_mode); + + pdata->phy_interface = dev_read_phy_mode(dev); + if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) return -EINVAL; - } pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0); -- cgit v1.1