Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2388686imd; Sun, 28 Oct 2018 09:01:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5ck59O47AsID39q4fJdL68thNKvaK+LnNL4wOiKcVjZGDFCPpcxYZam9JlpMiyM/mv0VWF5 X-Received: by 2002:a17:902:f01:: with SMTP id 1-v6mr11031927ply.8.1540742470935; Sun, 28 Oct 2018 09:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540742470; cv=none; d=google.com; s=arc-20160816; b=W9CKhP6enwnUS5RJnlu2FNqku58FbjSF7ISD2mpQ3ymLqEM+TVcHu2F4ivW4DZ8rO9 eZVE2kEIzVjy8Bsfpl7LhQ3Oqgud9V6f8Te1NF2dN25oREHWjDB3S3T0iVS32mct1+ty 06lTwlojU197LHL2WPRvK7yd6veIiJnJVFIQ7ExrHrmYFiZIIBRLlzOuecFtUKlbBnVE QL91/dkBi55XgIu9mtOE/7DdQ10S/u2ygSPVNv6QAetGg/nhn+qnL9YBTgU5TAjtsLYB Apqfx+zQ2dzQQ4pxp9e0Trldu+F34BrlVbNsUn0FnmeAKii5V4QuXD74cXCMN29F1xPK eNTA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=b1ioQRhSHSPBPs5FiShzcGcQL8pa0b/vdoY1rjSQsH4=; b=wvr0kJWsWI7bILvj8/2xEZXbWti0czz+H2CycGPfian0SuZ3axNz0/3lgVWHD3OXYS 2PZrBJUNrWkl4Cc1j8Q8u1uWtBQR3+lNbv2gE4L83REegt/rRosfIeI7slvqT8/OkR+o yH6hAxjB+oqkF8/MMoaOYY+wOGcNnNDWVjZF1RrYwBuEyf3trRaqxM5gl9x70WOCNgr4 lPGP/AWPHvALeC7i8T0sI87HrqL4GS/hYHWgpevT+dq2vNHQ0KF67ejJuyNaY6yGitrH GhT4jlKou0FDp3gejE23BvJv5qQCTyYNKjwEJ8YiGjt4y6Mumwxf8Wt3ZzDA3IG5h0uo 9Fgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xHvPtStW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si18110666plp.173.2018.10.28.09.00.54; Sun, 28 Oct 2018 09:01:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xHvPtStW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbeJ2AlQ (ORCPT + 99 others); Sun, 28 Oct 2018 20:41:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:58266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727672AbeJ2AlQ (ORCPT ); Sun, 28 Oct 2018 20:41:16 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 B1FCD20843; Sun, 28 Oct 2018 15:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540742177; bh=9m3t/3LtuQuhc1+fao5lCvlyVDiqyVIY2vIK0UVsXQA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xHvPtStWiJjF1gH3j1ESTr4vo14hSqeKrJacAult870ja1WZoJnThJUFLAf6bVQ4O iKptqeHS+XdU9xFaqlPArwq4k2LfyXLlsbYUWA6w0u6KPZuH4g8eefYIkKC5Ldluc+ ++2CKTCubltxewD07hg+LxvJ79X9zfS1YgADCpvo= Date: Sun, 28 Oct 2018 15:56:11 +0000 From: Jonathan Cameron To: Renato Lui Geh Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, alexandru.Ardelean@analog.com, stefan.popa@analog.com, giuliano.belinassi@usp.br, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: Re: [PATCH v2 1/2] staging: iio: ad7780: update voltage on read Message-ID: <20181028155611.67abeafb@archlinux> In-Reply-To: <1f7b2c6ee0e18b1c43a8b27f482b08313c52d4e9.1540506298.git.renatogeh@gmail.com> References: <1f7b2c6ee0e18b1c43a8b27f482b08313c52d4e9.1540506298.git.renatogeh@gmail.com> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 25 Oct 2018 19:30:04 -0300 Renato Lui Geh wrote: > The ad7780 driver previously did not read the correct device output, as > it read an outdated value set at initialization. It now updates its > voltage on read. > > Signed-off-by: Renato Lui Geh > --- > drivers/staging/iio/adc/ad7780.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c > index b67412db0318..27972563bb6a 100644 > --- a/drivers/staging/iio/adc/ad7780.c > +++ b/drivers/staging/iio/adc/ad7780.c > @@ -87,11 +87,15 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, > long m) > { > struct ad7780_state *st = iio_priv(indio_dev); > + int voltage_uv = 0; No initialization needed as it is always set in the paths where it is used (before it is used). > > 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; Is there actually a reason (now) to have the stashed value of int_vref_mv in the state structure? Also, I think we are always replacing the value that is retrieved in probe so we can drop reading it there as well. Thanks, Jonathan > *val2 = chan->scan_type.realbits - 1; > return IIO_VAL_FRACTIONAL_LOG2;