]> Git Repo - J-linux.git/commitdiff
clk: Add a devm variant of clk_rate_exclusive_get()
authorUwe Kleine-König <[email protected]>
Thu, 4 Jan 2024 22:55:11 +0000 (23:55 +0100)
committerStephen Boyd <[email protected]>
Thu, 29 Feb 2024 01:01:55 +0000 (17:01 -0800)
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Acked-by: Russell King (Oracle) <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
drivers/clk/clk.c
include/linux/clk.h

index 2253c154a824834f8e58e9074de6e31a4f548c83..a3bc7fb90d0f2aa8b31d538a95f736a21f6976ce 100644 (file)
@@ -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);
index 06f1b292f8a00ad8f9221a2672baa71b9b6d41e7..24c49b01c25d26033f7504e519e7dd51a31a026a 100644 (file)
@@ -201,6 +201,18 @@ bool clk_is_match(const struct clk *p, const struct clk *q);
  */
 int clk_rate_exclusive_get(struct clk *clk);
 
+/**
+ * devm_clk_rate_exclusive_get - devm variant of clk_rate_exclusive_get
+ * @dev: device the exclusivity is bound to
+ * @clk: clock source
+ *
+ * Calls clk_rate_exclusive_get() on @clk and registers a devm cleanup handler
+ * on @dev to call clk_rate_exclusive_put().
+ *
+ * Must not be called from within atomic context.
+ */
+int devm_clk_rate_exclusive_get(struct device *dev, struct clk *clk);
+
 /**
  * clk_rate_exclusive_put - release exclusivity over the rate control of a
  *                          producer
This page took 0.064245 seconds and 4 git commands to generate.