Linux-remoteproc Archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] hwspinlock: stm32: Add missing clk_disable_unprepare in stm32_hwspinlock_probe
@ 2024-08-03  6:14 Gaosheng Cui
  2024-08-08  1:37 ` Baolin Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Gaosheng Cui @ 2024-08-03  6:14 UTC (permalink / raw)
  To: andersson, baolin.wang, mcoquelin.stm32, alexandre.torgue,
	cuigaosheng1
  Cc: linux-remoteproc, linux-stm32, linux-arm-kernel

Add the missing clk_disable_unprepare() before return in
stm32_hwspinlock_probe().

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 drivers/hwspinlock/stm32_hwspinlock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c
index bb5c7e5f7a80..a4e3b9a9e29d 100644
--- a/drivers/hwspinlock/stm32_hwspinlock.c
+++ b/drivers/hwspinlock/stm32_hwspinlock.c
@@ -103,6 +103,7 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
 	ret = devm_add_action_or_reset(dev, stm32_hwspinlock_disable_clk, pdev);
 	if (ret) {
 		dev_err(dev, "Failed to register action\n");
+		clk_disable_unprepare(hw->clk);
 		return ret;
 	}
 
@@ -112,8 +113,10 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
 	ret = devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops,
 					0, STM32_MUTEX_NUM_LOCKS);
 
-	if (ret)
+	if (ret) {
 		dev_err(dev, "Failed to register hwspinlock\n");
+		clk_disable_unprepare(hw->clk);
+	}
 
 	return ret;
 }
-- 
2.25.1


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

* Re: [PATCH -next] hwspinlock: stm32: Add missing clk_disable_unprepare in stm32_hwspinlock_probe
  2024-08-03  6:14 [PATCH -next] hwspinlock: stm32: Add missing clk_disable_unprepare in stm32_hwspinlock_probe Gaosheng Cui
@ 2024-08-08  1:37 ` Baolin Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Baolin Wang @ 2024-08-08  1:37 UTC (permalink / raw)
  To: Gaosheng Cui, andersson, mcoquelin.stm32, alexandre.torgue
  Cc: linux-remoteproc, linux-stm32, linux-arm-kernel



On 2024/8/3 14:14, Gaosheng Cui wrote:
> Add the missing clk_disable_unprepare() before return in
> stm32_hwspinlock_probe().
> 
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>   drivers/hwspinlock/stm32_hwspinlock.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c
> index bb5c7e5f7a80..a4e3b9a9e29d 100644
> --- a/drivers/hwspinlock/stm32_hwspinlock.c
> +++ b/drivers/hwspinlock/stm32_hwspinlock.c
> @@ -103,6 +103,7 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
>   	ret = devm_add_action_or_reset(dev, stm32_hwspinlock_disable_clk, pdev);
>   	if (ret) {
>   		dev_err(dev, "Failed to register action\n");
> +		clk_disable_unprepare(hw->clk);
>   		return ret;
>   	}
>   
> @@ -112,8 +113,10 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
>   	ret = devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops,
>   					0, STM32_MUTEX_NUM_LOCKS);
>   
> -	if (ret)
> +	if (ret) {
>   		dev_err(dev, "Failed to register hwspinlock\n");
> +		clk_disable_unprepare(hw->clk);
> +	}

I don't think this is needed, because if the device initialization 
fails, stm32_hwspinlock_disable_clk() will be called to disable the 
clock automatically when the device releases its resources. Please check 
how devm_add_action_or_reset() work.

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

end of thread, other threads:[~2024-08-08  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-03  6:14 [PATCH -next] hwspinlock: stm32: Add missing clk_disable_unprepare in stm32_hwspinlock_probe Gaosheng Cui
2024-08-08  1:37 ` Baolin Wang

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 read-only IMAP folder(s) and NNTP newsgroup(s).