Skip to content

Commit 5597540

Browse files
Li Zetaobroonie
authored andcommitted
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: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230810114858.2103928-1-lizetao1@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 252b911 commit 5597540

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/regulator/qcom_rpm-regulator.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,11 +956,10 @@ static int rpm_reg_probe(struct platform_device *pdev)
956956
}
957957

958958
for (reg = match->data; reg->name; reg++) {
959-
vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
959+
vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL);
960960
if (!vreg)
961961
return -ENOMEM;
962962

963-
memcpy(vreg, reg->template, sizeof(*vreg));
964963
mutex_init(&vreg->lock);
965964

966965
vreg->dev = &pdev->dev;

0 commit comments

Comments
 (0)