diff mbox series

[-next] media: nxp: Use devm_kmemdup to replace devm_kmalloc + memcpy

Message ID 20230810115220.2104189-1-lizetao1@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] media: nxp: Use devm_kmemdup to replace devm_kmalloc + memcpy | expand

Commit Message

Li Zetao Aug. 10, 2023, 11:52 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/media/platform/nxp/imx8-isi/imx8-isi-core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index 5fdd0fe9efbe..c62f5e27469a 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -392,12 +392,10 @@  static int mxc_isi_clk_get(struct mxc_isi_dev *isi)
 			  * sizeof(*isi->clks);
 	int ret;
 
-	isi->clks = devm_kmalloc(isi->dev, size, GFP_KERNEL);
+	isi->clks = devm_kmemdup(isi->dev, isi->pdata->clks, size, GFP_KERNEL);
 	if (!isi->clks)
 		return -ENOMEM;
 
-	memcpy(isi->clks, isi->pdata->clks, size);
-
 	ret = devm_clk_bulk_get(isi->dev, isi->pdata->num_clks,
 				isi->clks);
 	if (ret < 0) {