From patchwork Sat Dec 31 08:00:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 638706 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 DB46BC4167B for ; Sat, 31 Dec 2022 08:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbiLaIAh (ORCPT ); Sat, 31 Dec 2022 03:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbiLaIAg (ORCPT ); Sat, 31 Dec 2022 03:00:36 -0500 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB08CE0C for ; Sat, 31 Dec 2022 00:00:35 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BWnApyjIetht4BWnBpyodI; Sat, 31 Dec 2022 09:00:33 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 09:00:33 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: =?utf-8?q?Marek_Beh=C3=BAn?= , Wim Van Sebroeck , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-watchdog@vger.kernel.org Subject: [PATCH] watchdog: armada_37xx: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 09:00:31 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the need of a dedicated function used with devm_add_action_or_reset(). Signed-off-by: Christophe JAILLET --- drivers/watchdog/armada_37xx_wdt.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c index ac9fed1ef681..e58652939f8a 100644 --- a/drivers/watchdog/armada_37xx_wdt.c +++ b/drivers/watchdog/armada_37xx_wdt.c @@ -246,11 +246,6 @@ static const struct watchdog_ops armada_37xx_wdt_ops = { .get_timeleft = armada_37xx_wdt_get_timeleft, }; -static void armada_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static int armada_37xx_wdt_probe(struct platform_device *pdev) { struct armada_37xx_watchdog *dev; @@ -280,18 +275,10 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev) return -ENOMEM; /* init clock */ - dev->clk = devm_clk_get(&pdev->dev, NULL); + dev->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dev->clk)) return PTR_ERR(dev->clk); - ret = clk_prepare_enable(dev->clk); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, - armada_clk_disable_unprepare, dev->clk); - if (ret) - return ret; - dev->clk_rate = clk_get_rate(dev->clk); if (!dev->clk_rate) return -EINVAL;