Skip to contentSkip to conversation

iio: adc: sun20i-gpadc: Use devm_reset_control_get_exclusive_deasserted() in sun20i_gpadc_probe()

PATCH In review Markus Elfring 3 participants 3 messages Nov 14 – Nov 15

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

PATCH 1/1 iio: adc: sun20i-gpadc: Use devm_reset_control_get_exclusive_deasserted() in sun20i_gpadc_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2026 17:55:16 +0100

Use devm_reset_control_get_exclusive_deasserted() to replace the explicit reset acquisition, deassertion, and cleanup action registered with devm_add_action_or_reset().
Simplify reset handling and remove the custom reset assertion callback while preserving reset assertion during cleanup.

The source code was transformed by using the Coccinelle software.

---
 drivers/iio/adc/sun20i-gpadc-iio.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/iio/adc/sun20i-gpadc-iio.c +3 -17
index baa7661db13b..070d061572c6 100644
@@ -157,13 +157,6 @@ static const struct iio_info sun20i_gpadc_iio_info = {
 	.fwnode_xlate = sun20i_gpadc_fwnode_xlate,
 };
 
-static void sun20i_gpadc_reset_assert(void *data)
-{
-	struct reset_control *rst = data;
-
-	reset_control_assert(rst);
-}
-
 static const struct iio_chan_spec sun20i_gpadc_chan_template = {
 	.type = IIO_VOLTAGE,
 	.indexed = 1,
@@ -225,17 +218,10 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
 	if (ret == 0)
 		return dev_err_probe(dev, -ENODEV, "needs at least one clocks\n");
 
-	rst = devm_reset_control_get_exclusive(dev, NULL);
+	rst = devm_reset_control_get_exclusive_deasserted(dev, NULL);
 	if (IS_ERR(rst))
-		return dev_err_probe(dev, PTR_ERR(rst), "failed to get reset control\n");
-
-	ret = reset_control_deassert(rst);
-	if (ret)
-		return dev_err_probe(dev, ret, "failed to deassert reset\n");
-
-	ret = devm_add_action_or_reset(dev, sun20i_gpadc_reset_assert, rst);
-	if (ret)
-		return ret;
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "failed to get and deassert reset\n");
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
Signature · 1 line
2.56.0
maintainer Acked-by on v1 1/1
#1 lore raw

Dne sobota, 14. november 2026 ob 18:08:10 Srednjeevropski standardni čas je Markus Elfring napisal(a):

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2026 17:55:16 +0100

Use devm_reset_control_get_exclusive_deasserted() to replace the explicit reset acquisition, deassertion, and cleanup action registered with devm_add_action_or_reset().
Simplify reset handling and remove the custom reset assertion callback while preserving reset assertion during cleanup.

Quoted 3 lines

The source code was transformed by using the Coccinelle software.

Best regards,
Jernej

Quoted 44 lines
---
 drivers/iio/adc/sun20i-gpadc-iio.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/iio/adc/sun20i-gpadc-iio.c +3 -17
index baa7661db13b..070d061572c6 100644
@@ -157,13 +157,6 @@ static const struct iio_info sun20i_gpadc_iio_info = {
 	.fwnode_xlate = sun20i_gpadc_fwnode_xlate,
 };
 
-static void sun20i_gpadc_reset_assert(void *data)
-{
-	struct reset_control *rst = data;
-
-	reset_control_assert(rst);
-}
-
 static const struct iio_chan_spec sun20i_gpadc_chan_template = {
 	.type = IIO_VOLTAGE,
 	.indexed = 1,
@@ -225,17 +218,10 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
 	if (ret == 0)
 		return dev_err_probe(dev, -ENODEV, "needs at least one clocks\n");
 
-	rst = devm_reset_control_get_exclusive(dev, NULL);
+	rst = devm_reset_control_get_exclusive_deasserted(dev, NULL);
 	if (IS_ERR(rst))
-		return dev_err_probe(dev, PTR_ERR(rst), "failed to get reset control\n");
-
-	ret = reset_control_deassert(rst);
-	if (ret)
-		return dev_err_probe(dev, ret, "failed to deassert reset\n");
-
-	ret = devm_add_action_or_reset(dev, sun20i_gpadc_reset_assert, rst);
-	if (ret)
-		return ret;
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "failed to get and deassert reset\n");
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
maintainer
#2 lore raw
Quoted 10 lines · On Sat, 14 Nov 2026 18:19:12 +0100 Jernej Škrabec <[email protected]>…

Dne sobota, 14. november 2026 ob 18:08:10 Srednjeevropski standardni čas je Markus Elfring napisal(a):

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Sat, 14 Nov 2026 17:55:16 +0100

Use devm_reset_control_get_exclusive_deasserted() to replace the explicit reset acquisition, deassertion, and cleanup action registered with devm_add_action_or_reset().
Simplify reset handling and remove the custom reset assertion callback while preserving reset assertion during cleanup.

Quoted 6 lines
Quoted 3 lines

The source code was transformed by using the Coccinelle software.

Like for like swap as far as I can tell, so applied to the testing branch of iio.git

Thanks,

Jonathan

Quoted 51 lines

Best regards,
Jernej

Quoted 44 lines
---
 drivers/iio/adc/sun20i-gpadc-iio.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/iio/adc/sun20i-gpadc-iio.c +3 -17
index baa7661db13b..070d061572c6 100644
@@ -157,13 +157,6 @@ static const struct iio_info sun20i_gpadc_iio_info = {
 	.fwnode_xlate = sun20i_gpadc_fwnode_xlate,
 };
 
-static void sun20i_gpadc_reset_assert(void *data)
-{
-	struct reset_control *rst = data;
-
-	reset_control_assert(rst);
-}
-
 static const struct iio_chan_spec sun20i_gpadc_chan_template = {
 	.type = IIO_VOLTAGE,
 	.indexed = 1,
@@ -225,17 +218,10 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
 	if (ret == 0)
 		return dev_err_probe(dev, -ENODEV, "needs at least one clocks\n");
 
-	rst = devm_reset_control_get_exclusive(dev, NULL);
+	rst = devm_reset_control_get_exclusive_deasserted(dev, NULL);
 	if (IS_ERR(rst))
-		return dev_err_probe(dev, PTR_ERR(rst), "failed to get reset control\n");
-
-	ret = reset_control_deassert(rst);
-	if (ret)
-		return dev_err_probe(dev, ret, "failed to deassert reset\n");
-
-	ret = devm_add_action_or_reset(dev, sun20i_gpadc_reset_assert, rst);
-	if (ret)
-		return ret;
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "failed to get and deassert reset\n");
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)