diff options
Diffstat (limited to 'drivers/net/gianfar_mii.c')
-rw-r--r-- | drivers/net/gianfar_mii.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index ebcfb27a904e..bf73eea98010 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -136,12 +136,12 @@ static int gfar_mdio_reset(struct mii_bus *bus) | |||
136 | 136 | ||
137 | /* Wait until the bus is free */ | 137 | /* Wait until the bus is free */ |
138 | while ((gfar_read(®s->miimind) & MIIMIND_BUSY) && | 138 | while ((gfar_read(®s->miimind) & MIIMIND_BUSY) && |
139 | timeout--) | 139 | --timeout) |
140 | cpu_relax(); | 140 | cpu_relax(); |
141 | 141 | ||
142 | mutex_unlock(&bus->mdio_lock); | 142 | mutex_unlock(&bus->mdio_lock); |
143 | 143 | ||
144 | if(timeout <= 0) { | 144 | if(timeout == 0) { |
145 | printk(KERN_ERR "%s: The MII Bus is stuck!\n", | 145 | printk(KERN_ERR "%s: The MII Bus is stuck!\n", |
146 | bus->name); | 146 | bus->name); |
147 | return -EBUSY; | 147 | return -EBUSY; |
@@ -164,8 +164,7 @@ static int gfar_mdio_probe(struct device *dev) | |||
164 | if (NULL == dev) | 164 | if (NULL == dev) |
165 | return -EINVAL; | 165 | return -EINVAL; |
166 | 166 | ||
167 | new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL); | 167 | new_bus = mdiobus_alloc(); |
168 | |||
169 | if (NULL == new_bus) | 168 | if (NULL == new_bus) |
170 | return -ENOMEM; | 169 | return -ENOMEM; |
171 | 170 | ||
@@ -196,7 +195,7 @@ static int gfar_mdio_probe(struct device *dev) | |||
196 | 195 | ||
197 | new_bus->irq = pdata->irq; | 196 | new_bus->irq = pdata->irq; |
198 | 197 | ||
199 | new_bus->dev = dev; | 198 | new_bus->parent = dev; |
200 | dev_set_drvdata(dev, new_bus); | 199 | dev_set_drvdata(dev, new_bus); |
201 | 200 | ||
202 | /* | 201 | /* |
@@ -211,19 +210,21 @@ static int gfar_mdio_probe(struct device *dev) | |||
211 | gfar_write(&enet_regs->tbipa, 0); | 210 | gfar_write(&enet_regs->tbipa, 0); |
212 | for (i = PHY_MAX_ADDR; i > 0; i--) { | 211 | for (i = PHY_MAX_ADDR; i > 0; i--) { |
213 | u32 phy_id; | 212 | u32 phy_id; |
214 | int r; | ||
215 | 213 | ||
216 | r = get_phy_id(new_bus, i, &phy_id); | 214 | err = get_phy_id(new_bus, i, &phy_id); |
217 | if (r) | 215 | if (err) |
218 | return r; | 216 | goto bus_register_fail; |
219 | 217 | ||
220 | if (phy_id == 0xffffffff) | 218 | if (phy_id == 0xffffffff) |
221 | break; | 219 | break; |
222 | } | 220 | } |
223 | 221 | ||
224 | /* The bus is full. We don't support using 31 PHYs, sorry */ | 222 | /* The bus is full. We don't support using 31 PHYs, sorry */ |
225 | if (i == 0) | 223 | if (i == 0) { |
226 | return -EBUSY; | 224 | err = -EBUSY; |
225 | |||
226 | goto bus_register_fail; | ||
227 | } | ||
227 | 228 | ||
228 | gfar_write(&enet_regs->tbipa, i); | 229 | gfar_write(&enet_regs->tbipa, i); |
229 | 230 | ||
@@ -240,7 +241,7 @@ static int gfar_mdio_probe(struct device *dev) | |||
240 | bus_register_fail: | 241 | bus_register_fail: |
241 | iounmap(regs); | 242 | iounmap(regs); |
242 | reg_map_fail: | 243 | reg_map_fail: |
243 | kfree(new_bus); | 244 | mdiobus_free(new_bus); |
244 | 245 | ||
245 | return err; | 246 | return err; |
246 | } | 247 | } |
@@ -256,7 +257,7 @@ static int gfar_mdio_remove(struct device *dev) | |||
256 | 257 | ||
257 | iounmap((void __iomem *)bus->priv); | 258 | iounmap((void __iomem *)bus->priv); |
258 | bus->priv = NULL; | 259 | bus->priv = NULL; |
259 | kfree(bus); | 260 | mdiobus_free(bus); |
260 | 261 | ||
261 | return 0; | 262 | return 0; |
262 | } | 263 | } |