ff8288d48458839747ab66da0b3ecf326ed9c622
[openwrt/staging/jow.git] /
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
5
6 Use iopoll macro instead of while loop.
7
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>
11 ---
12 drivers/net/dsa/qca8k.c | 23 +++++++++++------------
13 drivers/net/dsa/qca8k.h | 2 ++
14 2 files changed, 13 insertions(+), 12 deletions(-)
15
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
19 static int
20 qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask)
21 {
22 - unsigned long timeout;
23 + u32 val;
24 + int ret;
25
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,
29 + priv, reg);
30
31 - /* loop until the busy flag has cleared */
32 - do {
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
37 + */
38 + if (ret < 0 && val < 0)
39 + return val;
40
41 - if (!busy)
42 - break;
43 - cond_resched();
44 - } while (!time_after_eq(jiffies, timeout));
45 -
46 - return time_after_eq(jiffies, timeout);
47 + return ret;
48 }
49
50 static void
51 --- a/drivers/net/dsa/qca8k.h
52 +++ b/drivers/net/dsa/qca8k.h
53 @@ -18,6 +18,8 @@
54 #define PHY_ID_QCA8337 0x004dd036
55 #define QCA8K_ID_QCA8337 0x13
56
57 +#define QCA8K_BUSY_WAIT_TIMEOUT 20
58 +
59 #define QCA8K_NUM_FDB_RECORDS 2048
60
61 #define QCA8K_CPU_PORT 0