From patchwork Sun Oct 16 17:09:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAC0AC4332F for ; Sun, 16 Oct 2022 17:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbiJPRKq (ORCPT ); Sun, 16 Oct 2022 13:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbiJPRKe (ORCPT ); Sun, 16 Oct 2022 13:10:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0384833405 for ; Sun, 16 Oct 2022 10:10:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D9C61B80D26 for ; Sun, 16 Oct 2022 17:09:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9B17C433D6; Sun, 16 Oct 2022 17:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665940169; bh=OmjUXOg8l1mQVp6gTMJ2W/f4edV9ISlnMuDB+fBN1+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ke8ZlIGtmCn8dfhSaKEWzdUaJN4LUdgmm5qIE1cEpDXI1lIA5MQ3tT6Furh4EN1DV blyQrFNV3u5P1VR/57qjax/SZGkc9s6NAg0GJW/EFf9Bh4h50H4WrFBvqvScSpMXyM ZslhWaFqTjvwQsF+u++9pou+rWSq5JccRKuLyH2y7sfSHEgig6xTOEaetaFE3g8eBT OIjVX1gtsfVHNRyBRepBtnXiP85GNYvr+UCiYVtNKEJcdWcQapWNx3kjDj2greIZxO 9+xwKX5N5f2JCpEF47FuRiFD/Sd/iNNRivrgVhAqszkQfPqAADbL79Nfz5qQH0EkRj QRe7WT+gjCssQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 1/5] iio: adc: cc10001: Add local struct device *dev variable to avoid repitition Date: Sun, 16 Oct 2022 18:09:46 +0100 Message-Id: <20221016170950.387751-2-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016170950.387751-1-jic23@kernel.org> References: <20221016170950.387751-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron There are lots of uses of this in probe() and we are about to introduce some more, so add a local variable to simplify this. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cc10001_adc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index e16ac935693b..eeaea1362ed1 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -307,14 +307,15 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev, static int cc10001_adc_probe(struct platform_device *pdev) { - struct device_node *node = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *node = dev->of_node; struct cc10001_adc_device *adc_dev; unsigned long adc_clk_rate; struct iio_dev *indio_dev; unsigned long channel_map; int ret; - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev)); + indio_dev = devm_iio_device_alloc(dev, sizeof(*adc_dev)); if (indio_dev == NULL) return -ENOMEM; @@ -326,7 +327,7 @@ static int cc10001_adc_probe(struct platform_device *pdev) channel_map &= ~ret; } - adc_dev->reg = devm_regulator_get(&pdev->dev, "vref"); + adc_dev->reg = devm_regulator_get(dev, "vref"); if (IS_ERR(adc_dev->reg)) return PTR_ERR(adc_dev->reg); @@ -334,7 +335,7 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (ret) return ret; - indio_dev->name = dev_name(&pdev->dev); + indio_dev->name = dev_name(dev); indio_dev->info = &cc10001_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -344,23 +345,23 @@ static int cc10001_adc_probe(struct platform_device *pdev) goto err_disable_reg; } - adc_dev->adc_clk = devm_clk_get(&pdev->dev, "adc"); + adc_dev->adc_clk = devm_clk_get(dev, "adc"); if (IS_ERR(adc_dev->adc_clk)) { - dev_err(&pdev->dev, "failed to get the clock\n"); + dev_err(dev, "failed to get the clock\n"); ret = PTR_ERR(adc_dev->adc_clk); goto err_disable_reg; } ret = clk_prepare_enable(adc_dev->adc_clk); if (ret) { - dev_err(&pdev->dev, "failed to enable the clock\n"); + dev_err(dev, "failed to enable the clock\n"); goto err_disable_reg; } adc_clk_rate = clk_get_rate(adc_dev->adc_clk); if (!adc_clk_rate) { ret = -EINVAL; - dev_err(&pdev->dev, "null clock rate!\n"); + dev_err(dev, "null clock rate!\n"); goto err_disable_clk; } From patchwork Sun Oct 16 17:09:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED03FC4332F for ; Sun, 16 Oct 2022 17:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiJPRKk (ORCPT ); Sun, 16 Oct 2022 13:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbiJPRK3 (ORCPT ); Sun, 16 Oct 2022 13:10:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F16637433 for ; Sun, 16 Oct 2022 10:10:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A1423B80D3F for ; Sun, 16 Oct 2022 17:09:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 487BAC433C1; Sun, 16 Oct 2022 17:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665940171; bh=yMEU6m7C5v4zXwvzejTlF0IMyMCyY93HoJZmR5I5d18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pP6+wfAP/brj7h3y7DGpCgbIl6uoCoa5mO47wVNe6cyfFtB9TYaCDg9wrENm65w7i WErT7F3VRNMxg/rO5F9U2xCiEmmQ4gL+0KCJEGwai6lQG7PSt/pMXhu7JJzWxMFh7+ udSVBv3APnhUkRpp4DXju3zr4uGC2YedRoLDzly/kKkfJB/xDh6p9KmZTrNSl3gDFq oGSHZ9hTHOdal9/7dLcRzckBdXJE36ghvo248HGptYFNTFwpz5oPD1PW/UCw7yYh9k RM1jotOy+by9ThXxvVEPlHUT/GRnAmCnhkCFdLkzwBMa/RW6HBA2JUxpxh7rPMSq/t UhbwevJYyoAcw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 2/5] iio: adc: cc10001: Add devm_add_action_or_reset() to disable regulator. Date: Sun, 16 Oct 2022 18:09:47 +0100 Message-Id: <20221016170950.387751-3-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016170950.387751-1-jic23@kernel.org> References: <20221016170950.387751-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron As the voltage of this regulator is queried, we cannot use the devm_regulator_get_enable() call and have to role our own disable. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cc10001_adc.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index eeaea1362ed1..4f42ceb40ded 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -305,6 +305,11 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev, return 0; } +static void cc10001_reg_disable(void *priv) +{ + regulator_disable(priv); +} + static int cc10001_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -335,27 +340,28 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(dev, cc10001_reg_disable, adc_dev->reg); + if (ret) + return ret; + indio_dev->name = dev_name(dev); indio_dev->info = &cc10001_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; adc_dev->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(adc_dev->reg_base)) { - ret = PTR_ERR(adc_dev->reg_base); - goto err_disable_reg; - } + if (IS_ERR(adc_dev->reg_base)) + return PTR_ERR(adc_dev->reg_base); adc_dev->adc_clk = devm_clk_get(dev, "adc"); if (IS_ERR(adc_dev->adc_clk)) { dev_err(dev, "failed to get the clock\n"); - ret = PTR_ERR(adc_dev->adc_clk); - goto err_disable_reg; + return PTR_ERR(adc_dev->adc_clk); } ret = clk_prepare_enable(adc_dev->adc_clk); if (ret) { dev_err(dev, "failed to enable the clock\n"); - goto err_disable_reg; + return ret; } adc_clk_rate = clk_get_rate(adc_dev->adc_clk); @@ -400,8 +406,6 @@ static int cc10001_adc_probe(struct platform_device *pdev) iio_triggered_buffer_cleanup(indio_dev); err_disable_clk: clk_disable_unprepare(adc_dev->adc_clk); -err_disable_reg: - regulator_disable(adc_dev->reg); return ret; } @@ -414,7 +418,6 @@ static int cc10001_adc_remove(struct platform_device *pdev) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); clk_disable_unprepare(adc_dev->adc_clk); - regulator_disable(adc_dev->reg); return 0; } From patchwork Sun Oct 16 17:09:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8278EC4332F for ; Sun, 16 Oct 2022 17:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiJPRKP (ORCPT ); Sun, 16 Oct 2022 13:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbiJPRKD (ORCPT ); Sun, 16 Oct 2022 13:10:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E86248F1 for ; Sun, 16 Oct 2022 10:09:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13DF4B80D41 for ; Sun, 16 Oct 2022 17:09:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E422BC433D6; Sun, 16 Oct 2022 17:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665940172; bh=oYhj+l2sg4gIFpJawaeeru5wkinVX/YuP3hnhwyO2tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nTiHkApKX+XkdK86Wjp4rR/a9nhSF+3FHaSbtv7YqNNwdzg+qY3ZOG0D9zHrK6sSm WyjSUBML9jZ+rEoiQBSlWRFfGi1e8zWfx1r0rx3MIGJJq8VhksfaFLsvQUybqz32r+ enJ1jOe9dgzZcZoL+nIuq4FHSuU8Zis9ZemfIBT267LphK7JF3K4iHOHGRQbMSsImI MMfuyZjguA2yo2IMTCdLju8ndos38d9Cuo5gTybALV0J9r0/7kLoTxdN1Ddm3qS1CN XtSjRbv47T13cMzQxDZuTLN63irSj4kpzim8MIQ2s4B9RCyrKGEDikBm1SVHBVIlB2 LmPm2jJ1q5VmA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 3/5] iio: adc: cc10001: Use devm_clk_get_enabled() to avoid boilerplate. Date: Sun, 16 Oct 2022 18:09:48 +0100 Message-Id: <20221016170950.387751-4-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016170950.387751-1-jic23@kernel.org> References: <20221016170950.387751-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron As this driver just enables clock in probe() and disables in remove() we can use this new function to replace boilerplate and simplify error paths. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cc10001_adc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index 4f42ceb40ded..332f0e06369f 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -352,23 +352,16 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (IS_ERR(adc_dev->reg_base)) return PTR_ERR(adc_dev->reg_base); - adc_dev->adc_clk = devm_clk_get(dev, "adc"); + adc_dev->adc_clk = devm_clk_get_enabled(dev, "adc"); if (IS_ERR(adc_dev->adc_clk)) { dev_err(dev, "failed to get the clock\n"); return PTR_ERR(adc_dev->adc_clk); } - ret = clk_prepare_enable(adc_dev->adc_clk); - if (ret) { - dev_err(dev, "failed to enable the clock\n"); - return ret; - } - adc_clk_rate = clk_get_rate(adc_dev->adc_clk); if (!adc_clk_rate) { - ret = -EINVAL; dev_err(dev, "null clock rate!\n"); - goto err_disable_clk; + return -EINVAL; } adc_dev->eoc_delay_ns = NSEC_PER_SEC / adc_clk_rate; @@ -385,14 +378,14 @@ static int cc10001_adc_probe(struct platform_device *pdev) /* Setup the ADC channels available on the device */ ret = cc10001_adc_channel_init(indio_dev, channel_map); if (ret < 0) - goto err_disable_clk; + return ret; mutex_init(&adc_dev->lock); ret = iio_triggered_buffer_setup(indio_dev, NULL, &cc10001_adc_trigger_h, NULL); if (ret < 0) - goto err_disable_clk; + return ret; ret = iio_device_register(indio_dev); if (ret < 0) @@ -404,8 +397,6 @@ static int cc10001_adc_probe(struct platform_device *pdev) err_cleanup_buffer: iio_triggered_buffer_cleanup(indio_dev); -err_disable_clk: - clk_disable_unprepare(adc_dev->adc_clk); return ret; } @@ -417,7 +408,6 @@ static int cc10001_adc_remove(struct platform_device *pdev) cc10001_adc_power_down(adc_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - clk_disable_unprepare(adc_dev->adc_clk); return 0; } From patchwork Sun Oct 16 17:09:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E1AFC433FE for ; Sun, 16 Oct 2022 17:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbiJPRKP (ORCPT ); Sun, 16 Oct 2022 13:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbiJPRKD (ORCPT ); Sun, 16 Oct 2022 13:10:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B54A127DDA for ; Sun, 16 Oct 2022 10:09:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 763B4B80D42 for ; Sun, 16 Oct 2022 17:09:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F00C433C1; Sun, 16 Oct 2022 17:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665940174; bh=W0xdDPHm3+2JR9MhpcF3bBGNh6Sc94k3A142m5RGwy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lW4gc+U/seHLhIG9e5goNwWU2Ke1PKZNRAYNmYFeWploFJywenAee+g2l79ej3Fdx IdzXuE6cvzA+gPx2QrzRQDzSlkD6frJQAiMzIKBLbGo3B/wkmHXwGmodv/3MknWfue HK+E+2L9Chq2MKfN4PGpDR1tevoEf9f9g//t+r3VGgcvw140T5z/ltXrbdODK9zebe Eb5uuBEQVQ3SLsiE3hfo9IxJ5HhYJ/10CdR4gCCvJCGVSAvONclzJSlPfKvRq9EjHo XGDJ//9JK/wexvCyLD5HmwAsIzsgXqw91zseIN4ZGDo/5lDOtKo1arU1oB1Xenq6Kj /W2mbqhMV6UQQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 4/5] iio: adc: cc10001: Use devm_ to call device power down. Date: Sun, 16 Oct 2022 18:09:49 +0100 Message-Id: <20221016170950.387751-5-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016170950.387751-1-jic23@kernel.org> References: <20221016170950.387751-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron It is presumably safe to call the powerdown whether or not we are in the commented shared state (the driver always did this). The power down was previously out of order wrt to the probe() function so move using devm_ will ensure it occurs after the userspace interfaces are removed. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cc10001_adc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index 332f0e06369f..b0daaec7ff16 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -310,6 +310,11 @@ static void cc10001_reg_disable(void *priv) regulator_disable(priv); } +static void cc10001_pd_cb(void *priv) +{ + cc10001_adc_power_down(priv); +} + static int cc10001_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -375,6 +380,9 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (adc_dev->shared) cc10001_adc_power_up(adc_dev); + ret = devm_add_action_or_reset(dev, cc10001_pd_cb, adc_dev); + if (ret) + return ret; /* Setup the ADC channels available on the device */ ret = cc10001_adc_channel_init(indio_dev, channel_map); if (ret < 0) @@ -405,7 +413,6 @@ static int cc10001_adc_remove(struct platform_device *pdev) struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct cc10001_adc_device *adc_dev = iio_priv(indio_dev); - cc10001_adc_power_down(adc_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); From patchwork Sun Oct 16 17:09:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007942 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15B1EC4332F for ; Sun, 16 Oct 2022 17:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbiJPRK1 (ORCPT ); Sun, 16 Oct 2022 13:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbiJPRKO (ORCPT ); Sun, 16 Oct 2022 13:10:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CBF3121F for ; Sun, 16 Oct 2022 10:10:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94451B80D44 for ; Sun, 16 Oct 2022 17:09:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 919E4C433D7; Sun, 16 Oct 2022 17:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665940175; bh=OLtfYai7gFMwNSnBiWGLmqeLgGk5N+D5CRtvVtWILBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6IPmDO8e0Clr+DCQ0WwLJZgvoegv3AWibf9KiLSc5JT5Rf7PeWzKHY6/NKFNUWZC QCbLz8Ip5X1sI9uT2JJtm1rIyItWndpN/anepyKfCtzbVdnCev2War4jIUIaFUPZnw 7k0vPkXFuesrMQJcxconqPuGRQxR6ruB6Q/67hHhsByNQsPcRVlS8O1oj01fdI2dOm Zpv1HdEwTFxR7Ckaw6D32EdINnI1liZYhDg9WP9C4bMGNV+MPQJrDPc5UF21kS4sEu fAdw95zBy3BmN7rX48+sHMX80mR9aRcQOmz3O/uwhGuGCf8ZE9KSkkHe+GyJyNnGpB CHaWo6V3UbbKA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 5/5] iio: adc: cc10001: Switch remaining IIO calls in probe to devm_ forms. Date: Sun, 16 Oct 2022 18:09:50 +0100 Message-Id: <20221016170950.387751-6-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016170950.387751-1-jic23@kernel.org> References: <20221016170950.387751-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron As everything else is now handled by devm managed releases the triggered buffer setup and IIO device registration can also be moved over to their devm forms allowing dropping of remove(). Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cc10001_adc.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index b0daaec7ff16..ab71004ea8f1 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -390,33 +390,12 @@ static int cc10001_adc_probe(struct platform_device *pdev) mutex_init(&adc_dev->lock); - ret = iio_triggered_buffer_setup(indio_dev, NULL, - &cc10001_adc_trigger_h, NULL); + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + &cc10001_adc_trigger_h, NULL); if (ret < 0) return ret; - ret = iio_device_register(indio_dev); - if (ret < 0) - goto err_cleanup_buffer; - - platform_set_drvdata(pdev, indio_dev); - - return 0; - -err_cleanup_buffer: - iio_triggered_buffer_cleanup(indio_dev); - return ret; -} - -static int cc10001_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct cc10001_adc_device *adc_dev = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - - return 0; + return devm_iio_device_register(dev, indio_dev); } static const struct of_device_id cc10001_adc_dt_ids[] = { @@ -431,7 +410,6 @@ static struct platform_driver cc10001_adc_driver = { .of_match_table = cc10001_adc_dt_ids, }, .probe = cc10001_adc_probe, - .remove = cc10001_adc_remove, }; module_platform_driver(cc10001_adc_driver);