From: Jinjie Ruan <ruanjinjie@huawei.com> To: <linux-watchdog@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <wim@linux-watchdog.org>, <linux@roeck-us.net>, <nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>, <claudiu.beznea@tuxon.dev>, <xt.hu@cqplus1.com> Cc: <ruanjinjie@huawei.com> Subject: [PATCH -next 1/3] watchdog: at91sam9_wdt: Use the devm_clk_get_enabled() helper function Date: Thu, 24 Aug 2023 21:55:12 +0800 [thread overview] Message-ID: <20230824135514.2661364-2-ruanjinjie@huawei.com> (raw) 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. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- drivers/watchdog/at91sam9_wdt.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index fed7be246442..b111b28acb94 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -348,25 +348,21 @@ static int __init at91wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); - wdt->sclk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(wdt->sclk)) - return PTR_ERR(wdt->sclk); - - err = clk_prepare_enable(wdt->sclk); - if (err) { + wdt->sclk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(wdt->sclk)) { dev_err(&pdev->dev, "Could not enable slow clock\n"); - return err; + return PTR_ERR(wdt->sclk); } if (pdev->dev.of_node) { err = of_at91wdt_init(pdev->dev.of_node, wdt); if (err) - goto err_clk; + return err; } err = at91_wdt_init(pdev, wdt); if (err) - goto err_clk; + return err; platform_set_drvdata(pdev, wdt); @@ -374,11 +370,6 @@ static int __init at91wdt_probe(struct platform_device *pdev) wdt->wdd.timeout, wdt->nowayout); return 0; - -err_clk: - clk_disable_unprepare(wdt->sclk); - - return err; } static int __exit at91wdt_remove(struct platform_device *pdev) @@ -388,7 +379,6 @@ static int __exit at91wdt_remove(struct platform_device *pdev) pr_warn("I quit now, hardware will probably reboot!\n"); del_timer(&wdt->timer); - clk_disable_unprepare(wdt->sclk); return 0; } -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Jinjie Ruan <ruanjinjie@huawei.com> To: <linux-watchdog@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <wim@linux-watchdog.org>, <linux@roeck-us.net>, <nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>, <claudiu.beznea@tuxon.dev>, <xt.hu@cqplus1.com> Cc: <ruanjinjie@huawei.com> Subject: [PATCH -next 1/3] watchdog: at91sam9_wdt: Use the devm_clk_get_enabled() helper function Date: Thu, 24 Aug 2023 21:55:12 +0800 [thread overview] Message-ID: <20230824135514.2661364-2-ruanjinjie@huawei.com> (raw) 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. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- drivers/watchdog/at91sam9_wdt.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index fed7be246442..b111b28acb94 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -348,25 +348,21 @@ static int __init at91wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); - wdt->sclk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(wdt->sclk)) - return PTR_ERR(wdt->sclk); - - err = clk_prepare_enable(wdt->sclk); - if (err) { + wdt->sclk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(wdt->sclk)) { dev_err(&pdev->dev, "Could not enable slow clock\n"); - return err; + return PTR_ERR(wdt->sclk); } if (pdev->dev.of_node) { err = of_at91wdt_init(pdev->dev.of_node, wdt); if (err) - goto err_clk; + return err; } err = at91_wdt_init(pdev, wdt); if (err) - goto err_clk; + return err; platform_set_drvdata(pdev, wdt); @@ -374,11 +370,6 @@ static int __init at91wdt_probe(struct platform_device *pdev) wdt->wdd.timeout, wdt->nowayout); return 0; - -err_clk: - clk_disable_unprepare(wdt->sclk); - - return err; } static int __exit at91wdt_remove(struct platform_device *pdev) @@ -388,7 +379,6 @@ static int __exit at91wdt_remove(struct platform_device *pdev) pr_warn("I quit now, hardware will probably reboot!\n"); del_timer(&wdt->timer); - clk_disable_unprepare(wdt->sclk); return 0; } -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-08-24 13:56 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-24 13:55 Jinjie Ruan [this message] 2023-08-24 13:55 ` [PATCH -next 1/3] watchdog: at91sam9_wdt: Use the devm_clk_get_enabled() helper function Jinjie Ruan 2023-08-24 13:55 ` [PATCH -next 2/3] watchdog: ath79_wdt: " Jinjie Ruan 2023-08-24 13:55 ` Jinjie Ruan 2023-08-24 15:47 ` Guenter Roeck 2023-08-24 15:47 ` Guenter Roeck 2023-08-24 13:55 ` [PATCH -next 3/3] watchdog: sunplus: " Jinjie Ruan 2023-08-24 13:55 ` Jinjie Ruan 2023-08-24 15:47 ` Guenter Roeck 2023-08-24 15:47 ` Guenter Roeck 2023-08-24 15:46 ` [PATCH -next 1/3] watchdog: at91sam9_wdt: " Guenter Roeck 2023-08-24 15:46 ` Guenter Roeck 2023-08-25 4:15 ` claudiu beznea 2023-08-25 4:15 ` claudiu beznea
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230824135514.2661364-2-ruanjinjie@huawei.com \ --to=ruanjinjie@huawei.com \ --cc=alexandre.belloni@bootlin.com \ --cc=claudiu.beznea@tuxon.dev \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-watchdog@vger.kernel.org \ --cc=linux@roeck-us.net \ --cc=nicolas.ferre@microchip.com \ --cc=wim@linux-watchdog.org \ --cc=xt.hu@cqplus1.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.