Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Giorgi Tchankvetadze and committed by
Jonathan Cameron
86133fb1 bd66aa1c

+1 -1
+1 -1
drivers/iio/adc/ade9000.c
··· 1123 1123 tmp &= ~ADE9000_PHASE_C_POS_BIT; 1124 1124 1125 1125 switch (tmp) { 1126 - case ADE9000_REG_AWATTOS: 1126 + case ADE9000_REG_AWATT: 1127 1127 return regmap_write(st->regmap, 1128 1128 ADE9000_ADDR_ADJUST(ADE9000_REG_AWATTOS, 1129 1129 chan->channel), val);