Commit 55975401 authored by Li Zetao's avatar Li Zetao Committed by Mark Brown

regulator: qcom_rpm-regulator: Use devm_kmemdup to replace devm_kmalloc + memcpy

Use the helper function devm_kmemdup() rather than duplicating its
implementation, which helps to enhance code readability.
Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230810114858.2103928-1-lizetao1@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 252b9116
...@@ -956,11 +956,10 @@ static int rpm_reg_probe(struct platform_device *pdev) ...@@ -956,11 +956,10 @@ static int rpm_reg_probe(struct platform_device *pdev)
} }
for (reg = match->data; reg->name; reg++) { for (reg = match->data; reg->name; reg++) {
vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL);
if (!vreg) if (!vreg)
return -ENOMEM; return -ENOMEM;
memcpy(vreg, reg->template, sizeof(*vreg));
mutex_init(&vreg->lock); mutex_init(&vreg->lock);
vreg->dev = &pdev->dev; vreg->dev = &pdev->dev;
......
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