From patchwork Sat Dec 31 12:57:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13086042 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 10263C3DA7D for ; Sat, 31 Dec 2022 12:59:01 +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=PdCUMsnlKNmxHZ7MhaUODgeUg9fGBEa23OkWd/+H2sM=; b=TocKWmyBgpBILx eBd5fHKyx4ljU8gKDAbcJN4bA19W2Z6/XkvfEHCHkt0WXG/NGyWxNMSd4ifAe3MQGAYOYWic/d8d0 R/SDC6wjfrblj+MHnI5SsnNvA58H1DfzGfbhfOefxvkMTQh2VvqLKhhVO0JyizXcu1SNmFPowjTQA PagS9htXGrx7TyoapP6gxZFpTifvMvAffFiHhBEPi1OhZnkaur7PLaTZCPjd2btQCW1HG8qaj7L8Y j3o4X61Jzw0zXCDk3zltMewDBhlNBdmzE6fjmsAEsZEl/+w0LBoUdDDwK93ohXC2tcEUfmq1rKOp7 V9nR+cB13brSRIq2WoXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBbR1-005TJ7-D8; Sat, 31 Dec 2022 12:57:59 +0000 Received: from smtp-25.smtpout.orange.fr ([80.12.242.25] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pBbQw-005THj-Uf for linux-arm-kernel@lists.infradead.org; Sat, 31 Dec 2022 12:57:56 +0000 Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BbQup0AJWtht4BbQupzILR; Sat, 31 Dec 2022 13:57:53 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 13:57:53 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Wim Van Sebroeck , Guenter Roeck , Michal Simek Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] watchdog: of_xilinx_wdt: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 13:57:49 +0100 Message-Id: <2b041dc8230a4ed255051bb2d323da8a51a8d0be.1672491445.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-20221231_045755_168835_20BBA467 X-CRM114-Status: GOOD ( 11.08 ) 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 Acked-by: Michal Simek Reviewed-by: Guenter Roeck --- V2: remove xwdt_clk_disable_unprepare() as-well Note that the order of operations is slightly modified by this patch. The clk is now prepare_enable()'ed before calling clk_get_rate(). --- drivers/watchdog/of_xilinx_wdt.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index 3318544366b8..2a079ca04aa3 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -154,11 +154,6 @@ static u32 xwdt_selftest(struct xwdt_device *xdev) return XWT_TIMER_FAILED; } -static void xwdt_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static int xwdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -193,7 +188,7 @@ static int xwdt_probe(struct platform_device *pdev) watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); - xdev->clk = devm_clk_get(dev, NULL); + xdev->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(xdev->clk)) { if (PTR_ERR(xdev->clk) != -ENOENT) return PTR_ERR(xdev->clk); @@ -211,15 +206,6 @@ static int xwdt_probe(struct platform_device *pdev) "The watchdog clock freq cannot be obtained\n"); } else { pfreq = clk_get_rate(xdev->clk); - rc = clk_prepare_enable(xdev->clk); - if (rc) { - dev_err(dev, "unable to enable clock\n"); - return rc; - } - rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, - xdev->clk); - if (rc) - return rc; } /*