1 From 2ad255f2faaffb3af786031fba2e7955454b558a Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Fri, 14 May 2021 22:59:52 +0200
4 Subject: [PATCH] net: dsa: qca8k: use iopoll macro for qca8k_busy_wait
6 Use iopoll macro instead of while loop.
8 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
9 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
12 drivers/net/dsa/qca8k.c | 23 +++++++++++------------
13 drivers/net/dsa/qca8k.h | 2 ++
14 2 files changed, 13 insertions(+), 12 deletions(-)
16 --- a/drivers/net/dsa/qca8k.c
17 +++ b/drivers/net/dsa/qca8k.c
18 @@ -262,21 +262,20 @@ static struct regmap_config qca8k_regmap
20 qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask)
22 - unsigned long timeout;
26 - timeout = jiffies + msecs_to_jiffies(20);
27 + ret = read_poll_timeout(qca8k_read, val, !(val & mask),
28 + 0, QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false,
31 - /* loop until the busy flag has cleared */
33 - u32 val = qca8k_read(priv, reg);
34 - int busy = val & mask;
35 + /* Check if qca8k_read has failed for a different reason
36 + * before returning -ETIMEDOUT
38 + if (ret < 0 && val < 0)
44 - } while (!time_after_eq(jiffies, timeout));
46 - return time_after_eq(jiffies, timeout);
51 --- a/drivers/net/dsa/qca8k.h
52 +++ b/drivers/net/dsa/qca8k.h
54 #define PHY_ID_QCA8337 0x004dd036
55 #define QCA8K_ID_QCA8337 0x13
57 +#define QCA8K_BUSY_WAIT_TIMEOUT 20
59 #define QCA8K_NUM_FDB_RECORDS 2048
61 #define QCA8K_CPU_PORT 0