From patchwork Fri Feb 16 12:09:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10224575 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 22B1B603EE for ; Fri, 16 Feb 2018 12:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12FAA28D21 for ; Fri, 16 Feb 2018 12:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 055DB28EC0; Fri, 16 Feb 2018 12:09:27 +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 5081128D21 for ; Fri, 16 Feb 2018 12:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965847AbeBPMJZ (ORCPT ); Fri, 16 Feb 2018 07:09:25 -0500 Received: from mail-by2nam01on0086.outbound.protection.outlook.com ([104.47.34.86]:24864 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965781AbeBPMJY (ORCPT ); Fri, 16 Feb 2018 07:09:24 -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=MyuBaT4BIotlWXmQOHe3+aW+tdCRawKkcGQnFo71ViE=; b=WEA2JK9Y2r6Q2r+3NRveN/qda3al84oZVX+mVBc7N4VBZaBZPggCndvgwfKTAJ3O1z5DbOZj+FwY16VGryw5u+DUdmYsKxY23AcUpaB6ztwMH4mEXRIA1P5d7OnHfGXombQ2NFkHivvekxHrOC8D1VzDrUMghTnUz7Vp5IcC8xw= Received: from BN3PR03CA0110.namprd03.prod.outlook.com (2603:10b6:400:4::28) by BN3PR0301MB0833.namprd03.prod.outlook.com (2a01:111:e400:4022::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Fri, 16 Feb 2018 12:09:20 +0000 Received: from BL2FFO11FD027.protection.gbl (2a01:111:f400:7c09::106) by BN3PR03CA0110.outlook.office365.com (2603:10b6:400:4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.506.18 via Frontend Transport; Fri, 16 Feb 2018 12:09:20 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; metafoo.de; dkim=none (message not signed) header.d=none;metafoo.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 BL2FFO11FD027.mail.protection.outlook.com (10.173.161.106) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.485.12 via Frontend Transport; Fri, 16 Feb 2018 12:09:20 +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 w1GC9Jkn009476 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Fri, 16 Feb 2018 04:09:19 -0800 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; Fri, 16 Feb 2018 07:09:20 -0500 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w1GC9Igc008851; Fri, 16 Feb 2018 07:09:18 -0500 From: Alexandru Ardelean To: CC: , , Alexandru Ardelean Subject: [PATCH] staging: iio: ad5933: merge ring init function into probe function Date: Fri, 16 Feb 2018 14:09:15 +0200 Message-ID: <20180216120915.19277-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)(39860400002)(39380400002)(376002)(346002)(396003)(2980300002)(438002)(199004)(189003)(478600001)(36756003)(5660300001)(5890100001)(53416004)(356003)(1076002)(8936002)(246002)(47776003)(6666003)(50226002)(106466001)(8676002)(2906002)(6916009)(54906003)(50466002)(48376002)(1857600001)(106002)(51416003)(7696005)(316002)(16586007)(107886003)(305945005)(7636002)(4326008)(26005)(77096007)(336011)(2351001)(86362001)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0301MB0833; H:nwd2mta4.analog.com; FPR:; SPF:Pass; PTR:nwd2mail11.analog.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD027; 1:qJxMqH4RWwxmpm4QhSwkq8ZSL8DbtG7OU+nymV1H2Ra3RQ7QSBJXg38sWosmkewMMwedvQjDm6Y9eK5eYvbKsrj2i5cHlz/Dk0xcu/Firk3JTqd4jcduXZoeRzHshVgs X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1393de39-9ec3-4f49-cebf-08d575361c48 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN3PR0301MB0833; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB0833; 3:8712BKDliaH8A8qbpkDUTAsoLvsz3NJobz/cIYvphD+4nktQ3ehj1IqtfuROPaiHxN/DolydRdsCFw+vcXNE5359jOswuWHhCdIxahHAs778JK9EtlMxQml0aAWNywHZpAzlCL/gBSK+OA+ol0trWAxp/6PibgiL279yQtVvFR17KBzV/PQBfDdQU0MohwcGD0IcSNs//1sXZT6Og9N/OwWXCb2wtz1tdvvNGfFOrcjN82pqcKNC8n5glIBcbZHbx4W1/ex6BkG3gm2snWGRHhj+G3mjCpmra4Zwakjmn1jNUGeaZl9QomyzZzcLLc80VQM/L3pcOZodAlWMuUYUvA==; 25:bCYA86/kxs6gAW3CJoGvhO8ri4yAVzjdVCkH/BmDxq8Smi/zC2lJb68Jzt6RMLftu8YA5zBGngjqwSNShbnwMgV5fTMvXGbIG6WbM7FBvcuCwrSPicnVJRDp0dbpCV7j7moD9b3CAhe8auZEPOG7aNcIjOb24gFm04RahZNgEcfLMIwjZ+32RlBvUEcwdycIOJiX2nHujbtyBqwcY+OVLqgIG+VX+XeNcgmsx9vjGu8MUgMs968EID/VIJ3hbOw4D698f26UtC1LcyRUOYVzQREUuLuMd/VwVOjO0t6CmNJOwNBeXa4Mtvg1Ba53tjmscaRL1HgVeQm9A3VYDvJvbFWVH70K+ohLfEXysEAnt/U= X-MS-TrafficTypeDiagnostic: BN3PR0301MB0833: X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB0833; 31:MFiUwS+wKsblOD/SwfeFQTC/+uA3TCdxIH16ZF44bWOOYwlz1R2JTs2SvogSkPj64qaY4tNTotAw/n/NpG0XfzayHmR4O1IgmXbnk//BCzjUAv0zFEAcFwmOIopmy0yomdJwFAz0KXAQkfVpz/rD8XEsXjT8bOBJxnGViDW+xgMxOuj6YAVwd8okndC9aneVlbc84Q4DVAyj5egBsWvQbey+VyAqwEMPI3E+kbr20uA=; 20:OLUOxThIc90Hvotsd+QGcfCvTqKUGqezQHjcEyHrg0BapV8vFB8RTVY9jZfTywbrCcDVJR+ESqNc2Oi6nXvByNLh+ODgNeGDzxGiqTShbPDDs6s3GXodicA8w8uhE37MPi3QJlE3kveP1vpyqDvDYNVL7vX9l4pJZCa7EshnbaWZ/QZH+KYPIiOiLrBmr0+7SvQeVQxUsSYtuf0pga0QAIRBDCU53bA4/nWkXUbym6ZmFx3w9Ke/dMkgFVbaxRGFffK2Qm6WjEY1AFf0fJR6Bfn0fuZiuZhvKvWQgrCuIPuL+TZhiruRJJISTQf1cUwXaFMYqpVBgDSwLWBdigGQV/DsF7jzMx7Ti2v43mdqf6cQCj87MIzNbS6IKUCXuEQYYEXOLTenAF08VIsijZXuGOnXx3Uu4l/b8M6uHzGRWf/xin4ubjS+w8nYbuaQrxjv9WJPFPybsuQu4tkbcEd6m8Cg4rqHrvxKrEU1TknpAX4pQPSrNBPOFY7ODJxJaAj7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(944501161)(3002001)(93006095)(93004095)(10201501046)(6055026)(6041288)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BN3PR0301MB0833; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0301MB0833; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB0833; 4:qvh3VinJxnYTQ+YBFA3OUIOsLW+JJpTr80urKDSLuDijtAN3f+Jxi703e5PFD/ot5DBRSZ/P6FFGIp8xQnYye3YKLpdL2mO7vA+dDxUB8mlYfhyH1+tm5MOuFZV84zRXKbhcyVYd4dnxTLjmFMUWS5YqoHPSe94BXiW5fcoVUJ8cPhS/m/raQo7fqRDQpELqhJUpZdMekwbUk07HDsP2fJciyEL/1dA0sEnGXPAq61gcqULRZD9Wj4cxpvcDuYp3FYmhfvVP/vibvU60cRzFYaia/0gkmQZajJd6zAwojypjB6019DpbSc/ScNPkjMBz X-Forefront-PRVS: 0585417D7B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB0833; 23:bG0Kwd0lh7/BHwItCV+Fk629seXLzvLs1AUWPeC?= =?us-ascii?Q?TEDz5HsNbinDpzUkBFuY9+m5zq3MuhngmhTNxa7vcwTWskzl1WI39aboJ7qO?= =?us-ascii?Q?4XYhvrxSyBCQffdmeoSEghAHT0eTQOgOFE1MfphkubkERY74G+seSEfhu0EW?= =?us-ascii?Q?q38YhRTjF5qNOfMRWOeT8+WkJu8UX933aPGeimyec22vm3yUlilS7Gj1dC+z?= =?us-ascii?Q?xrM/xVJT/IdPr1mMtecstRT/kv7R5vqwNVLavGlQqNz+/QAd7sUxPCmr1a+1?= =?us-ascii?Q?dS25me+yVALfDh56HBsi6LJgSe5cDPrFBK1gTIcmplwOdbwsaSAVXvyouvBN?= =?us-ascii?Q?Q9REC2nzsSs0diigT5cyJL1gFvcx+Epk6FIkKFqmc9aKA+KAoQAgG5zG78oq?= =?us-ascii?Q?Ikwp+iYA0dxLaw+s+oEJT+WJKERdOwBzLuL42IL+maOPzYg7tZqidwTvKQfP?= =?us-ascii?Q?lc+LDRzi5upxLqJy2ZFDn8e5aZ83Ji+X4E0kiwGiwEYyKuhG8Vi92924favy?= =?us-ascii?Q?9PLKsOMOest+us7gl98NwX3HEIOX/ANr/MXM5Yrl/jKNcXC1gfu/vEwinUo9?= =?us-ascii?Q?VrrZ5+e6CTFO1OXL9wwv+3Hk/6K3dLgwSVkWPxYDr4bBtzCiyoCkQqMdeeMl?= =?us-ascii?Q?xhJNOeLJH8kafIi4ufLNLtGz79NL2Dxp0eGR75QSBbzUXXTNwSC8A3SEMnIt?= =?us-ascii?Q?5H1tzA9ux+amcYjhhybby9yjmlL8XqqG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eEFLgUK80pmJ6j09jHUjf08qJNmq+s4S/SJakPjNgyFJ9Mhbwoue3yOTWDrC/vjr8Ew5NACi46aAoSrDXW1QXo9NWFhVqlsau42cAqkMyzG11+SsjcvRsnqlDmZu/y8xTjdJrrNRV7n9ASlnOC36Or8co3okz3tqF43I4JB/WZwC7eCFLBYIG+Zad+PvUnxpz6HvCpV2e0D/o+rjGSydpMDeEFLvUJ1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2018 12:09:20.4918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1393de39-9ec3-4f49-cebf-08d575361c48 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: BN3PR0301MB0833 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 This is a small cleanup of the driver's init code. It does not fix anything. The `devm_iio_kfifo_allocate()` function is used instead of `iio_kfifo_allocate()`. This removes the need for explicit deallocation of the driver's iio_buffer, which will now be handled via `iio_device_unregister()`. The `setup_ops` assignment has been moved into the `ad5933_probe()` call, since it's a one-liner. Signed-off-by: Alexandru Ardelean --- Note: this change is based on top of `fixes-togreg-post-rc1` branch which contains commit (7d2b8e6aaf9: staging: iio: ad5933: switch buffer mode to software) drivers/staging/iio/impedance-analyzer/ad5933.c | 35 +++++++------------------ 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3bcf49466361..1cab67b3a81e 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -635,22 +635,6 @@ static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { .postdisable = ad5933_ring_postdisable, }; -static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - struct iio_buffer *buffer; - - buffer = iio_kfifo_allocate(); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(indio_dev, buffer); - - /* Ring buffer functions - here trigger setup related */ - indio_dev->setup_ops = &ad5933_ring_setup_ops; - - return 0; -} - static void ad5933_work(struct work_struct *work) { struct ad5933_state *st = container_of(work, @@ -714,12 +698,19 @@ static int ad5933_probe(struct i2c_client *client, int ret, voltage_uv = 0; struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev); struct ad5933_state *st; + struct iio_buffer *buffer; struct iio_dev *indio_dev; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; + buffer = devm_iio_kfifo_allocate(&client->dev); + if (!buffer) + return -ENOMEM; + + iio_device_attach_buffer(indio_dev, buffer); + st = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); st->client = client; @@ -763,23 +754,18 @@ static int ad5933_probe(struct i2c_client *client, indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); indio_dev->channels = ad5933_channels; indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); - - ret = ad5933_register_ring_funcs_and_init(indio_dev); - if (ret) - goto error_disable_reg; + indio_dev->setup_ops = &ad5933_ring_setup_ops; ret = ad5933_setup(st); if (ret) - goto error_unreg_ring; + goto error_disable_reg; ret = iio_device_register(indio_dev); if (ret) - goto error_unreg_ring; + goto error_disable_reg; return 0; -error_unreg_ring: - iio_kfifo_free(indio_dev->buffer); error_disable_reg: regulator_disable(st->reg); @@ -792,7 +778,6 @@ static int ad5933_remove(struct i2c_client *client) struct ad5933_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - iio_kfifo_free(indio_dev->buffer); regulator_disable(st->reg); return 0;