Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3709924imu; Mon, 28 Jan 2019 09:25:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4gGC/NL2UPgI5HV+RJsZ7RPKB25sKJbBHVtQphGvxG6xl69iJIM4AjRLZpHnA/MIhPny4p X-Received: by 2002:a62:184e:: with SMTP id 75mr22317301pfy.28.1548696324238; Mon, 28 Jan 2019 09:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696324; cv=none; d=google.com; s=arc-20160816; b=YKyZD3OnJ+1e9bGLAbqB9aru13GZhMonimfSP1PHQll37R0/fQ1oVdPFzxDXzZoTTI WawTaWz9ATcApJ3hg5sqOFU3uF8LSAkObbqMD5aIxuY3ZR+fe5jQsTFm2G9KlJ5XCjC4 nwOx3ff3iVv2+CgkNp7+PejTKKOpXeH4OJmW9PlZd/YTLrD8gh0w38Q/cFBqeYAsFrLo KBdRWiq/17FKCY+uMkV0vevunQPWWrIKCByVO4xdkY3MvFiFY+qHbj25HmUrC3U69/6p DudAgzKlEpQDEEhw3RIjC7DuQGJUidRqhHyICUlc6S01L/edyammp4bDdUQ3rc+hOebO OTsA== 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:date:subject:cc:to:from :dkim-signature; bh=A+8Ub3RhEZuKBylMgjkUsf/MC9pzNvJZvDiHbVU3tcE=; b=KzgMEKpN7XKconTN0lDG7H/7OCqLtBGxFaODgTI1d8fN7YEeJUpVqhrI9GHA8qo0ei m6lJGfXYWcVlZCM1oB+6inKOUooj6/5Gm+ImYUF2mlq6t8EdXRasQuFcqgtMryKYA+z6 VjbI4xIr5Mie75NiB/WbVe7OLaTBIAdnygQXLWgkheayh8QvPLrzNT+IRMXnIkptZRr9 3I1cX7vwyRPwLhsNSYfb1yl2AC1CJYSd43dUlzLH2LtiUHtNaPKnI0zKTo8OlNrzivkC 2YhoDxWGhHJJ8kpf8hYK/5eplwP4kMyv1L3+VqU1Jg7tWgZfaGwbYojSJpjZ6KNFemMa zowQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jzYUu9sL; 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 v25si8171025pgk.341.2019.01.28.09.25.06; Mon, 28 Jan 2019 09:25:24 -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=jzYUu9sL; 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 S1731194AbfA1RZB (ORCPT + 99 others); Mon, 28 Jan 2019 12:25:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:46618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730946AbfA1QBV (ORCPT ); Mon, 28 Jan 2019 11:01:21 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E98421848; Mon, 28 Jan 2019 16:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691280; bh=6XmbR9o94oA3A7vxe0qFYRKgPp34Ow09bmKA7ggN0ic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzYUu9sLmAr4zSTinaLkH2l+L9reVy0r7twy74ZslNMmfISv94/WbeQq2gQp0KGx/ 6nIrHPFdGc8fPWOGUhngSLU35lGpNo8IMCL0k1msc7GafFy0HnYpyhc4sy8N6S653K kEhCTo7JVmYq1anaPw9ik8SJw2tTRjiqOf2QCNzM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Renato Lui Geh , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 044/258] staging: iio: ad7780: update voltage on read Date: Mon, 28 Jan 2019 10:55:50 -0500 Message-Id: <20190128155924.51521-44-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Renato Lui Geh [ 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 16d72072c076..8bcb5d5de749 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