phylib: rework to prepare for OF registration of PHYs
This patch makes changes in preparation for supporting open firmware device tree descriptions of MDIO busses. Changes include: - Cleanup handling of phy_map[] entries; they are already NULLed when registering and so don't need to be re-cleared, and it is good practice to clear them out when unregistering. - Split phy_device registration out into a new function so that the OF helpers can do two stage registration (separate allocation and registration steps). Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Andy Fleming <afleming@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
739649c53d
commit
4dea547fef
@@ -113,7 +113,6 @@ int mdiobus_register(struct mii_bus *bus)
|
||||
bus->reset(bus);
|
||||
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++) {
|
||||
bus->phy_map[i] = NULL;
|
||||
if ((bus->phy_mask & (1 << i)) == 0) {
|
||||
struct phy_device *phydev;
|
||||
|
||||
@@ -150,6 +149,7 @@ void mdiobus_unregister(struct mii_bus *bus)
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++) {
|
||||
if (bus->phy_map[i])
|
||||
device_unregister(&bus->phy_map[i]->dev);
|
||||
bus->phy_map[i] = NULL;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(mdiobus_unregister);
|
||||
@@ -188,35 +188,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
|
||||
if (IS_ERR(phydev) || phydev == NULL)
|
||||
return phydev;
|
||||
|
||||
/* There's a PHY at this address
|
||||
* We need to set:
|
||||
* 1) IRQ
|
||||
* 2) bus_id
|
||||
* 3) parent
|
||||
* 4) bus
|
||||
* 5) mii_bus
|
||||
* And, we need to register it */
|
||||
|
||||
phydev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL;
|
||||
|
||||
phydev->dev.parent = bus->parent;
|
||||
phydev->dev.bus = &mdio_bus_type;
|
||||
dev_set_name(&phydev->dev, PHY_ID_FMT, bus->id, addr);
|
||||
|
||||
phydev->bus = bus;
|
||||
|
||||
/* Run all of the fixups for this PHY */
|
||||
phy_scan_fixups(phydev);
|
||||
|
||||
err = device_register(&phydev->dev);
|
||||
err = phy_device_register(phydev);
|
||||
if (err) {
|
||||
printk(KERN_ERR "phy %d failed to register\n", addr);
|
||||
phy_device_free(phydev);
|
||||
phydev = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bus->phy_map[addr] = phydev;
|
||||
|
||||
return phydev;
|
||||
}
|
||||
EXPORT_SYMBOL(mdiobus_scan);
|
||||
|
Reference in New Issue
Block a user