]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: renesas: rzg2l: Add helper for mod clock enable/disable
authorBiju Das <biju.das.jz@bp.renesas.com>
Tue, 24 Mar 2026 11:43:09 +0000 (11:43 +0000)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 26 Mar 2026 18:40:14 +0000 (19:40 +0100)
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: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20260324114329.268249-5-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
drivers/clk/renesas/rzg2l-cpg.c

index f9e4af7f49d002e7086e28f2553d0775b62acc09..a38401c18dcfb9e6e14148eb7aa80d3ab0e68e70 100644 (file)
@@ -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,9 +1465,11 @@ 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));
-                       rzg2l_mod_clock_module_set_state(clock, false);
+                       if (set_mstop_state)
+                               rzg2l_mod_clock_module_set_state(clock, false);
                } else {
-                       rzg2l_mod_clock_module_set_state(clock, true);
+                       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);