Skip to contentSkip to conversation

iio: adc: ade9000: fix wrong register in CALIBBIAS case for active power

PATCH Applied Giorgi Tchankvetadze 4 participants 4 messages Feb 26 – Feb 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
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(-)
drivers/iio/adc/ade9000.c +1 -1
index 5dcc26a08970..1499fb1c718a 100644
@@ -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);
Signature · 1 line
2.52.0
#1 lore raw
Quoted 11 lines · 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.

Quoted 6 lines

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Giorgi Tchankvetadze
Quoted 28 lines

-----Original Message-----
From: Giorgi Tchankvetadze <[email protected]>
Sent: Thursday, February 26, 2026 4:07 PM
To: Miclaus, Antoniu <[email protected]>
Cc: [email protected]; Hennerich, Michael <[email protected]>; [email protected]; David Lechner <[email protected]>; Sa, Nuno <[email protected]>; [email protected]; [email protected]; linux- [email protected]; Giorgi Tchankvetadze <[email protected]>
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.

Quoted 7 lines

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")

---

Quoted 25 lines

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(-)
drivers/iio/adc/ade9000.c +1 -1
index 5dcc26a08970..1499fb1c718a 100644
@@ -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-

Quoted 1 line

channel), val);

--
2.52.0

maintainer Applied
#3 lore raw
Quoted 32 lines · Antoniu
Quoted 32 lines

-----Original Message-----
From: Giorgi Tchankvetadze <[email protected]>
Sent: Thursday, February 26, 2026 4:07 PM
To: Miclaus, Antoniu <[email protected]>
Cc: [email protected]; Hennerich, Michael <[email protected]>; [email protected]; David Lechner <[email protected]>; Sa, Nuno <[email protected]>; [email protected]; [email protected]; linux- [email protected]; Giorgi Tchankvetadze <[email protected]>
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).

Quoted 5 lines
Quoted 3 lines
Fixes 81de7b4619fc ("iio: adc: add ade9000 support")

---

Applied to the fixes-togreg branch of iio.git and marked for stable.

Quoted 27 lines
Quoted 26 lines

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(-)
drivers/iio/adc/ade9000.c +1 -1
index 5dcc26a08970..1499fb1c718a 100644
@@ -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-

Quoted 1 line

channel), val);

--
2.52.0