Re: [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module

From: Jonathan Cameron

Date: Sat Aug 15 2026 - 21:06:20 EST


On Wed, 5 Aug 2026 16:31:59 +0400
Giorgi Tchankvetadze <giorgitchankvetadze1997@xxxxxxxxx> wrote:

> From: Giorgi Tchankvetadze <giorgi@xxxxxxxxxxxxxxxxx>
>
> twl4030_madc_set_power() does a read-modify-write on MADC_CTRL1 but
> reads it from TWL_MODULE_MAIN_CHARGE while writing it back to
> TWL4030_MODULE_MADC.
>
> Fix it by reading MADC_CTRL1 from TWL4030_MODULE_MADC
> so the read-modify-write operates on the register's actual
> contents.
>
> Fixes: f99c1d4f94f9 ("mfd: Add twl4030 madc driver")
> Signed-off-by: Giorgi Tchankvetadze <giorgi@xxxxxxxxxxxxxxxxx>
Whilst I agree this looks likely to be correct, the register
map for this device is crazy, the defines not named in helpful
way and generally it is hard to be entirely sure what was intended.

So, can you provide some background. Is this a problem you ran into,
code inspection, or AI looking for possible problems?

Have you checked what is in the register that seems to be being
incorrectly read? Basically I'm looking for more detail.

Amit is listed in the original driver and is still about - so...
Amit any idea? Was at least 12 years ago (I got bored looking
beyond that) so feel free to say you have no idea :)

> ---
> drivers/iio/adc/twl4030-madc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 0ee7e16b5e24..1156e68ebd91 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -718,7 +718,7 @@ static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on)
> u8 regval;
> int ret;
>
> - ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE,
> + ret = twl_i2c_read_u8(TWL4030_MODULE_MADC,
> &regval, TWL4030_MADC_CTRL1);
> if (ret) {
> dev_err(madc->dev, "unable to read madc ctrl1 reg 0x%X\n",