Commit b4d64193 authored by Baolin Wang's avatar Baolin Wang Committed by Bjorn Andersson

hwspinlock: sprd: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()

Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.
Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 3070c416
...@@ -79,6 +79,13 @@ static const struct hwspinlock_ops sprd_hwspinlock_ops = { ...@@ -79,6 +79,13 @@ static const struct hwspinlock_ops sprd_hwspinlock_ops = {
.relax = sprd_hwspinlock_relax, .relax = sprd_hwspinlock_relax,
}; };
static void sprd_hwspinlock_disable(void *data)
{
struct sprd_hwspinlock_dev *sprd_hwlock = data;
clk_disable_unprepare(sprd_hwlock->clk);
}
static int sprd_hwspinlock_probe(struct platform_device *pdev) static int sprd_hwspinlock_probe(struct platform_device *pdev)
{ {
struct sprd_hwspinlock_dev *sprd_hwlock; struct sprd_hwspinlock_dev *sprd_hwlock;
...@@ -109,6 +116,14 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev) ...@@ -109,6 +116,14 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = devm_add_action_or_reset(&pdev->dev, sprd_hwspinlock_disable,
sprd_hwlock);
if (ret) {
dev_err(&pdev->dev,
"Failed to add hwspinlock disable action\n");
return ret;
}
/* set the hwspinlock to record user id to identify subsystems */ /* set the hwspinlock to record user id to identify subsystems */
writel(HWSPINLOCK_USER_BITS, sprd_hwlock->base + HWSPINLOCK_RECCTRL); writel(HWSPINLOCK_USER_BITS, sprd_hwlock->base + HWSPINLOCK_RECCTRL);
...@@ -124,7 +139,6 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev) ...@@ -124,7 +139,6 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev)
&sprd_hwspinlock_ops, 0, SPRD_HWLOCKS_NUM); &sprd_hwspinlock_ops, 0, SPRD_HWLOCKS_NUM);
if (ret) { if (ret) {
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(sprd_hwlock->clk);
return ret; return ret;
} }
...@@ -137,7 +151,6 @@ static int sprd_hwspinlock_remove(struct platform_device *pdev) ...@@ -137,7 +151,6 @@ static int sprd_hwspinlock_remove(struct platform_device *pdev)
hwspin_lock_unregister(&sprd_hwlock->bank); hwspin_lock_unregister(&sprd_hwlock->bank);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(sprd_hwlock->clk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment