mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module
@ 2026-08-05 12:31 Giorgi Tchankvetadze
  2026-08-06  6:52 ` Joshua Crofts
  2026-08-16  1:06 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Giorgi Tchankvetadze @ 2026-08-05 12:31 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Giorgi Tchankvetadze, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Danilo Krummrich, Takashi Sakamoto, Dixit Parmar, Keerthy,
	Samuel Ortiz, linux-iio, linux-kernel

From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>

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@tchankvetadze.com>
---
 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",
-- 
2.52.0


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

* Re: [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module
  2026-08-05 12:31 [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module Giorgi Tchankvetadze
@ 2026-08-06  6:52 ` Joshua Crofts
  2026-08-16  1:06 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-08-06  6:52 UTC (permalink / raw)
  To: Giorgi Tchankvetadze
  Cc: Jonathan Cameron, Giorgi Tchankvetadze, David Lechner,
	Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Danilo Krummrich, Takashi Sakamoto, Dixit Parmar, Keerthy,
	Samuel Ortiz, linux-iio, linux-kernel

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

> From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> 
> 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@tchankvetadze.com>
> ---

This makes sense.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards,
Joshua Crofts

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

* Re: [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module
  2026-08-05 12:31 [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module Giorgi Tchankvetadze
  2026-08-06  6:52 ` Joshua Crofts
@ 2026-08-16  1:06 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-08-16  1:06 UTC (permalink / raw)
  To: Giorgi Tchankvetadze
  Cc: Giorgi Tchankvetadze, David Lechner, Nuno Sá,
	Andy Shevchenko, Uwe Kleine-König (The Capable Hub),
	Danilo Krummrich, Takashi Sakamoto, Dixit Parmar, Keerthy,
	Samuel Ortiz, linux-iio, linux-kernel, amitk

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

> From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> 
> 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@tchankvetadze.com>
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",


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

end of thread, other threads:[~2026-08-16  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05 12:31 [PATCH] iio: adc: twl4030-madc: read MADC_CTRL1 from the correct module Giorgi Tchankvetadze
2026-08-06  6:52 ` Joshua Crofts
2026-08-16  1:06 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®