Skip to content

Commit 61cbfb5

Browse files
ceclandumitrujic23
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 <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent e81bb58 commit 61cbfb5

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
@@ -844,8 +844,6 @@ static int ad7124_parse_channel_config(struct iio_dev *indio_dev,
844844
st->channels = channels;
845845

846846
device_for_each_child_node_scoped(dev, child) {
847-
cfg = &st->channels[channel].cfg;
848-
849847
ret = fwnode_property_read_u32(child, "reg", &channel);
850848
if (ret)
851849
return ret;
@@ -863,6 +861,7 @@ static int ad7124_parse_channel_config(struct iio_dev *indio_dev,
863861
st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
864862
AD7124_CHANNEL_AINM(ain[1]);
865863

864+
cfg = &st->channels[channel].cfg;
866865
cfg->bipolar = fwnode_property_read_bool(child, "bipolar");
867866

868867
ret = fwnode_property_read_u32(child, "adi,reference-select", &tmp);

0 commit comments

Comments
 (0)