summaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@marvell.com>2008-10-08 16:29:57 -0700
committerDavid S. Miller <davem@davemloft.net>2008-10-08 16:29:57 -0700
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 63400815448..d25a3025113 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -250,7 +250,7 @@ struct mv643xx_eth_shared_private {
/*
* Provides access to local SMI interface.
*/
- struct mii_bus smi_bus;
+ struct mii_bus *smi_bus;
/*
* 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)
* Set up and register SMI bus.
*/
if (pd == NULL || pd->shared_smi == NULL) {
- msp->smi_bus.priv = msp;
- msp->smi_bus.name = "mv643xx_eth smi";
- msp->smi_bus.read = smi_bus_read;
- msp->smi_bus.write = smi_bus_write,
- snprintf(msp->smi_bus.id, MII_BUS_ID_SIZE, "%d", pdev->id);
- msp->smi_bus.parent = &pdev->dev;
- msp->smi_bus.phy_mask = 0xffffffff;
- if (mdiobus_register(&msp->smi_bus) < 0)
+ msp->smi_bus = mdiobus_alloc();
+ if (msp->smi_bus == NULL)
goto out_unmap;
+
+ msp->smi_bus->priv = msp;
+ msp->smi_bus->name = "mv643xx_eth smi";
+ msp->smi_bus->read = smi_bus_read;
+ msp->smi_bus->write = smi_bus_write,
+ snprintf(msp->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id);
+ msp->smi_bus->parent = &pdev->dev;
+ msp->smi_bus->phy_mask = 0xffffffff;
+ if (mdiobus_register(msp->smi_bus) < 0)
+ goto out_free_mii_bus;
msp->smi = msp;
} else {
msp->smi = platform_get_drvdata(pd->shared_smi);
@@ -2411,6 +2415,8 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
return 0;
+out_free_mii_bus:
+ mdiobus_free(msp->smi_bus);
out_unmap:
iounmap(msp->base);
out_free:
@@ -2424,8 +2430,10 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev);
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
- if (pd == NULL || pd->shared_smi == NULL)
- mdiobus_unregister(&msp->smi_bus);
+ if (pd == NULL || pd->shared_smi == NULL) {
+ mdiobus_free(msp->smi_bus);
+ mdiobus_unregister(msp->smi_bus);
+ }
if (msp->err_interrupt != NO_IRQ)
free_irq(msp->err_interrupt, msp);
iounmap(msp->base);
@@ -2493,7 +2501,7 @@ static void set_params(struct mv643xx_eth_private *mp,
static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
int phy_addr)
{
- struct mii_bus *bus = &mp->shared->smi->smi_bus;
+ struct mii_bus *bus = mp->shared->smi->smi_bus;
struct phy_device *phydev;
int start;
int num;