mdio: Move allocation of interrupts into core
Have mdio_alloc() create the array of interrupt numbers, and initialize it to POLLING. This is what most MDIO drivers want, so allowing code to be removed from the drivers. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
35d2aeac98
commit
e7f4dc3536
@@ -1983,7 +1983,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
|
||||
struct net_device *ndev = platform_get_drvdata(pdev);
|
||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||
struct device_node *node;
|
||||
int err = -ENXIO, i;
|
||||
int err = -ENXIO;
|
||||
u32 mii_speed, holdtime;
|
||||
|
||||
/*
|
||||
@@ -2065,15 +2065,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
|
||||
fep->mii_bus->priv = fep;
|
||||
fep->mii_bus->parent = &pdev->dev;
|
||||
|
||||
fep->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
|
||||
if (!fep->mii_bus->irq) {
|
||||
err = -ENOMEM;
|
||||
goto err_out_free_mdiobus;
|
||||
}
|
||||
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++)
|
||||
fep->mii_bus->irq[i] = PHY_POLL;
|
||||
|
||||
node = of_get_child_by_name(pdev->dev.of_node, "mdio");
|
||||
if (node) {
|
||||
err = of_mdiobus_register(fep->mii_bus, node);
|
||||
@@ -2083,7 +2074,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
if (err)
|
||||
goto err_out_free_mdio_irq;
|
||||
goto err_out_free_mdiobus;
|
||||
|
||||
mii_cnt++;
|
||||
|
||||
@@ -2093,8 +2084,6 @@ static int fec_enet_mii_init(struct platform_device *pdev)
|
||||
|
||||
return 0;
|
||||
|
||||
err_out_free_mdio_irq:
|
||||
kfree(fep->mii_bus->irq);
|
||||
err_out_free_mdiobus:
|
||||
mdiobus_free(fep->mii_bus);
|
||||
err_out:
|
||||
@@ -2105,7 +2094,6 @@ static void fec_enet_mii_remove(struct fec_enet_private *fep)
|
||||
{
|
||||
if (--mii_cnt == 0) {
|
||||
mdiobus_unregister(fep->mii_bus);
|
||||
kfree(fep->mii_bus->irq);
|
||||
mdiobus_free(fep->mii_bus);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
struct mpc52xx_fec_mdio_priv {
|
||||
struct mpc52xx_fec __iomem *regs;
|
||||
int mdio_irqs[PHY_MAX_ADDR];
|
||||
};
|
||||
|
||||
static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
|
||||
@@ -83,9 +82,6 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of)
|
||||
bus->read = mpc52xx_fec_mdio_read;
|
||||
bus->write = mpc52xx_fec_mdio_write;
|
||||
|
||||
/* setup irqs */
|
||||
bus->irq = priv->mdio_irqs;
|
||||
|
||||
/* setup registers */
|
||||
err = of_address_to_resource(np, 0, &res);
|
||||
if (err)
|
||||
|
@@ -172,23 +172,16 @@ static int fs_enet_mdio_probe(struct platform_device *ofdev)
|
||||
goto out_free_bus;
|
||||
|
||||
new_bus->phy_mask = ~0;
|
||||
new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
|
||||
if (!new_bus->irq) {
|
||||
ret = -ENOMEM;
|
||||
goto out_unmap_regs;
|
||||
}
|
||||
|
||||
new_bus->parent = &ofdev->dev;
|
||||
platform_set_drvdata(ofdev, new_bus);
|
||||
|
||||
ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
|
||||
if (ret)
|
||||
goto out_free_irqs;
|
||||
goto out_unmap_regs;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_irqs:
|
||||
kfree(new_bus->irq);
|
||||
out_unmap_regs:
|
||||
iounmap(bitbang->dir);
|
||||
out_free_bus:
|
||||
@@ -205,7 +198,6 @@ static int fs_enet_mdio_remove(struct platform_device *ofdev)
|
||||
struct bb_info *bitbang = bus->priv;
|
||||
|
||||
mdiobus_unregister(bus);
|
||||
kfree(bus->irq);
|
||||
free_mdio_bitbang(bus);
|
||||
iounmap(bitbang->dir);
|
||||
kfree(bitbang);
|
||||
|
@@ -166,23 +166,16 @@ static int fs_enet_mdio_probe(struct platform_device *ofdev)
|
||||
clrsetbits_be32(&fec->fecp->fec_mii_speed, 0x7E, fec->mii_speed);
|
||||
|
||||
new_bus->phy_mask = ~0;
|
||||
new_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
|
||||
if (!new_bus->irq) {
|
||||
ret = -ENOMEM;
|
||||
goto out_unmap_regs;
|
||||
}
|
||||
|
||||
new_bus->parent = &ofdev->dev;
|
||||
platform_set_drvdata(ofdev, new_bus);
|
||||
|
||||
ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
|
||||
if (ret)
|
||||
goto out_free_irqs;
|
||||
goto out_unmap_regs;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_irqs:
|
||||
kfree(new_bus->irq);
|
||||
out_unmap_regs:
|
||||
iounmap(fec->fecp);
|
||||
out_res:
|
||||
@@ -200,7 +193,6 @@ static int fs_enet_mdio_remove(struct platform_device *ofdev)
|
||||
struct fec_info *fec = bus->priv;
|
||||
|
||||
mdiobus_unregister(bus);
|
||||
kfree(bus->irq);
|
||||
iounmap(fec->fecp);
|
||||
kfree(fec);
|
||||
mdiobus_free(bus);
|
||||
|
@@ -69,7 +69,6 @@ struct fsl_pq_mdio {
|
||||
struct fsl_pq_mdio_priv {
|
||||
void __iomem *map;
|
||||
struct fsl_pq_mii __iomem *regs;
|
||||
int irqs[PHY_MAX_ADDR];
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -401,7 +400,6 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
|
||||
new_bus->read = &fsl_pq_mdio_read;
|
||||
new_bus->write = &fsl_pq_mdio_write;
|
||||
new_bus->reset = &fsl_pq_mdio_reset;
|
||||
new_bus->irq = priv->irqs;
|
||||
|
||||
err = of_address_to_resource(np, 0, &res);
|
||||
if (err < 0) {
|
||||
|
Reference in New Issue
Block a user