From patchwork Thu Sep 13 07:39:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10598801 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 5105D13B6 for ; Thu, 13 Sep 2018 07:39:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42C5B2A84F for ; Thu, 13 Sep 2018 07:39:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 366B02A867; Thu, 13 Sep 2018 07:39:39 +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 734342A84F for ; Thu, 13 Sep 2018 07:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbeIMMrw (ORCPT ); Thu, 13 Sep 2018 08:47:52 -0400 Received: from mail-bl2nam02on0074.outbound.protection.outlook.com ([104.47.38.74]:35797 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726680AbeIMMrw (ORCPT ); Thu, 13 Sep 2018 08:47:52 -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=L9BfWcbXr1dCXEFMo9Mupt3fO12khFPDvRGnMW5mRNY=; b=ekhWIAEl66aUDBTY5UZCA5I+DUlcU0aXfW2FqsdiXJspsk8eEZQnQ5JU+gvlt8cObMI+xgYX1mFvGPsbRRY23k/H7vRzfDoIuXolXVPcYF3nloK2hq+LwlITe+vHRzBrYRHPOdTiktc0rpY7fphnEG2qY5Z91GSZ+JByAKY4O+Q= Received: from CY4PR03CA0018.namprd03.prod.outlook.com (2603:10b6:903:33::28) by CY4PR03MB3126.namprd03.prod.outlook.com (2603:10b6:910:53::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.18; Thu, 13 Sep 2018 07:39:32 +0000 Received: from BN1AFFO11FD010.protection.gbl (2a01:111:f400:7c10::170) by CY4PR03CA0018.outlook.office365.com (2603:10b6:903:33::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1122.16 via Frontend Transport; Thu, 13 Sep 2018 07:39:32 +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 BN1AFFO11FD010.mail.protection.outlook.com (10.58.52.70) 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 07:39:32 +0000 Received: from NWD2HUBCAS8.ad.analog.com (nwd2hubcas8.ad.analog.com [10.64.69.108]) by nwd2mta4.analog.com (8.13.8/8.13.8) with ESMTP id w8D7dVX0032100 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Thu, 13 Sep 2018 00:39:32 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS8.ad.analog.com (10.64.69.108) with Microsoft SMTP Server id 14.3.301.0; Thu, 13 Sep 2018 03:39:31 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w8D7dRNQ023125; Thu, 13 Sep 2018 03:39:28 -0400 From: Alexandru Ardelean To: , , , CC: , , Alexandru Ardelean Subject: [PATCH] staging:iio:ad7606: fix voltage scales Date: Thu, 13 Sep 2018 10:39:20 +0300 Message-ID: <20180913073920.16089-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)(39860400002)(346002)(376002)(136003)(396003)(2980300002)(438002)(199004)(189003)(2616005)(246002)(8936002)(53416004)(36756003)(106002)(16586007)(4326008)(575784001)(86362001)(2201001)(54906003)(110136005)(47776003)(316002)(1076002)(5660300001)(8676002)(107886003)(2906002)(336012)(50226002)(7636002)(356003)(44832011)(106466001)(305945005)(186003)(51416003)(50466002)(7696005)(26005)(48376002)(77096007)(1857600001)(6666003)(126002)(478600001)(476003)(486006)(426003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB3126;H:nwd2mta4.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD010;1:pJpJ++harxXqznKQZ2U4GpdKqKmOrWjgOTRAyi74re7w6vS8qSucDa6BElnDTZ0o3OmCBCw1FYkhxwUWQLQsI0HyB52MRDioacate3FQ9f38vOhvCiuOgEiivejeYylW X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acf24e87-5c83-4ad7-a276-08d6194c0bbf X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:CY4PR03MB3126; X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3126;3:We4v/8uvJ7xl8KIHo3cevxT515q+JdEvM8EYMuQMnSbzlTHIV7keoDJ30R9w+G1nwvr7mVmJPJDyInsyguUKw4vUpP19qhidxlmZGRiRupUiW6QXkTFc/iUFJrMEMXvQISIlBK+51ZGBs9LLZvIUm79yaaA1uekUJ9PgSI3ZIAF0BmnbL8NN0zTO5643gpR/BJqc7mJMSq1HQh4SprqVfoqhIYNhbjylCHTCgNy+Fz5GRBjz48Xs5Dk9dGTfsbpX7mvzijjV3tC4Z+O6UPXbcqPgDfiV+7vEvKmP34zHeMPp97VI8rOjJ1WAoNXPWVRgCLN8phLF2EvuzN2YzQE1zkRLaMjBLa4LJOstUbL1B6I=;25:Mi93Xj8bRNqYZf9l/r++Z6PDE6vXN8xD8SXdOBDTS09ktC25YFJq7UAl8pNzegpOOQ9f0AqsbcPHGH2EKQ4OSD16iXmhI9QOj8+DS/8FN2sT45Jsf+SxUVLgQVQa0b+VDbzIgTYcRrXXWuyNszxKVCNZU3sgxFANuuaTABDzKZPdwSkz2gDckw5ksNDDULLZzYN36LvOA67R60MJMz5Id+H0GMakg0IujF6djIaRbOv+7sDmh78M417LFFCsmCvn0Bnzonlnxt23dMuPTH3k1z92N555dqcOhCOXq5+k5ujmPDZYXrK3sUmaNvpVy8HG+VU3SiPFTlg6UVHKx/7+gg== X-MS-TrafficTypeDiagnostic: CY4PR03MB3126: X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3126;31:h6jKS1jhVTOobuULvLTTWJyDU5TYZS4IPXDPYy2z3YdPMKb4KUVCArAiwKGrUNkHoo6aZt0qcxYHKKxswLoEegnrdk7waV7HR2mjRRxtAVO2695FWLUTorgf5fc/Y0v9kRIsqkRXHw1SaTibCC/BbyEl8dbK7T1WeJ1FsSH9J6g+sVDMIMu3BMKtXeGkwSRx4S3DI3nBX404rWJ9slRRFeSH+FNKvqxItwU9Dzr8Znw=;20:v5lLJ061ooUoXYujwzn3JyD1/Lf2Pz07Ee0RWCvsYPyuQyu0TBXYrefZbu17kkpf3J0wJqjSktTQK4ftghgydj4Y7x/iYLNy7o753Kzb5EZSVto3TA2jgXKQEDIC+cFwBFiV4sEsT9L7JvVYbFhkVyM6ogOy1mRhuMI6jim4R3RtfU9BqXnSFjZMoA3kGrzUit7wrquDjvxvWlFJDlQPx4AUki8SmRNug1Y6jfe9GFR+N3Ffp/7X4o9pIyeRrAbh1y2NfQg8D49QH0KnxxarhEHYqtEKyXCI8/i0n1sulB7kNkKa1waZ2t2zCO43i1q+TqmJDBiC1N20CRHs/QVlvjAUY+hTP9B8UO0tVWxEeu+g51etnJLTpcYrO7PbTK9yirfA0t1KeD4Jh2o4yyHy5TCcl6j7rb0nIgKH0DhjuakL14DWudViWMBFaed+ROBTd2P1kL57s0Ybt9R4rOZao+phU1eEr4DZHqhLTsSaRdFY4x6hm0gs9LtDItv0ti3T 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)(3002001)(93006095)(93004095)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050);SRVR:CY4PR03MB3126;BCL:0;PCL:0;RULEID:;SRVR:CY4PR03MB3126; X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB3126;4:uJSKcp5e33ZdPEguwg2wZYghEkElE+ySchOIZx4fm5D+pIqEVlPomkouDd08oKQqGv3kMUxl0GrUnQOpZU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TnPsJGONhUrROkt0c1DgFlcpDgN9fyp6yvnjDlnu926A+ml8aBhaLGUBqMf1HKfV5aB/mEfFdWtBgqqYSXerG7CQSJTHSKqaGfd3/56fOrKeoYhF04PRrEBIn+/WTwirU9+wFsu7UAxxXYWC7A1mCjvgT37/Lw==;5:i04Bj7zrsPUGW1Tj4H2eF7G2FUkIe54uDjsFDjLQEWEW3QH7891C1TO2kddJ+IiO76on6qmDbKEuD/XhsslF9KPaG7QBFd3z08lawcoQLVypiUirWjWBqnLWo9KHDBcGmz+XYZhD43LgBGVykzP02ckouPHn5iSPyPiQNBATOhU=;7:7Kxz5gVpfrjInqDrOqB7zwH9UHFnnCoqLMXMChW3J5X7rPnuHBjHAdutwH7QS0dD33dXh53ZmY5yZY9HOhTAJdc+3wSFFeDpOdQP1fLWHhnobTRMmeljnoSDRi4VwOQFAL5mqkmaHtDRXBM/LwB2tZcvxf4LdLUrttGEH3XkbEcevwn3i591063hismDlr1LJaPkjAYjA5ywshxmEs/dLwJaNSsmVe7EIxvLgi546tfmTxSVwRG2NpZXV/CnKbHE SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 07:39:32.3571 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acf24e87-5c83-4ad7-a276-08d6194c0bbf 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: CY4PR03MB3126 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 --- 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..8f0eebf7316d 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/2**16 and 10000/2**16 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)