diff mbox series

[1/2] iio:adc:ad7124: Parse configuration into correct local config structure.

Message ID 20210725172458.487343-2-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series iio:adc:ad7124: Convert to generic firmware handling | expand

Commit Message

Jonathan Cameron July 25, 2021, 5:24 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The channel index is used before it's been read from the device tree
child node.  Move it down a few lines so it reflects the correct setting.

Noticed by inspection, so test appreciated.

Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
 drivers/iio/adc/ad7124.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index e45c600fccc0..b2e49386d7dc 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -765,7 +765,6 @@  static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 	st->channels = channels;
 	for_each_available_child_of_node(np, child) {
-		cfg = &st->channels[channel].cfg;
 		ret = of_property_read_u32(child, "reg", &channel);
 		if (ret)
@@ -778,6 +777,8 @@  static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 			goto err;
+		cfg = &st->channels[channel].cfg;
 		ret = of_property_read_u32_array(child, "diff-channels",
 						 ain, 2);
 		if (ret)