Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1894529ima; Thu, 25 Oct 2018 06:41:39 -0700 (PDT) X-Google-Smtp-Source: AJdET5e4E3DUeL9H7Z8lt4i7pV1p3lRgwULylbCQsTqEXQ+QT/gLP+v41HwE9AsUNkMRRfCY1GwJ X-Received: by 2002:a63:5ec6:: with SMTP id s189mr1459365pgb.357.1540474899043; Thu, 25 Oct 2018 06:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540474899; cv=none; d=google.com; s=arc-20160816; b=ONNMtwWfolhHVuMt/6pU2470kSRJzYiqoyBE29cjFLsghwJ64lJIu9vcvVYSJtOG1V 6FFl1W0O1yBtByVpAz0xxBpfx0LxVulQl4LzsHTCoGv/YW4pnCq5eD2XGNYX7azkXd5t BZneSYSMIuLQTosuZ2JcVoYqpu967OBOHP9KrD+gl4iAdvkHeRxfKRFTS2vWxA5ePlXF m9i/u3FhuowYagRcAY1FTfOen8NkbNJ7NhbWvUucmCFkN880kCIq7/Ygrwf9Cw25AZTw QtybV9erDOyi5SZM9tXLA+nk4fp4Z7V8KxPofsDvDUDgNpTcrpfuysL9+RydHXsBxtK/ eWdA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=XGNYChhlDzhabujLwblyIviOsSVt6I8zjYVwTx+leHg=; b=iFHzowvm2vP8I7j9XKzAYH86BELwzOafC6SKpA3WmqSMU5hjiu4RoU5A0GDYaHwUjI Flc0lgmpRDU1Xy2gM92fyEOpaD4hzTQFXST3YHHFOOYOC9iwkuM1O6LwPQLKczaHs1y9 Ys5c68fmd1CsK8+IrMz2pwCDK7oPm2V/tetICycWdkV41XJ7q99/wmPFg4rHMuv5YFP0 wryZQrubnHw1W0xXKTpGiUc3Ktcb6n4+0QmtmBZ6BktyfDjD1dpUzH0Za2mnVjDMrjXZ bwH2pZmOaByVmA+gH4BGdI6APHbWQb1ZWPgomhSSDgL7animx2dpXSvcYYmjgsPdP1FP wqIw== ARC-Authentication-Results: i=1; mx.google.com; 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 d12-v6si8267257pga.81.2018.10.25.06.41.20; Thu, 25 Oct 2018 06:41:39 -0700 (PDT) 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; 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 S1727606AbeJYWLa (ORCPT + 99 others); Thu, 25 Oct 2018 18:11:30 -0400 Received: from www381.your-server.de ([78.46.137.84]:43548 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbeJYWLa (ORCPT ); Thu, 25 Oct 2018 18:11:30 -0400 Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by www381.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gFfqO-0000Pk-P4; Thu, 25 Oct 2018 15:38:36 +0200 Received: from [2003:93:4d12:1e00:8200:bff:fe9b:6612] by sslproxy03.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gFfqO-0008PH-GZ; Thu, 25 Oct 2018 15:38:36 +0200 Subject: Re: [PATCH] staging: iio: ad7780: update voltage on read To: Renato Lui Geh , Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, alexandru.Ardelean@analog.com, stefan.popa@analog.com, giuliano.belinassi@usp.br Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com References: <20181025133223.kn7cjlyep7bmx2mm@renatolg> From: Lars-Peter Clausen Message-ID: Date: Thu, 25 Oct 2018 15:38:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181025133223.kn7cjlyep7bmx2mm@renatolg> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.100.2/25067/Wed Oct 24 23:01:03 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25/2018 03:32 PM, Renato Lui Geh wrote: > The ad7780 driver previously did not read the correct device output. > This patch fixes two issues. > > - The driver read an outdated value set at initialization. It now > updates its voltage on read. > - Variable val subtracted an uninitialized value on > IIO_CHAN_INFO_OFFSET. This was fixed by assiging the correct value > instead. > > Signed-off-by: Renato Lui Geh Hi, Thanks for the patch, this looks good. But please create one patch per issue and do not put unrelated changes into the same patch. Also your mail client seems to have replaced tabs in the patch with spaces, this means the patch will not apply cleanly. Check the Documentation/email-clients.txt file for some hints how to configure your mail client so it will not break patches. - Lars > --- > drivers/staging/iio/adc/ad7780.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7780.c > b/drivers/staging/iio/adc/ad7780.c > index b67412db0318..06700fe554a2 100644 > --- a/drivers/staging/iio/adc/ad7780.c > +++ b/drivers/staging/iio/adc/ad7780.c > @@ -87,16 +87,20 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, >                long m) > { >     struct ad7780_state *st = iio_priv(indio_dev); > +    int voltage_uv = 0; > >     switch (m) { >     case IIO_CHAN_INFO_RAW: >         return ad_sigma_delta_single_conversion(indio_dev, chan, val); >     case IIO_CHAN_INFO_SCALE: > +        voltage_uv = regulator_get_voltage(st->reg); > +        if (voltage_uv) > +            st->int_vref_mv = voltage_uv/1000; >         *val = st->int_vref_mv * st->gain; >         *val2 = chan->scan_type.realbits - 1; >         return IIO_VAL_FRACTIONAL_LOG2; >     case IIO_CHAN_INFO_OFFSET: > -        *val -= (1 << (chan->scan_type.realbits - 1)); > +        *val = -(1 << (chan->scan_type.realbits - 1)); >         return IIO_VAL_INT; >     } >