@@ -2705,6 +2705,19 @@ void devm_clk_unregister(struct device *dev, struct clk *clk)
}
EXPORT_SYMBOL_GPL(devm_clk_unregister);
+int devm_acquire_clock(struct device *dev,
+ const struct devm_resource *resource)
+{
+ struct clk **clkp = dev_get_drvdata(dev) + resource->offset;
+
+ *clkp = devm_clk_get(dev, resource->name);
+ if (IS_ERR(*clkp))
+ return PTR_ERR(*clkp);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devm_acquire_clock);
+
/*
* clkdev helpers
*/
@@ -17,6 +17,7 @@
#include <linux/notifier.h>
struct device;
+struct devm_resource;
struct clk;
@@ -138,6 +139,15 @@ int clk_get_phase(struct clk *clk);
*/
bool clk_is_match(const struct clk *p, const struct clk *q);
+int devm_acquire_clock(struct device *dev,
+ const struct devm_resource *resource);
+
+#define DEVM_CLOCK(_struct, _member, _name) { \
+ .initfunc = devm_acquire_clock, \
+ .offset = offsetof_t(struct _struct, _member, struct clk *), \
+ .name = _name, \
+}
+
#else
static inline long clk_get_accuracy(struct clk *clk)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/clk/clk.c | 13 +++++++++++++ include/linux/clk.h | 10 ++++++++++ 2 files changed, 23 insertions(+)