All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs
@ 2016-08-16 22:38 Stephen Boyd
  2016-08-17  3:04 ` Javier Martinez Canillas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-08-16 22:38 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-kernel, linux-clk, Javier Martinez Canillas,
	Laxman Dewangan, Krzysztof Kozlowski

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

Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
 drivers/clk/clk-max77686.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c
index 19f620856571..b637f5979023 100644
--- a/drivers/clk/clk-max77686.c
+++ b/drivers/clk/clk-max77686.c
@@ -62,9 +62,8 @@ struct max77686_clk_init_data {
 
 struct max77686_clk_driver_data {
 	enum max77686_chip_name chip;
-	struct clk **clks;
 	struct max77686_clk_init_data *max_clk_data;
-	struct clk_onecell_data of_data;
+	size_t num_clks;
 };
 
 static const struct
@@ -160,6 +159,20 @@ static struct clk_ops max77686_clk_ops = {
 	.recalc_rate	= max77686_recalc_rate,
 };
 
+static struct clk_hw *
+of_clk_max77686_get(struct of_phandle_args *clkspec, void *data)
+{
+	struct max77686_clk_driver_data *drv_data = data;
+	unsigned int idx = clkspec->args[0];
+
+	if (idx >= drv_data->num_clks) {
+		pr_err("%s: invalid index %u\n", __func__, idx);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return &drv_data->max_clk_data[idx].hw;
+}
+
 static int max77686_clk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -209,14 +222,8 @@ static int max77686_clk_probe(struct platform_device *pdev)
 	if (!drv_data->max_clk_data)
 		return -ENOMEM;
 
-	drv_data->clks = devm_kcalloc(dev, num_clks,
-				      sizeof(*drv_data->clks), GFP_KERNEL);
-	if (!drv_data->clks)
-		return -ENOMEM;
-
 	for (i = 0; i < num_clks; i++) {
 		struct max77686_clk_init_data *max_clk_data;
-		struct clk *clk;
 		const char *clk_name;
 
 		max_clk_data = &drv_data->max_clk_data[i];
@@ -236,30 +243,23 @@ static int max77686_clk_probe(struct platform_device *pdev)
 
 		max_clk_data->hw.init = &max_clk_data->clk_idata;
 
-		clk = devm_clk_register(dev, &max_clk_data->hw);
-		if (IS_ERR(clk)) {
-			ret = PTR_ERR(clk);
+		ret = devm_clk_hw_register(dev, &max_clk_data->hw);
+		if (ret) {
 			dev_err(dev, "Failed to clock register: %d\n", ret);
 			return ret;
 		}
 
-		ret = clk_register_clkdev(clk, max_clk_data->clk_idata.name,
-					  NULL);
+		ret = clk_hw_register_clkdev(&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;
 		}
-		drv_data->clks[i] = clk;
 	}
 
-	platform_set_drvdata(pdev, drv_data);
-
 	if (parent->of_node) {
-		drv_data->of_data.clks = drv_data->clks;
-		drv_data->of_data.clk_num = num_clks;
-		ret = of_clk_add_provider(parent->of_node,
-					  of_clk_src_onecell_get,
-					  &drv_data->of_data);
+		ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get,
+					     drv_data);
 
 		if (ret < 0) {
 			dev_err(dev, "Failed to register OF clock provider: %d\n",
-- 
2.9.0.rc2.8.ga28705d

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

* Re: [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs
  2016-08-16 22:38 [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs Stephen Boyd
@ 2016-08-17  3:04 ` Javier Martinez Canillas
  2016-08-17  6:05 ` Krzysztof Kozlowski
  2016-08-18 23:42 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Javier Martinez Canillas @ 2016-08-17  3:04 UTC (permalink / raw)
  To: Stephen Boyd, Michael Turquette, Stephen Boyd
  Cc: linux-kernel, linux-clk, Laxman Dewangan, Krzysztof Kozlowski

Hello Stephen,

On 08/16/2016 06:38 PM, Stephen Boyd wrote:
> Now that we have clk_hw based provider APIs to register clks, we
> can get rid of struct clk pointers while registering clks in
> these drivers, allowing us to move closer to a clear split of
> consumer and provider clk APIs.
> 
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Laxman Dewangan <ldewangan@nvidia.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
> ---

The patch looks good to me.

Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

Also, I've tested this on an Exynos5800 Peach Pi Chromebook that has a
max77802 (supported by this driver) and the clocks are working correctly.

Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

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

* Re: [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs
  2016-08-16 22:38 [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs Stephen Boyd
  2016-08-17  3:04 ` Javier Martinez Canillas
@ 2016-08-17  6:05 ` Krzysztof Kozlowski
  2016-08-18 23:42 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2016-08-17  6:05 UTC (permalink / raw)
  To: Stephen Boyd, Michael Turquette, Stephen Boyd
  Cc: linux-kernel, linux-clk, Javier Martinez Canillas, Laxman Dewangan

On 08/17/2016 12:38 AM, Stephen Boyd wrote:
> Now that we have clk_hw based provider APIs to register clks, we
> can get rid of struct clk pointers while registering clks in
> these drivers, allowing us to move closer to a clear split of
> consumer and provider clk APIs.
> 
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Laxman Dewangan <ldewangan@nvidia.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
> ---
>  drivers/clk/clk-max77686.c | 42 +++++++++++++++++++++---------------------
>  1 file changed, 21 insertions(+), 21 deletions(-)

Looks correct. The pr_err() could be replaced to dev_err() but first
pointer to dev should be stored... so this may be fixed on different patch.

Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs
  2016-08-16 22:38 [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs Stephen Boyd
  2016-08-17  3:04 ` Javier Martinez Canillas
  2016-08-17  6:05 ` Krzysztof Kozlowski
@ 2016-08-18 23:42 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-08-18 23:42 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Michael Turquette, linux-kernel, linux-clk,
	Javier Martinez Canillas, Laxman Dewangan, Krzysztof Kozlowski

On 08/16, Stephen Boyd wrote:
> Now that we have clk_hw based provider APIs to register clks, we
> can get rid of struct clk pointers while registering clks in
> these drivers, allowing us to move closer to a clear split of
> consumer and provider clk APIs.
> 
> Cc: Javier Martinez Canillas <javier@osg.samsung.com>
> Cc: Laxman Dewangan <ldewangan@nvidia.com>
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-08-19  1:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 22:38 [PATCH v2] clk: max77686: Migrate to clk_hw based OF and registration APIs Stephen Boyd
2016-08-17  3:04 ` Javier Martinez Canillas
2016-08-17  6:05 ` Krzysztof Kozlowski
2016-08-18 23:42 ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.