drivers/iio/adc/ade9000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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.
Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
---
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
On Thu, Feb 26, 2026 at 05:37:42PM +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. Sounds like a good fix, but: - needs a Fixes tag - needs a reference to datasheet section / table / et cetera to prove the point Also, how did you found this? Code inspection? Testing on real HW? -- With Best Regards, Andy Shevchenko
On Thu, Feb 26, 2026 at 5:44 PM Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > Sounds like a good fix, but: > - needs a Fixes tag > - needs a reference to datasheet section / table / et cetera to prove the point Added both in v2. > Also, how did you found this? Code inspection? Testing on real HW? Code inspection. Unfortunately, I do not have a real hardware yet
© 2016 - 2026 Red Hat, Inc.