diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-03-07 16:32:45 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-03-07 16:32:45 +0000 |
commit | 295e64ddd8a090249cff8e010c8682c14b60c0e3 (patch) | |
tree | 406c139d1d6266d50958d7e5fdec56dc244d352e /target | |
parent | 6bf74d0a6cba08127ba8f4616527d42618527a31 (diff) | |
download | upstream-295e64ddd8a090249cff8e010c8682c14b60c0e3.tar.gz upstream-295e64ddd8a090249cff8e010c8682c14b60c0e3.tar.bz2 upstream-295e64ddd8a090249cff8e010c8682c14b60c0e3.zip |
generic: ar8216: improve ar8216_wait_bit function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30847 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 2e3a8426b0..26a79be7ef 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -468,14 +468,22 @@ static int ar8216_wait_bit(struct ar8216_priv *priv, int reg, u32 mask, u32 val) { int timeout = 20; + u32 t = 0; - while ((priv->read(priv, reg) & mask) != val) { - if (timeout-- <= 0) { - printk(KERN_ERR "ar8216: timeout waiting for operation to complete\n"); - return 1; - } + while (1) { + t = priv->read(priv, reg); + if ((t & mask) == val) + return 0; + + if (timeout-- <= 0) + break; + + udelay(10); } - return 0; + + pr_err("ar8216: timeout on reg %08x: %08x & %08x != %08x\n", + (unsigned int) reg, t, mask, val); + return -ETIMEDOUT; } static void @@ -958,11 +966,8 @@ ar8216_read_status(struct phy_device *phydev) /* flush the address translation unit */ mutex_lock(&priv->reg_mutex); ret = ar8216_wait_bit(priv, AR8216_REG_ATU, AR8216_ATU_ACTIVE, 0); - if (!ret) priv->write(priv, AR8216_REG_ATU, AR8216_ATU_OP_FLUSH); - else - ret = -ETIMEDOUT; mutex_unlock(&priv->reg_mutex); phydev->state = PHY_RUNNING; |