Skip to content

Commit 33cd08a

Browse files
committed
clk: renesas: rzg2l: Refactor rzg3l_cpg_pll_clk_endisable()
Reduce duplication by introducing mon_mask. Eliminate an else branch by moving common parts into variable pre-initializations. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/9cda94b9b37c562a305f4dd6091fd71246764fd2.1777562043.git.geert+renesas@glider.be
1 parent 44c1733 commit 33cd08a

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,27 +1197,25 @@ static int rzg3l_cpg_pll_clk_endisable(struct clk_hw *hw, bool enable)
11971197
{
11981198
struct pll_clk *pll_clk = to_pll(hw);
11991199
struct rzg2l_cpg_priv *priv = pll_clk->priv;
1200+
u32 mon_mask = RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK;
1201+
u32 val = RZG3L_PLL_STBY_RESETB_WEN;
12001202
u32 stby_offset, mon_offset;
1201-
u32 val, mon_val;
1203+
u32 mon_val = 0;
12021204
int ret;
12031205

12041206
stby_offset = RZG3L_PLL_STBY_OFFSET(pll_clk->conf);
12051207
mon_offset = RZG3L_PLL_MON_OFFSET(pll_clk->conf);
12061208

12071209
if (enable) {
1208-
val = RZG3L_PLL_STBY_RESETB_WEN | RZG3L_PLL_STBY_RESETB;
1209-
mon_val = RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK;
1210-
} else {
1211-
val = RZG3L_PLL_STBY_RESETB_WEN;
1212-
mon_val = 0;
1210+
val |= RZG3L_PLL_STBY_RESETB;
1211+
mon_val = mon_mask;
12131212
}
12141213

12151214
writel(val, priv->base + stby_offset);
12161215

12171216
/* ensure PLL is in normal/standby mode */
1218-
ret = readl_poll_timeout_atomic(priv->base + mon_offset, val, mon_val ==
1219-
(val & (RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK)),
1220-
10, 100);
1217+
ret = readl_poll_timeout_atomic(priv->base + mon_offset, val,
1218+
mon_val == (val & mon_mask), 10, 100);
12211219
if (ret)
12221220
dev_err(priv->dev, "Failed to %s PLL 0x%x/%pC\n", enable ?
12231221
"enable" : "disable", stby_offset, hw->clk);

0 commit comments

Comments
 (0)