Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bfin_mac: Use phy_find_first() instead of open-coding it

Use phy_find_first() to find the first phy device instead of
open-coding it.

Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Guenter Roeck and committed by
David S. Miller
713d4024 50ee6382

+2 -15
+2 -15
drivers/net/ethernet/adi/bfin_mac.c
··· 380 380 static int mii_probe(struct net_device *dev, int phy_mode) 381 381 { 382 382 struct bfin_mac_local *lp = netdev_priv(dev); 383 - struct phy_device *phydev = NULL; 383 + struct phy_device *phydev; 384 384 unsigned short sysctl; 385 - int i; 386 385 u32 sclk, mdc_div; 387 386 388 387 /* Enable PHY output early */ ··· 395 396 sysctl = (sysctl & ~MDCDIV) | SET_MDCDIV(mdc_div); 396 397 bfin_write_EMAC_SYSCTL(sysctl); 397 398 398 - /* search for connected PHY device */ 399 - for (i = 0; i < PHY_MAX_ADDR; ++i) { 400 - struct phy_device *const tmp_phydev = 401 - mdiobus_get_phy(lp->mii_bus, i); 402 - 403 - if (!tmp_phydev) 404 - continue; /* no PHY here... */ 405 - 406 - phydev = tmp_phydev; 407 - break; /* found it */ 408 - } 409 - 410 - /* now we are supposed to have a proper phydev, to attach to... */ 399 + phydev = phy_find_first(lp->mii_bus); 411 400 if (!phydev) { 412 401 netdev_err(dev, "no phy device found\n"); 413 402 return -ENODEV;