[PATCH 1/2] reset: uniphier-glue: Use reset_control_bulk API

Subsystems: reset controller framework, the rest

STALE1690d LANDED

Landed in mainline as 176cae387191 on 2022-05-03.

4 messages, 2 authors, 2021-12-16 · open the first message on its own page

[PATCH 1/2] reset: uniphier-glue: Use reset_control_bulk API

From: Philipp Zabel <p.zabel@pengutronix.de>
Date: 2021-12-15 09:40:20

This driver already uses the clk_bulk API. Simplify the driver by using
the reset_control_bulk API as well.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-uniphier-glue.c | 33 ++++++++++++-----------------
 1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/reset/reset-uniphier-glue.c b/drivers/reset/reset-uniphier-glue.c
index 908c1d5bc41e..9b22c4a91d77 100644
--- a/drivers/reset/reset-uniphier-glue.c
+++ b/drivers/reset/reset-uniphier-glue.c
@@ -23,7 +23,7 @@ struct uniphier_glue_reset_soc_data {
 
 struct uniphier_glue_reset_priv {
 	struct clk_bulk_data clk[MAX_CLKS];
-	struct reset_control *rst[MAX_RSTS];
+	struct reset_control_bulk_data rst[MAX_RSTS];
 	struct reset_simple_data rdata;
 	const struct uniphier_glue_reset_soc_data *data;
 };
@@ -34,8 +34,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 	struct uniphier_glue_reset_priv *priv;
 	struct resource *res;
 	resource_size_t size;
-	const char *name;
-	int i, ret, nr;
+	int i, ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -58,22 +57,20 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	for (i = 0; i < priv->data->nrsts; i++) {
-		name = priv->data->reset_names[i];
-		priv->rst[i] = devm_reset_control_get_shared(dev, name);
-		if (IS_ERR(priv->rst[i]))
-			return PTR_ERR(priv->rst[i]);
-	}
+	for (i = 0; i < priv->data->nrsts; i++)
+		priv->rst[i].id = priv->data->reset_names[i];
+	ret = devm_reset_control_bulk_get_shared(dev, priv->data->nrsts,
+						 priv->rst);
+	if (ret)
+		return ret;
 
 	ret = clk_bulk_prepare_enable(priv->data->nclks, priv->clk);
 	if (ret)
 		return ret;
 
-	for (nr = 0; nr < priv->data->nrsts; nr++) {
-		ret = reset_control_deassert(priv->rst[nr]);
-		if (ret)
-			goto out_rst_assert;
-	}
+	ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst);
+	if (ret)
+		goto out_clk_disable;
 
 	spin_lock_init(&priv->rdata.lock);
 	priv->rdata.rcdev.owner = THIS_MODULE;
@@ -91,9 +88,9 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 	return 0;
 
 out_rst_assert:
-	while (nr--)
-		reset_control_assert(priv->rst[nr]);
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
 
+out_clk_disable:
 	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
 
 	return ret;
@@ -102,10 +99,8 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 static int uniphier_glue_reset_remove(struct platform_device *pdev)
 {
 	struct uniphier_glue_reset_priv *priv = platform_get_drvdata(pdev);
-	int i;
 
-	for (i = 0; i < priv->data->nrsts; i++)
-		reset_control_assert(priv->rst[i]);
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
 
 	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
 
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

[PATCH 2/2] reset: uniphier-glue: Use devm_add_action_or_reset()

From: Philipp Zabel <p.zabel@pengutronix.de>
Date: 2021-12-15 09:40:26

Slightly simplify uniphier_glue_reset_probe() and drop
uniphier_glue_reset_remove() by using devm_add_action_or_reset()
for clock and reset cleanup.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/reset/reset-uniphier-glue.c | 50 ++++++++++++++---------------
 1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/drivers/reset/reset-uniphier-glue.c b/drivers/reset/reset-uniphier-glue.c
index 9b22c4a91d77..146fd5d45e99 100644
--- a/drivers/reset/reset-uniphier-glue.c
+++ b/drivers/reset/reset-uniphier-glue.c
@@ -28,6 +28,20 @@ struct uniphier_glue_reset_priv {
 	const struct uniphier_glue_reset_soc_data *data;
 };
 
+static void uniphier_clk_disable(void *_priv)
+{
+	struct uniphier_glue_reset_priv *priv = _priv;
+
+	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
+}
+
+static void uniphier_rst_assert(void *_priv)
+{
+	struct uniphier_glue_reset_priv *priv = _priv;
+
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
+}
+
 static int uniphier_glue_reset_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -68,9 +82,17 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ret = devm_add_action_or_reset(dev, uniphier_clk_disable, priv);
+	if (ret)
+		return ret;
+
 	ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst);
 	if (ret)
-		goto out_clk_disable;
+		return ret;
+
+	ret = devm_add_action_or_reset(dev, uniphier_rst_assert, priv);
+	if (ret)
+		return ret;
 
 	spin_lock_init(&priv->rdata.lock);
 	priv->rdata.rcdev.owner = THIS_MODULE;
@@ -81,30 +103,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	ret = devm_reset_controller_register(dev, &priv->rdata.rcdev);
-	if (ret)
-		goto out_rst_assert;
-
-	return 0;
-
-out_rst_assert:
-	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
-
-out_clk_disable:
-	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
-
-	return ret;
-}
-
-static int uniphier_glue_reset_remove(struct platform_device *pdev)
-{
-	struct uniphier_glue_reset_priv *priv = platform_get_drvdata(pdev);
-
-	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
-
-	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
-
-	return 0;
+	return devm_reset_controller_register(dev, &priv->rdata.rcdev);
 }
 
 static const char * const uniphier_pro4_clock_reset_names[] = {
@@ -172,7 +171,6 @@ MODULE_DEVICE_TABLE(of, uniphier_glue_reset_match);
 
 static struct platform_driver uniphier_glue_reset_driver = {
 	.probe = uniphier_glue_reset_probe,
-	.remove = uniphier_glue_reset_remove,
 	.driver = {
 		.name = "uniphier-glue-reset",
 		.of_match_table = uniphier_glue_reset_match,
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH 2/2] reset: uniphier-glue: Use devm_add_action_or_reset()

From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Date: 2021-12-16 00:34:26

On 2021/12/15 18:38, Philipp Zabel wrote:
Slightly simplify uniphier_glue_reset_probe() and drop
uniphier_glue_reset_remove() by using devm_add_action_or_reset()
for clock and reset cleanup.
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you,
quoted hunk
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
  drivers/reset/reset-uniphier-glue.c | 50 ++++++++++++++---------------
  1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/drivers/reset/reset-uniphier-glue.c
b/drivers/reset/reset-uniphier-glue.c
index 9b22c4a91d77..146fd5d45e99 100644
--- a/drivers/reset/reset-uniphier-glue.c
+++ b/drivers/reset/reset-uniphier-glue.c
@@ -28,6 +28,20 @@ struct uniphier_glue_reset_priv {
  	const struct uniphier_glue_reset_soc_data *data;
  };
  
+static void uniphier_clk_disable(void *_priv)
+{
+	struct uniphier_glue_reset_priv *priv = _priv;
+
+	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
+}
+
+static void uniphier_rst_assert(void *_priv)
+{
+	struct uniphier_glue_reset_priv *priv = _priv;
+
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
+}
+
  static int uniphier_glue_reset_probe(struct platform_device *pdev)
  {
  	struct device *dev = &pdev->dev;
@@ -68,9 +82,17 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  	if (ret)
  		return ret;
  
+	ret = devm_add_action_or_reset(dev, uniphier_clk_disable, priv);
+	if (ret)
+		return ret;
+
  	ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst);
  	if (ret)
-		goto out_clk_disable;
+		return ret;
+
+	ret = devm_add_action_or_reset(dev, uniphier_rst_assert, priv);
+	if (ret)
+		return ret;
  
  	spin_lock_init(&priv->rdata.lock);
  	priv->rdata.rcdev.owner = THIS_MODULE;
@@ -81,30 +103,7 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  
  	platform_set_drvdata(pdev, priv);
  
-	ret = devm_reset_controller_register(dev, &priv->rdata.rcdev);
-	if (ret)
-		goto out_rst_assert;
-
-	return 0;
-
-out_rst_assert:
-	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
-
-out_clk_disable:
-	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
-
-	return ret;
-}
-
-static int uniphier_glue_reset_remove(struct platform_device *pdev)
-{
-	struct uniphier_glue_reset_priv *priv =
platform_get_drvdata(pdev);
-
-	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
-
-	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
-
-	return 0;
+	return devm_reset_controller_register(dev, &priv->rdata.rcdev);
  }
  
  static const char * const uniphier_pro4_clock_reset_names[] = {
@@ -172,7 +171,6 @@ MODULE_DEVICE_TABLE(of, uniphier_glue_reset_match);
  
  static struct platform_driver uniphier_glue_reset_driver = {
  	.probe = uniphier_glue_reset_probe,
-	.remove = uniphier_glue_reset_remove,
  	.driver = {
  		.name = "uniphier-glue-reset",
  		.of_match_table = uniphier_glue_reset_match,
---
Best Regards
Kunihiko Hayashi

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH 1/2] reset: uniphier-glue: Use reset_control_bulk API

From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Date: 2021-12-16 00:34:27

Hi Philipp,

On 2021/12/15 18:38, Philipp Zabel wrote:
This driver already uses the clk_bulk API. Simplify the driver by using
the reset_control_bulk API as well.
Looks good to me.
It makes sense to use reset_control_bulk API.

Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you,
quoted hunk
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
  drivers/reset/reset-uniphier-glue.c | 33 ++++++++++++-----------------
  1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/reset/reset-uniphier-glue.c
b/drivers/reset/reset-uniphier-glue.c
index 908c1d5bc41e..9b22c4a91d77 100644
--- a/drivers/reset/reset-uniphier-glue.c
+++ b/drivers/reset/reset-uniphier-glue.c
@@ -23,7 +23,7 @@ struct uniphier_glue_reset_soc_data {
  
  struct uniphier_glue_reset_priv {
  	struct clk_bulk_data clk[MAX_CLKS];
-	struct reset_control *rst[MAX_RSTS];
+	struct reset_control_bulk_data rst[MAX_RSTS];
  	struct reset_simple_data rdata;
  	const struct uniphier_glue_reset_soc_data *data;
  };
@@ -34,8 +34,7 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  	struct uniphier_glue_reset_priv *priv;
  	struct resource *res;
  	resource_size_t size;
-	const char *name;
-	int i, ret, nr;
+	int i, ret;
  
  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
@@ -58,22 +57,20 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  	if (ret)
  		return ret;
  
-	for (i = 0; i < priv->data->nrsts; i++) {
-		name = priv->data->reset_names[i];
-		priv->rst[i] = devm_reset_control_get_shared(dev, name);
-		if (IS_ERR(priv->rst[i]))
-			return PTR_ERR(priv->rst[i]);
-	}
+	for (i = 0; i < priv->data->nrsts; i++)
+		priv->rst[i].id = priv->data->reset_names[i];
+	ret = devm_reset_control_bulk_get_shared(dev, priv->data->nrsts,
+						 priv->rst);
+	if (ret)
+		return ret;
  
  	ret = clk_bulk_prepare_enable(priv->data->nclks, priv->clk);
  	if (ret)
  		return ret;
  
-	for (nr = 0; nr < priv->data->nrsts; nr++) {
-		ret = reset_control_deassert(priv->rst[nr]);
-		if (ret)
-			goto out_rst_assert;
-	}
+	ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst);
+	if (ret)
+		goto out_clk_disable;
  
  	spin_lock_init(&priv->rdata.lock);
  	priv->rdata.rcdev.owner = THIS_MODULE;
@@ -91,9 +88,9 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  	return 0;
  
  out_rst_assert:
-	while (nr--)
-		reset_control_assert(priv->rst[nr]);
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
  
+out_clk_disable:
  	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
  
  	return ret;
@@ -102,10 +99,8 @@ static int uniphier_glue_reset_probe(struct
platform_device *pdev)
  static int uniphier_glue_reset_remove(struct platform_device *pdev)
  {
  	struct uniphier_glue_reset_priv *priv =
platform_get_drvdata(pdev);
-	int i;
  
-	for (i = 0; i < priv->data->nrsts; i++)
-		reset_control_assert(priv->rst[i]);
+	reset_control_bulk_assert(priv->data->nrsts, priv->rst);
  
  	clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
  
---
Best Regards
Kunihiko Hayashi

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help