Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1592325imd; Sun, 4 Nov 2018 06:00:13 -0800 (PST) X-Google-Smtp-Source: AJdET5cLk4mt6wrQgP4g2DntPRsXg1BTqsYBQOJI8I8jQgJpqsKtAcILNrZpgSlcXZqn+1d8uSB7 X-Received: by 2002:a63:aa48:: with SMTP id x8-v6mr16701917pgo.87.1541340013221; Sun, 04 Nov 2018 06:00:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340013; cv=none; d=google.com; s=arc-20160816; b=Xh5BMFg2X9XySPWywco3ulJg44k5TwqWGIN0TqmVN3Mv4SGOBDpYCc8TnJSTfq8hR5 7VSlwRUU5L45DxnPYwrXFZ+UbO+7lJbAlovQGkIHkCxkGk0dnUkT2r/yIxxOt5ljBA4d EnE1jVsvN5qSpxn0fWNo0aOCApNbDv1eShUDhOsXizCQd3Vsh6m0R38IDbJnjlXu1GNy Xq6uq2rdjnMwLoqyR0CESh2qKi3BalN/DOUXqhlSAMYvb6x2bi7db6ZKJWLdY0eNSYvb TYDlFzujSLriiF8ttSSTu97rhxTM9PZmypoo4kCWy8xTqDc40Rk9E7M9X5Vf34YgtMtb WUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sRQcoKmBa0iyxu4ShaILhJ//4H1puRfNYyLvWPat5pM=; b=qbd0TfFT9RSnRRqHUApwaguvEe9YLCYgq9OjpJM59vZFTnyWwAGN7niDxPGB0RTibF t33pytYJPHlrB26VOAER0oGmAY4jspSy7kL5qJqcbXSX0UdVa2OudSDEA4F22owjRs6p 6PAwM8DyI4cHK0QzsGBc3suHcsiLi/PWukI++OltdzL/Hrb6EO9IYxwf49ChPtWPkM45 bwhG6X4llV3vOxVwcsT/rJab3Fx5IMU/NXu4RiiJKs/B3/zy5sSxk2fefV9fZyHdd4Ry bbAZDpxQ+mXFis+Vi7c/BwYbErxmCGBw7Iqrq5ZiDQAEGzWKEVEg7cJTOpVHGroPwAIp Yb9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VxtL1i57; 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 c135-v6si32900593pfc.6.2018.11.04.05.59.58; Sun, 04 Nov 2018 06:00:13 -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=VxtL1i57; 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 S1731400AbeKDXI6 (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:48272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731388AbeKDXI6 (ORCPT ); Sun, 4 Nov 2018 18:08:58 -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 33C1720868; Sun, 4 Nov 2018 13:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339633; bh=z9RdV1w04O7Z2fepbUXdvVXEkhhZpkmI9LUgBIi0FwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxtL1i57545sztAD+BNpoLIS/z8TU8lDPiryai+L98lpITKAZX1EtG06P+VxjQROV 8lgT6NM9Y2BtRjU88EKgVSMhXITCCpiAfz7jb5/yCpznFyazz+nLXsWeuNZpFkaaqO pja/fY0IaDnFnO6iSir0m+Sj9m6fBSZB77fYbKL8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Sasha Levin Subject: [PATCH AUTOSEL 4.14 28/30] staging:iio:ad7606: fix voltage scales Date: Sun, 4 Nov 2018 08:53:23 -0500 Message-Id: <20181104135325.88524-28-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Ardelean [ Upstream commit 4ee033301c898dd0835d035d0e0eb768a3d35da1 ] Fixes commit 17be2a2905a6ec9aa27cd59521495e2f490d2af0 ("staging: iio: ad7606: replace range/range_available with corresponding scale"). The AD7606 devices don't have a 2.5V voltage range, they have 5V & 10V voltage range, which is selectable via the `gpio_range` descriptor. The scales also seem to have been miscomputed, because when they were applied to the raw values, the results differ from the expected values. After checking the ADC transfer function in the datasheet, these were re-computed. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/staging/iio/adc/ad7606.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index 18f5f139117e..0ff458fbee5e 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c @@ -26,9 +26,12 @@ #include "ad7606.h" -/* Scales are computed as 2.5/2**16 and 5/2**16 respectively */ +/* + * Scales are computed as 5000/32768 and 10000/32768 respectively, + * so that when applied to the raw values they provide mV values + */ static const unsigned int scale_avail[2][2] = { - {0, 38147}, {0, 76294} + {0, 152588}, {0, 305176} }; static int ad7606_reset(struct ad7606_state *st) -- 2.17.1