diff options
author | David S. Miller <davem@davemloft.net> | 2010-05-03 00:43:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-03 01:02:06 -0400 |
commit | 7ef527377b88ff05fb122a47619ea506c631c914 (patch) | |
tree | 2c2e774527d5f591b975834f43e8c6fd12fb38f2 /drivers/net/sb1250-mac.c | |
parent | 47d29646a2c1c147d8a7598aeac2c87dd71ed638 (diff) | |
parent | 1183f3838c588545592c042c0ce15015661ce7f2 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers/net/sb1250-mac.c')
-rw-r--r-- | drivers/net/sb1250-mac.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c index ba4770a6c2e4..fec3c29b2ea8 100644 --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c | |||
@@ -2256,17 +2256,36 @@ static int sbmac_init(struct platform_device *pldev, long long base) | |||
2256 | 2256 | ||
2257 | sc->mii_bus = mdiobus_alloc(); | 2257 | sc->mii_bus = mdiobus_alloc(); |
2258 | if (sc->mii_bus == NULL) { | 2258 | if (sc->mii_bus == NULL) { |
2259 | sbmac_uninitctx(sc); | 2259 | err = -ENOMEM; |
2260 | return -ENOMEM; | 2260 | goto uninit_ctx; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | sc->mii_bus->name = sbmac_mdio_string; | ||
2264 | snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); | ||
2265 | sc->mii_bus->priv = sc; | ||
2266 | sc->mii_bus->read = sbmac_mii_read; | ||
2267 | sc->mii_bus->write = sbmac_mii_write; | ||
2268 | sc->mii_bus->irq = sc->phy_irq; | ||
2269 | for (i = 0; i < PHY_MAX_ADDR; ++i) | ||
2270 | sc->mii_bus->irq[i] = SBMAC_PHY_INT; | ||
2271 | |||
2272 | sc->mii_bus->parent = &pldev->dev; | ||
2273 | /* | ||
2274 | * Probe PHY address | ||
2275 | */ | ||
2276 | err = mdiobus_register(sc->mii_bus); | ||
2277 | if (err) { | ||
2278 | printk(KERN_ERR "%s: unable to register MDIO bus\n", | ||
2279 | dev->name); | ||
2280 | goto free_mdio; | ||
2281 | } | ||
2282 | dev_set_drvdata(&pldev->dev, sc->mii_bus); | ||
2283 | |||
2263 | err = register_netdev(dev); | 2284 | err = register_netdev(dev); |
2264 | if (err) { | 2285 | if (err) { |
2265 | printk(KERN_ERR "%s.%d: unable to register netdev\n", | 2286 | printk(KERN_ERR "%s.%d: unable to register netdev\n", |
2266 | sbmac_string, idx); | 2287 | sbmac_string, idx); |
2267 | mdiobus_free(sc->mii_bus); | 2288 | goto unreg_mdio; |
2268 | sbmac_uninitctx(sc); | ||
2269 | return err; | ||
2270 | } | 2289 | } |
2271 | 2290 | ||
2272 | pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); | 2291 | pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); |
@@ -2282,19 +2301,15 @@ static int sbmac_init(struct platform_device *pldev, long long base) | |||
2282 | pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", | 2301 | pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", |
2283 | dev->name, base, eaddr); | 2302 | dev->name, base, eaddr); |
2284 | 2303 | ||
2285 | sc->mii_bus->name = sbmac_mdio_string; | ||
2286 | snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); | ||
2287 | sc->mii_bus->priv = sc; | ||
2288 | sc->mii_bus->read = sbmac_mii_read; | ||
2289 | sc->mii_bus->write = sbmac_mii_write; | ||
2290 | sc->mii_bus->irq = sc->phy_irq; | ||
2291 | for (i = 0; i < PHY_MAX_ADDR; ++i) | ||
2292 | sc->mii_bus->irq[i] = SBMAC_PHY_INT; | ||
2293 | |||
2294 | sc->mii_bus->parent = &pldev->dev; | ||
2295 | dev_set_drvdata(&pldev->dev, sc->mii_bus); | ||
2296 | |||
2297 | return 0; | 2304 | return 0; |
2305 | unreg_mdio: | ||
2306 | mdiobus_unregister(sc->mii_bus); | ||
2307 | dev_set_drvdata(&pldev->dev, NULL); | ||
2308 | free_mdio: | ||
2309 | mdiobus_free(sc->mii_bus); | ||
2310 | uninit_ctx: | ||
2311 | sbmac_uninitctx(sc); | ||
2312 | return err; | ||
2298 | } | 2313 | } |
2299 | 2314 | ||
2300 | 2315 | ||
@@ -2320,16 +2335,6 @@ static int sbmac_open(struct net_device *dev) | |||
2320 | goto out_err; | 2335 | goto out_err; |
2321 | } | 2336 | } |
2322 | 2337 | ||
2323 | /* | ||
2324 | * Probe PHY address | ||
2325 | */ | ||
2326 | err = mdiobus_register(sc->mii_bus); | ||
2327 | if (err) { | ||
2328 | printk(KERN_ERR "%s: unable to register MDIO bus\n", | ||
2329 | dev->name); | ||
2330 | goto out_unirq; | ||
2331 | } | ||
2332 | |||
2333 | sc->sbm_speed = sbmac_speed_none; | 2338 | sc->sbm_speed = sbmac_speed_none; |
2334 | sc->sbm_duplex = sbmac_duplex_none; | 2339 | sc->sbm_duplex = sbmac_duplex_none; |
2335 | sc->sbm_fc = sbmac_fc_none; | 2340 | sc->sbm_fc = sbmac_fc_none; |
@@ -2360,11 +2365,7 @@ static int sbmac_open(struct net_device *dev) | |||
2360 | return 0; | 2365 | return 0; |
2361 | 2366 | ||
2362 | out_unregister: | 2367 | out_unregister: |
2363 | mdiobus_unregister(sc->mii_bus); | ||
2364 | |||
2365 | out_unirq: | ||
2366 | free_irq(dev->irq, dev); | 2368 | free_irq(dev->irq, dev); |
2367 | |||
2368 | out_err: | 2369 | out_err: |
2369 | return err; | 2370 | return err; |
2370 | } | 2371 | } |
@@ -2553,9 +2554,6 @@ static int sbmac_close(struct net_device *dev) | |||
2553 | 2554 | ||
2554 | phy_disconnect(sc->phy_dev); | 2555 | phy_disconnect(sc->phy_dev); |
2555 | sc->phy_dev = NULL; | 2556 | sc->phy_dev = NULL; |
2556 | |||
2557 | mdiobus_unregister(sc->mii_bus); | ||
2558 | |||
2559 | free_irq(dev->irq, dev); | 2557 | free_irq(dev->irq, dev); |
2560 | 2558 | ||
2561 | sbdma_emptyring(&(sc->sbm_txdma)); | 2559 | sbdma_emptyring(&(sc->sbm_txdma)); |
@@ -2662,6 +2660,7 @@ static int __exit sbmac_remove(struct platform_device *pldev) | |||
2662 | 2660 | ||
2663 | unregister_netdev(dev); | 2661 | unregister_netdev(dev); |
2664 | sbmac_uninitctx(sc); | 2662 | sbmac_uninitctx(sc); |
2663 | mdiobus_unregister(sc->mii_bus); | ||
2665 | mdiobus_free(sc->mii_bus); | 2664 | mdiobus_free(sc->mii_bus); |
2666 | iounmap(sc->sbm_base); | 2665 | iounmap(sc->sbm_base); |
2667 | free_netdev(dev); | 2666 | free_netdev(dev); |