lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181101144044.11495-2-ricardo.ribalda@gmail.com>
Date:   Thu,  1 Nov 2018 15:40:40 +0100
From:   Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
To:     Stephen Boyd <sboyd@...nel.org>, Alan Tull <atull@...nel.org>,
        linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Subject: [PATCH 1/5] clk: Refactor of_clk_add_provider and of_clk_add_hw_provider

Both functions have almost the same functionality. Create a helper
function that is called by both functions.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
---
 drivers/clk/clk.c | 49 +++++++++++++++++++----------------------------
 1 file changed, 20 insertions(+), 29 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index d31055ae6ec6..cd3117e66ab8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3723,15 +3723,11 @@ of_clk_hw_onecell_get(struct of_phandle_args *clkspec, void *data)
 }
 EXPORT_SYMBOL_GPL(of_clk_hw_onecell_get);
 
-/**
- * of_clk_add_provider() - Register a clock provider for a node
- * @np: Device node pointer associated with clock provider
- * @clk_src_get: callback for decoding clock
- * @data: context pointer for @clk_src_get callback.
- */
-int of_clk_add_provider(struct device_node *np,
+static int __of_clk_add_provider(struct device_node *np,
 			struct clk *(*clk_src_get)(struct of_phandle_args *clkspec,
 						   void *data),
+			struct clk_hw *(*get)(struct of_phandle_args *clkspec,
+						 void *data),
 			void *data)
 {
 	struct of_clk_provider *cp;
@@ -3744,11 +3740,12 @@ int of_clk_add_provider(struct device_node *np,
 	cp->node = of_node_get(np);
 	cp->data = data;
 	cp->get = clk_src_get;
+	cp->get_hw = get;
 
 	mutex_lock(&of_clk_mutex);
 	list_add(&cp->link, &of_clk_providers);
 	mutex_unlock(&of_clk_mutex);
-	pr_debug("Added clock from %pOF\n", np);
+	pr_debug("Added clock%s from %pOF\n", get?"_hw provider":"", np);
 
 	ret = of_clk_set_defaults(np, true);
 	if (ret < 0)
@@ -3756,6 +3753,20 @@ int of_clk_add_provider(struct device_node *np,
 
 	return ret;
 }
+
+/**
+ * of_clk_add_provider() - Register a clock provider for a node
+ * @np: Device node pointer associated with clock provider
+ * @clk_src_get: callback for decoding clock
+ * @data: context pointer for @clk_src_get callback.
+ */
+int of_clk_add_provider(struct device_node *np,
+		struct clk *(*clk_src_get)(struct of_phandle_args *clkspec,
+					   void *data),
+		void *data)
+{
+	return  __of_clk_add_provider(np, clk_src_get, NULL, data);
+}
 EXPORT_SYMBOL_GPL(of_clk_add_provider);
 
 /**
@@ -3769,27 +3780,7 @@ int of_clk_add_hw_provider(struct device_node *np,
 						 void *data),
 			   void *data)
 {
-	struct of_clk_provider *cp;
-	int ret;
-
-	cp = kzalloc(sizeof(*cp), GFP_KERNEL);
-	if (!cp)
-		return -ENOMEM;
-
-	cp->node = of_node_get(np);
-	cp->data = data;
-	cp->get_hw = get;
-
-	mutex_lock(&of_clk_mutex);
-	list_add(&cp->link, &of_clk_providers);
-	mutex_unlock(&of_clk_mutex);
-	pr_debug("Added clk_hw provider from %pOF\n", np);
-
-	ret = of_clk_set_defaults(np, true);
-	if (ret < 0)
-		of_clk_del_provider(np);
-
-	return ret;
+	return  __of_clk_add_provider(np, NULL, get, data);
 }
 EXPORT_SYMBOL_GPL(of_clk_add_hw_provider);
 
-- 
2.19.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ