mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
net: stmmac: mdio: use phy_find_first to simplify stmmac_mdio_register
Simplify the code by using phy_find_first(). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20ca4962-9588-40b8-b021-fb349a92e9e5@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
1471a274b7
commit
4a107a0e83
@@ -584,7 +584,8 @@ int stmmac_mdio_register(struct net_device *ndev)
|
|||||||
struct device *dev = ndev->dev.parent;
|
struct device *dev = ndev->dev.parent;
|
||||||
struct fwnode_handle *fixed_node;
|
struct fwnode_handle *fixed_node;
|
||||||
struct fwnode_handle *fwnode;
|
struct fwnode_handle *fwnode;
|
||||||
int addr, found, max_addr;
|
struct phy_device *phydev;
|
||||||
|
int max_addr;
|
||||||
|
|
||||||
if (!mdio_bus_data)
|
if (!mdio_bus_data)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -668,40 +669,30 @@ int stmmac_mdio_register(struct net_device *ndev)
|
|||||||
if (priv->plat->phy_node || mdio_node)
|
if (priv->plat->phy_node || mdio_node)
|
||||||
goto bus_register_done;
|
goto bus_register_done;
|
||||||
|
|
||||||
found = 0;
|
phydev = phy_find_first(new_bus);
|
||||||
for (addr = 0; addr < max_addr; addr++) {
|
if (!phydev || phydev->mdio.addr > max_addr) {
|
||||||
struct phy_device *phydev = mdiobus_get_phy(new_bus, addr);
|
dev_warn(dev, "No PHY found\n");
|
||||||
|
err = -ENODEV;
|
||||||
if (!phydev)
|
goto no_phy_found;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If an IRQ was provided to be assigned after
|
* If an IRQ was provided to be assigned after
|
||||||
* the bus probe, do it here.
|
* the bus probe, do it here.
|
||||||
*/
|
*/
|
||||||
if (!mdio_bus_data->irqs &&
|
if (!mdio_bus_data->irqs && mdio_bus_data->probed_phy_irq > 0) {
|
||||||
(mdio_bus_data->probed_phy_irq > 0)) {
|
new_bus->irq[phydev->mdio.addr] = mdio_bus_data->probed_phy_irq;
|
||||||
new_bus->irq[addr] = mdio_bus_data->probed_phy_irq;
|
|
||||||
phydev->irq = mdio_bus_data->probed_phy_irq;
|
phydev->irq = mdio_bus_data->probed_phy_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're going to bind the MAC to this PHY bus,
|
* If we're going to bind the MAC to this PHY bus, and no PHY number
|
||||||
* and no PHY number was provided to the MAC,
|
* was provided to the MAC, use the one probed here.
|
||||||
* use the one probed here.
|
|
||||||
*/
|
*/
|
||||||
if (priv->plat->phy_addr == -1)
|
if (priv->plat->phy_addr == -1)
|
||||||
priv->plat->phy_addr = addr;
|
priv->plat->phy_addr = phydev->mdio.addr;
|
||||||
|
|
||||||
phy_attached_info(phydev);
|
phy_attached_info(phydev);
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found && !mdio_node) {
|
|
||||||
dev_warn(dev, "No PHY found\n");
|
|
||||||
err = -ENODEV;
|
|
||||||
goto no_phy_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
bus_register_done:
|
bus_register_done:
|
||||||
priv->mii = new_bus;
|
priv->mii = new_bus;
|
||||||
|
|||||||
Reference in New Issue
Block a user