Skip to content

Commit 6cf7f92

Browse files
ceclandumitrudumitruceclan
authored andcommitted
iio: adc: ad7124: fix DT configuration parsing
The cfg pointer is set before reading the channel number that the configuration should point to. This causes configurations to be shifted by one channel. For example setting bipolar to the first channel defined in the DT will cause bipolar mode to be active on the second defined channel. Fix by moving the cfg pointer setting after reading the channel number. Fixes: 7b8d045 ("iio: adc: ad7124: allow more than 8 channels") Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://patch.msgid.link/20240806085133.114547-1-dumitru.ceclan@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 92cc452 commit 6cf7f92

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/iio/adc/ad7124.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
846846
st->channels = channels;
847847

848848
for_each_available_child_of_node(np, child) {
849-
cfg = &st->channels[channel].cfg;
850-
851849
ret = of_property_read_u32(child, "reg", &channel);
852850
if (ret)
853851
goto err;
@@ -868,6 +866,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
868866
st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
869867
AD7124_CHANNEL_AINM(ain[1]);
870868

869+
cfg = &st->channels[channel].cfg;
871870
cfg->bipolar = of_property_read_bool(child, "bipolar");
872871

873872
ret = of_property_read_u32(child, "adi,reference-select", &tmp);

0 commit comments

Comments
 (0)