[PATCH] clkdev: add helper function to register one clock lookup for a struct clk

Carlo Caione carlo.caione at gmail.com
Thu Oct 18 15:40:16 EDT 2012


Signed-off-by: Carlo Caione <carlo.caione at gmail.com>
---
 drivers/clk/clkdev.c   | 21 +++++++++++++++++++++
 include/linux/clkdev.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 1ae822f..5441eeb 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -178,6 +178,27 @@ struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
 }
 EXPORT_SYMBOL(clkdev_alloc);
 
+int clk_register_clkdev(struct clk *clk, const char *con_id,
+	const char *dev_fmt, ...)
+{
+	struct clk_lookup *cl;
+	va_list ap;
+
+	if (IS_ERR(clk))
+                return PTR_ERR(clk);
+
+	va_start(ap, dev_fmt);
+	cl = clkdev_alloc(clk, con_id, dev_fmt, ap);
+	va_end(ap);
+
+	if (!cl)
+		return -ENOMEM;
+
+	clkdev_add(cl);
+
+	return 0;
+}
+
 int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
 	struct device_d *dev)
 {
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
index d2f0d89..1fc0ab9 100644
--- a/include/linux/clkdev.h
+++ b/include/linux/clkdev.h
@@ -33,6 +33,7 @@ void clkdev_drop(struct clk_lookup *cl);
 
 void clkdev_add_table(struct clk_lookup *, size_t);
 int clk_add_alias(const char *, const char *, char *, struct device_d *);
+int clk_register_clkdev(struct clk *, const char *, const char *, ...);
 
 int clkdev_add_physbase(struct clk *clk, unsigned long base, const char *id);
 
-- 
1.7.12.3




More information about the barebox mailing list