Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2771251imj; Mon, 11 Feb 2019 08:13:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IaIUOoBG7XlKZkVgyP3Jg+TuZP9f+AkZKEP+rI/RFnb6cP/J0VwjM4eVvUedX09gjL/cqBt X-Received: by 2002:a17:902:2b8a:: with SMTP id l10mr36444858plb.70.1549901597087; Mon, 11 Feb 2019 08:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901597; cv=none; d=google.com; s=arc-20160816; b=jNa21FpcnOiDhD65v9oyjfB8jn25DVmRoa6R6fZYj/QfOtWHet3eugVhJE9BMNjwGQ 07+aIlV3Z3kb0xCVIJ0ycNxP02N+rfashlD7hh8NVbuxHJsjJl4WvBTm5nv38OzP3iyw Fh/CdxNP0BFgHseG1NxUTa2jIpxkZxdjodAVwTr3wu4+ieMe2log+iYcLIDVHrPEyH/A SUrK6CnrkDYQlrGnIAuUI4P65roqriw7AS27ltA0iuxHwmuWH/TfGWn0EG9HjSKXhMp7 LNEXFFABNFIazf63bS2sxutXdB3C1gBL1mGQX7wBWu0AW77CrAUjEWqC1s/vSge0XRQ2 2d3g== 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=rq//cQhtvCfe4WBMOqvx8VW3g8HeT29gsWfVu3kXYbI=; b=cS0ztFiFwyfbuveQzBzpdg8xNLxlKgJvcFIjkTZm6D6j6bORa0EVJCwW+8HaxiJtLG qQGpcBD43v3qxOnlVsMT01UfFTXUbbTeG8dc/53XnudlgPKsRGnvVAEZb9ut4l7lkdN3 +80wm8M7didqLeU9/B1/SGEAEx8ZBBnn8hmoxk4BW5zpNta2Z1wMVq1l6pxIVlqvVuKC eJ2s8S8eXVhUbqi1yIlLUwi7JGmkY95JhIT4sd/tiaGxnCsFyYMNjzcN39P5f1/GGfVr H9qLDBJT8EPwAfGS0LLoO2JCSYmVZEI67YSvDwI0brYBDMYRI8xmm1E4bXXYvq/QVe27 RaHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dtvDgkQx; 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 b128si3222458pgc.450.2019.02.11.08.12.53; Mon, 11 Feb 2019 08:13:17 -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=dtvDgkQx; 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 S1729364AbfBKQMC (ORCPT + 99 others); Mon, 11 Feb 2019 11:12:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:56658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729018AbfBKOXf (ORCPT ); Mon, 11 Feb 2019 09:23:35 -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 F1573222A1; Mon, 11 Feb 2019 14:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895014; bh=2dlgSEQPCNM64eZ0TiG0I4uzFbDv5MmULrbjeJa7DEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dtvDgkQxh+6TYD5uxovsl5aZ4R5egR2GjMe65X1gzVHilUBFWnVXmbPhns3wqwAYk vKcL47wmJCCd5Jg/DGW0s0nB5Pr8HZIguNQ6WenX4g1N60aNp9TFIRiMw2BDyaml19 q25a42nbKBK8pgYJ6EYuHPeGQZDdjBTscby84BZE= 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.20 045/352] staging: iio: ad7780: update voltage on read Date: Mon, 11 Feb 2019 15:14:32 +0100 Message-Id: <20190211141849.159022864@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 b67412db0318..c7cb05cedbbc 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