From patchwork Tue Jan 16 11:10:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10166531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71A0F600CA for ; Tue, 16 Jan 2018 11:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F83928358 for ; Tue, 16 Jan 2018 11:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6366E2837E; Tue, 16 Jan 2018 11:11:02 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C9E0E28358 for ; Tue, 16 Jan 2018 11:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751126AbeAPLLA (ORCPT ); Tue, 16 Jan 2018 06:11:00 -0500 Received: from mail-dm3nam03on0072.outbound.protection.outlook.com ([104.47.41.72]:52688 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750832AbeAPLK7 (ORCPT ); Tue, 16 Jan 2018 06:10:59 -0500 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; bh=pCE6bHK4roGIrA3FwMSVHIzPLJqWgWuBEP9v7ULHP1A=; b=dEyIeuzKoQv8ggGi5hwRNlMUWsco5lbzsbfwbiR6NPS1gkUYUdHJF4nFMIPR5rqc/oiK13wqhHTitTeIdtQSX9fdiP5Ri88fQHGLU5BP1VIf+4r3f2OZ/Ld1m8xYr3YOeycOWPZkkFjxkQs6sudtILXwZcbJpERbnRpwnoW3XfI= Received: from CY4PR03CA0092.namprd03.prod.outlook.com (2603:10b6:910:4d::33) by BN1PR0301MB0690.namprd03.prod.outlook.com (2a01:111:e400:5a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Tue, 16 Jan 2018 11:10:57 +0000 Received: from BY2FFO11FD048.protection.gbl (2a01:111:f400:7c0c::139) by CY4PR03CA0092.outlook.office365.com (2603:10b6:910:4d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Tue, 16 Jan 2018 11:10:57 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; 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 BY2FFO11FD048.mail.protection.outlook.com (10.1.15.176) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Tue, 16 Jan 2018 11:10:56 +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 w0GBAtWE018242 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Tue, 16 Jan 2018 03:10:55 -0800 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; Tue, 16 Jan 2018 06:10:55 -0500 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w0GBAolN023641; Tue, 16 Jan 2018 06:10:52 -0500 From: To: CC: , Alexandru Ardelean Subject: [PATCH][V2] staging: iio: adc: ad7192: disable burnout currents on misconfig Date: Tue, 16 Jan 2018 13:10:47 +0200 Message-ID: <20180116111047.3262-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 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)(346002)(39380400002)(376002)(39860400002)(396003)(2980300002)(438002)(189003)(199004)(2876002)(16586007)(478600001)(5660300001)(6916009)(305945005)(86362001)(8936002)(50226002)(106002)(26005)(7636002)(53416004)(54906003)(246002)(356003)(86152003)(2906002)(8676002)(59450400001)(51416003)(50466002)(77096006)(48376002)(7696005)(107886003)(4326008)(316002)(36756003)(6666003)(106466001)(47776003)(1076002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0690; H:nwd2mta4.analog.com; FPR:; SPF:Pass; PTR:nwd2mail11.analog.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD048; 1:ynXR4SDWLIwG1PSactOiHDbnqkGnIQiJ5h3aZ3nGDFpC0jyxk4h21GpA0bv6XY5ivrpwrhcyeGC7c8Cm5MwjOiFTmpvIGCV7InMBwf1MTda1hUcEWZ0HlvJO+R5az/JM X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c97960b2-621f-41b5-9203-08d55cd1d153 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN1PR0301MB0690; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0690; 3:AOx3SiLBg6b8RwKJ5WLbRppirRjsxoSm6TrIE+pOIWL7kzQ7LCcamVJVI5rRt/6PVC7Q4BuyzCdblbXRuAtQfyD6yvP4CHEXvjLS93LQjcW011SlXN5fR9kAui0auh+47Jv+EI3X1Vvm99uJ9cDrYj8K+Qy+WTmoLnlqD9tBN7Df0qJqYqWrfCgV85ILTqbHrNnhGtSTCGAbndr6upP+lBU40v6xiwQv1mkYo8nzEaN3EOQXK0DB26H4iljhMSulkAtNRle92s2hTw8YEjpK/2f0GfIdVqr4/dRafcwLvq2tl6h4HlsbWMfPE5Ji66LLBqMxhkAHfucqa22Xc1x30g==; 25:OO4KpwkQQRo216eQq0x7wZ/LCRdbB0jKmiKskHciMhuBhR6kNn7MtY6a16hIbdefkEmNhNuP5oNulWVmizX2uwqvK1vT+nC9+/OdyZdVwP6MXYWguova1XWPuz2esKee7YknivI1nw9yEI7v6wPEgKS0u/3pFppsg7Hue59FUjSxgnrRMBV2IoNFEDellppU4kR60A+ld/uhO0le3Lc6JIJRu92nQ2lvrYUkE4b/YUCRMscvTbuAfjNYPJaT8xTVsKQiD/vSo8fQcyMzKD1Y3jOZ+AYFvFgwb8Us5doxP6jliHNbd7t5G/BkM44hbFVgh5YNWscIYZTzk92MSyI7tQs6mvBhhP9NM4HHG0Ff7m8= X-MS-TrafficTypeDiagnostic: BN1PR0301MB0690: X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0690; 31:QOut7ANKufYyLuQkrtHcE8ZZ0GfiKkEvQ/boQHdB5K6iyPMQYY0PC3rpAC5Taq0/xwZ5yx4Qj4jBTJAxDXR6QFLjfNHDlJXw4P+aSG/5si95LGDDDBeRV+O66TtHpduTuFfq0LeQrjAYr0z4V3hG/Cib16WYn3BJHGbRiP8KZsRGPWDvfLrCgolm/XNuPkyzEn9ledAB0hmOjpRrZoizlEZYGBDHQT69aXRCc9Z37fg=; 20:ulgf7v4cH4GyUUdTpxEQFyve6Nx9L940AlaGCGIFsmvuTOj0lT20LhgI8ko2u1/xLZmALkMvMXfYaYVBptnR8VoZxTPWMzm+YoOzu7IqPJyGTJUyGAoYMlD/LCmzpO75JrzVA9v6c5TaivFlUhJufdEDQpcJzivh+x3FVvE31KuYqSmhjsCwMyDCWzUrrVuCLo0+sxXR6i74+Ya93YV16/KIBKB29ildUGcXZ4cOF5SF9dV6JOFB65SPE8+YuJtDgmP21tKTt+BfxEV1YCDVpVFnY3Nej0cSlm0LJGbvZX40ZHf5JjpHkK3coB2nOcIn6Crvm33sx49bSqPvwzCMEm2dX181wgue8YFjozn2MLiJ1HpuaOAKDjO55Ev6w/jvj7pL1xiXmVXP37lqRHwsHNEl5tu18l3sGQoHHyoiEbPXfNhLW+9sA1bate4IQG9dt/OpvdKzp9gtD546zUZM+6t/SzFJFBv8S8EnxOqw90IltvoPI1VsP1wzTrSpWRBU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93004095)(3002001)(3231023)(944501161)(10201501046)(6055026)(6041268)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:BN1PR0301MB0690; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN1PR0301MB0690; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0690; 4:Jq9M1yGMmZMgxEnKS5tvPCCiim/kWVmasJGKa3X24PEUkZmvDCGNExfRNavI/f/u2bh+dEK8T17t2EqeokTgDg8lS9QFyQStOlSRhZIpQW4FPEaTLaN5iRDXSvj1jUCR1Ylneywzo0PLvcH/cyZoQDGm1C7k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xUfazVJwckZ4C5wMdQiW5jJR2VMke4jfyMnzXXtGRC8zlkHM6HgaftoKwbHEz7+YWzQBo=; 7:8QIOYSgVdbnJNGnpMN5yPJoYSTqBAiYzRtwCODKA71rniebmV1+GYsvX2U4/5dWOb5yp2H4cGXr5uuuBI3QFaHxKdM/Rhn+nc2ctjxdw+SEFEZdQBgdiHjxeayVpWrzoGpHJ5bYsUC7GV9J21l/ST+3Lh0gtqkxN8Dei3KluC63Pn/BxzxEXcVJ/N5Qe1FUu36EifVUq/hOiyjbcCmwj/FErQcnombUXjrH77DP+ItQP0fP5oCfabSGG8bgTr671 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 11:10:56.9352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c97960b2-621f-41b5-9203-08d55cd1d153 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: BN1PR0301MB0690 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 From: Alexandru Ardelean According to the datasheet for all ad719x ADCs, the burnout currents can be enabled only if buffer is enabled and CHOP is disabled. So, if neither of these conditions are met, then we should disable the burnout currents in the driver as well, and warn the user. This change doesn't fix anything. The burnout currents simply won't work if CHOP is enabled or buffer is disabled. The intent is to provide the user with some feedback instead of silently not working inside the chip. This is especially useful when considering device-tree support (and/or device-tree overlays) at a later point, which will allow for a quicker/simpler reconfiguration of the chip settings. Signed-off-by: Alexandru Ardelean --- drivers/staging/iio/adc/ad7192.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index d11c6de9c777..7f204013d6d4 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -266,6 +266,12 @@ static int ad7192_setup(struct ad7192_state *st, st->conf = AD7192_CONF_GAIN(0); + if (pdata->burnout_curr_en && (!pdata->buf_en || pdata->chop_en)) { + pdata->burnout_curr_en = false; + dev_warn(dev, + "Can't enable burnout currents: see CHOP or buffer\n"); + } + if (pdata->rej60_en) st->mode |= AD7192_MODE_REJ60;