Skip to contentSkip to conversation

Add a devm_of_clk_add_hw_provider() API

PATCH Applied Stephen Boyd 1 participant 5 messages Sep 1, 2017 – Nov 2, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add a devm_of_clk_add_hw_provider() API

This cleans up some open-coded versions of this API and makes it official. It's also another carrot to convert drivers to use the clk hw registration APIs instead of the clk registration APIs.

Stephen Boyd (2):
clk: Add devm_of_clk_add_hw_provider()/del_provider() APIs
clk: qcom: common: Migrate to devm_* APIs for resets and clk providers

 Documentation/driver-model/devres.txt |  1 +
 drivers/clk/clk.c                     | 52 +++++++++++++++++++++++++++++++++++
 drivers/clk/qcom/common.c             | 26 ++----------------
 include/linux/clk-provider.h          | 13 +++++++++
 4 files changed, 68 insertions(+), 24 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/2 clk: Add devm_of_clk_add_hw_provider()/del_provider() APIs

Sometimes we only have one of_clk_del_provider() call in driver error and remove paths, because we're missing a devm_of_clk_add_hw_provider() API. Introduce the API so we can convert drivers to use this and potentially reduce the amount of code needed to remove providers in drivers.

---
 Documentation/driver-model/devres.txt |  1 +
 drivers/clk/clk.c                     | 52 +++++++++++++++++++++++++++++++++++
 include/linux/clk-provider.h          | 13 +++++++++
 3 files changed, 66 insertions(+)
Documentation/driver-model/devres.txt +1 -0
index 30e04f7a690d..6b5e5e642b49 100644
@@ -237,6 +237,7 @@ CLOCK
   devm_clk_get()
   devm_clk_put()
   devm_clk_hw_register()
+  devm_of_clk_add_hw_provider()
 
 DMA
   dmam_alloc_coherent()
drivers/clk/clk.c +52 -0

64 lines not on this page · raw message

include/linux/clk-provider.h +13 -0
index 1fc113fbf955..5a002e64999b 100644
@@ -814,7 +814,12 @@ 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_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,
 				  void *data);
 struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec,
@@ -846,7 +851,15 @@ static inline int of_clk_add_hw_provider(struct device_node *np,
 {
 	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),
+			   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(
 	struct of_phandle_args *clkspec, void *data)
 {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author Applied
#2 lore raw

Re: [PATCH 1/2] clk: Add devm_of_clk_add_hw_provider()/del_provider() APIs

Quoted 8 lines · Stephen Boyd

Sometimes we only have one of_clk_del_provider() call in driver error and remove paths, because we're missing a devm_of_clk_add_hw_provider() API. Introduce the API so we can convert drivers to use this and potentially reduce the amount of code needed to remove providers in drivers.

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

PATCH 2/2 clk: qcom: common: Migrate to devm_* APIs for resets and clk providers

In reply to Stephen Boyd

Now that we have devm APIs for the reset controller and of clk hw provider APIs we can remove the custom code here.

---
 drivers/clk/qcom/common.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)
drivers/clk/qcom/common.c +2 -24
index d523991c945f..b35564c0493f 100644
@@ -111,16 +111,6 @@ qcom_pll_set_fsm_mode(struct regmap *map, u32 reg, u8 bias_count, u8 lock_count)
 }
 EXPORT_SYMBOL_GPL(qcom_pll_set_fsm_mode);
 
-static void qcom_cc_del_clk_provider(void *data)
-{
-	of_clk_del_provider(data);
-}
-
-static void qcom_cc_reset_unregister(void *data)
-{
-	reset_controller_unregister(data);
-}
-
 static void qcom_cc_gdsc_unregister(void *data)
 {
 	gdsc_unregister(data);
@@ -248,13 +238,7 @@ int qcom_cc_really_probe(struct platform_device *pdev,
 			return ret;
 	}
 
-	ret = of_clk_add_hw_provider(dev->of_node, qcom_cc_clk_hw_get, cc);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(dev, qcom_cc_del_clk_provider,
-				       pdev->dev.of_node);
-
+	ret = devm_of_clk_add_hw_provider(dev, qcom_cc_clk_hw_get, cc);
 	if (ret)
 		return ret;
 
@@ -266,13 +250,7 @@ int qcom_cc_really_probe(struct platform_device *pdev,
 	reset->regmap = regmap;
 	reset->reset_map = desc->resets;
 
-	ret = reset_controller_register(&reset->rcdev);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(dev, qcom_cc_reset_unregister,
-				       &reset->rcdev);
-
+	ret = devm_reset_controller_register(dev, &reset->rcdev);
 	if (ret)
 		return ret;
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author Applied
#4 lore raw

Re: [PATCH 2/2] clk: qcom: common: Migrate to devm_* APIs for resets and clk providers

Quoted 5 lines · Stephen Boyd

Now that we have devm APIs for the reset controller and of clk hw provider APIs we can remove the custom code here.

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project