Commit 867fb0bc authored by Biju Das's avatar Biju Das Committed by Geert Uytterhoeven
Browse files

clk: renesas: rzg2l: Add helper for mod clock enable/disable



Refactor rzg2l_mod_clock_endisable() by extracting its logic into a new
helper function rzg2l_mod_clock_endisable_helper(), which accepts an
additional set_mstop_state boolean parameter.  This allows callers to
control whether the module stop state is updated alongside the clock
enable/disable operation.  No functional change for existing callers.

Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20260324114329.268249-5-biju.das.jz@bp.renesas.com


Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent 5865d252
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -1439,7 +1439,8 @@ static int rzg2l_mod_clock_mstop_show(struct seq_file *s, void *what)
}
DEFINE_SHOW_ATTRIBUTE(rzg2l_mod_clock_mstop);

static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
static int rzg2l_mod_clock_endisable_helper(struct clk_hw *hw, bool enable,
					    bool set_mstop_state)
{
	struct mod_clock *clock = to_mod_clock(hw);
	struct rzg2l_cpg_priv *priv = clock->priv;
@@ -1464,8 +1465,10 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
	scoped_guard(spinlock_irqsave, &priv->rmw_lock) {
		if (enable) {
			writel(value, priv->base + CLK_ON_R(reg));
			if (set_mstop_state)
				rzg2l_mod_clock_module_set_state(clock, false);
		} else {
			if (set_mstop_state)
				rzg2l_mod_clock_module_set_state(clock, true);
			writel(value, priv->base + CLK_ON_R(reg));
		}
@@ -1486,6 +1489,11 @@ static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
	return error;
}

static int rzg2l_mod_clock_endisable(struct clk_hw *hw, bool enable)
{
	return rzg2l_mod_clock_endisable_helper(hw, enable, true);
}

static int rzg2l_mod_clock_enable(struct clk_hw *hw)
{
	struct mod_clock *clock = to_mod_clock(hw);