Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2722755imj; Mon, 11 Feb 2019 07:31:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IaYbPFx6DBI9di9EgesedB0BWsWtEHlz/jHiL1QEWnTGevu0QjCzIn2PzpFvS8WsK6d++kX X-Received: by 2002:a63:d20f:: with SMTP id a15mr33815193pgg.171.1549899083097; Mon, 11 Feb 2019 07:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899083; cv=none; d=google.com; s=arc-20160816; b=xPxnevtZqdkCOG0BrI3TH9LHZtRK6M5TdvZ0S0rc+FE9jEZ8yLAuMaoKDYuAGEGpUZ /dt23k29FMGV0bJ5n8TnMaJN2UqMGglGKyc5sO2wNXVHs+NIPJKxb2lSxX8rBzMq5r7U 71vxitvXx33YcKiXUyDyFLGLW5382sl23ubJXqrL6RaGUciBDVpIuI6eEjpQzW440gPo wDFh2ZLrRgPtp9yTTnednL7y2MQ66wWkuqbQUDgdTN7H8PRNDWmCKh/uvS75BIRJxG2h c03eEnOxGW43PVIFTOe1QvVMTpmVy1nQCb2Hmg7mwx88lLtCEsErgakNNGc+TYPeJ0NG D0fw== 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=FXU+dLjNKg0dVYwulivM5S484BlaHLByyyjyJzneaSs=; b=zqKnXzn8PlObQov/XURwGmUMTR97za+ICaD1qPffhjHYJkB9ejH4AXJVJ3mAUxKcjP OPi6VW2Pf/zyJEgbWa4cuDL4GvJNj+K2zAJO11mR4/9p1XusH+ZCsroORPz/9iJGrprq sDmW1maIkueQDvkcnt+C1teRqYu5Rh5JUM5nz/WoRZzVaonR7Td7T1aEDVixgKWszsJj 6L4m6QMr8zp3tGoFZvGMozVmne4Aq0T8QGqBPixBcpXWGiQ9mXirN33o4N0rs9jG7bQv RBWCfiovzCao7YYNId+Hag4d5hRMSLZtr8a2Dm803UySmOITtot5eZD2/Mdgdc1G0SES 1bBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NAs0cMjh; 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 s2si5906993pgl.125.2019.02.11.07.31.06; Mon, 11 Feb 2019 07:31:23 -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=NAs0cMjh; 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 S2389216AbfBKO4k (ORCPT + 99 others); Mon, 11 Feb 2019 09:56:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:43788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389192AbfBKO4d (ORCPT ); Mon, 11 Feb 2019 09:56:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 1BD4C2229E; Mon, 11 Feb 2019 14:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896992; bh=3w6D4m0X+K4/fL4y6VR3YYk1bSbJedq4zW+8ml9hS0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAs0cMjhyWG9ZG2dSAmPuwMZWUPejh1/f0qUy/G0vxc5gDzg18FUEeK07bR0Idul0 UkCjgDEUax2ixLowi1ysowe3FKrjr/TKsIFprkZ8m0hqRlzxXlxhyn10t60q8ZntG/ isj0Nbn7xqqeFJLrTs5tMnN4zQgtuFVQmyxsfAIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Renato Lui Geh , Alexandru Ardelean , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.14 025/205] staging: iio: ad7780: update voltage on read Date: Mon, 11 Feb 2019 15:17:03 +0100 Message-Id: <20190211141828.951245698@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 336650c785b62c3bea7c8cf6061c933a90241f67 ] 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 Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- 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 dec3ba6eba8a..52613f6a9dd8 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: - *val = st->int_vref_mv * st->gain; + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv < 0) + return voltage_uv; + *val = (voltage_uv / 1000) * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: -- 2.19.1