diff options
Diffstat (limited to 'drivers/net/phy/fixed.c')
-rw-r--r-- | drivers/net/phy/fixed.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index 1cec8967a089..b5e13f8d5e31 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | struct fixed_mdio_bus { | 25 | struct fixed_mdio_bus { |
26 | int irqs[PHY_MAX_ADDR]; | 26 | int irqs[PHY_MAX_ADDR]; |
27 | struct mii_bus mii_bus; | 27 | struct mii_bus *mii_bus; |
28 | struct list_head phys; | 28 | struct list_head phys; |
29 | }; | 29 | }; |
30 | 30 | ||
@@ -213,19 +213,27 @@ static int __init fixed_mdio_bus_init(void) | |||
213 | goto err_pdev; | 213 | goto err_pdev; |
214 | } | 214 | } |
215 | 215 | ||
216 | snprintf(fmb->mii_bus.id, MII_BUS_ID_SIZE, "0"); | 216 | fmb->mii_bus = mdiobus_alloc(); |
217 | fmb->mii_bus.name = "Fixed MDIO Bus"; | 217 | if (fmb->mii_bus == NULL) { |
218 | fmb->mii_bus.parent = &pdev->dev; | 218 | ret = -ENOMEM; |
219 | fmb->mii_bus.read = &fixed_mdio_read; | 219 | goto err_mdiobus_reg; |
220 | fmb->mii_bus.write = &fixed_mdio_write; | 220 | } |
221 | fmb->mii_bus.irq = fmb->irqs; | ||
222 | 221 | ||
223 | ret = mdiobus_register(&fmb->mii_bus); | 222 | snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "0"); |
223 | fmb->mii_bus->name = "Fixed MDIO Bus"; | ||
224 | fmb->mii_bus->parent = &pdev->dev; | ||
225 | fmb->mii_bus->read = &fixed_mdio_read; | ||
226 | fmb->mii_bus->write = &fixed_mdio_write; | ||
227 | fmb->mii_bus->irq = fmb->irqs; | ||
228 | |||
229 | ret = mdiobus_register(fmb->mii_bus); | ||
224 | if (ret) | 230 | if (ret) |
225 | goto err_mdiobus_reg; | 231 | goto err_mdiobus_alloc; |
226 | 232 | ||
227 | return 0; | 233 | return 0; |
228 | 234 | ||
235 | err_mdiobus_alloc: | ||
236 | mdiobus_free(fmb->mii_bus); | ||
229 | err_mdiobus_reg: | 237 | err_mdiobus_reg: |
230 | platform_device_unregister(pdev); | 238 | platform_device_unregister(pdev); |
231 | err_pdev: | 239 | err_pdev: |
@@ -238,7 +246,8 @@ static void __exit fixed_mdio_bus_exit(void) | |||
238 | struct fixed_mdio_bus *fmb = &platform_fmb; | 246 | struct fixed_mdio_bus *fmb = &platform_fmb; |
239 | struct fixed_phy *fp, *tmp; | 247 | struct fixed_phy *fp, *tmp; |
240 | 248 | ||
241 | mdiobus_unregister(&fmb->mii_bus); | 249 | mdiobus_unregister(fmb->mii_bus); |
250 | mdiobus_free(fmb->mii_bus); | ||
242 | platform_device_unregister(pdev); | 251 | platform_device_unregister(pdev); |
243 | 252 | ||
244 | list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { | 253 | list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { |