From patchwork Sat Dec 31 07:57:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13085979 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 CD54BC4332F for ; Sat, 31 Dec 2022 07:59:24 +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=POiC17ey7nDmCrVBCGH3iIvlnRJgRbx4rIbEn2Rq68A=; b=OBriwGY5R31iW9 ZS0ku0XwGV3dgk/O4tIaoNNzCtMsGX+P+O+YCXQnsITZMv9ML4NlKskLEAyYG44n/4M3R2lLnQi9C nvCIZ/pOUfIlXBg5dWtm7VFqo6k7Vv3uL8R0H6lFnKDiS9M6IHQwJ7hR1kyKurbTe3SqwGD37cppA asrsciHH3tAI4qPGQvnJo2W/dL9r5a/w6kqa4i/THhSLNwBfaf8VOyWioyih/boMLLCVNNsr393l3 kfELHun3JjPRHdtvsO9oWg4TtfGsxXaX4wrDMHIVmm/pJLQxxZ/agLGPts4obeEKxGs4kkWcYUG8P ZQ61cIQVZBFQeWhbM8OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBWkg-0028dM-BA; Sat, 31 Dec 2022 07:57:58 +0000 Received: from smtp-30.smtpout.orange.fr ([80.12.242.30] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBWkM-0028JU-1t for linux-arm-kernel@lists.infradead.org; Sat, 31 Dec 2022 07:57:41 +0000 Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BWk7pnAnoSTJGBWk7p3vlM; Sat, 31 Dec 2022 08:57:30 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 08:57:30 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Hector Martin , Sven Peter , Alyssa Rosenzweig , Wim Van Sebroeck , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org Subject: [PATCH] watchdog: apple: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 08:57:22 +0100 Message-Id: <6f312af6160d1e10b616c9adbd1fd8f822db964d.1672473415.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221230_235738_336686_88B0D9EA X-CRM114-Status: GOOD ( 10.25 ) 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 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 Reviewed-by: Guenter Roeck Reviewed-by: Sven Peter --- drivers/watchdog/apple_wdt.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/watchdog/apple_wdt.c b/drivers/watchdog/apple_wdt.c index 16aca21f13d6..eddeb0fede89 100644 --- a/drivers/watchdog/apple_wdt.c +++ b/drivers/watchdog/apple_wdt.c @@ -136,11 +136,6 @@ static int apple_wdt_restart(struct watchdog_device *wdd, unsigned long mode, return 0; } -static void apple_wdt_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static struct watchdog_ops apple_wdt_ops = { .owner = THIS_MODULE, .start = apple_wdt_start, @@ -162,7 +157,6 @@ static int apple_wdt_probe(struct platform_device *pdev) struct apple_wdt *wdt; struct clk *clk; u32 wdt_ctrl; - int ret; wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) @@ -172,19 +166,9 @@ static int apple_wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->regs)) return PTR_ERR(wdt->regs); - clk = devm_clk_get(dev, NULL); + clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(clk)) return PTR_ERR(clk); - - ret = clk_prepare_enable(clk); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, apple_wdt_clk_disable_unprepare, - clk); - if (ret) - return ret; - wdt->clk_rate = clk_get_rate(clk); if (!wdt->clk_rate) return -EINVAL;