linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations
@ 2018-12-03 12:17 Matti Vaittinen
  2018-12-03 12:17 ` [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Matti Vaittinen
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:17 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

Series add bd71837/bd71837 PMIC clock support + managed interfaces

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 =)

Patch 8 adds support for clock gate in ROHM bd71837 and bd71847 PMICs.
This change is included in the series because it depends on new managed
interfaces introduced in this series.

bd718x7 driver and devm interfaces are tested on BeagleBoneBlack and 
bd71837 break-out board. Clk area register interface of bd71847 is
identical to bd71837.

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

This series has been discussed for a while now. For those who want to
see whole discussion:

The bd71837 driver was originally proposed here
https://lore.kernel.org/lkml/d99c8762b0fbbcb18ec4f4d104191364c0ea798c.1528117485.git.matti.vaittinen@fi.rohmeurope.com/

clk portion was separated from that series and devm variants were
proposed here
https://lore.kernel.org/linux-clk/cover.1535630942.git.matti.vaittinen@fi.rohmeurope.com/

Cleanup to other drivers was initiated in this series while waiting for
MFD portions of bd718x7 to be applied. And now when MFD dependencies are in-tree
the patch version (4) combined bd718x7 driver back to this series.

Changelog (for this series) v5
- Split v4 patch 1. Place clkdev stuff to patch 1 and clk provider to patch 2
- Remove devm_clk_release_clkdev from devres.txt
- Added kerneldoc for managed provider registrations.
- Cleaned styling issues.

Changelog (for this series) v4
- Add support for ROHM bd718x7 PMIC clock gate. Included in this patch
  series because it depends on managed interfaces added in patch 1.

Changelog (for this series) 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 (for this series) 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 (9):
  clkdev: add managed clkdev lookup registration
  clk: of_clk - add managed 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
  clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock

 Documentation/driver-model/devres.txt |   2 +
 drivers/clk/Kconfig                   |   7 ++
 drivers/clk/Makefile                  |   1 +
 drivers/clk/clk-bd718x7.c             | 131 ++++++++++++++++++++++++++++++++++
 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                     |  65 ++++++++++++++---
 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 ++
 14 files changed, 325 insertions(+), 79 deletions(-)
 create mode 100644 drivers/clk/clk-bd718x7.c

-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* [PATCH v5 1/9] clkdev: add managed clkdev lookup registration
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
@ 2018-12-03 12:17 ` Matti Vaittinen
  2018-12-03 18:06   ` Russell King - ARM Linux
  2018-12-03 12:18 ` [PATCH v5 2/9] clk: of_clk - add managed provider registrations Matti Vaittinen
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:17 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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 |   1 +
 drivers/clk/clkdev.c                  | 122 ++++++++++++++++++++++++++--------
 include/linux/clkdev.h                |   4 ++
 3 files changed, 101 insertions(+), 26 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 43681ca0837f..dbf14326243b 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -238,6 +238,7 @@ CLOCK
   devm_clk_put()
   devm_clk_hw_register()
   devm_of_clk_add_hw_provider()
+  devm_clk_hw_register_clkdev()
 
 DMA
   dmaenginem_async_device_register()
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 9ab3db8b3988..68a1e55a60d2 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/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 related	[flat|nested] 15+ messages in thread

* [PATCH v5 2/9] clk: of_clk - add managed provider registrations
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
  2018-12-03 12:17 ` [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Matti Vaittinen
@ 2018-12-03 12:18 ` Matti Vaittinen
  2018-12-03 12:19 ` [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:18 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 Documentation/driver-model/devres.txt |  1 +
 drivers/clk/clk.c                     | 65 ++++++++++++++++++++++++++++++-----
 include/linux/clk-provider.h          | 11 ++++++
 3 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index dbf14326243b..97c9c575b2af 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -238,6 +238,7 @@ 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()
 
 DMA
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index af011974d4ec..30beb60bd8f9 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,19 +3906,62 @@ 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);
-	if (!ret) {
-		*ptr = np;
+	*ptr = of_node;
+	ret = of_clk_add_hw_provider(of_node, get, data);
+	if (!ret)
 		devres_add(dev, ptr);
-	} else {
+	else
 		devres_free(ptr);
-	}
 
 	return ret;
 }
+
+/**
+ * devm_of_clk_add_hw_provider() - Managed clk provider node registration
+ * @dev: Device acting as the clock provider. Used for DT node and lifetime.
+ * @get: callback for decoding clk_hw
+ * @data: context pointer for @get callback.
+ *
+ * Returns 0 on success or an errno on failure.
+ *
+ * Registers clock provider for given device's node. Provider is automatically
+ * released at device exit.
+ */
+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);
 
+/**
+ * devm_of_clk_add_parent_hw_provider() - Managed clk provider node registration
+ * @dev: Device acting as the clock provider. Provider's DT node is parent node.
+ * @get: callback for decoding clk_hw
+ * @data: context pointer for @get callback.
+ *
+ * Returns 0 on success or an errno on failure.
+ *
+ * Registers clock provider for given device's parent node. Usable in cases
+ * where it really is the parent node that contains the provider information.
+ * Typical use-cases are MFD devices where the MFD sub-device is handling
+ * actual clock HW but the MFD node (parent) is containing the clock
+ * information.
+ *
+ * Provider is automatically released at device exit.
+ */
+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
@@ -3950,6 +3993,10 @@ static int devm_clk_provider_match(struct device *dev, void *res, void *data)
 	return *np == data;
 }
 
+/**
+ * devm_of_clk_del_provider() - Remove clock provider registered using devm
+ * @dev: Device to whose lifetime the clock provider was bound
+ */
 void devm_of_clk_del_provider(struct device *dev)
 {
 	int ret;
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(
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
  2018-12-03 12:17 ` [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Matti Vaittinen
  2018-12-03 12:18 ` [PATCH v5 2/9] clk: of_clk - add managed provider registrations Matti Vaittinen
@ 2018-12-03 12:19 ` Matti Vaittinen
  2018-12-03 12:19 ` [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Lee Jones
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:19 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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 22c937644c93..e65925d5e412 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 related	[flat|nested] 15+ messages in thread

* Re: [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (2 preceding siblings ...)
  2018-12-03 12:19 ` [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
@ 2018-12-03 12:19 ` Lee Jones
  2018-12-03 12:35   ` Matti Vaittinen
  2018-12-03 12:20 ` [PATCH v5 4/9] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Lee Jones @ 2018-12-03 12:19 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: mazziesaccount, mturquette, sboyd, cw00.choi, krzk, b.zolnierkie,
	linux, andy.gross, david.brown, pavel, andrew.smirnov,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

> Series add bd71837/bd71837 PMIC clock support + managed interfaces

[...]

> Matti Vaittinen (9):
>   clkdev: add managed clkdev lookup registration
>   clk: of_clk - add managed 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
>   clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock
> 
>  Documentation/driver-model/devres.txt |   2 +
>  drivers/clk/Kconfig                   |   7 ++
>  drivers/clk/Makefile                  |   1 +
>  drivers/clk/clk-bd718x7.c             | 131 ++++++++++++++++++++++++++++++++++
>  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                     |  65 ++++++++++++++---
>  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 ++
>  14 files changed, 325 insertions(+), 79 deletions(-)
>  create mode 100644 drivers/clk/clk-bd718x7.c

You've send me a cover letter and no patches.

I suggest that I should not be on the addressee list at all for this.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* [PATCH v5 4/9] clk: clk-st: avoid clkdev lookup leak at remove
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (3 preceding siblings ...)
  2018-12-03 12:19 ` [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Lee Jones
@ 2018-12-03 12:20 ` Matti Vaittinen
  2018-12-03 12:20 ` [PATCH v5 5/9] clk: clk-hi655x: Free of_provider " Matti Vaittinen
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:20 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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 3a0996f2d556..25d4b97aff9b 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 related	[flat|nested] 15+ messages in thread

* [PATCH v5 5/9] clk: clk-hi655x: Free of_provider at remove
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (4 preceding siblings ...)
  2018-12-03 12:20 ` [PATCH v5 4/9] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
@ 2018-12-03 12:20 ` Matti Vaittinen
  2018-12-03 12:21 ` [PATCH v5 6/9] clk: rk808: use managed version of of_provider registration Matti Vaittinen
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:20 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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 related	[flat|nested] 15+ messages in thread

* [PATCH v5 6/9] clk: rk808: use managed version of of_provider registration
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (5 preceding siblings ...)
  2018-12-03 12:20 ` [PATCH v5 5/9] clk: clk-hi655x: Free of_provider " Matti Vaittinen
@ 2018-12-03 12:21 ` Matti Vaittinen
  2018-12-03 12:22 ` [PATCH v5 7/9] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:21 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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 related	[flat|nested] 15+ messages in thread

* [PATCH v5 7/9] clk: clk-twl6040: Free of_provider at remove
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (6 preceding siblings ...)
  2018-12-03 12:21 ` [PATCH v5 6/9] clk: rk808: use managed version of of_provider registration Matti Vaittinen
@ 2018-12-03 12:22 ` Matti Vaittinen
  2018-12-03 12:23 ` [PATCH v5 8/9] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen
  2018-12-03 12:23 ` [PATCH v5 9/9] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock Matti Vaittinen
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:22 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.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


-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* [PATCH v5 8/9] clk: apcs-msm8916: simplify probe cleanup by using devm
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (7 preceding siblings ...)
  2018-12-03 12:22 ` [PATCH v5 7/9] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
@ 2018-12-03 12:23 ` Matti Vaittinen
  2018-12-03 12:23 ` [PATCH v5 9/9] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock Matti Vaittinen
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:23 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

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


-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* [PATCH v5 9/9] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock
  2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
                   ` (8 preceding siblings ...)
  2018-12-03 12:23 ` [PATCH v5 8/9] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen
@ 2018-12-03 12:23 ` Matti Vaittinen
  9 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:23 UTC (permalink / raw)
  To: mazziesaccount, matti.vaittinen
  Cc: mturquette, sboyd, cw00.choi, krzk, b.zolnierkie, linux,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

ROHM bd71837 and bd71847 contain 32768Hz clock gate. Support the clock
using generic clock framework. Note, only bd71837 is tested but bd71847
should be identical what comes to clk parts.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/clk/Kconfig       |   7 +++
 drivers/clk/Makefile      |   1 +
 drivers/clk/clk-bd718x7.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 drivers/clk/clk-bd718x7.c

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 81cdb4eaca07..2dc12bf75b1b 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -283,6 +283,13 @@ config COMMON_CLK_STM32H7
 	---help---
 	  Support for stm32h7 SoC family clocks
 
+config COMMON_CLK_BD718XX
+	tristate "Clock driver for ROHM BD718x7 PMIC"
+	depends on MFD_ROHM_BD718XX
+	help
+	  This driver supports ROHM BD71837 and ROHM BD71847
+	  PMICs clock gates.
+
 source "drivers/clk/actions/Kconfig"
 source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 72be7a38cff1..a47430b387db 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -21,6 +21,7 @@ endif
 obj-$(CONFIG_MACH_ASM9260)		+= clk-asm9260.o
 obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN)	+= clk-axi-clkgen.o
 obj-$(CONFIG_ARCH_AXXIA)		+= clk-axm5516.o
+obj-$(CONFIG_COMMON_CLK_BD718XX)	+= clk-bd718x7.o
 obj-$(CONFIG_COMMON_CLK_CDCE706)	+= clk-cdce706.o
 obj-$(CONFIG_COMMON_CLK_CDCE925)	+= clk-cdce925.o
 obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c
new file mode 100644
index 000000000000..df5f1068ce8e
--- /dev/null
+++ b/drivers/clk/clk-bd718x7.c
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 ROHM Semiconductors
+// bd71837.c  -- ROHM BD71837MWV clock driver
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/mfd/rohm-bd718x7.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/regmap.h>
+
+struct bd718xx_clk {
+	struct clk_hw hw;
+	u8 reg;
+	u8 mask;
+	struct platform_device *pdev;
+	struct bd718xx *mfd;
+};
+
+static int bd71837_clk_set(struct clk_hw *hw, int status)
+{
+	struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw);
+
+	return regmap_update_bits(c->mfd->regmap, c->reg, c->mask, status);
+}
+
+static void bd71837_clk_disable(struct clk_hw *hw)
+{
+	int rv;
+	struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw);
+
+	rv = bd71837_clk_set(hw, 0);
+	if (rv)
+		dev_dbg(&c->pdev->dev, "Failed to disable 32K clk (%d)\n", rv);
+}
+
+static int bd71837_clk_enable(struct clk_hw *hw)
+{
+	return bd71837_clk_set(hw, 1);
+}
+
+static int bd71837_clk_is_enabled(struct clk_hw *hw)
+{
+	int enabled;
+	int rval;
+	struct bd718xx_clk *c = container_of(hw, struct bd718xx_clk, hw);
+
+	rval = regmap_read(c->mfd->regmap, c->reg, &enabled);
+
+	if (rval)
+		return rval;
+
+	return enabled & c->mask;
+}
+
+static const struct clk_ops bd71837_clk_ops = {
+	.prepare = &bd71837_clk_enable,
+	.unprepare = &bd71837_clk_disable,
+	.is_prepared = &bd71837_clk_is_enabled,
+};
+
+static int bd71837_clk_probe(struct platform_device *pdev)
+{
+	struct bd718xx_clk *c;
+	int rval = -ENOMEM;
+	const char *parent_clk;
+	struct device *parent = pdev->dev.parent;
+	struct bd718xx *mfd = dev_get_drvdata(parent);
+	struct clk_init_data init = {
+		.name = "bd718xx-32k-out",
+		.ops = &bd71837_clk_ops,
+	};
+
+	c = devm_kzalloc(&pdev->dev, sizeof(*c), GFP_KERNEL);
+	if (!c)
+		return -ENOMEM;
+
+	init.num_parents = 1;
+	parent_clk = of_clk_get_parent_name(parent->of_node, 0);
+
+	init.parent_names = &parent_clk;
+	if (!parent_clk) {
+		dev_err(&pdev->dev, "No parent clk found\n");
+		return -EINVAL;
+	}
+
+	c->reg = BD718XX_REG_OUT32K;
+	c->mask = BD718XX_OUT32K_EN;
+	c->mfd = mfd;
+	c->pdev = pdev;
+	c->hw.init = &init;
+
+	of_property_read_string_index(parent->of_node,
+				      "clock-output-names", 0, &init.name);
+
+	rval = devm_clk_hw_register(&pdev->dev, &c->hw);
+	if (!rval) {
+		rval = devm_clk_hw_register_clkdev(&pdev->dev,
+						   &c->hw, init.name, NULL);
+		if (rval)
+			dev_warn(&pdev->dev, "Failed to register clkdev\n");
+		if (parent->of_node) {
+			rval = devm_of_clk_add_parent_hw_provider(&pdev->dev,
+					     of_clk_hw_simple_get, &c->hw);
+			if (rval)
+				dev_err(&pdev->dev,
+					"adding clk provider failed\n");
+		}
+	} else {
+		dev_err(&pdev->dev, "failed to register 32K clk");
+	}
+
+	return rval;
+}
+
+static struct platform_driver bd71837_clk = {
+	.driver = {
+		.name = "bd718xx-clk",
+	},
+	.probe = bd71837_clk_probe,
+};
+
+module_platform_driver(bd71837_clk);
+
+MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
+MODULE_DESCRIPTION("BD71837 chip clk driver");
+MODULE_LICENSE("GPL");
-- 
2.14.3


-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* Re: [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations
  2018-12-03 12:19 ` [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Lee Jones
@ 2018-12-03 12:35   ` Matti Vaittinen
  2018-12-03 12:56     ` Lee Jones
  0 siblings, 1 reply; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-03 12:35 UTC (permalink / raw)
  To: Lee Jones
  Cc: mazziesaccount, mturquette, sboyd, cw00.choi, krzk, b.zolnierkie,
	linux, andy.gross, david.brown, pavel, andrew.smirnov,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel


Hi de Ho Lee,

On Mon, Dec 03, 2018 at 12:19:51PM +0000, Lee Jones wrote:
> > Series add bd71837/bd71837 PMIC clock support + managed interfaces
> 
> You've send me a cover letter and no patches.
I am afraid the patches may be still on their way... I added recipients
to git format-patch via command-line so you are probably included also
in patch mails :(

> 
> I suggest that I should not be on the addressee list at all for this.

I'm terribly sorry for spamming! I must've done some mistake with the
get_maintainer.pl as I copied the recipients from that output. I may
have accidentally included some old patch to maintainer query.

> 
> -- 
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

-- 
Matti Vaittinen
ROHM Semiconductors

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

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

* Re: [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations
  2018-12-03 12:35   ` Matti Vaittinen
@ 2018-12-03 12:56     ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2018-12-03 12:56 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: mazziesaccount, mturquette, sboyd, cw00.choi, krzk, b.zolnierkie,
	linux, andy.gross, david.brown, pavel, andrew.smirnov,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

On Mon, 03 Dec 2018, Matti Vaittinen wrote:

> 
> Hi de Ho Lee,
> 
> On Mon, Dec 03, 2018 at 12:19:51PM +0000, Lee Jones wrote:
> > > Series add bd71837/bd71837 PMIC clock support + managed interfaces
> > 
> > You've send me a cover letter and no patches.
> > 
> I am afraid the patches may be still on their way... I added recipients
> to git format-patch via command-line so you are probably included also
> in patch mails :(

Ah I see.  Yes, I see that they have started to come through.

> > I suggest that I should not be on the addressee list at all for this.
> 
> I'm terribly sorry for spamming! I must've done some mistake with the
> get_maintainer.pl as I copied the recipients from that output. I may
> have accidentally included some old patch to maintainer query.

No problem.  If you could remove me from future mails though, that
would be appreciated.  The torrent it fierce enough without receiving
correspondence that is not relevant to me.  Thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v5 1/9] clkdev: add managed clkdev lookup registration
  2018-12-03 12:17 ` [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Matti Vaittinen
@ 2018-12-03 18:06   ` Russell King - ARM Linux
  2018-12-04  8:03     ` Matti Vaittinen
  0 siblings, 1 reply; 15+ messages in thread
From: Russell King - ARM Linux @ 2018-12-03 18:06 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: mazziesaccount, mturquette, sboyd, cw00.choi, krzk, b.zolnierkie,
	andy.gross, david.brown, pavel, andrew.smirnov, lee.jones,
	pombredanne, sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki,
	linux-doc, linux-kernel, linux-clk, linux-arm-kernel

Hi,

On Mon, Dec 03, 2018 at 02:17:56PM +0200, Matti Vaittinen wrote:
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index 9ab3db8b3988..68a1e55a60d2 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)
> +{
> +

No need for this blank line.

> +	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);

Please move "dev_id);" onto the line above.

> @@ -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);

Please keep this as:

	if (IS_ERR(clk))
		return PTR_ERR(clk);

	return do_clk_register_clkdev(__clk_get_hw(clk), &cl, con_id,
				      dev_id);

rather than inverting it - it makes it more consistent with code elsewhere.

> +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);

How can "l" be NULL here?  How can *l be NULL?

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

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

* Re: [PATCH v5 1/9] clkdev: add managed clkdev lookup registration
  2018-12-03 18:06   ` Russell King - ARM Linux
@ 2018-12-04  8:03     ` Matti Vaittinen
  0 siblings, 0 replies; 15+ messages in thread
From: Matti Vaittinen @ 2018-12-04  8:03 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: mazziesaccount, mturquette, sboyd, cw00.choi, krzk, b.zolnierkie,
	andy.gross, david.brown, pavel, andrew.smirnov, pombredanne,
	sjhuang, akshu.agrawal, djkurtz, rafael.j.wysocki, linux-doc,
	linux-kernel, linux-clk, linux-arm-kernel

Hello Russell,

Thanks for the review. I do appreciate this. I'll send out v6 where I'll
have these fixed =)

On Mon, Dec 03, 2018 at 06:06:12PM +0000, Russell King - ARM Linux wrote:
> > +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);
> 
> How can "l" be NULL here?  How can *l be NULL?

I really don't know if there is any "sane" way to end up having the
devres data NULLed. I admit I looked an example on how others had
implemented the match. These checks were present in devm_clk_match
and devm_regmap_irq_chip_match so I assumed there is a way to end up
having NULL there. Thus I played safe. OTOH it seems that for example
devm_hwmon_match does omit these checks and I really don't see right
away why the dr->data would be NULL. So I'll remove the check.

Br,
	Matti Vaittinen

> 
> -- 
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
> According to speedtest.net: 11.9Mbps down 500kbps up

-- 
Matti Vaittinen
ROHM Semiconductors

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

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

end of thread, other threads:[~2018-12-04  8:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 12:17 [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Matti Vaittinen
2018-12-03 12:17 ` [PATCH v5 1/9] clkdev: add managed clkdev lookup registration Matti Vaittinen
2018-12-03 18:06   ` Russell King - ARM Linux
2018-12-04  8:03     ` Matti Vaittinen
2018-12-03 12:18 ` [PATCH v5 2/9] clk: of_clk - add managed provider registrations Matti Vaittinen
2018-12-03 12:19 ` [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm Matti Vaittinen
2018-12-03 12:19 ` [PATCH v5 0/9] clk: clkdev: managed clk lookup and provider registrations Lee Jones
2018-12-03 12:35   ` Matti Vaittinen
2018-12-03 12:56     ` Lee Jones
2018-12-03 12:20 ` [PATCH v5 4/9] clk: clk-st: avoid clkdev lookup leak at remove Matti Vaittinen
2018-12-03 12:20 ` [PATCH v5 5/9] clk: clk-hi655x: Free of_provider " Matti Vaittinen
2018-12-03 12:21 ` [PATCH v5 6/9] clk: rk808: use managed version of of_provider registration Matti Vaittinen
2018-12-03 12:22 ` [PATCH v5 7/9] clk: clk-twl6040: Free of_provider at remove Matti Vaittinen
2018-12-03 12:23 ` [PATCH v5 8/9] clk: apcs-msm8916: simplify probe cleanup by using devm Matti Vaittinen
2018-12-03 12:23 ` [PATCH v5 9/9] clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock 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).