summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGiorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>2026-02-26 18:07:02 +0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2026-03-01 11:20:10 +0000
commit86133fb1ec36b2f5cec29d71fbae84877c3a1358 (patch)
tree112a6bdf1b41c7c96ebb79401bd199b88f712826 /drivers
parentbd66aa1c8b8cabf459064a46d3430a5ec5138418 (diff)
iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power
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> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/adc/ade9000.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index c62c6480dd0a..945a159e5de6 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);