Linux clock framework development
 help / color / mirror / Atom feed
From: Myeonghun Pak <mhun512@gmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	Myeonghun Pak <mhun512@gmail.com>, Ijae Kim <ae878000@gmail.com>
Subject: [PATCH v2] clk: si5341: disable input clock on probe failure and remove
Date: Mon, 29 Jun 2026 01:19:43 +0900	[thread overview]
Message-ID: <20260628161958.25876-1-mhun512@gmail.com> (raw)
In-Reply-To: <20260626093410.67573-1-mhun512@gmail.com>

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@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
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

      parent reply	other threads:[~2026-06-28 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  9:33 [PATCH] clk: si5341: disable input clock on probe failure and remove Myeonghun Pak
2026-06-26 10:13 ` Mike Looijmans
2026-06-28 16:19 ` Myeonghun Pak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260628161958.25876-1-mhun512@gmail.com \
    --to=mhun512@gmail.com \
    --cc=ae878000@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.looijmans@topic.nl \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox