Commit 637bcd19 authored by Baolin Wang's avatar Baolin Wang Committed by Bjorn Andersson
Browse files

hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory



Use devm_kzalloc() to allocate memory.

Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 5ee45e0c
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -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,17 +121,14 @@ 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;

	return 0;

reg_fail:
	if (ret) {
		pm_runtime_disable(&pdev->dev);
	kfree(bank);
		return ret;
	}

	return 0;
}

static int u8500_hsem_remove(struct platform_device *pdev)
{
	struct hwspinlock_device *bank = platform_get_drvdata(pdev);
@@ -147,7 +145,6 @@ static int u8500_hsem_remove(struct platform_device *pdev)
	}

	pm_runtime_disable(&pdev->dev);
	kfree(bank);

	return 0;
}