linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations
@ 2018-11-02 12:34 Matti Vaittinen
  2018-11-02 12:34 ` [PATCH v3 1/7] clk: clkdev/of_clk - add managed " Matti Vaittinen
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:34 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

Patch series adding managed clkdev and of_provider registrations

Few clk drivers appear to be leaking clkdev lookup registrations at
driver remove. The patch series adds devm versions of lookup
registrations and cleans up few drivers. Driver clean-up patches have
not been tested as I lack the HW. All testing and comments if
driver/device removal is even possible for changed drivers is highly
appreciated. If removal is not possible I will gladly drop the patches
from series - although leaking lookups may serve as bad example for new
developers =)

Changed drivers are:
clk-max77686, clk-st, clk-hi655x, rk808, clk-twl6040
and apcs-msm8916.

New devm registration variants have been tested on BeagleBoneBlack
using ROHM BD71837 PMIC driver.

Same devm variants were earlier proposed together with BD71837/BD71847
PMIC clk driver in this series:
https://lore.kernel.org/linux-clk/cover.1535630942.git.matti.vaittinen@fi.rohmeurope.com/

The BD71837/BD71847 work is currently pending for related MFD commits to
get merged in clk-tree and the devm functions are now submitted in this
series.

Changelog v3
Address issues spotted by Krzysztof Kozlowski
- Drop patch 3 for clk-s3c2410-dclk as this device can never be removed
- Fix indentiation for clk-max77686
- Rest  of the patches are unchanged.

Changelog v2
Issue spotted by 0-Day test suite
- Add a stub function 'devm_of_clk_add_parent_hw_provider' for no OF config.
- patches 2-8 are unchanged.

This patch series is based on clk-next

---

Matti Vaittinen (7):
  clk: clkdev/of_clk - add managed lookup and provider registrations
  clk: clk-max77686: Clean clkdev lookup leak and use devm
  clk: clk-st: avoid clkdev lookup leak at remove
  clk: clk-hi655x: Free of_provider at remove
  clk: rk808: use managed version of of_provider registration
  clk: clk-twl6040: Free of_provider at remove
  clk: apcs-msm8916: simplify probe cleanup by using devm

 Documentation/driver-model/devres.txt |   3 +
 drivers/clk/clk-hi655x.c              |   4 +-
 drivers/clk/clk-max77686.c            |  29 ++------
 drivers/clk/clk-rk808.c               |  15 +----
 drivers/clk/clk-twl6040.c             |   5 +-
 drivers/clk/clk.c                     |  28 ++++++--
 drivers/clk/clkdev.c                  | 122 ++++++++++++++++++++++++++--------
 drivers/clk/qcom/apcs-msm8916.c       |   5 +-
 drivers/clk/x86/clk-st.c              |   3 +-
 include/linux/clk-provider.h          |  11 +++
 include/linux/clkdev.h                |   4 ++
 11 files changed, 153 insertions(+), 76 deletions(-)

-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/7] clk: clkdev/of_clk - add managed lookup and provider registrations
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
@ 2018-11-02 12:34 ` Matti Vaittinen
  2018-11-02 12:35 ` [PATCH v3 2/7] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:34 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

With MFD devices the clk properties may be contained in MFD (parent) DT
node. Current devm_of_clk_add_hw_provider assumes the clk is bound to MFD
subdevice not to MFD device (parent). Add
devm_of_clk_add_hw_provider_parent to tackle this issue.

Also clkdev registration lacks of managed registration functions and it
seems few drivers do not drop clkdev lookups at exit. Add
devm_clk_hw_register_clkdev and devm_clk_release_clkdev to ease lookup
releasing at exit.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 Documentation/driver-model/devres.txt |   3 +
 drivers/clk/clk.c                     |  28 ++++++--
 drivers/clk/clkdev.c                  | 122 ++++++++++++++++++++++++++--------
 include/linux/clk-provider.h          |  11 +++
 include/linux/clkdev.h                |   4 ++
 5 files changed, 136 insertions(+), 32 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 43681ca0837f..fac63760b01c 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -238,6 +238,9 @@ CLOCK
   devm_clk_put()
   devm_clk_hw_register()
   devm_of_clk_add_hw_provider()
+  devm_of_clk_add_parent_hw_provider()
+  devm_clk_hw_register_clkdev()
+  devm_clk_release_clkdev()
 
 DMA
   dmaenginem_async_device_register()
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index af011974d4ec..9bb921eb90f6 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3893,12 +3893,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,
+static int __devm_of_clk_add_hw_provider(struct device *dev,
 			struct clk_hw *(*get)(struct of_phandle_args *clkspec,
 					      void *data),
-			void *data)
+			struct device_node *of_node, void *data)
 {
-	struct device_node **ptr, *np;
+	struct device_node **ptr;
 	int ret;
 
 	ptr = devres_alloc(devm_of_clk_release_provider, sizeof(*ptr),
@@ -3906,10 +3906,9 @@ int devm_of_clk_add_hw_provider(struct device *dev,
 	if (!ptr)
 		return -ENOMEM;
 
-	np = dev->of_node;
-	ret = of_clk_add_hw_provider(np, get, data);
+	*ptr = of_node;
+	ret = of_clk_add_hw_provider(of_node, get, data);
 	if (!ret) {
-		*ptr = np;
 		devres_add(dev, ptr);
 	} else {
 		devres_free(ptr);
@@ -3917,8 +3916,25 @@ int devm_of_clk_add_hw_provider(struct device *dev,
 
 	return ret;
 }
+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_hw_provider(dev, get, dev->of_node, data);
+}
 EXPORT_SYMBOL_GPL(devm_of_clk_add_hw_provider);
 
+int devm_of_clk_add_parent_hw_provider(struct device *dev,
+			struct clk_hw *(*get)(struct of_phandle_args *clkspec,
+					      void *data),
+			void *data)
+{
+	return __devm_of_clk_add_hw_provider(dev, get, dev->parent->of_node,
+					     data);
+}
+EXPORT_SYMBOL_GPL(devm_of_clk_add_parent_hw_provider);
+
 /**
  * of_clk_del_provider() - Remove a previously registered clock provider
  * @np: Device node pointer associated with clock provider
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 9ab3db8b3988..f6100b6e06fd 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -401,6 +401,25 @@ static struct clk_lookup *__clk_register_clkdev(struct clk_hw *hw,
 	return cl;
 }
 
+static int do_clk_register_clkdev(struct clk_hw *hw,
+	struct clk_lookup **cl, const char *con_id, const char *dev_id)
+{
+
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+	/*
+	 * Since dev_id can be NULL, and NULL is handled specially, we must
+	 * pass it as either a NULL format string, or with "%s".
+	 */
+	if (dev_id)
+		*cl = __clk_register_clkdev(hw, con_id, "%s",
+					   dev_id);
+	else
+		*cl = __clk_register_clkdev(hw, con_id, NULL);
+
+	return *cl ? 0 : -ENOMEM;
+}
+
 /**
  * clk_register_clkdev - register one clock lookup for a struct clk
  * @clk: struct clk to associate with all clk_lookups
@@ -420,20 +439,10 @@ int clk_register_clkdev(struct clk *clk, const char *con_id,
 {
 	struct clk_lookup *cl;
 
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
-	/*
-	 * Since dev_id can be NULL, and NULL is handled specially, we must
-	 * pass it as either a NULL format string, or with "%s".
-	 */
-	if (dev_id)
-		cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, "%s",
-					   dev_id);
-	else
-		cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, NULL);
-
-	return cl ? 0 : -ENOMEM;
+	if (!IS_ERR(clk))
+		return do_clk_register_clkdev(__clk_get_hw(clk), &cl, con_id,
+					      dev_id);
+	return PTR_ERR(clk);
 }
 EXPORT_SYMBOL(clk_register_clkdev);
 
@@ -456,18 +465,79 @@ int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id,
 {
 	struct clk_lookup *cl;
 
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	return do_clk_register_clkdev(hw, &cl, con_id, dev_id);
+}
+EXPORT_SYMBOL(clk_hw_register_clkdev);
 
-	/*
-	 * Since dev_id can be NULL, and NULL is handled specially, we must
-	 * pass it as either a NULL format string, or with "%s".
-	 */
-	if (dev_id)
-		cl = __clk_register_clkdev(hw, con_id, "%s", dev_id);
-	else
-		cl = __clk_register_clkdev(hw, con_id, NULL);
+static void devm_clkdev_release(struct device *dev, void *res)
+{
+	clkdev_drop(*(struct clk_lookup **)res);
+}
 
-	return cl ? 0 : -ENOMEM;
+static int devm_clk_match_clkdev(struct device *dev, void *res, void *data)
+{
+	struct clk_lookup **l = res;
+
+	if (!l || !*l) {
+		WARN_ON(!l || !*l);
+		return 0;
+	}
+	return *l == data;
 }
-EXPORT_SYMBOL(clk_hw_register_clkdev);
+
+/**
+ * devm_clk_release_clkdev - Resource managed clkdev lookup release
+ * @dev: device this lookup is bound
+ * @con_id: connection ID string on device
+ * @dev_id: format string describing device name
+ *
+ * Drop the clkdev lookup created with devm_clk_hw_register_clkdev.
+ * Normally this function will not need to be called and the resource
+ * management code will ensure that the resource is freed.
+ */
+void devm_clk_release_clkdev(struct device *dev, const char *con_id,
+			     const char *dev_id)
+{
+	struct clk_lookup *cl;
+	int rval;
+
+	cl = clk_find(dev_id, con_id);
+	WARN_ON(!cl);
+	rval = devres_release(dev, devm_clkdev_release,
+			      &devm_clk_match_clkdev, cl);
+	WARN_ON(rval);
+}
+EXPORT_SYMBOL(devm_clk_release_clkdev);
+
+/**
+ * devm_clk_hw_register_clkdev - managed clk lookup registration for clk_hw
+ * @dev: device this lookup is bound
+ * @hw: struct clk_hw to associate with all clk_lookups
+ * @con_id: connection ID string on device
+ * @dev_id: format string describing device name
+ *
+ * con_id or dev_id may be NULL as a wildcard, just as in the rest of
+ * clkdev.
+ *
+ * To make things easier for mass registration, we detect error clk_hws
+ * from a previous clk_hw_register_*() call, and return the error code for
+ * those.  This is to permit this function to be called immediately
+ * after clk_hw_register_*().
+ */
+int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw,
+				const char *con_id, const char *dev_id)
+{
+	int rval = -ENOMEM;
+	struct clk_lookup **cl;
+
+	cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL);
+	if (cl) {
+		rval = do_clk_register_clkdev(hw, cl, con_id, dev_id);
+		if (!rval)
+			devres_add(dev, cl);
+		else
+			devres_free(cl);
+	}
+	return rval;
+}
+EXPORT_SYMBOL(devm_clk_hw_register_clkdev);
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 60c51871b04b..a6663f084cf1 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -916,6 +916,10 @@ int devm_of_clk_add_hw_provider(struct device *dev,
 			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
 						 void *data),
 			   void *data);
+int devm_of_clk_add_parent_hw_provider(struct device *dev,
+			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
+						 void *data),
+			   void *data);
 void of_clk_del_provider(struct device_node *np);
 void devm_of_clk_del_provider(struct device *dev);
 struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec,
@@ -953,6 +957,13 @@ static inline int devm_of_clk_add_hw_provider(struct device *dev,
 {
 	return 0;
 }
+static inline int devm_of_clk_add_parent_hw_provider(struct device *dev,
+			   struct clk_hw *(*get)(struct of_phandle_args *clkspec,
+						 void *data),
+			   void *data)
+{
+	return 0;
+}
 static inline void of_clk_del_provider(struct device_node *np) {}
 static inline void devm_of_clk_del_provider(struct device *dev) {}
 static inline struct clk *of_clk_src_simple_get(
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
index 4890ff033220..ccb32af5848b 100644
--- a/include/linux/clkdev.h
+++ b/include/linux/clkdev.h
@@ -52,4 +52,8 @@ int clk_add_alias(const char *, const char *, const char *, struct device *);
 int clk_register_clkdev(struct clk *, const char *, const char *);
 int clk_hw_register_clkdev(struct clk_hw *, const char *, const char *);
 
+int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw,
+				const char *con_id, const char *dev_id);
+void devm_clk_release_clkdev(struct device *dev, const char *con_id,
+			     const char *dev_id);
 #endif
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 2/7] clk: clk-max77686: Clean clkdev lookup leak and use devm
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
  2018-11-02 12:34 ` [PATCH v3 1/7] clk: clkdev/of_clk - add managed " Matti Vaittinen
@ 2018-11-02 12:35 ` Matti Vaittinen
  2018-11-02 12:36 ` [PATCH v3 3/7] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:35 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

clk-max77686 never clean clkdev lookup at remove. This can cause
oops if clk-max77686 is removed and inserted again. Fix leak by
using new devm clkdev lookup registration. Simplify also error
path by using new devm_of_clk_add_parent_hw_provider.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/clk/clk-max77686.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c
index 02551fe4b87c..51a46179f6f8 100644
--- a/drivers/clk/clk-max77686.c
+++ b/drivers/clk/clk-max77686.c
@@ -235,8 +235,9 @@ static int max77686_clk_probe(struct platform_device *pdev)
 			return ret;
 		}
 
-		ret = clk_hw_register_clkdev(&max_clk_data->hw,
-					     max_clk_data->clk_idata.name, NULL);
+		ret = devm_clk_hw_register_clkdev(dev, &max_clk_data->hw,
+						  max_clk_data->clk_idata.name,
+						  NULL);
 		if (ret < 0) {
 			dev_err(dev, "Failed to clkdev register: %d\n", ret);
 			return ret;
@@ -244,8 +245,9 @@ static int max77686_clk_probe(struct platform_device *pdev)
 	}
 
 	if (parent->of_node) {
-		ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get,
-					     drv_data);
+		ret = devm_of_clk_add_parent_hw_provider(dev,
+							 of_clk_max77686_get,
+							 drv_data);
 
 		if (ret < 0) {
 			dev_err(dev, "Failed to register OF clock provider: %d\n",
@@ -261,27 +263,11 @@ static int max77686_clk_probe(struct platform_device *pdev)
 					 1 << MAX77802_CLOCK_LOW_JITTER_SHIFT);
 		if (ret < 0) {
 			dev_err(dev, "Failed to config low-jitter: %d\n", ret);
-			goto remove_of_clk_provider;
+			return ret;
 		}
 	}
 
 	return 0;
-
-remove_of_clk_provider:
-	if (parent->of_node)
-		of_clk_del_provider(parent->of_node);
-
-	return ret;
-}
-
-static int max77686_clk_remove(struct platform_device *pdev)
-{
-	struct device *parent = pdev->dev.parent;
-
-	if (parent->of_node)
-		of_clk_del_provider(parent->of_node);
-
-	return 0;
 }
 
 static const struct platform_device_id max77686_clk_id[] = {
@@ -297,7 +283,6 @@ static struct platform_driver max77686_clk_driver = {
 		.name  = "max77686-clk",
 	},
 	.probe = max77686_clk_probe,
-	.remove = max77686_clk_remove,
 	.id_table = max77686_clk_id,
 };
 
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 3/7] clk: clk-st: avoid clkdev lookup leak at remove
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
  2018-11-02 12:34 ` [PATCH v3 1/7] clk: clkdev/of_clk - add managed " Matti Vaittinen
  2018-11-02 12:35 ` [PATCH v3 2/7] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
@ 2018-11-02 12:36 ` Matti Vaittinen
  2018-11-02 12:36 ` [PATCH v3 4/7] clk: clk-hi655x: Free of_provider " Matti Vaittinen
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:36 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

Use devm based clkdev lookup registration to avoid leaking lookup
structures.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/x86/clk-st.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c
index fb62f3938008..32d8df9bd853 100644
--- a/drivers/clk/x86/clk-st.c
+++ b/drivers/clk/x86/clk-st.c
@@ -52,7 +52,8 @@ static int st_clk_probe(struct platform_device *pdev)
 		0, st_data->base + MISCCLKCNTL1, OSCCLKENB,
 		CLK_GATE_SET_TO_DISABLE, NULL);
 
-	clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL);
+	devm_clk_hw_register_clkdev(&pdev->dev, hws[ST_CLK_GATE], "oscout1",
+				    NULL);
 
 	return 0;
 }
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 4/7] clk: clk-hi655x: Free of_provider at remove
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (2 preceding siblings ...)
  2018-11-02 12:36 ` [PATCH v3 3/7] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
@ 2018-11-02 12:36 ` Matti Vaittinen
  2018-11-02 12:37 ` [PATCH v3 5/7] clk: rk808: use managed version of of_provider registration Matti Vaittinen
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:36 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

use devm variant for of_provider registration so provider is freed
at exit.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/clk-hi655x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-hi655x.c b/drivers/clk/clk-hi655x.c
index 403a0188634a..394d0109104d 100644
--- a/drivers/clk/clk-hi655x.c
+++ b/drivers/clk/clk-hi655x.c
@@ -107,8 +107,8 @@ static int hi655x_clk_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	return of_clk_add_hw_provider(parent->of_node, of_clk_hw_simple_get,
-				     &hi655x_clk->clk_hw);
+	return devm_of_clk_add_parent_hw_provider(&pdev->dev,
+				of_clk_hw_simple_get, &hi655x_clk->clk_hw);
 }
 
 static struct platform_driver hi655x_clk_driver = {
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 5/7] clk: rk808: use managed version of of_provider registration
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (3 preceding siblings ...)
  2018-11-02 12:36 ` [PATCH v3 4/7] clk: clk-hi655x: Free of_provider " Matti Vaittinen
@ 2018-11-02 12:37 ` Matti Vaittinen
  2018-11-02 12:37 ` [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
  2018-11-02 12:38 ` [PATCH v3 7/7] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:37 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

Simplify clean-up for rk808 by using managed version of of_provider
registration.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/clk-rk808.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c
index 6461f2820a5b..177340edaae5 100644
--- a/drivers/clk/clk-rk808.c
+++ b/drivers/clk/clk-rk808.c
@@ -138,23 +138,12 @@ static int rk808_clkout_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	return of_clk_add_hw_provider(node, of_clk_rk808_get, rk808_clkout);
-}
-
-static int rk808_clkout_remove(struct platform_device *pdev)
-{
-	struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
-	struct i2c_client *client = rk808->i2c;
-	struct device_node *node = client->dev.of_node;
-
-	of_clk_del_provider(node);
-
-	return 0;
+	return devm_of_clk_add_parent_hw_provider(&pdev->dev,
+					of_clk_rk808_get, rk808_clkout);
 }
 
 static struct platform_driver rk808_clkout_driver = {
 	.probe = rk808_clkout_probe,
-	.remove = rk808_clkout_remove,
 	.driver		= {
 		.name	= "rk808-clkout",
 	},
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (4 preceding siblings ...)
  2018-11-02 12:37 ` [PATCH v3 5/7] clk: rk808: use managed version of of_provider registration Matti Vaittinen
@ 2018-11-02 12:37 ` Matti Vaittinen
  2018-11-02 12:49   ` Peter Ujfalusi
  2018-11-02 12:38 ` [PATCH v3 7/7] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen
  6 siblings, 1 reply; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:37 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

use devm variant for of_provider registration so provider is freed
at exit.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/clk-twl6040.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-twl6040.c b/drivers/clk/clk-twl6040.c
index 25dfe050ae9f..e9da09453eb2 100644
--- a/drivers/clk/clk-twl6040.c
+++ b/drivers/clk/clk-twl6040.c
@@ -108,9 +108,8 @@ static int twl6040_pdmclk_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, clkdata);
 
-	return of_clk_add_hw_provider(pdev->dev.parent->of_node,
-				      of_clk_hw_simple_get,
-				      &clkdata->pdmclk_hw);
+	return devm_of_clk_add_parent_hw_provider(&pdev->dev,
+			of_clk_hw_simple_get, &clkdata->pdmclk_hw);
 }
 
 static struct platform_driver twl6040_pdmclk_driver = {
-- 
2.14.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 7/7] clk: apcs-msm8916: simplify probe cleanup by using devm
  2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (5 preceding siblings ...)
  2018-11-02 12:37 ` [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
@ 2018-11-02 12:38 ` Matti Vaittinen
  6 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2018-11-02 12:38 UTC (permalink / raw)
  To: Jonathan Corbet, Michael Turquette, Stephen Boyd, Chanwoo Choi,
	Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz, Russell King,
	Andy Gross, David Brown, Kukjin Kim, Sylwester Nawrocki,
	Tomasz Figa, Andrey Smirnov, Sebastian Reichel, Guenter Roeck,
	Rob Herring, Matti Vaittinen, Huang Shijie, Akshu Agrawal,
	Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-doc, linux-kernel, linux-clk, linux-arm-kernel,
	linux-arm-msm, linux-soc, linux-samsung-soc, matti.vaittinen

use devm variant for of_provider registration.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/qcom/apcs-msm8916.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c
index b1cc8dbcd327..f4e0c136ab1a 100644
--- a/drivers/clk/qcom/apcs-msm8916.c
+++ b/drivers/clk/qcom/apcs-msm8916.c
@@ -96,8 +96,8 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev)
 		goto err;
 	}
 
-	ret = of_clk_add_hw_provider(parent->of_node, of_clk_hw_simple_get,
-				     &a53cc->clkr.hw);
+	ret = devm_of_clk_add_parent_hw_provider(dev, of_clk_hw_simple_get,
+						 &a53cc->clkr.hw);
 	if (ret) {
 		dev_err(dev, "failed to add clock provider: %d\n", ret);
 		goto err;
@@ -118,7 +118,6 @@ static int qcom_apcs_msm8916_clk_remove(struct platform_device *pdev)
 	struct device *parent = pdev->dev.parent;
 
 	clk_notifier_unregister(a53cc->pclk, &a53cc->clk_nb);
-	of_clk_del_provider(parent->of_node);
 
 	return 0;
 }
-- 
2.14.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove
  2018-11-02 12:37 ` [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
@ 2018-11-02 12:49   ` Peter Ujfalusi
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2018-11-02 12:49 UTC (permalink / raw)
  To: Matti Vaittinen, Jonathan Corbet, Michael Turquette,
	Stephen Boyd, Chanwoo Choi, Krzysztof Kozlowski,
	Bartlomiej Zolnierkiewicz, Russell King, Andy Gross, David Brown,
	Kukjin Kim, Sylwester Nawrocki, Tomasz Figa, Andrey Smirnov,
	Sebastian Reichel, Guenter Roeck, Rob Herring, Huang Shijie,
	Akshu Agrawal, Rafael J. Wysocki, Daniel Kurtz, mazziesaccount
  Cc: linux-samsung-soc, linux-doc, linux-arm-msm, linux-kernel,
	linux-soc, linux-clk, linux-arm-kernel



On 11/2/18 2:37 PM, Matti Vaittinen wrote:
> use devm variant for of_provider registration so provider is freed
> at exit.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> ---
>  drivers/clk/clk-twl6040.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/clk/clk-twl6040.c b/drivers/clk/clk-twl6040.c
> index 25dfe050ae9f..e9da09453eb2 100644
> --- a/drivers/clk/clk-twl6040.c
> +++ b/drivers/clk/clk-twl6040.c
> @@ -108,9 +108,8 @@ static int twl6040_pdmclk_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, clkdata);
>  
> -	return of_clk_add_hw_provider(pdev->dev.parent->of_node,
> -				      of_clk_hw_simple_get,
> -				      &clkdata->pdmclk_hw);
> +	return devm_of_clk_add_parent_hw_provider(&pdev->dev,
> +			of_clk_hw_simple_get, &clkdata->pdmclk_hw);
>  }
>  
>  static struct platform_driver twl6040_pdmclk_driver = {
> 

- Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-02 12:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02 12:34 [PATCH v3 0/7] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
2018-11-02 12:34 ` [PATCH v3 1/7] clk: clkdev/of_clk - add managed " Matti Vaittinen
2018-11-02 12:35 ` [PATCH v3 2/7] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
2018-11-02 12:36 ` [PATCH v3 3/7] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
2018-11-02 12:36 ` [PATCH v3 4/7] clk: clk-hi655x: Free of_provider " Matti Vaittinen
2018-11-02 12:37 ` [PATCH v3 5/7] clk: rk808: use managed version of of_provider registration Matti Vaittinen
2018-11-02 12:37 ` [PATCH v3 6/7] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
2018-11-02 12:49   ` Peter Ujfalusi
2018-11-02 12:38 ` [PATCH v3 7/7] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).