linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <stephen.boyd@linaro.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/34] clk: qcom: Migrate to clk_hw based registration and OF APIs
Date: Wed,  1 Jun 2016 16:15:00 -0700	[thread overview]
Message-ID: <20160601231533.9354-2-stephen.boyd@linaro.org> (raw)
In-Reply-To: <20160601231533.9354-1-stephen.boyd@linaro.org>

Now that we have clk_hw based provider APIs to register clks, we
can get rid of struct clk pointers in this driver, allowing us to
move closer to a clear split of consumer and provider clk APIs.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---

See commit 58657d189a2f and it's children for details on this
new registration API.

 drivers/clk/qcom/clk-regmap.c   |  5 ++--
 drivers/clk/qcom/clk-regmap.h   |  3 +--
 drivers/clk/qcom/common.c       | 58 +++++++++++++++++++++++------------------
 drivers/clk/qcom/gcc-msm8996.c  |  9 +++----
 drivers/clk/qcom/mmcc-msm8996.c |  9 +++----
 5 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/clk/qcom/clk-regmap.c b/drivers/clk/qcom/clk-regmap.c
index a58ba39a900c..1c856d330733 100644
--- a/drivers/clk/qcom/clk-regmap.c
+++ b/drivers/clk/qcom/clk-regmap.c
@@ -101,14 +101,13 @@ EXPORT_SYMBOL_GPL(clk_disable_regmap);
  * clk_regmap struct via this function so that the regmap is initialized
  * and so that the clock is registered with the common clock framework.
  */
-struct clk *devm_clk_register_regmap(struct device *dev,
-				     struct clk_regmap *rclk)
+int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk)
 {
 	if (dev && dev_get_regmap(dev, NULL))
 		rclk->regmap = dev_get_regmap(dev, NULL);
 	else if (dev && dev->parent)
 		rclk->regmap = dev_get_regmap(dev->parent, NULL);
 
-	return devm_clk_register(dev, &rclk->hw);
+	return devm_clk_hw_register(dev, &rclk->hw);
 }
 EXPORT_SYMBOL_GPL(devm_clk_register_regmap);
diff --git a/drivers/clk/qcom/clk-regmap.h b/drivers/clk/qcom/clk-regmap.h
index 491a63d537df..90d95cd11ec6 100644
--- a/drivers/clk/qcom/clk-regmap.h
+++ b/drivers/clk/qcom/clk-regmap.h
@@ -39,7 +39,6 @@ struct clk_regmap {
 int clk_is_enabled_regmap(struct clk_hw *hw);
 int clk_enable_regmap(struct clk_hw *hw);
 void clk_disable_regmap(struct clk_hw *hw);
-struct clk *
-devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk);
+int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk);
 
 #endif
diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index f7c226ab4307..fffcbaf0fba7 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -27,8 +27,8 @@
 
 struct qcom_cc {
 	struct qcom_reset_controller reset;
-	struct clk_onecell_data data;
-	struct clk *clks[];
+	struct clk_regmap **rclks;
+	size_t num_rclks;
 };
 
 const
@@ -102,8 +102,8 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
 	struct device_node *clocks_node;
 	struct clk_fixed_factor *factor;
 	struct clk_fixed_rate *fixed;
-	struct clk *clk;
 	struct clk_init_data init_data = { };
+	int ret;
 
 	clocks_node = of_find_node_by_path("/clocks");
 	if (clocks_node)
@@ -121,9 +121,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
 		init_data.name = path;
 		init_data.ops = &clk_fixed_rate_ops;
 
-		clk = devm_clk_register(dev, &fixed->hw);
-		if (IS_ERR(clk))
-			return PTR_ERR(clk);
+		ret = devm_clk_hw_register(dev, &fixed->hw);
+		if (ret)
+			return ret;
 	}
 	of_node_put(node);
 
@@ -141,9 +141,9 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,
 		init_data.flags = 0;
 		init_data.ops = &clk_fixed_factor_ops;
 
-		clk = devm_clk_register(dev, &factor->hw);
-		if (IS_ERR(clk))
-			return PTR_ERR(clk);
+		ret = devm_clk_hw_register(dev, &factor->hw);
+		if (ret)
+			return ret;
 	}
 
 	return 0;
@@ -174,42 +174,48 @@ int qcom_cc_register_sleep_clk(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(qcom_cc_register_sleep_clk);
 
+static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
+					 void *data)
+{
+	struct qcom_cc *cc = data;
+	unsigned int idx = clkspec->args[0];
+
+	if (idx >= cc->num_rclks) {
+		pr_err("%s: invalid index %u\n", __func__, idx);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return cc->rclks[idx] ? &cc->rclks[idx]->hw : ERR_PTR(-ENOENT);
+}
+
 int qcom_cc_really_probe(struct platform_device *pdev,
 			 const struct qcom_cc_desc *desc, struct regmap *regmap)
 {
 	int i, ret;
 	struct device *dev = &pdev->dev;
-	struct clk *clk;
-	struct clk_onecell_data *data;
-	struct clk **clks;
 	struct qcom_reset_controller *reset;
 	struct qcom_cc *cc;
 	struct gdsc_desc *scd;
 	size_t num_clks = desc->num_clks;
 	struct clk_regmap **rclks = desc->clks;
 
-	cc = devm_kzalloc(dev, sizeof(*cc) + sizeof(*clks) * num_clks,
-			  GFP_KERNEL);
+	cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
 	if (!cc)
 		return -ENOMEM;
 
-	clks = cc->clks;
-	data = &cc->data;
-	data->clks = clks;
-	data->clk_num = num_clks;
+	cc->rclks = rclks;
+	cc->num_rclks = num_clks;
 
 	for (i = 0; i < num_clks; i++) {
-		if (!rclks[i]) {
-			clks[i] = ERR_PTR(-ENOENT);
+		if (!rclks[i])
 			continue;
-		}
-		clk = devm_clk_register_regmap(dev, rclks[i]);
-		if (IS_ERR(clk))
-			return PTR_ERR(clk);
-		clks[i] = clk;
+
+		ret = devm_clk_register_regmap(dev, rclks[i]);
+		if (ret)
+			return ret;
 	}
 
-	ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, data);
+	ret = of_clk_add_hw_provider(dev->of_node, qcom_cc_clk_hw_get, cc);
 	if (ret)
 		return ret;
 
diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
index c9b96f318d9c..7a6fd069ba5d 100644
--- a/drivers/clk/qcom/gcc-msm8996.c
+++ b/drivers/clk/qcom/gcc-msm8996.c
@@ -3463,9 +3463,8 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table);
 
 static int gcc_msm8996_probe(struct platform_device *pdev)
 {
-	struct clk *clk;
 	struct device *dev = &pdev->dev;
-	int i;
+	int i, ret;
 	struct regmap *regmap;
 
 	regmap = qcom_cc_map(pdev, &gcc_msm8996_desc);
@@ -3479,9 +3478,9 @@ static int gcc_msm8996_probe(struct platform_device *pdev)
 	regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21));
 
 	for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
-		clk = devm_clk_register(dev, gcc_msm8996_hws[i]);
-		if (IS_ERR(clk))
-			return PTR_ERR(clk);
+		ret = devm_clk_hw_register(dev, gcc_msm8996_hws[i]);
+		if (ret)
+			return ret;
 	}
 
 	return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap);
diff --git a/drivers/clk/qcom/mmcc-msm8996.c b/drivers/clk/qcom/mmcc-msm8996.c
index 847dd9dadeca..384b812a153e 100644
--- a/drivers/clk/qcom/mmcc-msm8996.c
+++ b/drivers/clk/qcom/mmcc-msm8996.c
@@ -3305,9 +3305,8 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8996_match_table);
 
 static int mmcc_msm8996_probe(struct platform_device *pdev)
 {
-	struct clk *clk;
 	struct device *dev = &pdev->dev;
-	int i;
+	int i, ret;
 	struct regmap *regmap;
 
 	regmap = qcom_cc_map(pdev, &mmcc_msm8996_desc);
@@ -3320,9 +3319,9 @@ static int mmcc_msm8996_probe(struct platform_device *pdev)
 	regmap_update_bits(regmap, 0x5054, BIT(15), 0);
 
 	for (i = 0; i < ARRAY_SIZE(mmcc_msm8996_hws); i++) {
-		clk = devm_clk_register(dev, mmcc_msm8996_hws[i]);
-		if (IS_ERR(clk))
-			return PTR_ERR(clk);
+		ret = devm_clk_hw_register(dev, mmcc_msm8996_hws[i]);
+		if (ret)
+			return ret;
 	}
 
 	return qcom_cc_really_probe(pdev, &mmcc_msm8996_desc, regmap);
-- 
2.7.4

  reply	other threads:[~2016-06-01 23:24 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-01 23:14 [PATCH 00/34] Convert clk providers to clk_hw based APIs (part 1) Stephen Boyd
2016-06-01 23:15 ` Stephen Boyd [this message]
2016-06-01 23:15 ` [PATCH 02/34] clk: at91: Migrate to clk_hw based registration and OF APIs Stephen Boyd
2016-06-07 16:36   ` Alexandre Belloni
2016-06-07 16:40     ` Boris Brezillon
2016-09-15  0:39       ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 03/34] clk: highbank: " Stephen Boyd
2016-06-02  1:02   ` Rob Herring
2016-06-30 19:25   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 04/34] clk: bcm2835: " Stephen Boyd
2016-06-02 18:25   ` Eric Anholt
2016-09-15  0:36     ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 05/34] clk: bcm: iproc: " Stephen Boyd
2016-06-02 17:22   ` Ray Jui
2016-06-30 19:27   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 06/34] clk: bcm: kona: " Stephen Boyd
2016-08-24 23:08   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 07/34] clk: berlin: " Stephen Boyd
2016-06-05 17:41   ` Alexandre Belloni
     [not found]     ` <146528884761.28742.8093002152658120585@sboyd-linaro>
2016-06-07 16:33       ` Alexandre Belloni
2016-06-01 23:15 ` [PATCH 08/34] clk: asm9260: " Stephen Boyd
2016-08-24 23:09   ` Stephen Boyd
2016-08-24 23:10   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 09/34] clk: axi-clkgen: Migrate to clk_hw based OF and registration APIs Stephen Boyd
2016-08-24 23:11   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 10/34] clk: axm5516: " Stephen Boyd
2016-08-24 23:12   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 11/34] clk: cdce: " Stephen Boyd
2016-08-24 23:13   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 12/34] clk: cdce925: Migrate to clk_hw based OF and provider APIs Stephen Boyd
2016-08-25  0:19   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 13/34] clk: clps711x: Migrate to clk_hw based OF and registration APIs Stephen Boyd
2016-08-25  0:20   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 14/34] clk: cs2000: " Stephen Boyd
2016-08-25  0:21   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 15/34] clk: efm32gg: " Stephen Boyd
2016-08-25  0:22   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 16/34] clk: ls1x: " Stephen Boyd
2016-08-19  0:09   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 17/34] clk: maxgen: " Stephen Boyd
2016-06-07 18:50   ` Javier Martinez Canillas
2016-06-07 18:55     ` Javier Martinez Canillas
2016-08-16 20:06       ` Stephen Boyd
2016-08-17  3:00         ` Javier Martinez Canillas
2016-06-01 23:15 ` [PATCH 18/34] clk: mb86s7x: " Stephen Boyd
2016-08-25  0:27   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 19/34] clk: moxart: " Stephen Boyd
2016-08-25  0:25   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 20/34] clk: nomadik: " Stephen Boyd
2016-06-02 12:06   ` Linus Walleij
2016-06-30 19:26   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 21/34] clk: nspire: " Stephen Boyd
2016-08-25  0:25   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 22/34] clk: palmas: " Stephen Boyd
2016-08-25  0:25   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 23/34] clk: pwm: " Stephen Boyd
2016-08-25  0:25   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 24/34] clk: rk808: " Stephen Boyd
2016-08-25  0:30   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 25/34] clk: s2mps11: " Stephen Boyd
2016-06-03  7:18   ` Krzysztof Kozlowski
2016-06-08  7:22   ` Andi Shyti
2016-06-30 19:29   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 26/34] clk: scpi: " Stephen Boyd
2016-08-25  0:30   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 27/34] clk: si514: " Stephen Boyd
2016-08-25  0:30   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 28/34] clk: si5351: " Stephen Boyd
2016-08-25  0:30   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 29/34] clk: si570: " Stephen Boyd
2016-08-25  0:30   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 30/34] clk: stm32f3: " Stephen Boyd
2016-06-06 13:48   ` Daniel Thompson
2016-06-07  8:37     ` Stephen Boyd
2016-06-30 19:28   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 31/34] clk: twl6040: Migrate to clk_hw based " Stephen Boyd
2016-08-25  0:34   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 32/34] clk: u300: " Stephen Boyd
2016-06-02 12:06   ` Linus Walleij
2016-06-30 19:26   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 33/34] clk: vt8500: " Stephen Boyd
2016-08-25  0:36   ` Stephen Boyd
2016-06-01 23:15 ` [PATCH 34/34] clk: wm831x: " Stephen Boyd
2016-08-25  0:36   ` 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=20160601231533.9354-2-stephen.boyd@linaro.org \
    --to=stephen.boyd@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.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 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).