mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-24 19:49:54 +02:00
generic: ar8216: improve ar8216_wait_bit function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30847 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
47f3a7dbc1
commit
f7dadcb854
@ -468,14 +468,22 @@ static int
|
|||||||
ar8216_wait_bit(struct ar8216_priv *priv, int reg, u32 mask, u32 val)
|
ar8216_wait_bit(struct ar8216_priv *priv, int reg, u32 mask, u32 val)
|
||||||
{
|
{
|
||||||
int timeout = 20;
|
int timeout = 20;
|
||||||
|
u32 t = 0;
|
||||||
|
|
||||||
while ((priv->read(priv, reg) & mask) != val) {
|
while (1) {
|
||||||
if (timeout-- <= 0) {
|
t = priv->read(priv, reg);
|
||||||
printk(KERN_ERR "ar8216: timeout waiting for operation to complete\n");
|
if ((t & mask) == val)
|
||||||
return 1;
|
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
|
static void
|
||||||
@ -958,11 +966,8 @@ ar8216_read_status(struct phy_device *phydev)
|
|||||||
/* flush the address translation unit */
|
/* flush the address translation unit */
|
||||||
mutex_lock(&priv->reg_mutex);
|
mutex_lock(&priv->reg_mutex);
|
||||||
ret = ar8216_wait_bit(priv, AR8216_REG_ATU, AR8216_ATU_ACTIVE, 0);
|
ret = ar8216_wait_bit(priv, AR8216_REG_ATU, AR8216_ATU_ACTIVE, 0);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
priv->write(priv, AR8216_REG_ATU, AR8216_ATU_OP_FLUSH);
|
priv->write(priv, AR8216_REG_ATU, AR8216_ATU_OP_FLUSH);
|
||||||
else
|
|
||||||
ret = -ETIMEDOUT;
|
|
||||||
mutex_unlock(&priv->reg_mutex);
|
mutex_unlock(&priv->reg_mutex);
|
||||||
|
|
||||||
phydev->state = PHY_RUNNING;
|
phydev->state = PHY_RUNNING;
|
||||||
|
Loading…
Reference in New Issue
Block a user