summaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-01-31 08:57:15 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-02-01 09:01:34 +0100
commit8b0ca7a885eaa244b7cf23895f4ee9c264efcfbd (patch)
tree5d9178b2209c25a9ffcb058fda40fecf9a8e5d90 /drivers/clk
parenteab2a98fa6b33a75420ce50cd23147c659e4abd4 (diff)
downloadbarebox-8b0ca7a885eaa244b7cf23895f4ee9c264efcfbd.tar.gz
barebox-8b0ca7a885eaa244b7cf23895f4ee9c264efcfbd.tar.xz
clk: composite: add clk_hw registration functions
Save users the hassle of opencoding by providing wrappers with the same Linux semantics: names are duplicated, same arguments and struct clk_hw is returned. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220131075725.1873026-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-composite.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 479ac5e8ef..63056b7696 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -171,3 +171,28 @@ err:
kfree(composite);
return 0;
}
+
+struct clk_hw *clk_hw_register_composite(struct device_d *dev,
+ const char *name, const char * const *parent_names,
+ int num_parents,
+ struct clk_hw *mux_hw, const struct clk_ops *mux_ops,
+ struct clk_hw *rate_hw, const struct clk_ops *rate_ops,
+ struct clk_hw *gate_hw, const struct clk_ops *gate_ops,
+ unsigned long flags)
+{
+ struct clk *clk;
+ mux_hw->clk.ops = mux_ops;
+ rate_hw->clk.ops = rate_ops;
+ gate_hw->clk.ops = gate_ops;
+
+ parent_names = memdup_array(parent_names, num_parents);
+ if (!parent_names)
+ return ERR_PTR(-ENOMEM);
+
+ clk = clk_register_composite(xstrdup(name), parent_names, num_parents,
+ mux_hw ? &mux_hw->clk : NULL,
+ rate_hw ? &rate_hw->clk : NULL,
+ gate_hw ? &gate_hw->clk : NULL,
+ flags);
+ return clk_to_clk_hw(clk);
+}