From patchwork Sat Dec 31 12:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 37841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3329759wrt; Sat, 31 Dec 2022 05:00:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzl2URB8zfja7tSBs9ct+wytFojT6rEFHGsuxnfhXVS/WxLVtwC1BfnK1NkkuLA5pEJCTU X-Received: by 2002:a05:6402:360f:b0:470:49a2:ad7d with SMTP id el15-20020a056402360f00b0047049a2ad7dmr32123418edb.25.1672491603157; Sat, 31 Dec 2022 05:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672491603; cv=none; d=google.com; s=arc-20160816; b=K2xo+5sO3k5StrdYqPZlL/ynm999m+IktvOiJFPnnEuk+tMEo/3SEJFAvTV3BfAepF r7h13JyJBUeYaFK+SguDwML3xWhbZcnJp/ky5IJ8kFMPG/P7vlbkZvrImOr581YRVirj Ds3NUg0tsJqjE6p0NC5CDapD6Z3KJWoZNlkDGs4uUWDMR3iMnhfctZW7yJM4mgIYrmnU ElZaIZi2o83FOeWaKSSJSyAS+sbIhENx4RiWLQDPr9UrEdUq+Sf2Ht0i2ny4Y4NzD4Pm dzLMKhEuukw5crs1IXYgUMDFRplmNd87ApsOgH9jm+9g4/eY0qx6kRUUK6JDZJBkKq82 yr9Q== 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=vZOA27rhw3ee9eNWAEDtfbr8MbmigNhFElXSmuUSIts=; b=FMnE7e1Anw3QMepNs/guIBuD3iHUYlDn37nLElye5RJmNaV71Luq8dmSJo4y03FPJH /Xed9QzqJ2uPoYuE6eC2L2zRl7uHa1QKnYlAnWhTPrPZfKbjiq6HEU2KXvF6sC9SPJ8H V0+eZDwG9KwUDi2dEphYsecRPegXg9iWPpEbQNdX+eJIio81/p+e215w9wbDKD/CUTbr xOHCUclhqGfLAKr9vBY7JwGfeN0oL1yOEzjBeAVeaz6xx4yNX1Dh79t4tqlH5O7ysR+d h95q3hBH4gYfIqnMh4LanQFRhsxbEacolyR/YDD0KTTI0Ec7qV+EIwMdv616GZYWaG8n EORA== 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 dz8-20020a0564021d4800b0046fc4297641si22973165edb.293.2022.12.31.04.59.39; Sat, 31 Dec 2022 05:00:03 -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 S231926AbiLaMva (ORCPT + 99 others); Sat, 31 Dec 2022 07:51:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbiLaMv2 (ORCPT ); Sat, 31 Dec 2022 07:51:28 -0500 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF95B632F for ; Sat, 31 Dec 2022 04:51:26 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BbKbp3t8uexdxBbKcp9m3w; Sat, 31 Dec 2022 13:51:25 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 13:51:25 +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] watchdog: of_xilinx_wdt: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 13:51:20 +0100 Message-Id: <71551233b18f57037be9e75d2d6428534d7572d3.1672491065.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=ham 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?1753734549262273234?= X-GMAIL-MSGID: =?utf-8?q?1753734555404822579?= 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 --- 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 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index 3318544366b8..f184843380a3 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -193,7 +193,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 +211,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; } /*