linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Alexandru Tachici <alexandru.tachici@analog.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH 1/2] iio:adc:ad7124: Parse configuration into correct local config structure.
Date: Sun, 25 Jul 2021 18:24:57 +0100	[thread overview]
Message-ID: <20210725172458.487343-2-jic23@kernel.org> (raw)
In-Reply-To: <20210725172458.487343-1-jic23@kernel.org>

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


  reply	other threads:[~2021-07-25 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25 17:24 [PATCH 0/2] iio:adc:ad7124: Convert to generic firmware handling Jonathan Cameron
2021-07-25 17:24 ` Jonathan Cameron [this message]
2021-07-25 17:24 ` [PATCH 2/2] iio:adc:ad7124: Convert to fwnode handling of child node parsing Jonathan Cameron
2021-07-25 20:33   ` Andy Shevchenko
2021-07-27 13:51     ` Jonathan Cameron
2021-07-27 14:16       ` Andy Shevchenko
2021-07-27 18:20         ` Jonathan Cameron
2021-08-15 16:09           ` Jonathan Cameron
2021-10-03 15:45             ` Jonathan Cameron
2021-11-28 18:15               ` 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=20210725172458.487343-2-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandru.tachici@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).