public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 5/7] wdt: dw: Free the clock on error
Date: Wed, 9 Sep 2020 16:57:22 -0400	[thread overview]
Message-ID: <e182feae-f096-cea5-a0e8-6c9cff2ea9c6@gmail.com> (raw)
In-Reply-To: <20200901200758.543851-6-seanga2@gmail.com>

On 9/1/20 4:07 PM, Sean Anderson wrote:
> The clock subsystem requires that clk_free be called on clocks obtained via
> clk_get_*.
> 
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> 
> (no changes since v1)
> 
>  drivers/watchdog/designware_wdt.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
> index e6f5437056..189d555f29 100644
> --- a/drivers/watchdog/designware_wdt.c
> +++ b/drivers/watchdog/designware_wdt.c
> @@ -131,11 +131,13 @@ static int designware_wdt_probe(struct udevice *dev)
>  
>  	ret = clk_enable(&clk);
>  	if (ret)
> -		return ret;
> +		goto err;
>  
>  	priv->clk_khz = clk_get_rate(&clk) / 1000;
> -	if (!priv->clk_khz)
> -		return -EINVAL;
> +	if (!priv->clk_khz) {
> +		ret = -EINVAL;
> +		goto err;
> +	}
>  #else
>  	priv->clk_khz = CONFIG_DW_WDT_CLOCK_KHZ;
>  #endif
> @@ -145,15 +147,20 @@ static int designware_wdt_probe(struct udevice *dev)
>  
>  		ret = reset_get_bulk(dev, &resets);
>  		if (ret)
> -			return ret;
> +			goto err;
>  
>  		ret = reset_deassert_bulk(&resets);
>  		if (ret)
> -			return ret;
> +			goto err;
>  	}
>  
>  	/* reset to disable the watchdog */
>  	return designware_wdt_stop(dev);
> +
> +err:
> +	if (CONFIG_IS_ENABLED(CLK))

This should be an #if. Found by running CI at

https://dev.azure.com/seanga2/u-boot/_build/results?buildId=26&view=logs&jobId=673723c4-497f-506b-4750-995fcb7877b8&j=673723c4-497f-506b-4750-995fcb7877b8&t=b5278753-2bf3-55ba-a142-eaf3481f5b3e

Will be fixed in v4.

--Sean

> +		clk_free(&clk);
> +	return ret;
>  }
>  
>  static const struct wdt_ops designware_wdt_ops = {
> 

  reply	other threads:[~2020-09-09 20:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 20:07 [PATCH v3 0/7] wdt: Add support for watchdogs on Kendryte K210 Sean Anderson
2020-09-01 20:07 ` [PATCH v3 1/7] wdt: dw: Switch to using fls for log2 Sean Anderson
2020-09-07  1:43   ` Simon Glass
2020-09-01 20:07 ` [PATCH v3 2/7] wdt: dw: Switch to if(CONFIG()) instead of using #if Sean Anderson
2020-09-01 20:07 ` [PATCH v3 3/7] wdt: dw: Fix clock rate being off by 1000 Sean Anderson
2020-09-01 20:07 ` [PATCH v3 4/7] wdt: dw: Enable the clock before using it Sean Anderson
2020-09-01 20:07 ` [PATCH v3 5/7] wdt: dw: Free the clock on error Sean Anderson
2020-09-09 20:57   ` Sean Anderson [this message]
2020-09-01 20:07 ` [PATCH v3 6/7] riscv: Add watchdog bindings for the k210 Sean Anderson
2020-09-01 20:07 ` [PATCH v3 7/7] riscv: Enable watchdog " Sean Anderson
2020-09-07  1:43   ` Simon Glass
2020-09-09 20:35 ` [PATCH v3 0/7] wdt: Add support for watchdogs on Kendryte K210 Sean Anderson

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=e182feae-f096-cea5-a0e8-6c9cff2ea9c6@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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