[PATCH 2/4] clk: of: drop arguments from of_clk_init()

Sascha Hauer s.hauer at pengutronix.de
Wed Mar 22 01:32:43 PDT 2023


of_clk_init() should be used to register clock drivers declared with
CLK_OF_DECLARE and nothing else, so there shouldn't be a need to call
it with a non NULL "matches" argument.

Also there is no point in calling this function with another device tree
than the barebox live tree.

Drop both arguments.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/clk/clk.c   | 10 +++-------
 drivers/of/base.c   |  2 +-
 include/linux/clk.h |  5 ++---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 30fe43032b..c7ee6878c2 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -849,28 +849,24 @@ static int parent_ready(struct device_node *np)
 
 /**
  * of_clk_init() - Scan and init clock providers from the DT
- * @root: parent of the first level to probe or NULL for the root of the tree
- * @matches: array of compatible values and init functions for providers.
  *
  * This function scans the device tree for matching clock providers and
  * calls their initialization functions
  *
  * Returns 0 on success, < 0 on failure.
  */
-int of_clk_init(struct device_node *root, const struct of_device_id *matches)
+int of_clk_init(void)
 {
+	struct device_node *root = of_get_root_node();
+	const struct of_device_id *matches = __clk_of_table_start;
 	struct clock_provider *clk_provider, *next;
 	bool is_init_done;
 	bool force = false;
 	LIST_HEAD(clk_provider_list);
 	const struct of_device_id *match;
 
-	if (!root)
-		root = of_find_node_by_path("/");
 	if (!root)
 		return -EINVAL;
-	if (!matches)
-		matches = __clk_of_table_start;
 
 	/* First prepare the list of the clocks providers */
 	for_each_matching_node_and_match(root, matches, &match) {
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea4be9c512..acebba29a1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1757,7 +1757,7 @@ int barebox_register_of(struct device_node *root)
 	of_fix_tree(root);
 
 	if (IS_ENABLED(CONFIG_OFDEVICE)) {
-		of_clk_init(root, NULL);
+		of_clk_init();
 		if (!deep_probe_is_supported())
 			return of_probe();
 	}
diff --git a/include/linux/clk.h b/include/linux/clk.h
index bffed2bdcf..29c697a00b 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -686,7 +686,7 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
 unsigned int of_clk_get_parent_count(struct device_node *np);
 int of_clk_parent_fill(struct device_node *np, const char **parents,
 		       unsigned int size);
-int of_clk_init(struct device_node *root, const struct of_device_id *matches);
+int of_clk_init(void);
 int of_clk_add_provider(struct device_node *np,
 			struct clk *(*clk_src_get)(struct of_phandle_args *args,
 						   void *data),
@@ -742,8 +742,7 @@ static inline unsigned int of_clk_get_parent_count(struct device_node *np)
 {
 	return 0;
 }
-static inline int of_clk_init(struct device_node *root,
-			      const struct of_device_id *matches)
+static inline int of_clk_init(void)
 {
 	return 0;
 }
-- 
2.30.2




More information about the barebox mailing list