Skip to contentSkip to conversation

iio: dac: ad3530r: Fix incorrect masking for channels 4-7 in powerdown mode

PATCH Applied Kim Seer Paller 4 participants 4 messages Jun 26, 2025 – Jun 28, 2025

Subsystems (3)
lore
Share & tools
lore

Kim Seer Paller

author maintainer
#0 lore raw

PATCH 1/1 iio: dac: ad3530r: Fix incorrect masking for channels 4-7 in powerdown mode

In the current implementation of ad3530r_set_dac_powerdown() function, the macro AD3530R_OP_MODE_CHAN_MSK(chan->channel) is used to generate the bitmask for the operating mode of a specific channel. However, this macro does not account for channels 4-7, which map to the second register AD3530R_OUTPUT_OPERATING_MODE_1 for the 8 channeled device. As a result, the bitmask is incorrectly calculated for these channels, leading to improper configuration of the powerdown mode. Resolve this issue by adjusting the channel index for channels 4-7 by subtracting 4 before applying the macro. This ensures that the correct bitmask is generated for the second register.

Fixes 93583174a3df ("iio: dac: ad3530r: Add driver for AD3530R and AD3531R")
---
 drivers/iio/dac/ad3530r.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad3530r.c +3 -1
index f9752a571aa53ca0d7e199ed6a78550358185bf9..6134613777b8e1d4516109b74e0b3b79edb1ae75 100644
@@ -166,7 +166,9 @@ static ssize_t ad3530r_set_dac_powerdown(struct iio_dev *indio_dev,
 	      AD3530R_OUTPUT_OPERATING_MODE_0 :
 	      AD3530R_OUTPUT_OPERATING_MODE_1;
 	pdmode = powerdown ? st->chan[chan->channel].powerdown_mode : 0;
-	mask = AD3530R_OP_MODE_CHAN_MSK(chan->channel);
+	mask = chan->channel < AD3531R_MAX_CHANNELS ?
+	       AD3530R_OP_MODE_CHAN_MSK(chan->channel) :
+	       AD3530R_OP_MODE_CHAN_MSK(chan->channel - 4);
 	val = field_prep(mask, pdmode);
 
 	ret = regmap_update_bits(st->regmap, reg, mask, val);

---
base-commit: 0a2857e778599c2794dc89c40dc79ead631b34df
change-id: 20250626-bug_fix-404361f2f190

Best regards,

Signature · 1 line
Kim Seer Paller <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kim Seer Paller

In the current implementation of ad3530r_set_dac_powerdown() function, the macro AD3530R_OP_MODE_CHAN_MSK(chan->channel) is used to generate the bitmask for the operating mode of a specific channel. However, this macro does not account for channels 4-7, which map to the second register AD3530R_OUTPUT_OPERATING_MODE_1 for the 8 channeled device. As a result, the bitmask is incorrectly calculated for these channels, leading to improper configuration of the powerdown mode. Resolve this issue by adjusting the channel index for channels 4-7 by subtracting 4 before applying the macro. This ensures that the correct bitmask is generated for the second register.

Quoted 3 lines
Fixes 93583174a3df ("iio: dac: ad3530r: Add driver for AD3530R and AD3531R")

---

Reviewed-by on v1 1/1
#2 lore raw
In reply to Kim Seer Paller
Quoted 11 lines · Kim Seer Paller

In the current implementation of ad3530r_set_dac_powerdown() function, the macro AD3530R_OP_MODE_CHAN_MSK(chan->channel) is used to generate the bitmask for the operating mode of a specific channel. However, this macro does not account for channels 4-7, which map to the second register AD3530R_OUTPUT_OPERATING_MODE_1 for the 8 channeled device. As a result, the bitmask is incorrectly calculated for these channels, leading to improper configuration of the powerdown mode. Resolve this issue by adjusting the channel index for channels 4-7 by subtracting 4 before applying the macro. This ensures that the correct bitmask is generated for the second register.

Quoted 3 lines
Fixes 93583174a3df ("iio: dac: ad3530r: Add driver for AD3530R and AD3531R")

---

LGTM,

Quoted 27 lines

 drivers/iio/dac/ad3530r.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad3530r.c +0 -0

index f9752a571aa53ca0d7e199ed6a78550358185bf9..6134613777b8e1d4516109b74e0b3b79edb1 ae75 100644

drivers/iio/dac/ad3530r.c +0 -0
@@ -166,7 +166,9 @@ static ssize_t ad3530r_set_dac_powerdown(struct iio_dev
 *indio_dev,

        AD3530R_OUTPUT_OPERATING_MODE_0 :
        AD3530R_OUTPUT_OPERATING_MODE_1;
  pdmode = powerdown ? st->chan[chan->channel].powerdown_mode : 0;

drivers/iio/dac/ad3530r.c +3 -1
-	mask = AD3530R_OP_MODE_CHAN_MSK(chan->channel);
+	mask = chan->channel < AD3531R_MAX_CHANNELS ?
+	       AD3530R_OP_MODE_CHAN_MSK(chan->channel) :
+	       AD3530R_OP_MODE_CHAN_MSK(chan->channel - 4);

  val = field_prep(mask, pdmode);

  ret = regmap_update_bits(st->regmap, reg, mask, val);

---
base-commit: 0a2857e778599c2794dc89c40dc79ead631b34df
change-id: 20250626-bug_fix-404361f2f190

Best regards,

maintainer Applied
#3 lore raw
Quoted 12 lines · On Fri, 27 Jun 2025 16:54:33 +0100 Nuno Sá <[email protected]> wrote:
Quoted 11 lines · Kim Seer Paller

In the current implementation of ad3530r_set_dac_powerdown() function, the macro AD3530R_OP_MODE_CHAN_MSK(chan->channel) is used to generate the bitmask for the operating mode of a specific channel. However, this macro does not account for channels 4-7, which map to the second register AD3530R_OUTPUT_OPERATING_MODE_1 for the 8 channeled device. As a result, the bitmask is incorrectly calculated for these channels, leading to improper configuration of the powerdown mode. Resolve this issue by adjusting the channel index for channels 4-7 by subtracting 4 before applying the macro. This ensures that the correct bitmask is generated for the second register.

Quoted 7 lines
Quoted 3 lines
Fixes 93583174a3df ("iio: dac: ad3530r: Add driver for AD3530R and AD3531R")

---

LGTM,

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

Thanks,

Jonathan