All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>, Alan Tull <atull@kernel.org>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Subject: [PATCH 2/5] clk: Create devm_of_clk_add_provider
Date: Thu,  1 Nov 2018 15:40:41 +0100	[thread overview]
Message-ID: <20181101144044.11495-3-ricardo.ribalda@gmail.com> (raw)
In-Reply-To: <20181101144044.11495-1-ricardo.ribalda@gmail.com>

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@gmail.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


  parent reply	other threads:[~2018-11-01 14:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 14:40 [PATCH 0/5] Implement devm_of_clk_add_provider Ricardo Ribalda Delgado
2018-11-01 14:40 ` [PATCH 1/5] clk: Refactor of_clk_add_provider and of_clk_add_hw_provider Ricardo Ribalda Delgado
2018-11-01 14:40 ` Ricardo Ribalda Delgado [this message]
2018-11-01 14:40 ` [PATCH 3/5] clk: fixed-factor: Use devm_of_clk_add_provider Ricardo Ribalda Delgado
2018-11-01 14:40 ` [PATCH 4/5] clk: fixed-rate: " Ricardo Ribalda Delgado
2018-11-01 14:40 ` [PATCH 5/5] clk: gpio: " Ricardo Ribalda Delgado
2018-11-01 23:35 ` [PATCH 0/5] Implement devm_of_clk_add_provider Stephen Boyd
2018-11-02  6:54   ` Ricardo Ribalda Delgado
2018-11-02 16:05     ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181101144044.11495-3-ricardo.ribalda@gmail.com \
    --to=ricardo.ribalda@gmail.com \
    --cc=atull@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.