mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 08:08:54 +00:00
net: mdio: Move mdiobus_scan() within file
No functional change, just place it earlier in preparation for some refactoring. While at it, correct the comment format and one typo. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
c84f433ef5
commit
81d874e7c8
1 changed files with 50 additions and 51 deletions
|
@ -506,6 +506,56 @@ static int mdiobus_create_device(struct mii_bus *bus,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mdiobus_scan - scan a bus for MDIO devices.
|
||||||
|
* @bus: mii_bus to scan
|
||||||
|
* @addr: address on bus to scan
|
||||||
|
*
|
||||||
|
* This function scans the MDIO bus, looking for devices which can be
|
||||||
|
* identified using a vendor/product ID in registers 2 and 3. Not all
|
||||||
|
* MDIO devices have such registers, but PHY devices typically
|
||||||
|
* do. Hence this function assumes anything found is a PHY, or can be
|
||||||
|
* treated as a PHY. Other MDIO devices, such as switches, will
|
||||||
|
* probably not be found during the scan.
|
||||||
|
*/
|
||||||
|
struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
|
||||||
|
{
|
||||||
|
struct phy_device *phydev = ERR_PTR(-ENODEV);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
switch (bus->probe_capabilities) {
|
||||||
|
case MDIOBUS_NO_CAP:
|
||||||
|
case MDIOBUS_C22:
|
||||||
|
phydev = get_phy_device(bus, addr, false);
|
||||||
|
break;
|
||||||
|
case MDIOBUS_C45:
|
||||||
|
phydev = get_phy_device(bus, addr, true);
|
||||||
|
break;
|
||||||
|
case MDIOBUS_C22_C45:
|
||||||
|
phydev = get_phy_device(bus, addr, false);
|
||||||
|
if (IS_ERR(phydev))
|
||||||
|
phydev = get_phy_device(bus, addr, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_ERR(phydev))
|
||||||
|
return phydev;
|
||||||
|
|
||||||
|
/* For DT, see if the auto-probed phy has a corresponding child
|
||||||
|
* in the bus node, and set the of_node pointer in this case.
|
||||||
|
*/
|
||||||
|
of_mdiobus_link_mdiodev(bus, &phydev->mdio);
|
||||||
|
|
||||||
|
err = phy_device_register(phydev);
|
||||||
|
if (err) {
|
||||||
|
phy_device_free(phydev);
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
return phydev;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(mdiobus_scan);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
|
* __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
|
||||||
* @bus: target mii_bus
|
* @bus: target mii_bus
|
||||||
|
@ -679,57 +729,6 @@ void mdiobus_free(struct mii_bus *bus)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mdiobus_free);
|
EXPORT_SYMBOL(mdiobus_free);
|
||||||
|
|
||||||
/**
|
|
||||||
* mdiobus_scan - scan a bus for MDIO devices.
|
|
||||||
* @bus: mii_bus to scan
|
|
||||||
* @addr: address on bus to scan
|
|
||||||
*
|
|
||||||
* This function scans the MDIO bus, looking for devices which can be
|
|
||||||
* identified using a vendor/product ID in registers 2 and 3. Not all
|
|
||||||
* MDIO devices have such registers, but PHY devices typically
|
|
||||||
* do. Hence this function assumes anything found is a PHY, or can be
|
|
||||||
* treated as a PHY. Other MDIO devices, such as switches, will
|
|
||||||
* probably not be found during the scan.
|
|
||||||
*/
|
|
||||||
struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
|
|
||||||
{
|
|
||||||
struct phy_device *phydev = ERR_PTR(-ENODEV);
|
|
||||||
int err;
|
|
||||||
|
|
||||||
switch (bus->probe_capabilities) {
|
|
||||||
case MDIOBUS_NO_CAP:
|
|
||||||
case MDIOBUS_C22:
|
|
||||||
phydev = get_phy_device(bus, addr, false);
|
|
||||||
break;
|
|
||||||
case MDIOBUS_C45:
|
|
||||||
phydev = get_phy_device(bus, addr, true);
|
|
||||||
break;
|
|
||||||
case MDIOBUS_C22_C45:
|
|
||||||
phydev = get_phy_device(bus, addr, false);
|
|
||||||
if (IS_ERR(phydev))
|
|
||||||
phydev = get_phy_device(bus, addr, true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_ERR(phydev))
|
|
||||||
return phydev;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For DT, see if the auto-probed phy has a correspoding child
|
|
||||||
* in the bus node, and set the of_node pointer in this case.
|
|
||||||
*/
|
|
||||||
of_mdiobus_link_mdiodev(bus, &phydev->mdio);
|
|
||||||
|
|
||||||
err = phy_device_register(phydev);
|
|
||||||
if (err) {
|
|
||||||
phy_device_free(phydev);
|
|
||||||
return ERR_PTR(-ENODEV);
|
|
||||||
}
|
|
||||||
|
|
||||||
return phydev;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(mdiobus_scan);
|
|
||||||
|
|
||||||
static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
|
static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
|
||||||
{
|
{
|
||||||
preempt_disable();
|
preempt_disable();
|
||||||
|
|
Loading…
Reference in a new issue