summaryrefslogtreecommitdiff
path: root/drivers/hwspinlock
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang@linaro.org>2019-09-27 16:27:42 +0800
committerBjorn Andersson <bjorn.andersson@linaro.org>2019-10-04 20:20:20 -0700
commit637bcd19beeb9e40b8b64b41e8a8bdf03e918edd (patch)
tree20965dcb33943d08ae4728164b9954dfdf430778 /drivers/hwspinlock
parent5ee45e0c894636243361fdbaa17828fa00dc7f3a (diff)
downloadlwn-637bcd19beeb9e40b8b64b41e8a8bdf03e918edd.tar.gz
lwn-637bcd19beeb9e40b8b64b41e8a8bdf03e918edd.zip
hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory
Use devm_kzalloc() to allocate memory. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/hwspinlock')
-rw-r--r--drivers/hwspinlock/u8500_hsem.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hsem.c
index c247a87fd0b6..0e8d4ffa867d 100644
--- a/drivers/hwspinlock/u8500_hsem.c
+++ b/drivers/hwspinlock/u8500_hsem.c
@@ -106,7 +106,8 @@ static int u8500_hsem_probe(struct platform_device *pdev)
/* clear all interrupts */
writel(0xFFFF, io_base + HSEM_ICRALL);
- bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
+ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
+ GFP_KERNEL);
if (!bank)
return -ENOMEM;
@@ -120,15 +121,12 @@ static int u8500_hsem_probe(struct platform_device *pdev)
ret = hwspin_lock_register(bank, &pdev->dev, &u8500_hwspinlock_ops,
pdata->base_id, num_locks);
- if (ret)
- goto reg_fail;
+ if (ret) {
+ pm_runtime_disable(&pdev->dev);
+ return ret;
+ }
return 0;
-
-reg_fail:
- pm_runtime_disable(&pdev->dev);
- kfree(bank);
- return ret;
}
static int u8500_hsem_remove(struct platform_device *pdev)
@@ -147,7 +145,6 @@ static int u8500_hsem_remove(struct platform_device *pdev)
}
pm_runtime_disable(&pdev->dev);
- kfree(bank);
return 0;
}