diff options
author | Baolin Wang <baolin.wang7@gmail.com> | 2020-01-08 11:14:00 +0800 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2020-01-21 16:11:25 -0800 |
commit | 42f291ebfdd83a5bf04254f6bdc169f6e5a4152b (patch) | |
tree | c816c0923921502807bb86c43db145bd6c6fba60 /drivers/hwspinlock | |
parent | bf2740068a87e258ccc695d366c8a2c05b46de71 (diff) | |
download | lwn-42f291ebfdd83a5bf04254f6bdc169f6e5a4152b.tar.gz lwn-42f291ebfdd83a5bf04254f6bdc169f6e5a4152b.zip |
hwspinlock: omap: Use devm_kzalloc() to allocate memory
Use devm_kzalloc() to allocate memory, which can simplify the error
handling.
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Link: https://lore.kernel.org/r/c066ad704c1a5fd52c3002cac80ddd59b3901b01.1578453062.git.baolin.wang7@gmail.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/hwspinlock')
-rw-r--r-- | drivers/hwspinlock/omap_hwspinlock.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/hwspinlock/omap_hwspinlock.c b/drivers/hwspinlock/omap_hwspinlock.c index dbb1a4ca8204..3b05560456ea 100644 --- a/drivers/hwspinlock/omap_hwspinlock.c +++ b/drivers/hwspinlock/omap_hwspinlock.c @@ -119,7 +119,8 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) num_locks = i * 32; /* actual number of locks in this device */ - 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) { ret = -ENOMEM; goto runtime_err; @@ -133,15 +134,13 @@ static int omap_hwspinlock_probe(struct platform_device *pdev) ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops, base_id, num_locks); if (ret) - goto reg_fail; + goto runtime_err; dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n", num_locks); return 0; -reg_fail: - kfree(bank); runtime_err: pm_runtime_disable(&pdev->dev); return ret; @@ -159,7 +158,6 @@ static int omap_hwspinlock_remove(struct platform_device *pdev) } pm_runtime_disable(&pdev->dev); - kfree(bank); return 0; } |