From ed82a1742aee462cc0093212ea4b8838a98fc4ef Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 13 Apr 2020 09:51:51 +0200 Subject: clk: implement clk_register_fixed_rate 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 Signed-off-by: Sascha Hauer --- drivers/clk/clk-fixed.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c index 57bf36b39e..411f6fe473 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); } -- cgit v1.2.3