Message ID | 20240803061443.287117-1-cuigaosheng1@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [-next] hwspinlock: stm32: Add missing clk_disable_unprepare in stm32_hwspinlock_probe | expand |
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.
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; }
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(-)