fsl_pq_mdio: Fix kernel oops during OF address translation

Old P1020RDB device trees were not specifing tbipa address for
MDIO nodes, which is now causing this kernel oops:

...
eth2: TX BD ring size for Q[6]: 256
eth2: TX BD ring size for Q[7]: 256
Unable to handle kernel paging request for data at address 0x00000000
Faulting instruction address: 0xc0015504
Oops: Kernel access of bad area, sig: 11 [#1]
...
NIP [c0015504] memcpy+0x3c/0x9c
LR [c000a9f8] __of_translate_address+0xfc/0x21c
Call Trace:
[df839e00] [c000a94c] __of_translate_address+0x50/0x21c (unreliable)
[df839e50] [c01a33e8] get_gfar_tbipa+0xb0/0xe0
...

The old device trees are buggy, though having a dead ethernet is
better than a dead kernel, so fix the issue by using of_iomap().

Also, a somewhat similar issue exist in the probe() routine, though
there the oops is only a possibility. Nonetheless, fix it too.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Anton Vorontsov and committed by David S. Miller 3b1fd3e5 fda48a0d

+14 -6
+14 -6
drivers/net/fsl_pq_mdio.c
··· 205 static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 206 { 207 struct gfar __iomem *enet_regs; 208 - u32 __iomem *ioremap_tbipa; 209 - u64 addr, size; 210 211 /* 212 * This is mildly evil, but so is our hardware for doing this. ··· 218 return &enet_regs->tbipa; 219 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 220 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 221 - addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); 222 - ioremap_tbipa = ioremap(addr, size); 223 - return ioremap_tbipa; 224 } else 225 return NULL; 226 } ··· 275 u32 __iomem *tbipa; 276 struct mii_bus *new_bus; 277 int tbiaddr = -1; 278 u64 addr = 0, size = 0; 279 int err = 0; 280 ··· 294 new_bus->priv = priv; 295 fsl_pq_mdio_bus_name(new_bus->id, np); 296 297 /* Set the PHY base address */ 298 - addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); 299 map = ioremap(addr, size); 300 if (!map) { 301 err = -ENOMEM;
··· 205 static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 206 { 207 struct gfar __iomem *enet_regs; 208 209 /* 210 * This is mildly evil, but so is our hardware for doing this. ··· 220 return &enet_regs->tbipa; 221 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 222 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 223 + return of_iomap(np, 1); 224 } else 225 return NULL; 226 } ··· 279 u32 __iomem *tbipa; 280 struct mii_bus *new_bus; 281 int tbiaddr = -1; 282 + const u32 *addrp; 283 u64 addr = 0, size = 0; 284 int err = 0; 285 ··· 297 new_bus->priv = priv; 298 fsl_pq_mdio_bus_name(new_bus->id, np); 299 300 + addrp = of_get_address(np, 0, &size, NULL); 301 + if (!addrp) { 302 + err = -EINVAL; 303 + goto err_free_bus; 304 + } 305 + 306 /* Set the PHY base address */ 307 + addr = of_translate_address(np, addrp); 308 + if (addr == OF_BAD_ADDR) { 309 + err = -EINVAL; 310 + goto err_free_bus; 311 + } 312 + 313 map = ioremap(addr, size); 314 if (!map) { 315 err = -ENOMEM;