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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

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@xxxxxxxxxx>
Cc: Alexandru Tachici <alexandru.tachici@xxxxxxxxxx>
---
 drivers/iio/adc/ad7124.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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)
-- 
2.32.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux