* [PATCH v3 1/2] clk: palmas: Manage external-control prepare with devm
@ 2026-07-11 14:17 Myeonghun Pak
2026-07-11 14:17 ` [PATCH v3 2/2] clk: palmas: Use devm_of_clk_add_hw_provider() Myeonghun Pak
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-07-11 14:17 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: Brian Masney, linux-clk, linux-kernel, Myeonghun Pak, Ijae Kim
palmas_clks_init_configure() prepares the clock when an external control
pin is configured. The current driver only drops that prepare reference
when external control configuration fails.
If provider registration fails after that point, or if the driver is later
removed, the prepare reference remains held.
Register a device-managed action after clk_prepare() succeeds. This
balances the prepare reference on subsequent probe failure and driver
removal.
Fixes: 942d1d674931 ("clk: Add driver for Palmas clk32kg and clk32kgaudio clocks")
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 v3:
- Split external-control prepare lifetime handling from provider
registration.
drivers/clk/clk-palmas.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c
index 39049f62db..86a51edac8 100644
--- a/drivers/clk/clk-palmas.c
+++ b/drivers/clk/clk-palmas.c
@@ -194,6 +194,13 @@ static void palmas_clks_get_clk_data(struct platform_device *pdev,
cinfo->ext_control_pin = prop;
}
+static void palmas_clks_unprepare_ext_control(void *data)
+{
+ struct palmas_clock_info *cinfo = data;
+
+ clk_unprepare(cinfo->hw.clk);
+}
+
static int palmas_clks_init_configure(struct palmas_clock_info *cinfo)
{
int ret;
@@ -214,13 +221,18 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo)
return ret;
}
+ ret = devm_add_action_or_reset(cinfo->dev,
+ palmas_clks_unprepare_ext_control,
+ cinfo);
+ if (ret)
+ return ret;
+
ret = palmas_ext_control_req_config(cinfo->palmas,
cinfo->clk_desc->sleep_reqstr_id,
cinfo->ext_control_pin, true);
if (ret < 0) {
dev_err(cinfo->dev, "Ext config for %s failed, %d\n",
cinfo->clk_desc->clk_name, ret);
- clk_unprepare(cinfo->hw.clk);
return ret;
}
}
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v3 2/2] clk: palmas: Use devm_of_clk_add_hw_provider()
2026-07-11 14:17 [PATCH v3 1/2] clk: palmas: Manage external-control prepare with devm Myeonghun Pak
@ 2026-07-11 14:17 ` Myeonghun Pak
0 siblings, 0 replies; 2+ messages in thread
From: Myeonghun Pak @ 2026-07-11 14:17 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: Brian Masney, linux-clk, linux-kernel, Myeonghun Pak, Ijae Kim
Use devm_of_clk_add_hw_provider() to register the clock provider so its
lifetime is tied to the device. This removes the need for a remove callback
that only unregisters the provider.
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 v3:
- Split the device-managed provider conversion into a separate patch.
drivers/clk/clk-palmas.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c
index 86a51edac8..fdbf8445eb 100644
--- a/drivers/clk/clk-palmas.c
+++ b/drivers/clk/clk-palmas.c
@@ -242,7 +242,6 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo)
static int palmas_clks_probe(struct platform_device *pdev)
{
struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
- struct device_node *node = pdev->dev.of_node;
const struct palmas_clks_of_match_data *match_data;
struct palmas_clock_info *cinfo;
int ret;
@@ -276,24 +275,19 @@ static int palmas_clks_probe(struct platform_device *pdev)
return ret;
}
- ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, &cinfo->hw);
+ ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_simple_get,
+ &cinfo->hw);
if (ret < 0)
dev_err(&pdev->dev, "Fail to add clock driver, %d\n", ret);
return ret;
}
-static void palmas_clks_remove(struct platform_device *pdev)
-{
- of_clk_del_provider(pdev->dev.of_node);
-}
-
static struct platform_driver palmas_clks_driver = {
.driver = {
.name = "palmas-clk",
.of_match_table = palmas_clks_of_match,
},
.probe = palmas_clks_probe,
- .remove = palmas_clks_remove,
};
module_platform_driver(palmas_clks_driver);
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-11 14:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-11 14:17 [PATCH v3 1/2] clk: palmas: Manage external-control prepare with devm Myeonghun Pak
2026-07-11 14:17 ` [PATCH v3 2/2] clk: palmas: Use devm_of_clk_add_hw_provider() Myeonghun Pak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox