Skip to content

Commit 520e844

Browse files
kseerpnunojsa
authored andcommitted
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: 934ca94 ("iio: dac: ad3530r: Add driver for AD3530R and AD3531R") Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250626-bug_fix-v1-1-eb3c2b370f10@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 7910162 commit 520e844

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iio/dac/ad3530r.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ static ssize_t ad3530r_set_dac_powerdown(struct iio_dev *indio_dev,
166166
AD3530R_OUTPUT_OPERATING_MODE_0 :
167167
AD3530R_OUTPUT_OPERATING_MODE_1;
168168
pdmode = powerdown ? st->chan[chan->channel].powerdown_mode : 0;
169-
mask = AD3530R_OP_MODE_CHAN_MSK(chan->channel);
169+
mask = chan->channel < AD3531R_MAX_CHANNELS ?
170+
AD3530R_OP_MODE_CHAN_MSK(chan->channel) :
171+
AD3530R_OP_MODE_CHAN_MSK(chan->channel - 4);
170172
val = field_prep(mask, pdmode);
171173

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

0 commit comments

Comments
 (0)