linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Jinjie Ruan <ruanjinjie@huawei.com>,
	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, xt.hu@cqplus1.com
Subject: Re: [PATCH -next 1/3] watchdog: at91sam9_wdt: Use the devm_clk_get_enabled() helper function
Date: Fri, 25 Aug 2023 07:15:07 +0300	[thread overview]
Message-ID: <5d16a423-b184-4c5c-ad55-06e34811ca9a@tuxon.dev> (raw)
In-Reply-To: <20230824135514.2661364-2-ruanjinjie@huawei.com>



On 8/24/23 16:55, Jinjie Ruan 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.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>

> ---
>  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;
>  }

      parent reply	other threads:[~2023-08-25  4:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 15:47   ` Guenter Roeck
2023-08-24 13:55 ` [PATCH -next 3/3] watchdog: sunplus: " Jinjie Ruan
2023-08-24 15:47   ` Guenter Roeck
2023-08-24 15:46 ` [PATCH -next 1/3] watchdog: at91sam9_wdt: " Guenter Roeck
2023-08-25  4:15 ` claudiu beznea [this message]

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=5d16a423-b184-4c5c-ad55-06e34811ca9a@tuxon.dev \
    --to=claudiu.beznea@tuxon.dev \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nicolas.ferre@microchip.com \
    --cc=ruanjinjie@huawei.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).