diff mbox series

[-next] regulator: qcom_rpm-regulator: Use devm_kmemdup to replace devm_kmalloc + memcpy

Message ID 20230810114858.2103928-1-lizetao1@huawei.com
State Accepted
Commit 55975401fdf86ffe4736a557ae9d6f3d81ee5ba6
Headers show
Series [-next] regulator: qcom_rpm-regulator: Use devm_kmemdup to replace devm_kmalloc + memcpy | expand

Commit Message

Li Zetao Aug. 10, 2023, 11:48 a.m. UTC
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>
---
 drivers/regulator/qcom_rpm-regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index f95bc9208c13..9366488f0383 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -956,11 +956,10 @@  static int rpm_reg_probe(struct platform_device *pdev)
 	}
 
 	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)
 			return -ENOMEM;
 
-		memcpy(vreg, reg->template, sizeof(*vreg));
 		mutex_init(&vreg->lock);
 
 		vreg->dev = &pdev->dev;