* [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power
@ 2026-02-26 14:07 Giorgi Tchankvetadze
2026-02-26 14:36 ` Andy Shevchenko
2026-02-27 10:01 ` Miclaus, Antoniu
0 siblings, 2 replies; 4+ messages in thread
From: Giorgi Tchankvetadze @ 2026-02-26 14:07 UTC (permalink / raw)
To: antoniu.miclaus
Cc: lars, Michael.Hennerich, jic23, dlechner, nuno.sa, andy,
linux-iio, linux-kernel, Giorgi Tchankvetadze
The switch statement in ade9000_write_raw() attempts to match
chan->address against ADE9000_REG_AWATTOS (0x00F) to dispatch
the calibration offset write for active power channels. However,
chan->address is set via ADE9000_ADDR_ADJUST(ADE9000_REG_AWATT,
num), so after masking the phase bits, tmp holds
ADE9000_REG_AWATT (0x210), which never matches 0x00F.
As a result, writing IIO_CHAN_INFO_CALIBBIAS for IIO_POWER always
falls through to the default case and returns -EINVAL, making
active power offset calibration silently broken.
Fix this by matching against ADE9000_REG_AWATT instead, which is
the actual base address stored in chan->address for watt channels.
Reference:ADE9000 datasheet (Rev. B), AWATTOS is the offset correction
register at 0x00F (p. 44), while AWATT is the total active power
register at 0x210 (p. 48).
Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
---
v2:
- Added Fixes tag (Andy)
- Added datasheet reference (Rev. B, p. 44 and p. 48) (Andy)
drivers/iio/adc/ade9000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index 5dcc26a08970..1499fb1c718a 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -1123,7 +1123,7 @@ static int ade9000_write_raw(struct iio_dev *indio_dev,
tmp &= ~ADE9000_PHASE_C_POS_BIT;
switch (tmp) {
- case ADE9000_REG_AWATTOS:
+ case ADE9000_REG_AWATT:
return regmap_write(st->regmap,
ADE9000_ADDR_ADJUST(ADE9000_REG_AWATTOS,
chan->channel), val);
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power
2026-02-26 14:07 [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power Giorgi Tchankvetadze
@ 2026-02-26 14:36 ` Andy Shevchenko
2026-02-27 10:01 ` Miclaus, Antoniu
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-02-26 14:36 UTC (permalink / raw)
To: Giorgi Tchankvetadze
Cc: antoniu.miclaus, lars, Michael.Hennerich, jic23, dlechner,
nuno.sa, andy, linux-iio, linux-kernel
On Thu, Feb 26, 2026 at 06:07:02PM +0400, Giorgi Tchankvetadze wrote:
> The switch statement in ade9000_write_raw() attempts to match
> chan->address against ADE9000_REG_AWATTOS (0x00F) to dispatch
> the calibration offset write for active power channels. However,
> chan->address is set via ADE9000_ADDR_ADJUST(ADE9000_REG_AWATT,
> num), so after masking the phase bits, tmp holds
> ADE9000_REG_AWATT (0x210), which never matches 0x00F.
>
> As a result, writing IIO_CHAN_INFO_CALIBBIAS for IIO_POWER always
> falls through to the default case and returns -EINVAL, making
> active power offset calibration silently broken.
>
> Fix this by matching against ADE9000_REG_AWATT instead, which is
> the actual base address stored in chan->address for watt channels.
>
> Reference:ADE9000 datasheet (Rev. B), AWATTOS is the offset correction
> register at 0x00F (p. 44), while AWATT is the total active power
> register at 0x210 (p. 48).
Please, avoid sending a new version earlier than 24h after the previous one!
I think the best who can review this is somebody with HW. Preferably
one from vendor company.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power
2026-02-26 14:07 [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power Giorgi Tchankvetadze
2026-02-26 14:36 ` Andy Shevchenko
@ 2026-02-27 10:01 ` Miclaus, Antoniu
2026-02-28 13:18 ` Jonathan Cameron
1 sibling, 1 reply; 4+ messages in thread
From: Miclaus, Antoniu @ 2026-02-27 10:01 UTC (permalink / raw)
To: Giorgi Tchankvetadze
Cc: lars@metafoo.de, Hennerich, Michael, jic23@kernel.org,
David Lechner, Sa, Nuno, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
> Sent: Thursday, February 26, 2026 4:07 PM
> To: Miclaus, Antoniu <Antoniu.Miclaus@analog.com>
> Cc: lars@metafoo.de; Hennerich, Michael <Michael.Hennerich@analog.com>;
> jic23@kernel.org; David Lechner <dlechner@baylibre.com>; Sa, Nuno
> <Nuno.Sa@analog.com>; andy@kernel.org; linux-iio@vger.kernel.org; linux-
> kernel@vger.kernel.org; Giorgi Tchankvetadze
> <giorgitchankvetadze1997@gmail.com>
> Subject: [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for
> active power
>
> [External]
>
> The switch statement in ade9000_write_raw() attempts to match
> chan->address against ADE9000_REG_AWATTOS (0x00F) to dispatch
> the calibration offset write for active power channels. However,
> chan->address is set via ADE9000_ADDR_ADJUST(ADE9000_REG_AWATT,
> num), so after masking the phase bits, tmp holds
> ADE9000_REG_AWATT (0x210), which never matches 0x00F.
>
> As a result, writing IIO_CHAN_INFO_CALIBBIAS for IIO_POWER always
> falls through to the default case and returns -EINVAL, making
> active power offset calibration silently broken.
>
> Fix this by matching against ADE9000_REG_AWATT instead, which is
> the actual base address stored in chan->address for watt channels.
>
> Reference:ADE9000 datasheet (Rev. B), AWATTOS is the offset correction
> register at 0x00F (p. 44), while AWATT is the total active power
> register at 0x210 (p. 48).
>
> Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
> Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
> ---
Reviewed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> v2:
> - Added Fixes tag (Andy)
> - Added datasheet reference (Rev. B, p. 44 and p. 48) (Andy)
>
> drivers/iio/adc/ade9000.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
> index 5dcc26a08970..1499fb1c718a 100644
> --- a/drivers/iio/adc/ade9000.c
> +++ b/drivers/iio/adc/ade9000.c
> @@ -1123,7 +1123,7 @@ static int ade9000_write_raw(struct iio_dev
> *indio_dev,
> tmp &= ~ADE9000_PHASE_C_POS_BIT;
>
> switch (tmp) {
> - case ADE9000_REG_AWATTOS:
> + case ADE9000_REG_AWATT:
> return regmap_write(st->regmap,
>
> ADE9000_ADDR_ADJUST(ADE9000_REG_AWATTOS,
> chan-
> >channel), val);
> --
> 2.52.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power
2026-02-27 10:01 ` Miclaus, Antoniu
@ 2026-02-28 13:18 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-02-28 13:18 UTC (permalink / raw)
To: Miclaus, Antoniu
Cc: Giorgi Tchankvetadze, lars@metafoo.de, Hennerich, Michael,
David Lechner, Sa, Nuno, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
On Fri, 27 Feb 2026 10:01:41 +0000
"Miclaus, Antoniu" <Antoniu.Miclaus@analog.com> wrote:
> > -----Original Message-----
> > From: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
> > Sent: Thursday, February 26, 2026 4:07 PM
> > To: Miclaus, Antoniu <Antoniu.Miclaus@analog.com>
> > Cc: lars@metafoo.de; Hennerich, Michael <Michael.Hennerich@analog.com>;
> > jic23@kernel.org; David Lechner <dlechner@baylibre.com>; Sa, Nuno
> > <Nuno.Sa@analog.com>; andy@kernel.org; linux-iio@vger.kernel.org; linux-
> > kernel@vger.kernel.org; Giorgi Tchankvetadze
> > <giorgitchankvetadze1997@gmail.com>
> > Subject: [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for
> > active power
> >
> > [External]
> >
> > The switch statement in ade9000_write_raw() attempts to match
> > chan->address against ADE9000_REG_AWATTOS (0x00F) to dispatch
> > the calibration offset write for active power channels. However,
> > chan->address is set via ADE9000_ADDR_ADJUST(ADE9000_REG_AWATT,
> > num), so after masking the phase bits, tmp holds
> > ADE9000_REG_AWATT (0x210), which never matches 0x00F.
> >
> > As a result, writing IIO_CHAN_INFO_CALIBBIAS for IIO_POWER always
> > falls through to the default case and returns -EINVAL, making
> > active power offset calibration silently broken.
> >
> > Fix this by matching against ADE9000_REG_AWATT instead, which is
> > the actual base address stored in chan->address for watt channels.
> >
> > Reference:ADE9000 datasheet (Rev. B), AWATTOS is the offset correction
> > register at 0x00F (p. 44), while AWATT is the total active power
> > register at 0x210 (p. 48).
> >
> > Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
> > Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
> > ---
>
> Reviewed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
>
> > v2:
> > - Added Fixes tag (Andy)
> > - Added datasheet reference (Rev. B, p. 44 and p. 48) (Andy)
> >
> > drivers/iio/adc/ade9000.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
> > index 5dcc26a08970..1499fb1c718a 100644
> > --- a/drivers/iio/adc/ade9000.c
> > +++ b/drivers/iio/adc/ade9000.c
> > @@ -1123,7 +1123,7 @@ static int ade9000_write_raw(struct iio_dev
> > *indio_dev,
> > tmp &= ~ADE9000_PHASE_C_POS_BIT;
> >
> > switch (tmp) {
> > - case ADE9000_REG_AWATTOS:
> > + case ADE9000_REG_AWATT:
> > return regmap_write(st->regmap,
> >
> > ADE9000_ADDR_ADJUST(ADE9000_REG_AWATTOS,
> > chan-
> > >channel), val);
> > --
> > 2.52.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-28 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 14:07 [PATCH v2] iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power Giorgi Tchankvetadze
2026-02-26 14:36 ` Andy Shevchenko
2026-02-27 10:01 ` Miclaus, Antoniu
2026-02-28 13:18 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox