From patchwork Tue Apr 18 20:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13216137 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 EBBE5C77B75 for ; Tue, 18 Apr 2023 20:21:22 +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=/0upjRBtR5pGOUW2gOyc7uPlM+Udg98FCjFTshk62lY=; b=WfiKHNRBwSAvX6 iXMcb9cf21RLU/wfwmeXYwNztDYx80Ix6L3MpfiX2DmyzpytmYZI1KzUGYssbPlorQOoU88FBC9Af iJx6ugPwzj+2wL5RxLsFhxwburjZKEX31Y+DLcaoVGyY084ySlpUH3NWdxEOS4S9f+kU6aQQQW2NX ui/mDug7FxHdU+B/DiKv7mn64vLojFCPErN4r3IRlOBUgmikrhwia+xbkNKb2NLr/iR8UtQe0wQsk N4HwjJd9FznP9/dncw/gOBGeYD982I8IFZvqjidvHFQZZ47xDRIz8rFr7Wm/bz76TLqNIxGXYJ9Ur n8aBKdroqic31aziNVzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1porpC-003Gh2-0y; Tue, 18 Apr 2023 20:21:14 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1porp9-003Gfr-2V for linux-riscv@lists.infradead.org; Tue, 18 Apr 2023 20:21:13 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1porp3-00015Z-5c; Tue, 18 Apr 2023 22:21:05 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1porp1-00CBOu-S9; Tue, 18 Apr 2023 22:21:03 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1porp1-00EKQX-7N; Tue, 18 Apr 2023 22:21:03 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Palmer Dabbelt , Paul Walmsley , Thierry Reding Cc: linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH] pwm: sifive: Simplify using devm_clk_get_prepared() Date: Tue, 18 Apr 2023 22:21:02 +0200 Message-Id: <20230418202102.117658-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1550; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=NYxZWUDL6nqiY43zsSH7XZr/b16Ctti/9W/FJz0Ev7A=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBkPvutB00RQEQfGSGcQrUwuEACxMe9MCrSPmiH0 NPEB58pXAWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZD77rQAKCRCPgPtYfRL+ Tvb8CACjjgcTK4kMt/9A7UXWDyzc0XLdesSwzd5wx1e2NnXtckUcrIezj7JlWsHxA6/Rl9qyuM2 vJU4CDn2dB4USGlC1t9RmYgd2tOxhd4hU8bBtOeTZ6Nj/vFK5NsDXnTF6rwDgBhpSMVbl17IxN2 l9l5d+QGXtDLlmb9kvRvDDQK0zC1p0QxlHx4bTVhc6glYXYDC3M5EyvUdeaFUgktG7uvSt4ra+k bejXUd7AXfM/WobXW90sehZAzjapj+bzFU/g9GE0lE/F1Rx6JzUYWhf4iQQonuXzTG5MY3W+DEO KsQBzbulbaZhlXiJDHI0ZFzZNWQp0BGPplUppGszqWe0nmax X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_132111_831975_E324E1AB X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Instead of preparing the clk after it was requested and unpreparing in .probe()'s error path and .remove(), use devm_clk_get_prepared() which copes for unpreparing automatically. Signed-off-by: Uwe Kleine-König Reviewed-by: Emil Renner Berthing --- drivers/pwm/pwm-sifive.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) base-commit: 247ee6c780406513c6031a7f4ea41f1648b03295 diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 5b0574f635f6..ae49d67ab2b1 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -244,12 +244,12 @@ static int pwm_sifive_probe(struct platform_device *pdev) if (IS_ERR(ddata->regs)) return PTR_ERR(ddata->regs); - ddata->clk = devm_clk_get(dev, NULL); + ddata->clk = devm_clk_get_prepared(dev, NULL); if (IS_ERR(ddata->clk)) return dev_err_probe(dev, PTR_ERR(ddata->clk), "Unable to find controller clock\n"); - ret = clk_prepare_enable(ddata->clk); + ret = clk_enable(ddata->clk); if (ret) { dev_err(dev, "failed to enable clock for pwm: %d\n", ret); return ret; @@ -308,7 +308,6 @@ static int pwm_sifive_probe(struct platform_device *pdev) clk_disable(ddata->clk); --enabled_clks; } - clk_unprepare(ddata->clk); return ret; } @@ -327,8 +326,6 @@ static void pwm_sifive_remove(struct platform_device *dev) if (pwm->state.enabled) clk_disable(ddata->clk); } - - clk_unprepare(ddata->clk); } static const struct of_device_id pwm_sifive_of_match[] = {