diff options
author | Olliver Schinagl <oliver@schinagl.nl> | 2022-08-31 17:20:52 +0200 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2022-09-14 12:03:57 +0200 |
commit | 9cec4a0ea45b241cc54c5bc172510b843f19229e (patch) | |
tree | 62842628a9c28317c8f79cd5ffad445ffaaaea34 /target/linux | |
parent | cf2c9498bed5e2f34170ada394be26348949f107 (diff) | |
download | upstream-9cec4a0ea45b241cc54c5bc172510b843f19229e.tar.gz upstream-9cec4a0ea45b241cc54c5bc172510b843f19229e.tar.bz2 upstream-9cec4a0ea45b241cc54c5bc172510b843f19229e.zip |
realtek: Use built-in functionality for timeout loop
In commit 81e3017609be ("realtek: clean up rtl838x MDIO busy wait loop")
a hand-crafted loop was created, that nearly exactly replicate the
iopoll's `read_poll_timeout` functionality.
Use that instead.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Diffstat (limited to 'target/linux')
-rw-r--r-- | target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c index 524594d725..f56901d707 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <asm/mach-rtl838x/mach-rtl83xx.h> +#include <linux/iopoll.h> #include <net/nexthop.h> #include "rtl83xx.h" @@ -1805,20 +1806,14 @@ irqreturn_t rtl838x_switch_irq(int irq, void *dev_id) int rtl838x_smi_wait_op(int timeout) { - unsigned long end = jiffies + usecs_to_jiffies(timeout); + int ret = 0; + u32 val; - while (1) { - if (!(sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_1) & 0x1)) - return 0; + ret = readx_poll_timeout(sw_r32, RTL838X_SMI_ACCESS_PHY_CTRL_1, val, val & 0x1, 20, timeout); + if (ret) + pr_err("%s: timeout\n", __func__); - if (time_after(jiffies, end)) - break; - - usleep_range(10, 20); - } - - pr_err("rtl838x_smi_wait_op: timeout\n"); - return -1; + return ret; } /* |