aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/mdio_bus.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-04-25 08:52:46 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-27 05:53:45 -0400
commit4dea547fef1ba23f9d23f5e7f5218187a7dcf1b3 (patch)
tree5d3ef6350d21c5a8ad952ef6f89f7d47099caf0a /drivers/net/phy/mdio_bus.c
parent739649c53d7f78f5bf41bdfd1a858ee90c7a687a (diff)
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>
Diffstat (limited to 'drivers/net/phy/mdio_bus.c')
-rw-r--r--drivers/net/phy/mdio_bus.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b754020cbe75..bd4e8d72dc08 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -113,7 +113,6 @@ int mdiobus_register(struct mii_bus *bus)
113 bus->reset(bus); 113 bus->reset(bus);
114 114
115 for (i = 0; i < PHY_MAX_ADDR; i++) { 115 for (i = 0; i < PHY_MAX_ADDR; i++) {
116 bus->phy_map[i] = NULL;
117 if ((bus->phy_mask & (1 << i)) == 0) { 116 if ((bus->phy_mask & (1 << i)) == 0) {
118 struct phy_device *phydev; 117 struct phy_device *phydev;
119 118
@@ -150,6 +149,7 @@ void mdiobus_unregister(struct mii_bus *bus)
150 for (i = 0; i < PHY_MAX_ADDR; i++) { 149 for (i = 0; i < PHY_MAX_ADDR; i++) {
151 if (bus->phy_map[i]) 150 if (bus->phy_map[i])
152 device_unregister(&bus->phy_map[i]->dev); 151 device_unregister(&bus->phy_map[i]->dev);
152 bus->phy_map[i] = NULL;
153 } 153 }
154} 154}
155EXPORT_SYMBOL(mdiobus_unregister); 155EXPORT_SYMBOL(mdiobus_unregister);
@@ -188,35 +188,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
188 if (IS_ERR(phydev) || phydev == NULL) 188 if (IS_ERR(phydev) || phydev == NULL)
189 return phydev; 189 return phydev;
190 190
191 /* There's a PHY at this address 191 err = phy_device_register(phydev);
192 * We need to set:
193 * 1) IRQ
194 * 2) bus_id
195 * 3) parent
196 * 4) bus
197 * 5) mii_bus
198 * And, we need to register it */
199
200 phydev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL;
201
202 phydev->dev.parent = bus->parent;
203 phydev->dev.bus = &mdio_bus_type;
204 dev_set_name(&phydev->dev, PHY_ID_FMT, bus->id, addr);
205
206 phydev->bus = bus;
207
208 /* Run all of the fixups for this PHY */
209 phy_scan_fixups(phydev);
210
211 err = device_register(&phydev->dev);
212 if (err) { 192 if (err) {
213 printk(KERN_ERR "phy %d failed to register\n", addr);
214 phy_device_free(phydev); 193 phy_device_free(phydev);
215 phydev = NULL; 194 return NULL;
216 } 195 }
217 196
218 bus->phy_map[addr] = phydev;
219
220 return phydev; 197 return phydev;
221} 198}
222EXPORT_SYMBOL(mdiobus_scan); 199EXPORT_SYMBOL(mdiobus_scan);