Message ID | 20221111112657.1521307-2-mitja@lxnav.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp684352wru; Fri, 11 Nov 2022 03:29:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Ea+B1E4eyvt+p6zkkdiZspqGWgwqEexlpFhUyRlZX/I+nHMwrYkqh7thzt0mNV1ql2M/g X-Received: by 2002:a17:902:ea05:b0:179:fe95:f6d9 with SMTP id s5-20020a170902ea0500b00179fe95f6d9mr1871068plg.51.1668166181741; Fri, 11 Nov 2022 03:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668166181; cv=none; d=google.com; s=arc-20160816; b=BSChU5BdFrZAVDPdt3dN7ILMQiBHyErs7jSR0sFT/5CeW38SlJD28/9ZnLGON45orm znbwGP3CJf9rIMl7yZdc2RKxKEPLD/fT/70Xhuuhpt4Y6cWmObzBE8NftadXgQI1kWvb 4gbVRBblczFQm92JKZDwuHA+JSmcrIM3xEQOlqDPIWtPUizDiRxIdHYXYHTL0OL8KW66 oGCoJrAyMj9LYqFKaFKYJ2BWbXtjn8pWx5142CNs1uFVlGPOtHr43HT6vGQ4NymUYOIC MUXFTTRD75foXYrWShhwLhTfHF9ehTUUnuY0FHGNw7YwsKlnq9pbJiPcbv68pWMvlcRC JBdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9BmkVh6jIh/jyhyFFqsPkAGeVwmF2cJMvet6/U1c940=; b=anZMO3zMMSgrQ6zPTCxA/MPgjZiy1/+gabHEKFX17J8KzAmVBw2peenzwYt2fi8NVH BLcDSkmo6HJXBjcfphBvvj+7ibNemRrkJXZLjezmE4NVaA2WNw3HSofFI1alj4Yx7OnG S4KopFXnba5xjHm7ajHbyt+xEHVx6AntJGuX9gBZ3alE28o/6S2uFhMvCnQoF7o/QziN 5MLdVqXd220kcI0YK/DzeJ+nZDunAlafPsPvhZ4VnVDWXYmzSrLK/VCH4TH2WlI2Z4Zk 5Ch5DKMrgEDs9Orr6/+b8KYbwHv27k6aVwHZdZdYQJeCIyHLa++lNyg45hhSHJdRRXjb 9xXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lxnav.com header.s=dhl header.b=cigeI+HJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=lxnav.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020aa7888b000000b0055fa098c388si2519632pfe.259.2022.11.11.03.29.27; Fri, 11 Nov 2022 03:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lxnav.com header.s=dhl header.b=cigeI+HJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=lxnav.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233192AbiKKL2M (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Fri, 11 Nov 2022 06:28:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiKKL2D (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Nov 2022 06:28:03 -0500 Received: from dhl.lxnav.com (dhl.lxnav.com [IPv6:2a01:4f8:c010:2f07::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5C8A60EBB for <linux-kernel@vger.kernel.org>; Fri, 11 Nov 2022 03:28:02 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 45F504070D; Fri, 11 Nov 2022 12:27:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lxnav.com; s=dhl; t=1668166078; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=9BmkVh6jIh/jyhyFFqsPkAGeVwmF2cJMvet6/U1c940=; b=cigeI+HJRe6JIJ2uzZTjx0+QwIL3d2NcFzzLCU7g4uLi1ePXFF50sMtilsU0UpDeOOdkkG gbSo/GwMuqGRzKd7/fAL16JNWFIo2SYjq3eqk7JoTsUFNg4Ey4AL4xdpU1ca5jEfnP4FCx NoVJ/6F/FTicNLbic8Y45Hs7tuc3kzeRcr99xHilkL5FG7Ay0rzL/5a0rnM1OV427OWUjT EL9Zu2n6nlubE3JO/eAxbmwuY67N3o5s84c+m/ECFbu/PmD/Q+HMiJ0kQx/ZtH7NnSGjSu nyhFeeup7/c0KFjJ04iz6pPJ/93BpZ3P0kCvNtv2ZQYcCrFhRlRC+HUNn9ZHfg== From: Mitja Spes <mitja@lxnav.com> To: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Mitja Spes <mitja@lxnav.com>, Angelo Compagnucci <angelo.compagnucci@gmail.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] iio: adc: mcp3422: fix scale read bug Date: Fri, 11 Nov 2022 12:26:53 +0100 Message-Id: <20221111112657.1521307-2-mitja@lxnav.com> In-Reply-To: <20221111112657.1521307-1-mitja@lxnav.com> References: <20221111112657.1521307-1-mitja@lxnav.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749199021830437023?= X-GMAIL-MSGID: =?utf-8?q?1749199021830437023?= |
Series | iio: adc: mcp3422 improvements | |
Commit Message
Mitja Špes
Nov. 11, 2022, 11:26 a.m. UTC
Scale was returned for currently active channel instead of the specified
channel.
Signed-off-by: Mitja Spes <mitja@lxnav.com>
Fixes: 07914c84ba30 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC")
---
drivers/iio/adc/mcp3422.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, 11 Nov 2022 12:26:53 +0100 Mitja Spes <mitja@lxnav.com> wrote: > Scale was returned for currently active channel instead of the specified > channel. > > Signed-off-by: Mitja Spes <mitja@lxnav.com> > Fixes: 07914c84ba30 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC") Hi Mitja, One trivial comment inline. I might tidy that up whilst applying if others are otherwise happy with this patch. If you do a v2 for some other reason please get rid of that unrelated change. Jonathan > --- > drivers/iio/adc/mcp3422.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c > index da353dcb1e9d..3d53de300c89 100644 > --- a/drivers/iio/adc/mcp3422.c > +++ b/drivers/iio/adc/mcp3422.c > @@ -164,8 +164,9 @@ static int mcp3422_read_raw(struct iio_dev *iio, > struct mcp3422 *adc = iio_priv(iio); > int err; > > + u8 req_channel = channel->channel; > u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config); > - u8 pga = MCP3422_PGA(adc->config); > + u8 pga = adc->pga[req_channel]; > > switch (mask) { > case IIO_CHAN_INFO_RAW: > @@ -175,7 +176,6 @@ static int mcp3422_read_raw(struct iio_dev *iio, > return IIO_VAL_INT; > > case IIO_CHAN_INFO_SCALE: > - Unrelated change. No problem with cleaning this up but definitely not in a fix patch! > *val1 = 0; > *val2 = mcp3422_scales[sample_rate][pga]; > return IIO_VAL_INT_PLUS_NANO;
Hi Jonathan, On Sat, Nov 12, 2022 at 5:57 PM Jonathan Cameron <jic23@kernel.org> wrote: > One trivial comment inline. I might tidy that up whilst applying if others are > otherwise happy with this patch. If you do a v2 for some other reason please > get rid of that unrelated change. Ok, I will move it to a styling patch and fix it in v2. Kind regards, Mitja
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index da353dcb1e9d..3d53de300c89 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -164,8 +164,9 @@ static int mcp3422_read_raw(struct iio_dev *iio, struct mcp3422 *adc = iio_priv(iio); int err; + u8 req_channel = channel->channel; u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config); - u8 pga = MCP3422_PGA(adc->config); + u8 pga = adc->pga[req_channel]; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -175,7 +176,6 @@ static int mcp3422_read_raw(struct iio_dev *iio, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val1 = 0; *val2 = mcp3422_scales[sample_rate][pga]; return IIO_VAL_INT_PLUS_NANO;