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: 37840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3329670wrt; Sat, 31 Dec 2022 04:59:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXtc0AuTflnwdRI7YmYu0hiJjNC7O8PKBaK6aSbMEbRkCanm8+xfs5XftMJYDKpCZVNj1y0f X-Received: by 2002:a17:906:f6c1:b0:7cd:ffd:51f2 with SMTP id jo1-20020a170906f6c100b007cd0ffd51f2mr37388821ejb.57.1672491590817; Sat, 31 Dec 2022 04:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672491590; cv=none; d=google.com; s=arc-20160816; b=e3+AoMEWrpWyBun0kAMul6AZZbSBjeq8EMPryMv0wTOpQu1zKCujp53VTXPyS3LOew db3MvgYzOcQnMHhl2bicKz66VEDEJ/hDxCDXcCEphoajLi7DBK6ZE2eXnh3fC/mTbX94 huk/muO1et6BT7Xl+dZniJANN0V0OnELUVMZoawxOORAlsWczkWOCJE3Fml2rRFEiIyD grMAPFuADLkDeHYW0GdE60inS2qkhvBKaNj7r93u+z8wxf0/CuY8akOHC54FDDz3rEhU vv+f7hfRPYHsYPaD/HFUuKKXCz0/YlJd0rgVx6Xuo1jmul8IjltuLFgLMtI98b4bv50P MCKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eNUCldOj9yLKKgAr97JnM+wCDDpPR9Erz2uq09RH0sA=; b=AiKdXYmawZMt0TyDElWRmzYRJsC0k69vuJO4rRqY3V7GG7UtIxIfvEchB3H+j6/b24 FiyoKUZYDtamaNGLwpweyyUEEerp5uYqOWvVucu1Y7SXT6ERuuEq6MiLYGqTg43yTC2w gcGuCNG0YniZg3Y/g8evMHBrzTc+gKKgZhQ3oJDFSvqGG0Xmb+Re/O0umikCOOE9J+yX T/n9pLacIBKaNLhAUbld4N1l/f8vBLddpgSJqCyCOGKiONgv9ttpP65PMFLNCwaZgN0v nYdK1Hp7z9bziiVGxVOmbYNKr+miywcqcx71SULEeWyxxfEOWH6cyyn4PZfyOB1S1Efh ekEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq6-20020a1709073f0600b0084c7031304dsi11206833ejc.624.2022.12.31.04.59.26; Sat, 31 Dec 2022 04:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235484AbiLaM55 (ORCPT + 99 others); Sat, 31 Dec 2022 07:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbiLaM5z (ORCPT ); Sat, 31 Dec 2022 07:57:55 -0500 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9462960E0 for ; Sat, 31 Dec 2022 04:57:54 -0800 (PST) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753734542226940798?= X-GMAIL-MSGID: =?utf-8?q?1753734542226940798?= 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; } /*