[PATCH v2] clk: si5341: disable input clock on probe failure and remove

From: Myeonghun Pak

Date: Sun Jun 28 2026 - 12:20:19 EST


si5341_clk_select_active_input() prepares and enables the selected
input clock, but the driver never disables it. devm_clk_get() only
releases the clock handle; it does not unwind the prepare/enable count.

Register a devm cleanup action for the exact input clock after
clk_prepare_enable() succeeds. This unwinds the prepare/enable reference
on both probe failure after input selection and driver detach, without
having to re-read the current input parent later.

Fixes: 3044a860fd09 ("clk: Add Si5341/Si5340 driver")
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
Changes in v2:
- Use devm_add_action_or_reset() for the prepared input clock.
- Drop the prepared_input state and manual cleanup calls.

drivers/clk/clk-si5341.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c
index 2499b77..2c36757 100644
--- a/drivers/clk/clk-si5341.c
+++ b/drivers/clk/clk-si5341.c
@@ -1426,6 +1426,11 @@ static int si5341_initialize_pll(struct clk_si5341 *data)
SI5341_PLL_M_NUM, m_num, m_den);
}

+static void si5341_clk_disable_unprepare(void *clk)
+{
+ clk_disable_unprepare(clk);
+}
+
static int si5341_clk_select_active_input(struct clk_si5341 *data)
{
int res;
@@ -1463,6 +1468,12 @@ static int si5341_clk_select_active_input(struct clk_si5341 *data)
if (err < 0)
return err;

+ err = devm_add_action_or_reset(&data->i2c_client->dev,
+ si5341_clk_disable_unprepare,
+ data->input_clk[res]);
+ if (err < 0)
+ return err;
+
return res;
}

--
2.50.0