aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2010-06-02 06:45:22 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-02 06:45:22 -0400
commite95095540c5276fc9922cb14376afc36f846af1f (patch)
treeb82715e012b90e32eddd50d97cd9771525810d4d
parentf9f3545e1e5de3d3f5376ae6c522aedb1205f4e1 (diff)
net/mpc52xx_phy: Various code cleanups
- don't free bus->irq (obsoleted by ca816d98170942371535b3e862813b0aba9b7d90) - don't dispose irqs (should be done in of_mdiobus_register()) - use fec-pointer consistently in transfer() - use resource_size() - cosmetic fixes Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/fec_mpc52xx_phy.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index 006f64d9f96a..dbaf72cbb233 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -29,15 +29,14 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
29 int reg, u32 value) 29 int reg, u32 value)
30{ 30{
31 struct mpc52xx_fec_mdio_priv *priv = bus->priv; 31 struct mpc52xx_fec_mdio_priv *priv = bus->priv;
32 struct mpc52xx_fec __iomem *fec; 32 struct mpc52xx_fec __iomem *fec = priv->regs;
33 int tries = 3; 33 int tries = 3;
34 34
35 value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK; 35 value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK;
36 value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK; 36 value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK;
37 37
38 fec = priv->regs;
39 out_be32(&fec->ievent, FEC_IEVENT_MII); 38 out_be32(&fec->ievent, FEC_IEVENT_MII);
40 out_be32(&priv->regs->mii_data, value); 39 out_be32(&fec->mii_data, value);
41 40
42 /* wait for it to finish, this takes about 23 us on lite5200b */ 41 /* wait for it to finish, this takes about 23 us on lite5200b */
43 while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) 42 while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries)
@@ -47,7 +46,7 @@ static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id,
47 return -ETIMEDOUT; 46 return -ETIMEDOUT;
48 47
49 return value & FEC_MII_DATA_OP_RD ? 48 return value & FEC_MII_DATA_OP_RD ?
50 in_be32(&priv->regs->mii_data) & FEC_MII_DATA_DATAMSK : 0; 49 in_be32(&fec->mii_data) & FEC_MII_DATA_DATAMSK : 0;
51} 50}
52 51
53static int mpc52xx_fec_mdio_read(struct mii_bus *bus, int phy_id, int reg) 52static int mpc52xx_fec_mdio_read(struct mii_bus *bus, int phy_id, int reg)
@@ -69,9 +68,8 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
69 struct device_node *np = of->dev.of_node; 68 struct device_node *np = of->dev.of_node;
70 struct mii_bus *bus; 69 struct mii_bus *bus;
71 struct mpc52xx_fec_mdio_priv *priv; 70 struct mpc52xx_fec_mdio_priv *priv;
72 struct resource res = {}; 71 struct resource res;
73 int err; 72 int err;
74 int i;
75 73
76 bus = mdiobus_alloc(); 74 bus = mdiobus_alloc();
77 if (bus == NULL) 75 if (bus == NULL)
@@ -93,7 +91,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
93 err = of_address_to_resource(np, 0, &res); 91 err = of_address_to_resource(np, 0, &res);
94 if (err) 92 if (err)
95 goto out_free; 93 goto out_free;
96 priv->regs = ioremap(res.start, res.end - res.start + 1); 94 priv->regs = ioremap(res.start, resource_size(&res));
97 if (priv->regs == NULL) { 95 if (priv->regs == NULL) {
98 err = -ENOMEM; 96 err = -ENOMEM;
99 goto out_free; 97 goto out_free;
@@ -118,10 +116,6 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
118 out_unmap: 116 out_unmap:
119 iounmap(priv->regs); 117 iounmap(priv->regs);
120 out_free: 118 out_free:
121 for (i=0; i<PHY_MAX_ADDR; i++)
122 if (bus->irq[i] != PHY_POLL)
123 irq_dispose_mapping(bus->irq[i]);
124 kfree(bus->irq);
125 kfree(priv); 119 kfree(priv);
126 mdiobus_free(bus); 120 mdiobus_free(bus);
127 121
@@ -133,23 +127,16 @@ static int mpc52xx_fec_mdio_remove(struct of_device *of)
133 struct device *dev = &of->dev; 127 struct device *dev = &of->dev;
134 struct mii_bus *bus = dev_get_drvdata(dev); 128 struct mii_bus *bus = dev_get_drvdata(dev);
135 struct mpc52xx_fec_mdio_priv *priv = bus->priv; 129 struct mpc52xx_fec_mdio_priv *priv = bus->priv;
136 int i;
137 130
138 mdiobus_unregister(bus); 131 mdiobus_unregister(bus);
139 dev_set_drvdata(dev, NULL); 132 dev_set_drvdata(dev, NULL);
140
141 iounmap(priv->regs); 133 iounmap(priv->regs);
142 for (i=0; i<PHY_MAX_ADDR; i++)
143 if (bus->irq[i] != PHY_POLL)
144 irq_dispose_mapping(bus->irq[i]);
145 kfree(priv); 134 kfree(priv);
146 kfree(bus->irq);
147 mdiobus_free(bus); 135 mdiobus_free(bus);
148 136
149 return 0; 137 return 0;
150} 138}
151 139
152
153static struct of_device_id mpc52xx_fec_mdio_match[] = { 140static struct of_device_id mpc52xx_fec_mdio_match[] = {
154 { .compatible = "fsl,mpc5200b-mdio", }, 141 { .compatible = "fsl,mpc5200b-mdio", },
155 { .compatible = "fsl,mpc5200-mdio", }, 142 { .compatible = "fsl,mpc5200-mdio", },
@@ -171,5 +158,4 @@ struct of_platform_driver mpc52xx_fec_mdio_driver = {
171/* let fec driver call it, since this has to be registered before it */ 158/* let fec driver call it, since this has to be registered before it */
172EXPORT_SYMBOL_GPL(mpc52xx_fec_mdio_driver); 159EXPORT_SYMBOL_GPL(mpc52xx_fec_mdio_driver);
173 160
174
175MODULE_LICENSE("Dual BSD/GPL"); 161MODULE_LICENSE("Dual BSD/GPL");