All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe()
@ 2023-04-26  6:52 Christophe JAILLET
  2023-04-26  6:52 ` [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Christophe JAILLET
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-04-26  6:52 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Philipp Zabel, Steffen Trumtrar
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	Wim Van Sebroeck, linux-watchdog

The commit in Fixes has only updated the remove function and missed the
error handling path of the probe.

Add the missing reset_control_assert() call.

Fixes: 65a3b6935d92 ("watchdog: dw_wdt: get reset lines from dt")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/watchdog/dw_wdt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 6f88bd81f8a1..a1354a59eb37 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -635,7 +635,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 
 	ret = dw_wdt_init_timeouts(dw_wdt, dev);
 	if (ret)
-		goto out_disable_clk;
+		goto out_assert_rst;
 
 	wdd = &dw_wdt->wdd;
 	wdd->ops = &dw_wdt_ops;
@@ -667,12 +667,15 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 
 	ret = watchdog_register_device(wdd);
 	if (ret)
-		goto out_disable_pclk;
+		goto out_assert_rst;
 
 	dw_wdt_dbgfs_init(dw_wdt);
 
 	return 0;
 
+out_assert_rst:
+	reset_control_assert(dw_wdt->rst);
+
 out_disable_pclk:
 	clk_disable_unprepare(dw_wdt->pclk);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] watchdog: dw_wdt: Simplify clk management
  2023-04-26  6:52 [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Christophe JAILLET
@ 2023-04-26  6:52 ` Christophe JAILLET
  2023-04-26 13:47   ` Guenter Roeck
  2023-04-26  7:32 ` [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Philipp Zabel
  2023-04-26 13:46 ` Guenter Roeck
  2 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2023-04-26  6:52 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-watchdog

Use devm_clk_get_enabled() instead of hand-writing it.
This saves some LoC.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This change the order the resources will be released, so review with care.
---
 drivers/watchdog/dw_wdt.c | 44 ++++++++++-----------------------------
 1 file changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index a1354a59eb37..84dca3695f86 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -566,22 +566,16 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	 * to the common timer/bus clocks configuration, in which the very
 	 * first found clock supply both timer and APB signals.
 	 */
-	dw_wdt->clk = devm_clk_get(dev, "tclk");
+	dw_wdt->clk = devm_clk_get_enabled(dev, "tclk");
 	if (IS_ERR(dw_wdt->clk)) {
-		dw_wdt->clk = devm_clk_get(dev, NULL);
+		dw_wdt->clk = devm_clk_get_enabled(dev, NULL);
 		if (IS_ERR(dw_wdt->clk))
 			return PTR_ERR(dw_wdt->clk);
 	}
 
-	ret = clk_prepare_enable(dw_wdt->clk);
-	if (ret)
-		return ret;
-
 	dw_wdt->rate = clk_get_rate(dw_wdt->clk);
-	if (dw_wdt->rate == 0) {
-		ret = -EINVAL;
-		goto out_disable_clk;
-	}
+	if (dw_wdt->rate == 0)
+		return -EINVAL;
 
 	/*
 	 * Request APB clock if device is configured with async clocks mode.
@@ -590,21 +584,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	 * so the pclk phandle reference is left optional. If it couldn't be
 	 * found we consider the device configured in synchronous clocks mode.
 	 */
-	dw_wdt->pclk = devm_clk_get_optional(dev, "pclk");
-	if (IS_ERR(dw_wdt->pclk)) {
-		ret = PTR_ERR(dw_wdt->pclk);
-		goto out_disable_clk;
-	}
-
-	ret = clk_prepare_enable(dw_wdt->pclk);
-	if (ret)
-		goto out_disable_clk;
+	dw_wdt->pclk = devm_clk_get_optional_enabled(dev, "pclk");
+	if (IS_ERR(dw_wdt->pclk))
+		return PTR_ERR(dw_wdt->pclk);
 
 	dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
-	if (IS_ERR(dw_wdt->rst)) {
-		ret = PTR_ERR(dw_wdt->rst);
-		goto out_disable_pclk;
-	}
+	if (IS_ERR(dw_wdt->rst))
+		return PTR_ERR(dw_wdt->rst);
 
 	/* Enable normal reset without pre-timeout by default. */
 	dw_wdt_update_mode(dw_wdt, DW_WDT_RMOD_RESET);
@@ -621,12 +607,12 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 				       IRQF_SHARED | IRQF_TRIGGER_RISING,
 				       pdev->name, dw_wdt);
 		if (ret)
-			goto out_disable_pclk;
+			return ret;
 
 		dw_wdt->wdd.info = &dw_wdt_pt_ident;
 	} else {
 		if (ret == -EPROBE_DEFER)
-			goto out_disable_pclk;
+			return ret;
 
 		dw_wdt->wdd.info = &dw_wdt_ident;
 	}
@@ -675,12 +661,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 
 out_assert_rst:
 	reset_control_assert(dw_wdt->rst);
-
-out_disable_pclk:
-	clk_disable_unprepare(dw_wdt->pclk);
-
-out_disable_clk:
-	clk_disable_unprepare(dw_wdt->clk);
 	return ret;
 }
 
@@ -692,8 +672,6 @@ static void dw_wdt_drv_remove(struct platform_device *pdev)
 
 	watchdog_unregister_device(&dw_wdt->wdd);
 	reset_control_assert(dw_wdt->rst);
-	clk_disable_unprepare(dw_wdt->pclk);
-	clk_disable_unprepare(dw_wdt->clk);
 }
 
 #ifdef CONFIG_OF
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe()
  2023-04-26  6:52 [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Christophe JAILLET
  2023-04-26  6:52 ` [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Christophe JAILLET
@ 2023-04-26  7:32 ` Philipp Zabel
  2023-04-26 13:46 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2023-04-26  7:32 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Wim Van Sebroeck, Guenter Roeck, Steffen Trumtrar, linux-kernel,
	kernel-janitors, Wim Van Sebroeck, linux-watchdog

Hi Christophe,

On Wed, Apr 26, 2023 at 08:52:48AM +0200, Christophe JAILLET wrote:
> The commit in Fixes has only updated the remove function and missed the
> error handling path of the probe.
> 
> Add the missing reset_control_assert() call.
> 
> Fixes: 65a3b6935d92 ("watchdog: dw_wdt: get reset lines from dt")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe()
  2023-04-26  6:52 [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Christophe JAILLET
  2023-04-26  6:52 ` [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Christophe JAILLET
  2023-04-26  7:32 ` [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Philipp Zabel
@ 2023-04-26 13:46 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2023-04-26 13:46 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Wim Van Sebroeck, Philipp Zabel, Steffen Trumtrar, linux-kernel,
	kernel-janitors, Wim Van Sebroeck, linux-watchdog

On Wed, Apr 26, 2023 at 08:52:48AM +0200, Christophe JAILLET wrote:
> The commit in Fixes has only updated the remove function and missed the
> error handling path of the probe.
> 
> Add the missing reset_control_assert() call.
> 
> Fixes: 65a3b6935d92 ("watchdog: dw_wdt: get reset lines from dt")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/dw_wdt.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index 6f88bd81f8a1..a1354a59eb37 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -635,7 +635,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  
>  	ret = dw_wdt_init_timeouts(dw_wdt, dev);
>  	if (ret)
> -		goto out_disable_clk;
> +		goto out_assert_rst;
>  
>  	wdd = &dw_wdt->wdd;
>  	wdd->ops = &dw_wdt_ops;
> @@ -667,12 +667,15 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  
>  	ret = watchdog_register_device(wdd);
>  	if (ret)
> -		goto out_disable_pclk;
> +		goto out_assert_rst;
>  
>  	dw_wdt_dbgfs_init(dw_wdt);
>  
>  	return 0;
>  
> +out_assert_rst:
> +	reset_control_assert(dw_wdt->rst);
> +
>  out_disable_pclk:
>  	clk_disable_unprepare(dw_wdt->pclk);
>  
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] watchdog: dw_wdt: Simplify clk management
  2023-04-26  6:52 ` [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Christophe JAILLET
@ 2023-04-26 13:47   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2023-04-26 13:47 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Wim Van Sebroeck, linux-kernel, kernel-janitors, linux-watchdog

On Wed, Apr 26, 2023 at 08:52:49AM +0200, Christophe JAILLET wrote:
> Use devm_clk_get_enabled() instead of hand-writing it.
> This saves some LoC.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> This change the order the resources will be released, so review with care.
> ---
>  drivers/watchdog/dw_wdt.c | 44 ++++++++++-----------------------------
>  1 file changed, 11 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
> index a1354a59eb37..84dca3695f86 100644
> --- a/drivers/watchdog/dw_wdt.c
> +++ b/drivers/watchdog/dw_wdt.c
> @@ -566,22 +566,16 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  	 * to the common timer/bus clocks configuration, in which the very
>  	 * first found clock supply both timer and APB signals.
>  	 */
> -	dw_wdt->clk = devm_clk_get(dev, "tclk");
> +	dw_wdt->clk = devm_clk_get_enabled(dev, "tclk");
>  	if (IS_ERR(dw_wdt->clk)) {
> -		dw_wdt->clk = devm_clk_get(dev, NULL);
> +		dw_wdt->clk = devm_clk_get_enabled(dev, NULL);
>  		if (IS_ERR(dw_wdt->clk))
>  			return PTR_ERR(dw_wdt->clk);
>  	}
>  
> -	ret = clk_prepare_enable(dw_wdt->clk);
> -	if (ret)
> -		return ret;
> -
>  	dw_wdt->rate = clk_get_rate(dw_wdt->clk);
> -	if (dw_wdt->rate == 0) {
> -		ret = -EINVAL;
> -		goto out_disable_clk;
> -	}
> +	if (dw_wdt->rate == 0)
> +		return -EINVAL;
>  
>  	/*
>  	 * Request APB clock if device is configured with async clocks mode.
> @@ -590,21 +584,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  	 * so the pclk phandle reference is left optional. If it couldn't be
>  	 * found we consider the device configured in synchronous clocks mode.
>  	 */
> -	dw_wdt->pclk = devm_clk_get_optional(dev, "pclk");
> -	if (IS_ERR(dw_wdt->pclk)) {
> -		ret = PTR_ERR(dw_wdt->pclk);
> -		goto out_disable_clk;
> -	}
> -
> -	ret = clk_prepare_enable(dw_wdt->pclk);
> -	if (ret)
> -		goto out_disable_clk;
> +	dw_wdt->pclk = devm_clk_get_optional_enabled(dev, "pclk");
> +	if (IS_ERR(dw_wdt->pclk))
> +		return PTR_ERR(dw_wdt->pclk);
>  
>  	dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
> -	if (IS_ERR(dw_wdt->rst)) {
> -		ret = PTR_ERR(dw_wdt->rst);
> -		goto out_disable_pclk;
> -	}
> +	if (IS_ERR(dw_wdt->rst))
> +		return PTR_ERR(dw_wdt->rst);
>  
>  	/* Enable normal reset without pre-timeout by default. */
>  	dw_wdt_update_mode(dw_wdt, DW_WDT_RMOD_RESET);
> @@ -621,12 +607,12 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  				       IRQF_SHARED | IRQF_TRIGGER_RISING,
>  				       pdev->name, dw_wdt);
>  		if (ret)
> -			goto out_disable_pclk;
> +			return ret;
>  
>  		dw_wdt->wdd.info = &dw_wdt_pt_ident;
>  	} else {
>  		if (ret == -EPROBE_DEFER)
> -			goto out_disable_pclk;
> +			return ret;
>  
>  		dw_wdt->wdd.info = &dw_wdt_ident;
>  	}
> @@ -675,12 +661,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
>  
>  out_assert_rst:
>  	reset_control_assert(dw_wdt->rst);
> -
> -out_disable_pclk:
> -	clk_disable_unprepare(dw_wdt->pclk);
> -
> -out_disable_clk:
> -	clk_disable_unprepare(dw_wdt->clk);
>  	return ret;
>  }
>  
> @@ -692,8 +672,6 @@ static void dw_wdt_drv_remove(struct platform_device *pdev)
>  
>  	watchdog_unregister_device(&dw_wdt->wdd);
>  	reset_control_assert(dw_wdt->rst);
> -	clk_disable_unprepare(dw_wdt->pclk);
> -	clk_disable_unprepare(dw_wdt->clk);
>  }
>  
>  #ifdef CONFIG_OF
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-26 13:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26  6:52 [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Christophe JAILLET
2023-04-26  6:52 ` [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Christophe JAILLET
2023-04-26 13:47   ` Guenter Roeck
2023-04-26  7:32 ` [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Philipp Zabel
2023-04-26 13:46 ` Guenter Roeck

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.