mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Dumitru Ceclan <mitrutzceclan@gmail.com>
Cc: lars@metafoo.de, jic23@kernel.org, alexandru.tachici@analog.com,
	 Jonathan.Cameron@huawei.com, linux-iio@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Dumitru Ceclan <dumitru.ceclan@analog.com>
Subject: Re: [PATCH] iio: adc: ad7124: fix DT configuration parsing
Date: Tue, 06 Aug 2024 12:45:06 +0200	[thread overview]
Message-ID: <15304301efe5c23d55984f8a1f2a5016d7be213d.camel@gmail.com> (raw)
In-Reply-To: <20240806085133.114547-1-dumitru.ceclan@analog.com>

On Tue, 2024-08-06 at 11:51 +0300, Dumitru Ceclan wrote:
> 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: 7b8d045e497a ("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>

>  drivers/iio/adc/ad7124.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index 3beed78496c5..672d41bac8ca 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -839,8 +839,6 @@ static int ad7124_parse_channel_config(struct iio_dev
> *indio_dev,
>  	st->channels = channels;
>  
>  	device_for_each_child_node_scoped(dev, child) {
> -		cfg = &st->channels[channel].cfg;
> -
>  		ret = fwnode_property_read_u32(child, "reg", &channel);
>  		if (ret)
>  			return ret;
> @@ -858,6 +856,7 @@ static int ad7124_parse_channel_config(struct iio_dev
> *indio_dev,
>  		st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
>  						  AD7124_CHANNEL_AINM(ain[1]);
>  
> +		cfg = &st->channels[channel].cfg;
>  		cfg->bipolar = fwnode_property_read_bool(child, "bipolar");
>  
>  		ret = fwnode_property_read_u32(child, "adi,reference-select",
> &tmp);


  reply	other threads:[~2024-08-06 10:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06  8:51 Dumitru Ceclan
2024-08-06 10:45 ` Nuno Sá [this message]
2024-08-06 16:04   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15304301efe5c23d55984f8a1f2a5016d7be213d.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alexandru.tachici@analog.com \
    --cc=dumitru.ceclan@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitrutzceclan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®