Skip to content

Commit 7df8eea

Browse files
committed
clk: renesas: rzg2l: 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/900543d4b9abc1004e6aecdb676f23e5508ae96f.1685692810.git.geert+renesas@glider.be
1 parent d0414e7 commit 7df8eea

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,9 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
903903
unsigned int reg = clock->off;
904904
struct device *dev = priv->dev;
905905
unsigned long flags;
906-
unsigned int i;
907906
u32 bitmask = BIT(clock->bit);
908907
u32 value;
908+
int error;
909909

910910
if (!clock->off) {
911911
dev_dbg(dev, "%pC does not support ON/OFF\n", hw->clk);
@@ -930,19 +930,13 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
930930
if (!priv->info->has_clk_mon_regs)
931931
return 0;
932932

933-
for (i = 1000; i > 0; --i) {
934-
if (((readl(priv->base + CLK_MON_R(reg))) & bitmask))
935-
break;
936-
cpu_relax();
937-
}
938-
939-
if (!i) {
933+
error = readl_poll_timeout_atomic(priv->base + CLK_MON_R(reg), value,
934+
value & bitmask, 0, 10);
935+
if (error)
940936
dev_err(dev, "Failed to enable CLK_ON %p\n",
941937
priv->base + CLK_ON_R(reg));
942-
return -ETIMEDOUT;
943-
}
944938

945-
return 0;
939+
return error;
946940
}
947941

948942
static int rzg2l_mod_clock_enable(struct clk_hw *hw)

0 commit comments

Comments
 (0)