Commit 2ad255f2 authored by Ansuel Smith's avatar Ansuel Smith Committed by David S. Miller

net: dsa: qca8k: use iopoll macro for qca8k_busy_wait

Use iopoll macro instead of while loop.
Signed-off-by: default avatarAnsuel Smith <ansuelsmth@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5d9e0684
...@@ -262,21 +262,20 @@ static struct regmap_config qca8k_regmap_config = { ...@@ -262,21 +262,20 @@ static struct regmap_config qca8k_regmap_config = {
static int static int
qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask) qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask)
{ {
unsigned long timeout; u32 val;
int ret;
timeout = jiffies + msecs_to_jiffies(20);
/* loop until the busy flag has cleared */ ret = read_poll_timeout(qca8k_read, val, !(val & mask),
do { 0, QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false,
u32 val = qca8k_read(priv, reg); priv, reg);
int busy = val & mask;
if (!busy) /* Check if qca8k_read has failed for a different reason
break; * before returning -ETIMEDOUT
cond_resched(); */
} while (!time_after_eq(jiffies, timeout)); if (ret < 0 && val < 0)
return val;
return time_after_eq(jiffies, timeout); return ret;
} }
static void static void
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#define PHY_ID_QCA8337 0x004dd036 #define PHY_ID_QCA8337 0x004dd036
#define QCA8K_ID_QCA8337 0x13 #define QCA8K_ID_QCA8337 0x13
#define QCA8K_BUSY_WAIT_TIMEOUT 20
#define QCA8K_NUM_FDB_RECORDS 2048 #define QCA8K_NUM_FDB_RECORDS 2048
#define QCA8K_CPU_PORT 0 #define QCA8K_CPU_PORT 0
......
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