From patchwork Fri Jan 5 15:40:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10146689 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 AD24A601A1 for ; Fri, 5 Jan 2018 15:40:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9935E28449 for ; Fri, 5 Jan 2018 15:40:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C12728701; Fri, 5 Jan 2018 15:40:46 +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 EBC8928479 for ; Fri, 5 Jan 2018 15:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbeAEPkp (ORCPT ); Fri, 5 Jan 2018 10:40:45 -0500 Received: from mail-bl2nam02on0061.outbound.protection.outlook.com ([104.47.38.61]:38540 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751617AbeAEPko (ORCPT ); Fri, 5 Jan 2018 10:40:44 -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=kibG/0bhw4L/YFqMFLKQBUKhamKM+c2evNl+7ftiwEM=; b=cUBhfzT1sfIb9lzj7lPx1uhUReQWtgyjzwLrQN6LRQADNkNwOU2DWOi1OqrTwJbvRA3VO/TepAW0aJPe8f/kZN+ZARt+uD/MlaosskkKndPfHBzRWLLmYGgMhsC2XS8SvEFm3S+WMJdqi+M21n4N7dsfwgx2ArZ6GIMfMtKAiIg= Received: from BN3PR03CA0105.namprd03.prod.outlook.com (10.174.66.23) by BY2PR0301MB2054.namprd03.prod.outlook.com (10.163.196.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Fri, 5 Jan 2018 15:40:42 +0000 Received: from BN1BFFO11FD009.protection.gbl (2a01:111:f400:7c10::1:103) by BN3PR03CA0105.outlook.office365.com (2603:10b6:400:4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Fri, 5 Jan 2018 15:40:41 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) 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.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BN1BFFO11FD009.mail.protection.outlook.com (10.58.144.72) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Fri, 5 Jan 2018 15:40:14 +0000 Received: from NWD2HUBCAS9.ad.analog.com (nwd2hubcas9.ad.analog.com [10.64.69.109]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id w05Fee3K019778 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Fri, 5 Jan 2018 07:40:40 -0800 Received: from NWD2MBX7.ad.analog.com ([fe80::190e:f9c1:9a22:9663]) by NWD2HUBCAS9.ad.analog.com ([fe80::44a2:871b:49ab:ea47%12]) with mapi id 14.03.0210.002; Fri, 5 Jan 2018 10:40:41 -0500 From: "Ardelean, Alexandru" To: "linux-iio@vger.kernel.org" Subject: RE: [PATCH 1/2] staging: iio: adc: ad7192: add device-tree support to driver Thread-Topic: [PATCH 1/2] staging: iio: adc: ad7192: add device-tree support to driver Thread-Index: AQHThjjh8Vo9nDFvrUOxVH66SdhpOqNlaiRV Date: Fri, 5 Jan 2018 15:40:40 +0000 Message-ID: References: <20180105152133.9681-1-alexandru.ardelean@analog.com> In-Reply-To: <20180105152133.9681-1-alexandru.ardelean@analog.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.50.1.244] MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(39860400002)(376002)(346002)(396003)(2980300002)(438002)(199004)(189003)(2906002)(106466001)(7696005)(5660300001)(46406003)(53546011)(102836004)(2501003)(5250100002)(2351001)(8936002)(76176011)(8746002)(86362001)(316002)(6916009)(6246003)(2950100002)(106002)(305945005)(478600001)(47776003)(23726003)(3846002)(6116002)(55846006)(14454004)(356003)(246002)(7636002)(7736002)(33656002)(97756001)(50466002)(2920100001)(2900100001)(8676002)(229853002)(5640700003)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB2054; H:nwd2mta1.analog.com; FPR:; SPF:Pass; PTR:nwd2mail10.analog.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD009; 1:VWyKa2gRFi9MEl+9b6Zvsg/LG8N/lZqcBmK2xC0PWhDULjG/gPaAz9kYOPd1yrv8HR+q6K7XDPbKuDpRrj67q9FTyO2g41Fsx71mlagmZKHiRDh6Oh967frP8IM6t5kw X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42b0de1f-6d25-4d5c-4d41-08d554529d25 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BY2PR0301MB2054; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB2054; 3:cJSydirflkvQdThOymt8sJ69G8r/zlAoNLlDKkjQ2hapQj/nMjv4yNJqt55Gqu7BQXimssZiKwHHAWcq+3dOZo2gemdfBWgFXg3iLDAKBE90aL6GLkp+byzjgOwqq3nTmYeUsYU0IptiJ2mq6mWo2j170jzJz5qRrBTlmb6qGcPuC55joIToRYkCkNMAxtEZ7X0XDd8qd3Qm/fxWpzhJIKaY1j+iKKiaTwML/DjiHvkNGos3fRtQo91tf3ChGbwpAS+JLjugkxMk/s27EcksMZdtKslyxO4aJ/g4g8jRhx6V7gEaqkQZn243FxCjcP/VtnHgdvcie58n9bXa6HrRUQ==; 25:dRUFoAbe467Vshh0pvmRpa4X9rxacMyDXIE5sXZoncTwY/dLixpDO1A5AloFrVeY8BO8zV5+1fNsNyg6r0EaFnf0Pf2NAKI3hkclL5UfeDFRzy6aRy5uAzpbIS/M4TO+ebjuZR/GQBPCjPAl8fmcJ/HC+GN5B8odM2Dgi6ZCfDQxjJMVs2BaTEboqh99u8DaNPR59xxeNQTDj4y9Trp5/bCv2/CRq+RXL2rShgPz6L/1EttHvzkJcEH+ok7O/gITqijstTL29YWqhGpdVRzXe0bgpAXl8Gj3yP+RrrkKcAPZl0g9irN5K/w4oQsptBez8Ube/SleAXnLTZEnvQmb4Q==; 31:V9gO56DP8wghfumMGK14K6Q5yFuIn36c1DRrxEA6qasvxk/p38uw8qypmDCpZTyy4jRTIGYXPrizvk6kF0cNbHnHccmcg4GDYUyTpniwO+R7h7b+0enSi/CpOJXZMsDPK84r+hvan9m32WX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-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(232431446821674); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(10201501046)(93006095)(93004095)(6055026)(6041268)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:BY2PR0301MB2054; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BY2PR0301MB2054; X-Forefront-PRVS: 05437568AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB2054; 23:HRP8Zsc/A4NSDNtFGKTocUot9ywLk26Ge8iK3EC?= =?us-ascii?Q?Nx6hEPkmWl6CHkKTzNRfiTkh88ncQedgiSvKlCaYIxloPB6kJWSDNOZX7ClP?= =?us-ascii?Q?EMV4Pv7OsC4BuNTVVFTN4vT3y2F7Y6ORVh7+esopXKu379OABQG4rl5Ntean?= =?us-ascii?Q?HVg9HRW0TO8DtyC79gj/re962KNu3nkCaB0rGp1Ql2NuT3MjSfe8hVhnnUT9?= =?us-ascii?Q?M2JQ3z2z/oad6n1UrAit/lGVFWwMBN+qzQLaRtmWlHVPCCwSgWxRc+BXmkH+?= =?us-ascii?Q?WFQMvoBvhCkPL3qeksecQ9MNDRooYNGgJwv3vi5P2i3W3u3F9QP170NKD7I+?= =?us-ascii?Q?1BgnNh2atxn2kFjTLXwsAWSJLrMRnkGu2AZVZuEfGKRbPXJuoXG22OTq3Vk5?= =?us-ascii?Q?ix3yGxHc4x00gJDMr4YF2eLv7MpegBPfT3J/yI3O+E3IOTQBbM8h5RI16j22?= =?us-ascii?Q?m84hguZFy/gK8i7uS/6x3AFvCJckQAllwDLPqkk9oYzQBZVcMWDoAafgvqT0?= =?us-ascii?Q?QKmA9MwNJn/tULS8fFDxsuwIjmbz0oOwsh8BDnn8v2AecsWBUKv1JSd4dwDY?= =?us-ascii?Q?q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oW9OIC/xNpfw0GlmQSzKo3BcvXk0o=; 5:Q9vgm6zBMcr+TubOhXyAenlm+DlTw7oMTRVCwJTeJgKzGCs7nou+Tg+d2CxVJ5sXqVYRdz1gmeoRipdEvH9hpbAfGcILppr+Z6B45guEoPYLhytrGu4gnhPCsRvtK9v71RFr9U9vnm5QJ9IdYtaO7jhqK4CJ54W/QlG6yNmQCOI=; 24:aHII3d5jY8bTM9/5da/WpOOvGxHBiOOD+ZhNmQRyaZGzL6rPo/hCTQ4YewnG5MAw9nFKqR7HnGiUnzXVNVPfkhEilRTnjoWTsPiidiIBi1M=; 7:kPAuDBNnPrMW9cOZ7UN2LfCnA2T2kCl/aBLmf80Yvklx+4htLv5lLwkDGFfLs+j0He54f+xbKoPNrsrXLazPybxhl7E1jHp/Gv7gnD2CeCQdOpnOogS6WSCSapKeMXpx563Q1UL+b4U++CLOE8PtlhoZA3UKZWYDVtx3Q8zuZFHrvE8NTEKFUGo9zoaesjXEOouzuJwSubd4TlK+d3/fvOAMr2kiRgFsYQZfN6iTSY+5FqGa8xhjL+lvXsOgIlSw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2018 15:40:14.2220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42b0de1f-6d25-4d5c-4d41-08d554529d25 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.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB2054 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@analog.com [alexandru.ardelean@analog.com] Sent: Friday, January 05, 2018 5:21 PM To: linux-iio@vger.kernel.org Cc: Ardelean, Alexandru Subject: [PATCH 1/2] staging: iio: adc: ad7192: add device-tree support to driver From: Alexandru Ardelean Admittedly, this will always use up to sizeof(struct ad7192_platform_data) bytes (~12 bytes at most) on the stack, during the probing of the device. But this will maintain most of the other init code unchanged. Signed-off-by: Alexandru Ardelean --- drivers/staging/iio/adc/ad7192.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) + } + if (!spi->irq) { dev_err(&spi->dev, "no IRQ?\n"); return -ENODEV; -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index cadfb96734ed..fca988330588 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -610,18 +610,41 @@ static const struct iio_chan_spec ad7193_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(14), }; +static void ad7192_parse_dt(struct device_node *np, + struct ad7192_platform_data *pdata) +{ + of_property_read_u16(np, "adi,reference-voltage-mv", &pdata->vref_mv); + of_property_read_u8(np, "adi,clock-source-select", &pdata->clock_source_sel); + of_property_read_u32(np, "adi,external-clock-Hz", &pdata->ext_clk_hz); + pdata->refin2_en = of_property_read_bool(np, "adi,refin2-pins-enable"); + pdata->rej60_en = of_property_read_bool(np, "adi,rejection-60-Hz-enable"); + pdata->sinc3_en = of_property_read_bool(np, "adi,sinc3-filter-enable"); + pdata->chop_en = of_property_read_bool(np, "adi,chop-enable"); + pdata->buf_en = of_property_read_bool(np, "adi,buffer-enable"); + pdata->unipolar_en = of_property_read_bool(np, "adi,unipolar-enable"); + pdata->burnout_curr_en = of_property_read_bool(np, "adi,burnout-currents-enable"); +} + static int ad7192_probe(struct spi_device *spi) { const struct ad7192_platform_data *pdata = dev_get_platdata(&spi->dev); + const struct device_node *of_node = dev_of_node(&spi->dev); + struct ad7192_platform_data lpdata; struct ad7192_state *st; struct iio_dev *indio_dev; int ret, voltage_uv = 0; - if (!pdata) { - dev_err(&spi->dev, "no platform data?\n"); + if (!pdata && !of_node) { + dev_err(&spi->dev, "no platform data or device tree configuration?\n"); return -ENODEV; } + if (!pdata) { + memset(&lpdata, 0, sizeof(lpdata)); + pdata = &lpdata; + ad7192_parse_dt(of_node, pdata); weird how my compiler did not catch this const qualifier disregard.... though, this did work on an ARM64 [Raspberry Pi] i guess i'll have to re-spin this as well