From patchwork Sat Dec 31 14:22:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 37869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3365612wrt; Sat, 31 Dec 2022 06:26:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXveNqJ4j1juckDH6+ih0l770WhqrRJ+H5DGiwCGluItUDfgrBJ9VxEbu2E5EfeEz/7WA0GI X-Received: by 2002:a50:9f09:0:b0:467:4df0:718c with SMTP id b9-20020a509f09000000b004674df0718cmr30864855edf.9.1672496769990; Sat, 31 Dec 2022 06:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672496769; cv=none; d=google.com; s=arc-20160816; b=bOlQnmFHlH5t//X1pndiaPQZugDB38I5O044+fuZdU1Rr6j3PjXsRZTz4FMl3YKlwI 7OgqHlbGxyCtRCa1MOux8cu7BxrOzVUgLMLo6XL4YaqhFtIJ+ep2AJpNh8SKrGO6c0c5 zhjzddh8FVg2D9KnZf2ZtXI7TctA5KXQGZjd8qA7bMgPHFOYE4E25HiLzrmQlY0/43Vw RdUXQjYdaBjFIsZeLRASDeOuGubeWCTy2pUOwstXVVzMKh3d+G1MIHuelOHy829wbE0Z nOLKvOT9XmDd07kVcurBMFbZImlRkz+clUSt/7gTPEPrHC5HxRpKP8Py7bU/y27y+6HG 5Zkw== 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=p/XHqGdejqDF02kWfB/s6XnDctBBa3hpgCg4lQWIZL8=; b=t7syM9R/gUCF1dmoOspPYC8GirXZTFC5VtLbhyW69M1/uUSngYJEj7fC47yUNboYbq X1SdmAp7v70pGbU1qvm3rvjRLARfGI4OA47IE6l5bJHHsmpuf7Ij2G9gvzmyNsSuokOg 2WJ58ieabziNPQIIa3BQdPkzo+x+adD4gP1J+sUc1Qjb95atJVqeV8F7jnbJ5jgivHct hSdU7Yvaj+L4yAxHY0PLs/0zWPzuRP/jfcM1Ct1/VW9gCClZ7LWQ8tEP0ie2uCvvrQP6 VRAx5WPCv/5thXrF8kWeFXstvhjuA1dlxa1K7ir4JYtDbRzgmr6eVhtuf4HwlktVBFBT V9kg== 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 sd40-20020a1709076e2800b00841e8b0d992si21295644ejc.77.2022.12.31.06.25.46; Sat, 31 Dec 2022 06:26:09 -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 S229486AbiLaOXD (ORCPT + 99 others); Sat, 31 Dec 2022 09:23:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiLaOXC (ORCPT ); Sat, 31 Dec 2022 09:23:02 -0500 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F112D10A4 for ; Sat, 31 Dec 2022 06:23:00 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BclGp4iYmTOlqBclGpfRCi; Sat, 31 Dec 2022 15:22:59 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 15:22:59 +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-wdt: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 15:22:57 +0100 Message-Id: <4335b4201b535ebc749a98bad0b99e3cb5317c39.1672496563.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?1753739972700716171?= X-GMAIL-MSGID: =?utf-8?q?1753739972700716171?= 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-wdt.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/watchdog/pic32-wdt.c b/drivers/watchdog/pic32-wdt.c index 41715d68d9e9..6d1a00222991 100644 --- a/drivers/watchdog/pic32-wdt.c +++ b/drivers/watchdog/pic32-wdt.c @@ -162,11 +162,6 @@ static const struct of_device_id pic32_wdt_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, pic32_wdt_dt_ids); -static void pic32_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static int pic32_wdt_drv_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -186,22 +181,12 @@ static int pic32_wdt_drv_probe(struct platform_device *pdev) if (!wdt->rst_base) return -ENOMEM; - wdt->clk = devm_clk_get(dev, NULL); + wdt->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(wdt->clk)) { dev_err(dev, "clk not found\n"); return PTR_ERR(wdt->clk); } - ret = clk_prepare_enable(wdt->clk); - if (ret) { - dev_err(dev, "clk enable failed\n"); - return ret; - } - ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, - wdt->clk); - if (ret) - return ret; - if (pic32_wdt_is_win_enabled(wdt)) { dev_err(dev, "windowed-clear mode is not supported.\n"); return -ENODEV;