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-3-ricardo.ribalda@gmail.com>
Date:   Thu,  1 Nov 2018 15:40:41 +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 2/5] clk: Create devm_of_clk_add_provider

Implement devm_ flavour of of_clk_add_provider. This will help fixing
of_node_get-put imbalances.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
---
 Documentation/driver-model/devres.txt |  1 +
 drivers/clk/clk.c                     | 29 ++++++++++++++++++++++-----
 include/linux/clk-provider.h          | 11 ++++++++++
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 43681ca0837f..a8e066d42355 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -237,6 +237,7 @@ CLOCK
   devm_clk_get()
   devm_clk_put()
   devm_clk_hw_register()
+  devm_of_clk_add_provider()
   devm_of_clk_add_hw_provider()
 
 DMA
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index cd3117e66ab8..d315ffa6a32f 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3789,10 +3789,12 @@ static void devm_of_clk_release_provider(struct device *dev, void *res)
 	of_clk_del_provider(*(struct device_node **)res);
 }
 
-int devm_of_clk_add_hw_provider(struct device *dev,
-			struct clk_hw *(*get)(struct of_phandle_args *clkspec,
-					      void *data),
-			void *data)
+static int __devm_of_clk_add_provider(struct device *dev,
+		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 device_node **ptr, *np;
 	int ret;
@@ -3803,7 +3805,7 @@ int devm_of_clk_add_hw_provider(struct device *dev,
 		return -ENOMEM;
 
 	np = dev->of_node;
-	ret = of_clk_add_hw_provider(np, get, data);
+	ret = __of_clk_add_provider(np, clk_src_get, get, data);
 	if (!ret) {
 		*ptr = np;
 		devres_add(dev, ptr);
@@ -3813,6 +3815,23 @@ int devm_of_clk_add_hw_provider(struct device *dev,
 
 	return ret;
 }
+
+int devm_of_clk_add_provider(struct device *dev,
+		struct clk *(*clk_src_get)(struct of_phandle_args *clkspec,
+					   void *data),
+		void *data)
+{
+	return __devm_of_clk_add_provider(dev, clk_src_get, NULL, data);
+}
+EXPORT_SYMBOL_GPL(devm_of_clk_add_provider);
+
+int devm_of_clk_add_hw_provider(struct device *dev,
+			struct clk_hw *(*get)(struct of_phandle_args *clkspec,
+					      void *data),
+			void *data)
+{
+	return __devm_of_clk_add_provider(dev, NULL, get, data);
+}
 EXPORT_SYMBOL_GPL(devm_of_clk_add_hw_provider);
 
 /**
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 08b1aa70a38d..bbd86fe656ef 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -905,6 +905,10 @@ int of_clk_add_hw_provider(struct device_node *np,
 			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
 						 void *data),
 			   void *data);
+int devm_of_clk_add_provider(struct device *dev,
+		struct clk *(*clk_src_get)(struct of_phandle_args *clkspec,
+					   void *data),
+		void *data);
 int devm_of_clk_add_hw_provider(struct device *dev,
 			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
 						 void *data),
@@ -939,6 +943,13 @@ static inline int of_clk_add_hw_provider(struct device_node *np,
 {
 	return 0;
 }
+static inline int devm_of_clk_add_provider(struct device *dev,
+		struct clk *(*clk_src_get)(struct of_phandle_args *clkspec,
+					   void *data),
+		void *data)
+{
+	return 0;
+}
 static inline int devm_of_clk_add_hw_provider(struct device *dev,
 			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
 						 void *data),
-- 
2.19.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ