clk: Add a devm variant of clk_rate_exclusive_get()
[linux-2.6-microblaze.git] / drivers / clk / clk.c
index 2253c15..a3bc7fb 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);