From patchwork Thu Sep 13 08:44:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10598857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A827C13B6 for ; Thu, 13 Sep 2018 08:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 991542A677 for ; Thu, 13 Sep 2018 08:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7602A6FB; Thu, 13 Sep 2018 08:44:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 136642A677 for ; Thu, 13 Sep 2018 08:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbeIMNxQ (ORCPT ); Thu, 13 Sep 2018 09:53:16 -0400 Received: from mail-eopbgr730041.outbound.protection.outlook.com ([40.107.73.41]:26656 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726794AbeIMNxQ (ORCPT ); Thu, 13 Sep 2018 09:53:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8qurliWC7VynqIIC2Clbyb4joa2pPcMdQqvpdgOTZoo=; b=a00JL1AhLKXBENztBIQWSzH2MlkL/E6NOj+Hu9IeM0lYCRuULIIn04FqidYqOOKHXgHDL9MYKt5qLsezzZk791pczN24wkbbin9bwSOVQRj72e/php7VK2vLyHDx2S2vw0x6RHsB74AO8bOLbwS+thsG6b9Kkzbn3zo0CzamlYw= Received: from CY1PR03CA0030.namprd03.prod.outlook.com (2603:10b6:600::40) by DM5PR03MB3129.namprd03.prod.outlook.com (2603:10b6:4:3c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.17; Thu, 13 Sep 2018 08:44:45 +0000 Received: from BL2FFO11FD019.protection.gbl (2a01:111:f400:7c09::116) by CY1PR03CA0030.outlook.office365.com (2603:10b6:600::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1143.15 via Frontend Transport; Thu, 13 Sep 2018 08:44:44 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta4.analog.com; Received: from nwd2mta4.analog.com (137.71.25.57) by BL2FFO11FD019.mail.protection.outlook.com (10.173.161.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1122.11 via Frontend Transport; Thu, 13 Sep 2018 08:44:44 +0000 Received: from NWD2HUBCAS9.ad.analog.com (nwd2hubcas9.ad.analog.com [10.64.69.109]) by nwd2mta4.analog.com (8.13.8/8.13.8) with ESMTP id w8D8iiCb016221 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Thu, 13 Sep 2018 01:44:44 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS9.ad.analog.com (10.64.69.109) with Microsoft SMTP Server id 14.3.210.2; Thu, 13 Sep 2018 04:44:44 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w8D8igRP027874; Thu, 13 Sep 2018 04:44:42 -0400 From: Alexandru Ardelean To: , , , CC: , , Alexandru Ardelean Subject: [PATCH V2] staging:iio:ad7606: fix voltage scales Date: Thu, 13 Sep 2018 11:44:09 +0300 Message-ID: <20180913084409.5986-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(346002)(376002)(39860400002)(2980300002)(438002)(189003)(199004)(54534003)(51416003)(7696005)(26005)(106002)(186003)(426003)(2616005)(336012)(7636002)(48376002)(356003)(305945005)(106466001)(486006)(2201001)(1076002)(44832011)(50226002)(77096007)(476003)(8936002)(126002)(86362001)(6666003)(53416004)(36756003)(316002)(16586007)(47776003)(2906002)(5660300001)(478600001)(50466002)(110136005)(54906003)(8676002)(246002)(4326008)(107886003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB3129;H:nwd2mta4.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD019;1:a2BpUtBJzvj0DPrFASECTtM9wv6Nlkg4zRJ9UWgYD9HNNcQJt3NUK5VU72a6DT8+kUZuhuHywwHg4ya4sXZZQCs8xSh1XQcBxlqPBDJaaDmSX+uGiDIm1D0uTgktUqcV X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b497010b-1258-4eaa-36ab-08d619552784 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM5PR03MB3129; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3129;3:ICHfk2HGP8xjyN3D7sLWDpjQKXIUrlRbQQMjkCa0tYB+4w4jXilfnHweEuSPuBctgeZSF73Ir/qrsv8zKbdphrBDRBKj487i6DY4MVI7pir3A1IVSaJ9lBVGOEQZi/g8B55FklQ/A2tQkypnFx+iYpjZqlR1VXqQ5DaTFxrwK/u1TDCvoWQcnU9ar/cFkvwiVmQVw553nQhqVGNLeh7bT1DveaTNWcZ4mL+gsJ6NAiGRAZ5bqCJl2p0aDraEQ3VblDv1OFXgFHQqu4MZ1CuN5rdUleMWLtFkcnidHKm3L9+csA/VbgKpEfQWPdTX7Nlp0p73v+ZlOebBknHt+L27/EuSAA4xAjQmQNV6h3PBLY4=;25:VZBs6ngXXaeT0F6DHoAavsCTBbbjGgaQnHTb9zK+p3DG4ZCtUKVTnT1mZ3Bmcs2mi2xj4Te2H7vddh45iYOMm8sAUNAFKL5Xs1DXld24SSJNfj/fpHgQeultEcLCa74cFFodDismOdC6ri5QR0Hh/225NegJ1hCcVM63JGRuetlvKvNLm2o1px4HfxajaK2PaC4wpEXwoql9xgVlhWbOpj4ndxJgfpJ73M9WHlf+W0zn4t9xtqJQYOBSkP8BQ96arTl8BaDmT5sZqijTHa48cvpHntNAS7XEP51vp3/kzt9UKhMHnOI6raxrpk3J0tsFHk4fD9hNrh/KBP6O8Lhpzw== X-MS-TrafficTypeDiagnostic: DM5PR03MB3129: X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3129;31:Y7GcvKSwm/WaKgZI8VO7s8yUqjvtGtIO1t3xbNJHhAsTKbD/kVxLlrTrX7Lk68/bpeNszzLleNeKAPvKj5IWsvOCxRHfpfhEx6gFdBAN1sz06RbsNyZDOkhGkEDeNjXTU/zhe9WtOyy/ldcSlhXZT2HiB4QKhBtY8VvWwgOmAlh176NhVOtXgRw8YaCM4PeOECcRsGWS/nbxYUctoZNQMnGJ28ggO3EvMEfiHIaGsjg=;20:iKGhD1XrNjleAR7aLWggKcEigDgSlH9WwKTq4Ous+l9H/HhleilnZelVa9p0ZgnojTb6BMZKv3Pow9JU9zJXZn4wtHI7NK8K7gBm6ltlidlMaeuMIdOFScDF2gjg0mvH2SiD+fobLDQ24/eEhp+32Zr0hdR/qLrC/yu6Fu/ssI9BFbkFW1ODA0mR/5YcWLExJ11bF2FC3yl8cF2gsIV6+OndYej8T1awj23+tMZ2MfkFms5tsm3Tz+JwDvs9pdMAWtkYR0BbHGSAQQyKmksw5McRZOZopRl7MsoAKJW4GjU3e03zWLPTsn+KMrVoq8zDMI3vOfggikA87/7wNq4RoFug6UKUrZJcjRWp+Q3xoK1mrQO+EJtTZ5Dqmpki++okG1VoYkzi0+8JCjyIB5JOkpVqdY9AnvxoQyaEvifoRmoLoeRbfwsNLFDZ05XwOx3xDtX6qEwJRPNf/z/t3Imv81Ey+mFj9MkfH/GMzZqWIgVpEKJx+q2/4ArZaRBCRdp7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674)(788757137089); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93004095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699050);SRVR:DM5PR03MB3129;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB3129; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB3129;4:oHvqyWezTPtm6Mf5xYbOUmT/aI0h1S6yDxOCbtjkTh+xfltsxgy0XiBmJOM230OGxC5birvvOx9T2BIEeSbwXC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GwULtjOdymS7DIsF7sjUCto5zltdz2E0bQwWKtykkZWpGlEv1gVLH1G22bi+d+yEAnncD39Hwm+pF6fX799FACvq6Q5w7aTSFdoB90K9Euj6fUwhkVwefW8kyaITDatKLEH0OoxOMwZ2w4nayg==;5:xUm1P6a1xTgq5xpjflwpeDsT93311TPlR8XRlpiLdnoj3c2kMiaYfcBe34Bg0U6dpc8iwmSCgKL2uoUxKE9/B6PV4KQbRrCzZTjW6599epTGPZb6hDlDyNBS0WJMhbmnYlc0P7bvvSLqJkCxbHg8AdYtK2aFxtsG3m/LmAt/ksc=;7:gORJZKufTInbOjM/cFhDMTZGIDGs4OcfoTJYCg/HrEFfeGKNJzB8Vhj07DD1vii2B01kJ4tVvVpBNGTOPOJZz1WIA8BWIrEiQHmRLZeIvvH3CS0tIA5qIQQRi3Y+vIJ6yomsA9m6fe2cPhsbFVP7NaUKkieXoTWKTwFGK72Pclqi1FMO0Q8U0w6niOi2CxD4AS2eAt5LRciHj5x/jTNHsWxTlvUZThZbS80kDjUJuQzMENVqDE/QVQELUhvZVM3W SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 08:44:44.4300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b497010b-1258-4eaa-36ab-08d619552784 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta4.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB3129 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changelog V1 -> V2: * changed 2.5/2**16 and 5/2**16 -> 5000/32768 and 10000/32768, because my computation of 32768 in power of 2 is also wrong; it's 2**15, not 2**16 and the datasheet mentions 32768, so use that value drivers/staging/iio/adc/ad7606.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index c5fe3003075b..87d5fb073c95 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c @@ -26,9 +26,11 @@ #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)