Message ID | 624106aa86ef7e49f16b11b229528eabd63de8f7.1672485257.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3300483wrt; Sat, 31 Dec 2022 03:26:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXswewI5MGBC5bm7TaSlHgqQqWXOu30InGQUBpQIfeolETmMlPJw9K2c2Fb8Xok8GGRdMhnq X-Received: by 2002:a05:6a20:d013:b0:af:ae14:9ecb with SMTP id hu19-20020a056a20d01300b000afae149ecbmr35582210pzb.17.1672486000584; Sat, 31 Dec 2022 03:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672486000; cv=none; d=google.com; s=arc-20160816; b=KL/mLfaPkQiOYN04r9Ne6fist+8zt1xcXEufeWQK3ko3wOrJetNn96eSNHnqbkKXOl h3eaZhlFjRIMDvOc3ugJC0KcCIM7y/XXYf+SpLa4WmBKJ+FXhVhQVBs4rlsbUcORUG6t 73wY5Y1vOvEyUJJ/UvXbKN8JxGWMjokbCHRLTwcmvnrIFR4YkG2O5OqriY3Ub76Ckea1 INRzBopXDki7gKP7XuzG0GuYkY4tVpxfdXfjgbEwryHo88JBQWD0X23uvXVIvNf/NwYL N74kQETpDkx4CqSB/UIpTHJZd+9RVrmtihXtSVoBDu34yoJygqy98Fz99X7YmdR7gqGl bS4A== 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=uAWXF6eyCYgScFcE2UfNlr8vaPNSkdmmpVYpekzBCQo=; b=QSDdqZJAFZCg0OPpLrxiu2qb0NhJP0f/8lzLU0+duNlQ8jrY6dAmAqU2DXEC1QKUzQ wbhs5iUulQGwNnNd3qfPQYuGGbbL/KCD4eTpLkc5WeeLMcOttUAdlNt6PR3AaSTeq+pK Y7cnjqraEjcJiBpmQ5osZpbRnAHzL8XudGCGE655XO7U0wpZPsP6s3glYEnACl5hIye8 c5448z2oUs9eVLzGcoi2XxNv7gmqYK+tJ+0+jTxu3DlJ0SGG4HLmTDhnOKQjvdpBlgtl cNPNY9IHAx2WSAIoLpcn+CiTuthRGZXsTWUqojTWUC2GHE2IcIY/Q3xRbwTYn0nFQSCq khPA== 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 u14-20020a63790e000000b00499413885dasi15709414pgc.359.2022.12.31.03.26.26; Sat, 31 Dec 2022 03:26:40 -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 S235435AbiLaLOh (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Sat, 31 Dec 2022 06:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiLaLOg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 31 Dec 2022 06:14:36 -0500 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A090363F9 for <linux-kernel@vger.kernel.org>; Sat, 31 Dec 2022 03:14:35 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BZoupLWNG8ao3BZovp4Bzp; Sat, 31 Dec 2022 12:14:33 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 31 Dec 2022 12:14:33 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Keguang Zhang <keguang.zhang@gmail.com>, Wim Van Sebroeck <wim@linux-watchdog.org>, Guenter Roeck <linux@roeck-us.net> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-mips@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: [PATCH] watchdog: loongson1: Use devm_clk_get_enabled() helper Date: Sat, 31 Dec 2022 12:14:30 +0100 Message-Id: <624106aa86ef7e49f16b11b229528eabd63de8f7.1672485257.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753728680236417499?= X-GMAIL-MSGID: =?utf-8?q?1753728680236417499?= |
Series |
watchdog: loongson1: Use devm_clk_get_enabled() helper
|
|
Commit Message
Christophe JAILLET
Dec. 31, 2022, 11:14 a.m. UTC
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 <christophe.jaillet@wanadoo.fr>
---
Note that I get a compilation error because <loongson1.h> is not found on
my system (x86_64).
So I think that a "depends on LOONG<something>" in missing in a KConfig
file.
Fixing it could help compilation farms build-bots.
---
drivers/watchdog/loongson1_wdt.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
Comments
On Sat, Dec 31, 2022 at 12:14:30PM +0100, Christophe JAILLET wrote: > 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 <christophe.jaillet@wanadoo.fr> > --- > Note that I get a compilation error because <loongson1.h> is not found on > my system (x86_64). > So I think that a "depends on LOONG<something>" in missing in a KConfig > file. > > Fixing it could help compilation farms build-bots. Why would depends on MACH_LOONGSON32 be insufficient ? Not reviewing the series further until this is resolved. It looks like I am missing something serious. Guenter > --- > drivers/watchdog/loongson1_wdt.c | 17 +---------------- > 1 file changed, 1 insertion(+), 16 deletions(-) > > diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c > index bb3d075c0633..c55656cfb403 100644 > --- a/drivers/watchdog/loongson1_wdt.c > +++ b/drivers/watchdog/loongson1_wdt.c > @@ -79,11 +79,6 @@ static const struct watchdog_ops ls1x_wdt_ops = { > .set_timeout = ls1x_wdt_set_timeout, > }; > > -static void ls1x_clk_disable_unprepare(void *data) > -{ > - clk_disable_unprepare(data); > -} > - > static int ls1x_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -100,20 +95,10 @@ static int ls1x_wdt_probe(struct platform_device *pdev) > if (IS_ERR(drvdata->base)) > return PTR_ERR(drvdata->base); > > - drvdata->clk = devm_clk_get(dev, pdev->name); > + drvdata->clk = devm_clk_get_enabled(dev, pdev->name); > if (IS_ERR(drvdata->clk)) > return PTR_ERR(drvdata->clk); > > - err = clk_prepare_enable(drvdata->clk); > - if (err) { > - dev_err(dev, "clk enable failed\n"); > - return err; > - } > - err = devm_add_action_or_reset(dev, ls1x_clk_disable_unprepare, > - drvdata->clk); > - if (err) > - return err; > - > clk_rate = clk_get_rate(drvdata->clk); > if (!clk_rate) > return -EINVAL; > -- > 2.34.1 >
On Sat, Dec 31, 2022 at 12:14:30PM +0100, Christophe JAILLET wrote: > 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 <christophe.jaillet@wanadoo.fr> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > Note that I get a compilation error because <loongson1.h> is not found on > my system (x86_64). > So I think that a "depends on LOONG<something>" in missing in a KConfig > file. It has "depends on MACH_LOONGSON32" and is not expected to be buildable if MACH_LOONGSON32 is not selected. It builds just fine if MACH_LOONGSON32 is selected. Guenter > > Fixing it could help compilation farms build-bots. > --- > drivers/watchdog/loongson1_wdt.c | 17 +---------------- > 1 file changed, 1 insertion(+), 16 deletions(-) > > diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c > index bb3d075c0633..c55656cfb403 100644 > --- a/drivers/watchdog/loongson1_wdt.c > +++ b/drivers/watchdog/loongson1_wdt.c > @@ -79,11 +79,6 @@ static const struct watchdog_ops ls1x_wdt_ops = { > .set_timeout = ls1x_wdt_set_timeout, > }; > > -static void ls1x_clk_disable_unprepare(void *data) > -{ > - clk_disable_unprepare(data); > -} > - > static int ls1x_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -100,20 +95,10 @@ static int ls1x_wdt_probe(struct platform_device *pdev) > if (IS_ERR(drvdata->base)) > return PTR_ERR(drvdata->base); > > - drvdata->clk = devm_clk_get(dev, pdev->name); > + drvdata->clk = devm_clk_get_enabled(dev, pdev->name); > if (IS_ERR(drvdata->clk)) > return PTR_ERR(drvdata->clk); > > - err = clk_prepare_enable(drvdata->clk); > - if (err) { > - dev_err(dev, "clk enable failed\n"); > - return err; > - } > - err = devm_add_action_or_reset(dev, ls1x_clk_disable_unprepare, > - drvdata->clk); > - if (err) > - return err; > - > clk_rate = clk_get_rate(drvdata->clk); > if (!clk_rate) > return -EINVAL;
diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c index bb3d075c0633..c55656cfb403 100644 --- a/drivers/watchdog/loongson1_wdt.c +++ b/drivers/watchdog/loongson1_wdt.c @@ -79,11 +79,6 @@ static const struct watchdog_ops ls1x_wdt_ops = { .set_timeout = ls1x_wdt_set_timeout, }; -static void ls1x_clk_disable_unprepare(void *data) -{ - clk_disable_unprepare(data); -} - static int ls1x_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -100,20 +95,10 @@ static int ls1x_wdt_probe(struct platform_device *pdev) if (IS_ERR(drvdata->base)) return PTR_ERR(drvdata->base); - drvdata->clk = devm_clk_get(dev, pdev->name); + drvdata->clk = devm_clk_get_enabled(dev, pdev->name); if (IS_ERR(drvdata->clk)) return PTR_ERR(drvdata->clk); - err = clk_prepare_enable(drvdata->clk); - if (err) { - dev_err(dev, "clk enable failed\n"); - return err; - } - err = devm_add_action_or_reset(dev, ls1x_clk_disable_unprepare, - drvdata->clk); - if (err) - return err; - clk_rate = clk_get_rate(drvdata->clk); if (!clk_rate) return -EINVAL;