From patchwork Fri Aug 18 09:33:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13357553 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F908C678DC for ; Fri, 18 Aug 2023 09:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ukHfrDnXDPRibXwEBjMdnGmV4KpyVYTxbfHIthFGWsk=; b=1RPbaaFKqTkcNF KHe6izBW8j0ygGDYgSzmHiXh0r/iHyuIUUfgF/7gvOMP7sh0rhDOZA2W5TpCJ/tL5Gd02ICfLe6ZS hxs3Y3dv2JkioYoF95PPlupPWGK27Cimd6EUtiQg4eIEbIEnIB3o2/x62I9zbgKZM7uqMr4zREHxX aECGSeuuSZDOOeowGdwtj+i61IeGE2/5Bd6wG3XOg0xUaGdIyrxHLBBA5ba2Fi7jdoWVImphOSqIV WmlDhPCeeBuM6CX12WFW1/6dXkK9JmrFU/S9X1L2ukDz0hrYFvNk92fDJ0GnFXYHLgf9AjVVBC2Sp LhbjqJMwvPLsA2lYAFBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWvrl-0086Yp-0V; Fri, 18 Aug 2023 09:34:01 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWvrh-0086YN-2y for linux-arm-kernel@lists.infradead.org; Fri, 18 Aug 2023 09:33:59 +0000 Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RRxVM0J1VzkXDk; Fri, 18 Aug 2023 17:32:27 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 18 Aug 2023 17:33:50 +0800 From: Ruan Jinjie To: , , Lee Jones , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam CC: Subject: [PATCH -next] mfd: mxs-lradc: Use the devm_clk_get_enabled() helper function Date: Fri, 18 Aug 2023 17:33:08 +0800 Message-ID: <20230818093309.1053544-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230818_023358_250587_84E78D49 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With devm_clk_get_enabled() the call to clk_disable_unprepare() can be dropped from the error path and the remove callback. Signed-off-by: Ruan Jinjie --- drivers/mfd/mxs-lradc.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/mfd/mxs-lradc.c b/drivers/mfd/mxs-lradc.c index 111d11fd25aa..6d6d417bad5a 100644 --- a/drivers/mfd/mxs-lradc.c +++ b/drivers/mfd/mxs-lradc.c @@ -144,16 +144,10 @@ static int mxs_lradc_probe(struct platform_device *pdev) lradc->soc = (enum mxs_lradc_id)of_id->data; - lradc->clk = devm_clk_get(&pdev->dev, NULL); + lradc->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(lradc->clk)) { - dev_err(dev, "Failed to get the delay unit clock\n"); - return PTR_ERR(lradc->clk); - } - - ret = clk_prepare_enable(lradc->clk); - if (ret) { dev_err(dev, "Failed to enable the delay unit clock\n"); - return ret; + return PTR_ERR(lradc->clk); } ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", @@ -177,8 +171,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Unsupported number of touchscreen wires (%d)\n" , ts_wires); - ret = -EINVAL; - goto err_clk; + return -EINVAL; } } else { lradc->buffer_vchans = BUFFER_VCHANS_ALL; @@ -187,10 +180,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, lradc); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENOMEM; - goto err_clk; - } + if (!res) + return -ENOMEM; switch (lradc->soc) { case IMX23_LRADC: @@ -205,15 +196,14 @@ static int mxs_lradc_probe(struct platform_device *pdev) break; default: dev_err(dev, "Unsupported SoC\n"); - ret = -ENODEV; - goto err_clk; + return -ENODEV; } ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, &cells[ADC_CELL], 1, NULL, 0, NULL); if (ret) { dev_err(&pdev->dev, "Failed to add the ADC subdevice\n"); - goto err_clk; + return ret; } if (!lradc->touchscreen_wire) @@ -224,23 +214,14 @@ static int mxs_lradc_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "Failed to add the touchscreen subdevice\n"); - goto err_clk; + return ret; } return 0; - -err_clk: - clk_disable_unprepare(lradc->clk); - - return ret; } static int mxs_lradc_remove(struct platform_device *pdev) { - struct mxs_lradc *lradc = platform_get_drvdata(pdev); - - clk_disable_unprepare(lradc->clk); - return 0; }