aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/fixed.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/fixed.c')
-rw-r--r--drivers/net/phy/fixed.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 4e07956a483b..cf24cc34debe 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -24,7 +24,7 @@
24 24
25struct fixed_mdio_bus { 25struct 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
@@ -115,8 +115,7 @@ static int fixed_phy_update_regs(struct fixed_phy *fp)
115 115
116static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) 116static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num)
117{ 117{
118 struct fixed_mdio_bus *fmb = container_of(bus, struct fixed_mdio_bus, 118 struct fixed_mdio_bus *fmb = bus->priv;
119 mii_bus);
120 struct fixed_phy *fp; 119 struct fixed_phy *fp;
121 120
122 if (reg_num >= MII_REGS_NUM) 121 if (reg_num >= MII_REGS_NUM)
@@ -213,19 +212,28 @@ static int __init fixed_mdio_bus_init(void)
213 goto err_pdev; 212 goto err_pdev;
214 } 213 }
215 214
216 snprintf(fmb->mii_bus.id, MII_BUS_ID_SIZE, "0"); 215 fmb->mii_bus = mdiobus_alloc();
217 fmb->mii_bus.name = "Fixed MDIO Bus"; 216 if (fmb->mii_bus == NULL) {
218 fmb->mii_bus.dev = &pdev->dev; 217 ret = -ENOMEM;
219 fmb->mii_bus.read = &fixed_mdio_read; 218 goto err_mdiobus_reg;
220 fmb->mii_bus.write = &fixed_mdio_write; 219 }
221 fmb->mii_bus.irq = fmb->irqs;
222 220
223 ret = mdiobus_register(&fmb->mii_bus); 221 snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "0");
222 fmb->mii_bus->name = "Fixed MDIO Bus";
223 fmb->mii_bus->priv = fmb;
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
235err_mdiobus_alloc:
236 mdiobus_free(fmb->mii_bus);
229err_mdiobus_reg: 237err_mdiobus_reg:
230 platform_device_unregister(pdev); 238 platform_device_unregister(pdev);
231err_pdev: 239err_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) {