Skip to content

Commit d0414e7

Browse files
committed
clk: renesas: mstp: Convert to readl_poll_timeout_atomic()
Use readl_poll_timeout_atomic() instead of open-coding the same operation. As typically no retries are needed, 10 µs is a suitable timeout value. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/bce7d0bdd80c800aa150f1868b610b7d94f4cc66.1685692810.git.geert+renesas@glider.be
1 parent 14e5366 commit d0414e7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/clk/renesas/clk-mstp.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/clk/renesas.h>
1515
#include <linux/device.h>
1616
#include <linux/io.h>
17+
#include <linux/iopoll.h>
1718
#include <linux/of.h>
1819
#include <linux/of_address.h>
1920
#include <linux/pm_clock.h>
@@ -78,8 +79,8 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
7879
struct mstp_clock_group *group = clock->group;
7980
u32 bitmask = BIT(clock->bit_index);
8081
unsigned long flags;
81-
unsigned int i;
8282
u32 value;
83+
int ret;
8384

8485
spin_lock_irqsave(&group->lock, flags);
8586

@@ -101,19 +102,14 @@ static int cpg_mstp_clock_endisable(struct clk_hw *hw, bool enable)
101102
if (!enable || !group->mstpsr)
102103
return 0;
103104

104-
for (i = 1000; i > 0; --i) {
105-
if (!(cpg_mstp_read(group, group->mstpsr) & bitmask))
106-
break;
107-
cpu_relax();
108-
}
109-
110-
if (!i) {
105+
/* group->width_8bit is always false if group->mstpsr is present */
106+
ret = readl_poll_timeout_atomic(group->mstpsr, value,
107+
!(value & bitmask), 0, 10);
108+
if (ret)
111109
pr_err("%s: failed to enable %p[%d]\n", __func__,
112110
group->smstpcr, clock->bit_index);
113-
return -ETIMEDOUT;
114-
}
115111

116-
return 0;
112+
return ret;
117113
}
118114

119115
static int cpg_mstp_clock_enable(struct clk_hw *hw)

0 commit comments

Comments
 (0)