Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4833098ybl; Wed, 22 Jan 2020 05:34:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwQlBatRHt6Es7bYRgq1WTuN9FoWJby/gMHNst7rZO+x0Ruud9hKPts0iOrvvsXE6bXILFj X-Received: by 2002:a05:6830:2141:: with SMTP id r1mr7305327otd.39.1579700096386; Wed, 22 Jan 2020 05:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579700096; cv=none; d=google.com; s=arc-20160816; b=MKjgbeyW+oc15cPj3xK6brAigb3RCcqy7jqsmttSm67+N151ZfRY6WPJtMJ5ClAEg7 RH7UaARAKVIBrqDJmfuTTw0dV3YECxwehctkGl9PvHzNXzEws2UuKchDr/gVwPDzkvLA g0HMv4Up8ScXOwIqdHNX8+1u5jxtmGeyYXg3NLT/kP0sVKGdbcYBc77LRruNUx1/hWYc OCtMiJCK0JF4SHlwqBgMoZxgH4hR1KVZXUX/A0V1qZ6OO4RDHBOQMtMruQc/j+xzsf0F KQ+QsnHLHn4s+/v06qV1qfbxaOnmMA+XvPgzpdX6gyRbo9k3Etx+qwUKPbL/1qcpvTV5 sBoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cPHiVQQ3Ze3/BOCX0+MDLBuqJhH3szqoiuMHCDpPIuE=; b=dF6/hdscr+M5vxWGxi5rCaCwPbLJcSg6XrqR6UkZLIAq0A3JPLPBHCJ19aEJirvxwi DOWnrzJNqVOgvH2ui3SBrI7vsK3C6ceRKyyS/e8/7bQqnl8rDTNC11ggpWfbgSRIRhq7 5RGaXkYFCV8G1Gj2tGL1Y0oC+B5s+87rIjgz4xIs5Np4JwohmjYbpvZwH72BNIADagpa ELDybnW/n9n+1219T0D6/0sRDtpOSJZ7vTI7tA7zFlKVYQlcGwavwrsZJRhnJ+KGSU46 VULaATGvPv+TCTncMpbqZAADI+Lhw3Y2icTAQw3VP4jvGJHiGq2RsPxsRn7Hf7KS88VC qvvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lUM76JBN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si23171136oiy.124.2020.01.22.05.34.40; Wed, 22 Jan 2020 05:34:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lUM76JBN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbgAVNUP (ORCPT + 99 others); Wed, 22 Jan 2020 08:20:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:36300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726103AbgAVNUL (ORCPT ); Wed, 22 Jan 2020 08:20:11 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 239112467A; Wed, 22 Jan 2020 13:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699210; bh=Pnms0mdwSSW50PLMZds+9J5iQ+280m3bmjraUAgTnto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUM76JBNXhaxPLyE9cMjz5ZK1jGPQsxQ//MYvznp1+0rXRlmy3c03gDrcxxiRiIw0 cHkpTkubKk95ptjtG9D0iWdAz+jhkMtdXyCdXlyZ9cKnhD/TKbJRGr0ix4xTyHsCco fKbAdnru/+nCjcKfijJbOoJ/xg9xT1HodZbQYTl4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Tachici , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 038/222] iio: adc: ad7124: Fix DT channel configuration Date: Wed, 22 Jan 2020 10:27:04 +0100 Message-Id: <20200122092836.253449337@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Tachici commit d7857e4ee1ba69732b16c73b2f2dde83ecd78ee4 upstream. This patch fixes device tree channel configuration. ad7124 driver reads channels configuration from the device tree. It expects to find channel specifications as child nodes. Before this patch ad7124 driver assumed that the child nodes are parsed by for_each_available_child_of_node in the order 0,1,2,3... This is wrong and the real order of the children can be seen by running: dtc -I fs /sys/firmware/devicetree/base on the machine. For example, running this on an rpi 3B+ yields the real children order: 4,2,0,7,5,3,1,6 Before this patch the driver assigned the channel configuration like this: - 0 <- 4 - 1 <- 2 - 2 <- 0 ........ For example, the symptoms can be observed by connecting the 4th channel to a 1V tension and then reading the in_voltage0-voltage19_raw sysfs (multiplied of course by the scale) one would see that channel 0 measures 1V and channel 4 measures only noise. Now the driver uses the reg property of each child in order to correctly identify to which channel the parsed configuration belongs to. Fixes b3af341bbd966: ("iio: adc: Add ad7124 support") Signed-off-by: Alexandru Tachici Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/ad7124.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -494,13 +494,11 @@ static int ad7124_of_parse_channel_confi 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;