From patchwork Sat Dec 31 14:20:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 37870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3365886wrt; Sat, 31 Dec 2022 06:26:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsxsNYLQNPPpMkOBj2l4eLDhNmbVyIlQjNMShQ5Av7XBPllYp2EV9+bKjnekq8ZFkQbpwq0 X-Received: by 2002:a17:907:d38c:b0:7c0:b0f9:e360 with SMTP id vh12-20020a170907d38c00b007c0b0f9e360mr29901621ejc.16.1672496812854; Sat, 31 Dec 2022 06:26:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672496812; cv=none; d=google.com; s=arc-20160816; b=LIWO1NuwdM4w2ZAZ37kQTyb/zOY5nU/Cyf+uK5Kwyg6kgyOxCCEVPr4WNu2VnBslgs D3+v6SJOaeUsiXLtTwaSHfG5eDAzgQKRXFYDwVpr2T8sQR7oKoV3TMKUxdHaP75OEafX /Bkn+1DENRYvApu0ZaV/9OP7ElhmXyP9Mu+XPhGWJnnaw2DUthY0jqjtSxOlH0c6AT3O kz3Ptd/OUjVkx4+FCZZJGTTCUDb+InanvMBymHDGRmCGI9zAWyO3jYuXyKDBEVNTvB7f OPwp5NRytjiwu7zpBGQWEgzyNTObaSQW0QWCltxQXYJ034b4ogM4XR3PBR6SOfgqYyl8 cDlw== 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=1Cpi8HDRLIVFjAHXWfiwawt7I1q3qc2y1FL9aywp77A=; b=B/Pxavrl/NcDB8HF8qSXXMwXY9Q6MpeJkSezntzrOu2KSUSNdmEc9jm6tYJhH0uklq QwgZ+O4Wi6m35q6kpZT5Mee6SX/jdJI36stU2NygPWwWxQtlPEB9sdnx1rWjcMH+cXv8 z0ApAzRGBr1iv3uxSUtVUzUkJbBzXMbStAmwIz1+FNbqUfwPaxMbwUKp3Iu2qpUJd4FA z62rfxwNww3ExRas/m82d8wMCNInjPdWY4Cus3jX7BXJM6Fwx7x1cfT1naPric+CX9eG WWEPPPXbUZusbrmrL54Ne8Px7BCVSzyUWE/rxFUT0yFLUIj1gWufsYgxTrymyQ1P1YsU VJjA== 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 mp30-20020a1709071b1e00b007c10d4cc297si19437181ejc.85.2022.12.31.06.26.28; Sat, 31 Dec 2022 06:26:52 -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 S230477AbiLaOUi (ORCPT + 99 others); Sat, 31 Dec 2022 09:20:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiLaOUg (ORCPT ); Sat, 31 Dec 2022 09:20:36 -0500 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D54DD2FD for ; Sat, 31 Dec 2022 06:20:34 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BcitpDw3rLrOWBcitp3DP1; Sat, 31 Dec 2022 15:20:32 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 15:20:32 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: 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: pic32-dmt: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 15:20:29 +0100 Message-Id: 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?1753740018130733873?= X-GMAIL-MSGID: =?utf-8?q?1753740018130733873?= 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 --- drivers/watchdog/pic32-dmt.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/watchdog/pic32-dmt.c b/drivers/watchdog/pic32-dmt.c index f43062b3c4c8..bc4ccddc75a3 100644 --- a/drivers/watchdog/pic32-dmt.c +++ b/drivers/watchdog/pic32-dmt.c @@ -164,11 +164,6 @@ static struct watchdog_device pic32_dmt_wdd = { .ops = &pic32_dmt_fops, }; -static void pic32_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static int pic32_dmt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -184,20 +179,12 @@ static int pic32_dmt_probe(struct platform_device *pdev) if (IS_ERR(dmt->regs)) return PTR_ERR(dmt->regs); - dmt->clk = devm_clk_get(dev, NULL); + dmt->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(dmt->clk)) { dev_err(dev, "clk not found\n"); return PTR_ERR(dmt->clk); } - ret = clk_prepare_enable(dmt->clk); - if (ret) - return ret; - ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, - dmt->clk); - if (ret) - return ret; - wdd->timeout = pic32_dmt_get_timeout_secs(dmt); if (!wdd->timeout) { dev_err(dev, "failed to read watchdog register timeout\n");