Commit 331c7372 authored by Dejin Zheng's avatar Dejin Zheng Committed by David S. Miller

net: phy: bcm84881: use phy_read_mmd_poll_timeout() to simplify the code

use phy_read_mmd_poll_timeout() to replace the poll codes for
simplify bcm84881_wait_init() function.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd971ff0
...@@ -22,30 +22,11 @@ enum { ...@@ -22,30 +22,11 @@ enum {
static int bcm84881_wait_init(struct phy_device *phydev) static int bcm84881_wait_init(struct phy_device *phydev)
{ {
unsigned int tries = 20; int val;
int ret, val;
do {
val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1);
if (val < 0) {
ret = val;
break;
}
if (!(val & MDIO_CTRL1_RESET)) {
ret = 0;
break;
}
if (!--tries) {
ret = -ETIMEDOUT;
break;
}
msleep(100);
} while (1);
if (ret) return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1,
phydev_err(phydev, "%s failed: %d\n", __func__, ret); val, !(val & MDIO_CTRL1_RESET),
100000, 2000000, false);
return ret;
} }
static int bcm84881_config_init(struct phy_device *phydev) static int bcm84881_config_init(struct phy_device *phydev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment