aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.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/mv643xx_eth.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/mv643xx_eth.c')
-rw-r--r--drivers/net/mv643xx_eth.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 634008154480..d25a30251139 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -250,7 +250,7 @@ struct mv643xx_eth_shared_private {
250 /* 250 /*
251 * Provides access to local SMI interface. 251 * Provides access to local SMI interface.
252 */ 252 */
253 struct mii_bus smi_bus; 253 struct mii_bus *smi_bus;
254 254
255 /* 255 /*
256 * If we have access to the error interrupt pin (which is 256 * If we have access to the error interrupt pin (which is
@@ -2363,15 +2363,19 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2363 * Set up and register SMI bus. 2363 * Set up and register SMI bus.
2364 */ 2364 */
2365 if (pd == NULL || pd->shared_smi == NULL) { 2365 if (pd == NULL || pd->shared_smi == NULL) {
2366 msp->smi_bus.priv = msp; 2366 msp->smi_bus = mdiobus_alloc();
2367 msp->smi_bus.name = "mv643xx_eth smi"; 2367 if (msp->smi_bus == NULL)
2368 msp->smi_bus.read = smi_bus_read;
2369 msp->smi_bus.write = smi_bus_write,
2370 snprintf(msp->smi_bus.id, MII_BUS_ID_SIZE, "%d", pdev->id);
2371 msp->smi_bus.parent = &pdev->dev;
2372 msp->smi_bus.phy_mask = 0xffffffff;
2373 if (mdiobus_register(&msp->smi_bus) < 0)
2374 goto out_unmap; 2368 goto out_unmap;
2369
2370 msp->smi_bus->priv = msp;
2371 msp->smi_bus->name = "mv643xx_eth smi";
2372 msp->smi_bus->read = smi_bus_read;
2373 msp->smi_bus->write = smi_bus_write,
2374 snprintf(msp->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id);
2375 msp->smi_bus->parent = &pdev->dev;
2376 msp->smi_bus->phy_mask = 0xffffffff;
2377 if (mdiobus_register(msp->smi_bus) < 0)
2378 goto out_free_mii_bus;
2375 msp->smi = msp; 2379 msp->smi = msp;
2376 } else { 2380 } else {
2377 msp->smi = platform_get_drvdata(pd->shared_smi); 2381 msp->smi = platform_get_drvdata(pd->shared_smi);
@@ -2411,6 +2415,8 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2411 2415
2412 return 0; 2416 return 0;
2413 2417
2418out_free_mii_bus:
2419 mdiobus_free(msp->smi_bus);
2414out_unmap: 2420out_unmap:
2415 iounmap(msp->base); 2421 iounmap(msp->base);
2416out_free: 2422out_free:
@@ -2424,8 +2430,10 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
2424 struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev); 2430 struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev);
2425 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data; 2431 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
2426 2432
2427 if (pd == NULL || pd->shared_smi == NULL) 2433 if (pd == NULL || pd->shared_smi == NULL) {
2428 mdiobus_unregister(&msp->smi_bus); 2434 mdiobus_free(msp->smi_bus);
2435 mdiobus_unregister(msp->smi_bus);
2436 }
2429 if (msp->err_interrupt != NO_IRQ) 2437 if (msp->err_interrupt != NO_IRQ)
2430 free_irq(msp->err_interrupt, msp); 2438 free_irq(msp->err_interrupt, msp);
2431 iounmap(msp->base); 2439 iounmap(msp->base);
@@ -2493,7 +2501,7 @@ static void set_params(struct mv643xx_eth_private *mp,
2493static struct phy_device *phy_scan(struct mv643xx_eth_private *mp, 2501static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
2494 int phy_addr) 2502 int phy_addr)
2495{ 2503{
2496 struct mii_bus *bus = &mp->shared->smi->smi_bus; 2504 struct mii_bus *bus = mp->shared->smi->smi_bus;
2497 struct phy_device *phydev; 2505 struct phy_device *phydev;
2498 int start; 2506 int start;
2499 int num; 2507 int num;