diff mbox series

iio: adc: ad7124: Fix DT channel configuration

Message ID 20191210090621.21714-1-alexandru.tachici@analog.com (mailing list archive)
State New, archived
Headers show
Series iio: adc: ad7124: Fix DT channel configuration | expand

Commit Message

Alexandru Tachici Dec. 10, 2019, 9:06 a.m. UTC
This patch fixes device tree channel configuration.

Before this patch, the driver assumed that the DT children (adc channels)
are parsed in the order they are written in the DT. Now the driver uses the
reg property of each child to correctly identify to which channel the
parsed configuration belongs to.

Fixes b3af341bbd966: ("iio: adc: Add ad7124 support")
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
---
 drivers/iio/adc/ad7124.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Jonathan Cameron Dec. 15, 2019, 3:39 p.m. UTC | #1
On Tue, 10 Dec 2019 11:06:21 +0200
Alexandru Tachici <alexandru.tachici@analog.com> wrote:

> This patch fixes device tree channel configuration.
> 
> Before this patch, the driver assumed that the DT children (adc channels)
> are parsed in the order they are written in the DT. Now the driver uses the
> reg property of each child to correctly identify to which channel the
> parsed configuration belongs to.
> 
> Fixes b3af341bbd966: ("iio: adc: Add ad7124 support")
> Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Hi Alexandru.

Patch seems correct to me, but I'd like a little more detail in this
description.  Could you give an example of what goes wrong without this
patch?  That will be useful for people to understand if this patch is
fixing a problem they are seeing.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/ad7124.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index edc6f1cc90b2..43a56c6f4cf3 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -489,13 +489,11 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
>  		st->channel_config[channel].buf_negative =
>  			of_property_read_bool(child, "adi,buffered-negative");
>  
> -		*chan = ad7124_channel_template;
> -		chan->address = channel;
> -		chan->scan_index = channel;
> -		chan->channel = ain[0];
> -		chan->channel2 = ain[1];
> -
> -		chan++;
> +		chan[channel] = ad7124_channel_template;
> +		chan[channel].address = channel;
> +		chan[channel].scan_index = channel;
> +		chan[channel].channel = ain[0];
> +		chan[channel].channel2 = ain[1];
>  	}
>  
>  	return 0;
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index edc6f1cc90b2..43a56c6f4cf3 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -489,13 +489,11 @@  static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 		st->channel_config[channel].buf_negative =
 			of_property_read_bool(child, "adi,buffered-negative");
 
-		*chan = ad7124_channel_template;
-		chan->address = channel;
-		chan->scan_index = channel;
-		chan->channel = ain[0];
-		chan->channel2 = ain[1];
-
-		chan++;
+		chan[channel] = ad7124_channel_template;
+		chan[channel].address = channel;
+		chan[channel].scan_index = channel;
+		chan[channel].channel = ain[0];
+		chan[channel].channel2 = ain[1];
 	}
 
 	return 0;