From patchwork Wed Apr 3 07:03:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10882947 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 6FC1E1575 for ; Wed, 3 Apr 2019 07:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599DE2894E for ; Wed, 3 Apr 2019 07:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DB152899E; Wed, 3 Apr 2019 07:04:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 02AD82894E for ; Wed, 3 Apr 2019 07:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbfDCHD4 (ORCPT ); Wed, 3 Apr 2019 03:03:56 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36454 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728799AbfDCHDx (ORCPT ); Wed, 3 Apr 2019 03:03:53 -0400 Received: by mail-pf1-f195.google.com with SMTP id z5so6655956pfn.3; Wed, 03 Apr 2019 00:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UanW9KkmJsWd7vTvVGIWm1rlHt42PgVmc/4x9rVyFLc=; b=eU7hZ8V0yhPwBMRz3qKiMzFvNN/CkUgRlP4Sb0mwBWE3hem/mgx+H/D/KtXJYk+2w4 HlcXOliZgN/uiXf6XQ7aNicx1n+Sf5TWBqA8Dzz+Jud9NTQr2VCXxMhVBi5tUn0sKSG8 xCN9CU69C0HLRNyYtDBwUHzd2SK3C+pAt2PSFXiMrfHkDavkj/szxqBPdbHSWpe2QJpC hYC3KXr8oF3xvuJo9+4rz4TH+vm/gmOIR834Hl09BNL2PgnXzzZEFlorsqKwbMCskfv0 jGulLelwP1IAgHd3fQoa5mfli5qat2IZxjzfOAVDTOsG0XgbbT2K9y11bBV7191quqwr k5GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UanW9KkmJsWd7vTvVGIWm1rlHt42PgVmc/4x9rVyFLc=; b=bK0kLhAoxzjMQAnybsCIIm2ryDR+/o5D92icwQyxDA5Jjw5Hz6QYKbDuPByVeuUmcn VGXTz3sPx/3E2BSzu2kyqcmgCMs/imEXoKsbQ8+EChOIG7lMIZ1PBN4/6jZPAfrXsEP0 9R4qBiNCx6bq91rieDkDHF2z/OzkVcKOsxgS0BV9CraLMiWlwjpP/yRkiwkcOeAnF7Qo nrKuvWGkPGaqBqBjfcSOXNvKsUkBRbDzgtqxhYng82syP++pwlHlH66HXy96drlQixx/ P2dl9v/RotU6MkMKt3wiIAaSYG77nhsS5K/03TwajkS4F4z7Q/PG91sVFz2+C35vjli7 pc2w== X-Gm-Message-State: APjAAAXfvozzzcbHl4uwOmTleTQ0VYMs6K15mPdXnwYuWNWnJJZrzcCG 2TUZqCu6IpIANrA6fVYM+Hav4DGw X-Google-Smtp-Source: APXvYqyr/q3jx0nUa6mpAp72yvXcDTBpHXDAcskc5a1UkcJyOmJYEbNxF1B9uS4AkosjtcOBvgQP3A== X-Received: by 2002:a62:8381:: with SMTP id h123mr20481130pfe.226.1554275032493; Wed, 03 Apr 2019 00:03:52 -0700 (PDT) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id e22sm20602750pfi.126.2019.04.03.00.03.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Apr 2019 00:03:51 -0700 (PDT) From: Andrey Smirnov To: linux-iio@vger.kernel.org Cc: Andrey Smirnov , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Chris Healy , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] iio: imx7d_adc: Drop imx7d_adc_remove() Date: Wed, 3 Apr 2019 00:03:25 -0700 Message-Id: <20190403070325.1077-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403070325.1077-1-andrew.smirnov@gmail.com> References: <20190403070325.1077-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 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 Since imx7d_adc_remove() does exactly the same thing as imx7d_adc_suspend() we can use the latter together with devm_add_action_or_reset() to get rid of the former. Signed-off-by: Andrey Smirnov Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Chris Healy Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/iio/adc/imx7d_adc.c | 55 ++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index c2fa0ab923ee..ed95909eada2 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -461,6 +461,24 @@ static int imx7d_adc_resume(struct device *dev) return 0; } +static int imx7d_adc_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct imx7d_adc *info = iio_priv(indio_dev); + + imx7d_adc_power_down(info); + + clk_disable_unprepare(info->clk); + regulator_disable(info->vref); + + return 0; +} + +static void __imx7d_adc_suspend(void *data) +{ + imx7d_adc_suspend(data); +} + static int imx7d_adc_probe(struct platform_device *pdev) { struct imx7d_adc *info; @@ -506,8 +524,6 @@ static int imx7d_adc_probe(struct platform_device *pdev) return ret; } - platform_set_drvdata(pdev, indio_dev); - init_completion(&info->completion); indio_dev->name = dev_name(dev); @@ -531,11 +547,13 @@ static int imx7d_adc_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(dev, __imx7d_adc_suspend, + &indio_dev->dev); + if (ret) + return ret; + ret = devm_iio_device_register(dev, indio_dev); if (ret) { - imx7d_adc_power_down(info); - clk_disable_unprepare(info->clk); - regulator_disable(info->vref); dev_err(&pdev->dev, "Couldn't register the device.\n"); return ret; } @@ -543,37 +561,10 @@ static int imx7d_adc_probe(struct platform_device *pdev) return 0; } -static int imx7d_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct imx7d_adc *info = iio_priv(indio_dev); - - imx7d_adc_power_down(info); - - clk_disable_unprepare(info->clk); - regulator_disable(info->vref); - - return 0; -} - -static int __maybe_unused imx7d_adc_suspend(struct device *dev) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct imx7d_adc *info = iio_priv(indio_dev); - - imx7d_adc_power_down(info); - - clk_disable_unprepare(info->clk); - regulator_disable(info->vref); - - return 0; -} - static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_suspend, imx7d_adc_resume); static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe, - .remove = imx7d_adc_remove, .driver = { .name = "imx7d_adc", .of_match_table = imx7d_adc_match,