diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-01-04 23:55:11 +0100 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2024-02-28 17:01:55 -0800 |
commit | b0cde62e4c548b2e7cb535caa6eb0df135888601 (patch) | |
tree | 217c73cf57689bc8526f3693edba34ce271c1f44 /drivers/clk | |
parent | 6613476e225e090cc9aad49be7fa504e290dd33d (diff) |
clk: Add a devm variant of clk_rate_exclusive_get()
This allows to simplify drivers that use clk_rate_exclusive_get()
in their probe routine as calling clk_rate_exclusive_put() is cared for
automatically.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20240104225512.1124519-2-u.kleine-koenig@pengutronix.de
Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 2253c154a824..a3bc7fb90d0f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -939,6 +939,25 @@ int clk_rate_exclusive_get(struct clk *clk) } EXPORT_SYMBOL_GPL(clk_rate_exclusive_get); +static void devm_clk_rate_exclusive_put(void *data) +{ + struct clk *clk = data; + + clk_rate_exclusive_put(clk); +} + +int devm_clk_rate_exclusive_get(struct device *dev, struct clk *clk) +{ + int ret; + + ret = clk_rate_exclusive_get(clk); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_clk_rate_exclusive_put, clk); +} +EXPORT_SYMBOL_GPL(devm_clk_rate_exclusive_get); + static void clk_core_unprepare(struct clk_core *core) { lockdep_assert_held(&prepare_lock); |