aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sb1250-mac.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@marvell.com>2008-10-08 19:29:57 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-08 19:29:57 -0400
commit298cf9beb9679522de995e249eccbd82f7c51999 (patch)
treecabbc9c696a063982aea9a24d8caa667daa33a1a /drivers/net/sb1250-mac.c
parent18ee49ddb0d242ed1d0e273038d5e4f6de7379d3 (diff)
phylib: move to dynamic allocation of struct mii_bus
This patch introduces mdiobus_alloc() and mdiobus_free(), and makes all mdio bus drivers use these functions to allocate their struct mii_bus'es dynamically. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net> Acked-by: Andy Fleming <afleming@freescale.com>
Diffstat (limited to 'drivers/net/sb1250-mac.c')
-rw-r--r--drivers/net/sb1250-mac.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index d0ee735590bb..2615d46e6e50 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -256,7 +256,7 @@ struct sbmac_softc {
256 struct net_device *sbm_dev; /* pointer to linux device */ 256 struct net_device *sbm_dev; /* pointer to linux device */
257 struct napi_struct napi; 257 struct napi_struct napi;
258 struct phy_device *phy_dev; /* the associated PHY device */ 258 struct phy_device *phy_dev; /* the associated PHY device */
259 struct mii_bus mii_bus; /* the MII bus */ 259 struct mii_bus *mii_bus; /* the MII bus */
260 int phy_irq[PHY_MAX_ADDR]; 260 int phy_irq[PHY_MAX_ADDR];
261 spinlock_t sbm_lock; /* spin lock */ 261 spinlock_t sbm_lock; /* spin lock */
262 int sbm_devflags; /* current device flags */ 262 int sbm_devflags; /* current device flags */
@@ -2348,10 +2348,17 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2348 /* This is needed for PASS2 for Rx H/W checksum feature */ 2348 /* This is needed for PASS2 for Rx H/W checksum feature */
2349 sbmac_set_iphdr_offset(sc); 2349 sbmac_set_iphdr_offset(sc);
2350 2350
2351 sc->mii_bus = mdiobus_alloc();
2352 if (sc->mii_bus == NULL) {
2353 sbmac_uninitctx(sc);
2354 return -ENOMEM;
2355 }
2356
2351 err = register_netdev(dev); 2357 err = register_netdev(dev);
2352 if (err) { 2358 if (err) {
2353 printk(KERN_ERR "%s.%d: unable to register netdev\n", 2359 printk(KERN_ERR "%s.%d: unable to register netdev\n",
2354 sbmac_string, idx); 2360 sbmac_string, idx);
2361 mdiobus_free(sc->mii_bus);
2355 sbmac_uninitctx(sc); 2362 sbmac_uninitctx(sc);
2356 return err; 2363 return err;
2357 } 2364 }
@@ -2369,17 +2376,17 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2369 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %s\n", 2376 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %s\n",
2370 dev->name, base, print_mac(mac, eaddr)); 2377 dev->name, base, print_mac(mac, eaddr));
2371 2378
2372 sc->mii_bus.name = sbmac_mdio_string; 2379 sc->mii_bus->name = sbmac_mdio_string;
2373 snprintf(sc->mii_bus.id, MII_BUS_ID_SIZE, "%x", idx); 2380 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx);
2374 sc->mii_bus.priv = sc; 2381 sc->mii_bus->priv = sc;
2375 sc->mii_bus.read = sbmac_mii_read; 2382 sc->mii_bus->read = sbmac_mii_read;
2376 sc->mii_bus.write = sbmac_mii_write; 2383 sc->mii_bus->write = sbmac_mii_write;
2377 sc->mii_bus.irq = sc->phy_irq; 2384 sc->mii_bus->irq = sc->phy_irq;
2378 for (i = 0; i < PHY_MAX_ADDR; ++i) 2385 for (i = 0; i < PHY_MAX_ADDR; ++i)
2379 sc->mii_bus.irq[i] = SBMAC_PHY_INT; 2386 sc->mii_bus->irq[i] = SBMAC_PHY_INT;
2380 2387
2381 sc->mii_bus.parent = &pldev->dev; 2388 sc->mii_bus->parent = &pldev->dev;
2382 dev_set_drvdata(&pldev->dev, &sc->mii_bus); 2389 dev_set_drvdata(&pldev->dev, sc->mii_bus);
2383 2390
2384 return 0; 2391 return 0;
2385} 2392}
@@ -2410,7 +2417,7 @@ static int sbmac_open(struct net_device *dev)
2410 /* 2417 /*
2411 * Probe PHY address 2418 * Probe PHY address
2412 */ 2419 */
2413 err = mdiobus_register(&sc->mii_bus); 2420 err = mdiobus_register(sc->mii_bus);
2414 if (err) { 2421 if (err) {
2415 printk(KERN_ERR "%s: unable to register MDIO bus\n", 2422 printk(KERN_ERR "%s: unable to register MDIO bus\n",
2416 dev->name); 2423 dev->name);
@@ -2447,7 +2454,7 @@ static int sbmac_open(struct net_device *dev)
2447 return 0; 2454 return 0;
2448 2455
2449out_unregister: 2456out_unregister:
2450 mdiobus_unregister(&sc->mii_bus); 2457 mdiobus_unregister(sc->mii_bus);
2451 2458
2452out_unirq: 2459out_unirq:
2453 free_irq(dev->irq, dev); 2460 free_irq(dev->irq, dev);
@@ -2463,7 +2470,7 @@ static int sbmac_mii_probe(struct net_device *dev)
2463 int i; 2470 int i;
2464 2471
2465 for (i = 0; i < PHY_MAX_ADDR; i++) { 2472 for (i = 0; i < PHY_MAX_ADDR; i++) {
2466 phy_dev = sc->mii_bus.phy_map[i]; 2473 phy_dev = sc->mii_bus->phy_map[i];
2467 if (phy_dev) 2474 if (phy_dev)
2468 break; 2475 break;
2469 } 2476 }
@@ -2641,7 +2648,7 @@ static int sbmac_close(struct net_device *dev)
2641 phy_disconnect(sc->phy_dev); 2648 phy_disconnect(sc->phy_dev);
2642 sc->phy_dev = NULL; 2649 sc->phy_dev = NULL;
2643 2650
2644 mdiobus_unregister(&sc->mii_bus); 2651 mdiobus_unregister(sc->mii_bus);
2645 2652
2646 free_irq(dev->irq, dev); 2653 free_irq(dev->irq, dev);
2647 2654
@@ -2750,6 +2757,7 @@ static int __exit sbmac_remove(struct platform_device *pldev)
2750 2757
2751 unregister_netdev(dev); 2758 unregister_netdev(dev);
2752 sbmac_uninitctx(sc); 2759 sbmac_uninitctx(sc);
2760 mdiobus_free(sc->mii_bus);
2753 iounmap(sc->sbm_base); 2761 iounmap(sc->sbm_base);
2754 free_netdev(dev); 2762 free_netdev(dev);
2755 2763