media: nxp: Use devm_kmemdup to replace devm_kmalloc + memcpy
authorLi Zetao <lizetao1@huawei.com>
Thu, 10 Aug 2023 11:52:20 +0000 (19:52 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 07:40:01 +0000 (09:40 +0200)
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>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c

index 81be744..f73facb 100644 (file)
@@ -406,12 +406,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) {