Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ti: davinci_emac: stop using bus type mdio_bus_type

This driver is the only user of mdio_bus_type outside phylib.
Using mdio_bus_type isn't strictly needed here, so use an alternative
approach. This will allow to make mdio_bus_type private to phylib
in a follow-up series.

Compile-tested only.

Note: Devices supported by this driver are OF-only, therefore the string
comparison in match_first_device() isn't needed any longer.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/cc8e83aa-48c3-4497-b6ad-760a7f9e25dc@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Heiner Kallweit and committed by
Paolo Abeni
e07bd1f7 f56438a7

+15 -24
+15 -24
drivers/net/ethernet/ti/davinci_emac.c
··· 1389 1389 return -EOPNOTSUPP; 1390 1390 } 1391 1391 1392 - static int match_first_device(struct device *dev, const void *data) 1393 - { 1394 - if (dev->parent && dev->parent->of_node) 1395 - return of_device_is_compatible(dev->parent->of_node, 1396 - "ti,davinci_mdio"); 1397 - 1398 - return !strncmp(dev_name(dev), "davinci_mdio", 12); 1399 - } 1400 - 1401 1392 /** 1402 1393 * emac_dev_open - EMAC device open 1403 1394 * @ndev: The DaVinci EMAC network adapter ··· 1408 1417 int i = 0; 1409 1418 struct emac_priv *priv = netdev_priv(ndev); 1410 1419 struct phy_device *phydev = NULL; 1411 - struct device *phy = NULL; 1412 1420 1413 1421 ret = pm_runtime_resume_and_get(&priv->pdev->dev); 1414 1422 if (ret < 0) { ··· 1492 1502 } 1493 1503 } 1494 1504 1495 - /* use the first phy on the bus if pdata did not give us a phy id */ 1505 + /* if no phy-handle and no fixed link, use the first phy on the bus */ 1496 1506 if (!phydev && !priv->phy_id) { 1497 - /* NOTE: we can't use bus_find_device_by_name() here because 1498 - * the device name is not guaranteed to be 'davinci_mdio'. On 1499 - * some systems it can be 'davinci_mdio.0' so we need to use 1500 - * strncmp() against the first part of the string to correctly 1501 - * match it. 1502 - */ 1503 - phy = bus_find_device(&mdio_bus_type, NULL, NULL, 1504 - match_first_device); 1505 - if (phy) { 1506 - priv->phy_id = dev_name(phy); 1507 - if (!priv->phy_id || !*priv->phy_id) 1508 - put_device(phy); 1507 + struct device_node *np; 1508 + 1509 + np = of_find_compatible_node(NULL, NULL, "ti,davinci_mdio"); 1510 + if (np) { 1511 + struct mii_bus *bus = of_mdio_find_bus(np); 1512 + 1513 + if (bus) { 1514 + struct phy_device *phy = phy_find_first(bus); 1515 + 1516 + if (phy) 1517 + priv->phy_id = phydev_name(phy); 1518 + put_device(&bus->dev); /* of_mdio_find_bus */ 1519 + } 1520 + of_node_put(np); /* of_find_compatible_node */ 1509 1521 } 1510 1522 } 1511 1523 ··· 1515 1523 phydev = phy_connect(ndev, priv->phy_id, 1516 1524 &emac_adjust_link, 1517 1525 PHY_INTERFACE_MODE_MII); 1518 - put_device(phy); /* reference taken by bus_find_device */ 1519 1526 if (IS_ERR(phydev)) { 1520 1527 dev_err(emac_dev, "could not connect to phy %s\n", 1521 1528 priv->phy_id);