* [PATCH v2 1/3] iio: adc: twl6030-gpadc: use devm_add_action_or_reset() to disable IRQ
2026-11-23 3:53 [PATCH v2 0/3] iio: adc: twl6030-gpadc: convert probe/remove cleanup to devm Wanhui Fu
@ 2026-11-23 3:53 ` Wanhui Fu
2026-11-28 23:36 ` Jonathan Cameron
2026-11-23 3:53 ` [PATCH v2 2/3] iio: adc: twl6030-gpadc: switch to devm_iio_device_register() Wanhui Fu
2026-11-23 3:53 ` [PATCH v2 3/3] iio: adc: twl6030-gpadc: delete redundant dev_err() messages in probe Wanhui Fu
2 siblings, 1 reply; 6+ messages in thread
From: Wanhui Fu @ 2026-11-23 3:53 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio
Cc: Andreas Kemnade, David Lechner, Nuno Sá,
Andy Shevchenko, linux-kernel, Wanhui Fu
Register twl6030_gpadc_disable_irq() via devm_add_action_or_reset()
and remove the manual call from twl6030_gpadc_remove().
Modify twl6030_gpadc_enable_irq() and twl6030_gpadc_disable_irq() to
not take a mask argument, since the mask is always the same.
Fixes: 1696f36482e7 ("iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver")
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
drivers/iio/adc/twl6030-gpadc.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index e7fd371b3404..786059cf7513 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -360,8 +360,9 @@ static inline int twl6030_gpadc_read(u8 reg, u8 *val)
return twl_i2c_read(TWL6030_MODULE_GPADC, val, reg, 2);
}
-static int twl6030_gpadc_enable_irq(u8 mask)
+static int twl6030_gpadc_enable_irq(void)
{
+ u8 mask = TWL6030_GPADC_RT_SW1_EOC_MASK;
int ret;
ret = twl6030_interrupt_unmask(mask, REG_INT_MSK_LINE_B);
@@ -373,8 +374,10 @@ static int twl6030_gpadc_enable_irq(u8 mask)
return ret;
}
-static void twl6030_gpadc_disable_irq(u8 mask)
+static void twl6030_gpadc_disable_irq(void *data)
{
+ u8 mask = TWL6030_GPADC_RT_SW1_EOC_MASK;
+
twl6030_interrupt_mask(mask, REG_INT_MSK_LINE_B);
twl6030_interrupt_mask(mask, REG_INT_MSK_STS_B);
}
@@ -921,12 +924,16 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
if (ret)
return ret;
- ret = twl6030_gpadc_enable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK);
+ ret = twl6030_gpadc_enable_irq();
if (ret < 0) {
dev_err(dev, "failed to enable GPADC interrupt\n");
return ret;
}
+ ret = devm_add_action_or_reset(dev, twl6030_gpadc_disable_irq, NULL);
+ if (ret)
+ return ret;
+
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS,
TWL6030_REG_TOGGLE1);
if (ret < 0) {
@@ -967,7 +974,6 @@ static void twl6030_gpadc_remove(struct platform_device *pdev)
{
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- twl6030_gpadc_disable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK);
iio_device_unregister(indio_dev);
}
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/3] iio: adc: twl6030-gpadc: use devm_add_action_or_reset() to disable IRQ
2026-11-23 3:53 ` [PATCH v2 1/3] iio: adc: twl6030-gpadc: use devm_add_action_or_reset() to disable IRQ Wanhui Fu
@ 2026-11-28 23:36 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-11-28 23:36 UTC (permalink / raw)
To: Wanhui Fu
Cc: linux-iio, Andreas Kemnade, David Lechner, Nuno Sá,
Andy Shevchenko, linux-kernel
On Mon, 23 Nov 2026 11:53:29 +0800
Wanhui Fu <fuwh1120@163.com> wrote:
> Register twl6030_gpadc_disable_irq() via devm_add_action_or_reset()
> and remove the manual call from twl6030_gpadc_remove().
>
> Modify twl6030_gpadc_enable_irq() and twl6030_gpadc_disable_irq() to
> not take a mask argument, since the mask is always the same.
This doesn't state anywhere what is being fixed.
I want to see details on the cause and impact of the bug.
Jonathan
>
> Fixes: 1696f36482e7 ("iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver")
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>
> ---
> drivers/iio/adc/twl6030-gpadc.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
> index e7fd371b3404..786059cf7513 100644
> --- a/drivers/iio/adc/twl6030-gpadc.c
> +++ b/drivers/iio/adc/twl6030-gpadc.c
> @@ -360,8 +360,9 @@ static inline int twl6030_gpadc_read(u8 reg, u8 *val)
> return twl_i2c_read(TWL6030_MODULE_GPADC, val, reg, 2);
> }
>
> -static int twl6030_gpadc_enable_irq(u8 mask)
> +static int twl6030_gpadc_enable_irq(void)
> {
> + u8 mask = TWL6030_GPADC_RT_SW1_EOC_MASK;
> int ret;
>
> ret = twl6030_interrupt_unmask(mask, REG_INT_MSK_LINE_B);
> @@ -373,8 +374,10 @@ static int twl6030_gpadc_enable_irq(u8 mask)
> return ret;
> }
>
> -static void twl6030_gpadc_disable_irq(u8 mask)
> +static void twl6030_gpadc_disable_irq(void *data)
> {
> + u8 mask = TWL6030_GPADC_RT_SW1_EOC_MASK;
> +
> twl6030_interrupt_mask(mask, REG_INT_MSK_LINE_B);
> twl6030_interrupt_mask(mask, REG_INT_MSK_STS_B);
> }
> @@ -921,12 +924,16 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - ret = twl6030_gpadc_enable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK);
> + ret = twl6030_gpadc_enable_irq();
> if (ret < 0) {
> dev_err(dev, "failed to enable GPADC interrupt\n");
> return ret;
> }
>
> + ret = devm_add_action_or_reset(dev, twl6030_gpadc_disable_irq, NULL);
> + if (ret)
> + return ret;
> +
> ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS,
> TWL6030_REG_TOGGLE1);
> if (ret < 0) {
> @@ -967,7 +974,6 @@ static void twl6030_gpadc_remove(struct platform_device *pdev)
> {
> struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>
> - twl6030_gpadc_disable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK);
> iio_device_unregister(indio_dev);
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] iio: adc: twl6030-gpadc: switch to devm_iio_device_register()
2026-11-23 3:53 [PATCH v2 0/3] iio: adc: twl6030-gpadc: convert probe/remove cleanup to devm Wanhui Fu
2026-11-23 3:53 ` [PATCH v2 1/3] iio: adc: twl6030-gpadc: use devm_add_action_or_reset() to disable IRQ Wanhui Fu
@ 2026-11-23 3:53 ` Wanhui Fu
2026-11-23 3:53 ` [PATCH v2 3/3] iio: adc: twl6030-gpadc: delete redundant dev_err() messages in probe Wanhui Fu
2 siblings, 0 replies; 6+ messages in thread
From: Wanhui Fu @ 2026-11-23 3:53 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio
Cc: Andreas Kemnade, David Lechner, Nuno Sá,
Andy Shevchenko, linux-kernel, Wanhui Fu
Convert iio_device_register() to devm_iio_device_register().
This allows dropping the now-empty twl6030_gpadc_remove() and
the unused platform_set_drvdata() call.
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
drivers/iio/adc/twl6030-gpadc.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index 786059cf7513..591c7b3322c7 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -904,7 +904,6 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
gpadc->dev = dev;
gpadc->pdata = pdata;
- platform_set_drvdata(pdev, indio_dev);
mutex_init(&gpadc->lock);
init_completion(&gpadc->irq_complete);
@@ -967,14 +966,7 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
indio_dev->channels = pdata->iio_channels;
indio_dev->num_channels = pdata->nchannels;
- return iio_device_register(indio_dev);
-}
-
-static void twl6030_gpadc_remove(struct platform_device *pdev)
-{
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
-
- iio_device_unregister(indio_dev);
+ return devm_iio_device_register(dev, indio_dev);
}
static int twl6030_gpadc_suspend(struct device *pdev)
@@ -1006,7 +998,6 @@ static DEFINE_SIMPLE_DEV_PM_OPS(twl6030_gpadc_pm_ops, twl6030_gpadc_suspend,
static struct platform_driver twl6030_gpadc_driver = {
.probe = twl6030_gpadc_probe,
- .remove = twl6030_gpadc_remove,
.driver = {
.name = DRIVER_NAME,
.pm = pm_sleep_ptr(&twl6030_gpadc_pm_ops),
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 3/3] iio: adc: twl6030-gpadc: delete redundant dev_err() messages in probe
2026-11-23 3:53 [PATCH v2 0/3] iio: adc: twl6030-gpadc: convert probe/remove cleanup to devm Wanhui Fu
2026-11-23 3:53 ` [PATCH v2 1/3] iio: adc: twl6030-gpadc: use devm_add_action_or_reset() to disable IRQ Wanhui Fu
2026-11-23 3:53 ` [PATCH v2 2/3] iio: adc: twl6030-gpadc: switch to devm_iio_device_register() Wanhui Fu
@ 2026-11-23 3:53 ` Wanhui Fu
2026-11-28 23:37 ` Jonathan Cameron
2 siblings, 1 reply; 6+ messages in thread
From: Wanhui Fu @ 2026-11-23 3:53 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio
Cc: Andreas Kemnade, David Lechner, Nuno Sá,
Andy Shevchenko, linux-kernel, Wanhui Fu
twl_i2c_write() already logs error messages on I2C transfer
failures, so remove redundant dev_err() to simplify the probe
function.
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
drivers/iio/adc/twl6030-gpadc.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index 591c7b3322c7..6e20e5a31211 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -935,30 +935,22 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS,
TWL6030_REG_TOGGLE1);
- if (ret < 0) {
- dev_err(dev, "failed to enable GPADC module\n");
+ if (ret < 0)
return ret;
- }
ret = twl_i2c_write_u8(TWL_MODULE_USB, VBUS_MEAS, USB_VBUS_CTRL_SET);
- if (ret < 0) {
- dev_err(dev, "failed to wire up inputs\n");
+ if (ret < 0)
return ret;
- }
ret = twl_i2c_write_u8(TWL_MODULE_USB, ID_MEAS, USB_ID_CTRL_SET);
- if (ret < 0) {
- dev_err(dev, "failed to wire up inputs\n");
+ if (ret < 0)
return ret;
- }
ret = twl_i2c_write_u8(TWL6030_MODULE_ID0,
VBAT_MEAS | BB_MEAS | VAC_MEAS,
TWL6030_MISC1);
- if (ret < 0) {
- dev_err(dev, "failed to wire up inputs\n");
+ if (ret < 0)
return ret;
- }
indio_dev->name = DRIVER_NAME;
indio_dev->info = &twl6030_gpadc_iio_info;
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 3/3] iio: adc: twl6030-gpadc: delete redundant dev_err() messages in probe
2026-11-23 3:53 ` [PATCH v2 3/3] iio: adc: twl6030-gpadc: delete redundant dev_err() messages in probe Wanhui Fu
@ 2026-11-28 23:37 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-11-28 23:37 UTC (permalink / raw)
To: Wanhui Fu
Cc: linux-iio, Andreas Kemnade, David Lechner, Nuno Sá,
Andy Shevchenko, linux-kernel
On Mon, 23 Nov 2026 11:53:31 +0800
Wanhui Fu <fuwh1120@163.com> wrote:
> twl_i2c_write() already logs error messages on I2C transfer
> failures, so remove redundant dev_err() to simplify the probe
> function.
>
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>
This and patch 2 both look good to me, so I'll pick them up
once we have that extra info for patch 1.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread