From patchwork Sun Jul 25 17:24:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12398207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 405DBC4338F for ; Sun, 25 Jul 2021 17:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 251C560F35 for ; Sun, 25 Jul 2021 17:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbhGYQmI (ORCPT ); Sun, 25 Jul 2021 12:42:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:42340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbhGYQmI (ORCPT ); Sun, 25 Jul 2021 12:42:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D292D60F23; Sun, 25 Jul 2021 17:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627233758; bh=z9P0wpDzneyLHgDABBdsFR+B/22PlA5IQL2nE993VhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cpj9WhRPhttQ31VCP/tAiyHmH5xtkYV/eCJMsxvlQXJcYaO9ewRKz0ZxaMU9v3fqB M9qvTItMNLrpwTRhqhpuqPMIXjqRZ7PQ9QmJsuMsPO3XOmVkV6Yg/MXYA0D43gzJvW /zDVuEsiDAC1ByNyQwFgOgKdh4t38dUhDBe4OVYgEhxnxcLg6lZ/05qOjSR3ZHA7yr mQl7DzdakOx3ovLqUY+n6hHvaW0N12v2MoGHFes9S4sHtO8hi4PFmSO36/tefAyQPl 1oCL2yuIR+PBVgryPy6/GrJxgxedQOY4+YG7ZAwwa8Qq8nmmQ/KnhYuhH1HMSaZ2IC lSbmpeadCtAcg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Alexandru Tachici , Jonathan Cameron Subject: [PATCH 1/2] iio:adc:ad7124: Parse configuration into correct local config structure. Date: Sun, 25 Jul 2021 18:24:57 +0100 Message-Id: <20210725172458.487343-2-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210725172458.487343-1-jic23@kernel.org> References: <20210725172458.487343-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Alexandru Tachici --- 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)