fsl_pq_mdio: Clean up tbi address configuration

The code for setting the address of the internal TBI PHY was
convoluted enough without a maze of ifdefs. Clean it up a bit
so we allow the logic to fail down to -ENODEV at the end of
the if/else ladder, rather than using ifdefs to repeat the same
failure code over and over.

Also, remove the support for the auto-configuration. I'm not aware of
anyone using it, and it ends up using the bus mutex before it's been
initialized.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Andy Fleming and committed by David S. Miller 28d8ea2d a454dace

+8 -45
+8 -45
drivers/net/ethernet/freescale/fsl_pq_mdio.c
··· 183 183 } 184 184 EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); 185 185 186 - /* Scan the bus in reverse, looking for an empty spot */ 187 - static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) 188 - { 189 - int i; 190 186 191 - for (i = PHY_MAX_ADDR; i > 0; i--) { 192 - u32 phy_id; 193 - 194 - if (get_phy_id(new_bus, i, &phy_id)) 195 - return -1; 196 - 197 - if (phy_id == 0xffffffff) 198 - break; 199 - } 200 - 201 - return i; 202 - } 203 - 204 - 205 - #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) 206 187 static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 207 188 { 189 + #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) 208 190 struct gfar __iomem *enet_regs; 209 191 210 192 /* ··· 202 220 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 203 221 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 204 222 return of_iomap(np, 1); 205 - } else 206 - return NULL; 207 - } 223 + } 208 224 #endif 225 + return NULL; 226 + } 209 227 210 228 211 - #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) 212 229 static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) 213 230 { 231 + #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) 214 232 struct device_node *np = NULL; 215 233 int err = 0; 216 234 ··· 243 261 return err; 244 262 else 245 263 return -EINVAL; 246 - } 264 + #else 265 + return -ENODEV; 247 266 #endif 248 - 267 + } 249 268 250 269 static int fsl_pq_mdio_probe(struct platform_device *ofdev) 251 270 { ··· 322 339 of_device_is_compatible(np, "fsl,etsec2-mdio") || 323 340 of_device_is_compatible(np, "fsl,etsec2-tbi") || 324 341 of_device_is_compatible(np, "gianfar")) { 325 - #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) 326 342 tbipa = get_gfar_tbipa(regs, np); 327 343 if (!tbipa) { 328 344 err = -EINVAL; 329 345 goto err_free_irqs; 330 346 } 331 - #else 332 - err = -ENODEV; 333 - goto err_free_irqs; 334 - #endif 335 347 } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || 336 348 of_device_is_compatible(np, "ucc_geth_phy")) { 337 - #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) 338 349 u32 id; 339 350 static u32 mii_mng_master; 340 351 ··· 341 364 mii_mng_master = id; 342 365 ucc_set_qe_mux_mii_mng(id - 1); 343 366 } 344 - #else 345 - err = -ENODEV; 346 - goto err_free_irqs; 347 - #endif 348 367 } else { 349 368 err = -ENODEV; 350 369 goto err_free_irqs; ··· 359 386 } 360 387 361 388 if (tbiaddr == -1) { 362 - out_be32(tbipa, 0); 363 - 364 - tbiaddr = fsl_pq_mdio_find_free(new_bus); 365 - } 366 - 367 - /* 368 - * We define TBIPA at 0 to be illegal, opting to fail for boards that 369 - * have PHYs at 1-31, rather than change tbipa and rescan. 370 - */ 371 - if (tbiaddr == 0) { 372 389 err = -EBUSY; 373 390 374 391 goto err_free_irqs;