[PATCH 08/21] clk: implement clk_register_fixed_rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We lack a way to instantiate a fixed clock while specifying a parent.
This is used in the at91 clock code sync with upstream in a later
commit, so prepare by porting clk_register_fixed_rate.

It's based on the Linux commit of the same name with the difference that
it doesn't use (and thus doesn't require) a struct device_d * as first
parameter.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/clk/clk-fixed.c | 16 +++++++++++++++-
 include/linux/clk.h     |  9 ++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index 57bf36b39ecd..411f6fe4736a 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -37,17 +37,31 @@ static struct clk_ops clk_fixed_ops = {
 	.is_enabled = clk_is_enabled_always,
 };
 
-struct clk *clk_fixed(const char *name, int rate)
+struct clk *clk_register_fixed_rate(const char *name,
+				    const char *parent_name, unsigned long flags,
+				    unsigned long rate)
 {
 	struct clk_fixed *fix = xzalloc(sizeof *fix);
+	const char **parent_names = NULL;
 	int ret;
 
 	fix->rate = rate;
 	fix->clk.ops = &clk_fixed_ops;
 	fix->clk.name = name;
+	fix->clk.flags = flags;
+
+	if (parent_name) {
+		parent_names = kzalloc(sizeof(const char *), GFP_KERNEL);
+		if (!parent_names)
+			return ERR_PTR(-ENOMEM);
+
+		fix->clk.parent_names = parent_names;
+		fix->clk.num_parents = 1;
+	}
 
 	ret = clk_register(&fix->clk);
 	if (ret) {
+		free(parent_names);
 		free(fix);
 		return ERR_PTR(ret);
 	}
diff --git a/include/linux/clk.h b/include/linux/clk.h
index c3aeea80ddc5..efb0fe4415aa 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -325,7 +325,14 @@ struct clk_div_table {
 	unsigned int	div;
 };
 
-struct clk *clk_fixed(const char *name, int rate);
+struct clk *clk_register_fixed_rate(const char *name,
+				    const char *parent_name, unsigned long flags,
+				    unsigned long fixed_rate);
+
+static inline struct clk *clk_fixed(const char *name, int rate)
+{
+	return clk_register_fixed_rate(name, NULL, 0, rate);
+}
 
 struct clk_divider {
 	struct clk clk;
-- 
2.26.0.rc2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux