media: mediatek: vcodec: Drop unnecessary variable
authorFei Shao <fshao@chromium.org>
Thu, 21 Dec 2023 09:17:44 +0000 (09:17 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 26 Apr 2024 10:54:19 +0000 (11:54 +0100)
In mtk_vcodec_mem_alloc() and mtk_vcodec_mem_free(), the value of
mem->size is not expected to change before and when using the DMA APIs
and debug print, so there's no point in keeping local copies of it.

Drop the local variable "size" in the mentioned functions, and update
printk format identifiers accordingly.

This makes the code slightly more visually consistent, and retrieve a
small amount of memory that is used for no real purpose.

Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c

index ea8c35c0e667b9a5316e205b0ff5756c50dbffe0..23bea2702c9a2c79818b6401bc8d1693575ed2a9 100644 (file)
@@ -49,7 +49,6 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
 {
        enum mtk_instance_type inst_type = *((unsigned int *)priv);
        struct platform_device *plat_dev;
-       unsigned long size = mem->size;
        int id;
 
        if (inst_type == MTK_INST_ENCODER) {
@@ -64,15 +63,15 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
                id = dec_ctx->id;
        }
 
-       mem->va = dma_alloc_coherent(&plat_dev->dev, size, &mem->dma_addr, GFP_KERNEL);
+       mem->va = dma_alloc_coherent(&plat_dev->dev, mem->size, &mem->dma_addr, GFP_KERNEL);
        if (!mem->va) {
-               mtk_v4l2_err(plat_dev, "%s dma_alloc size=%ld failed!",
-                            __func__, size);
+               mtk_v4l2_err(plat_dev, "%s dma_alloc size=0x%zx failed!",
+                            __func__, mem->size);
                return -ENOMEM;
        }
 
-       mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%lx", id, mem->va,
-                      (unsigned long)mem->dma_addr, size);
+       mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%zx", id, mem->va,
+                      (unsigned long)mem->dma_addr, mem->size);
 
        return 0;
 }
@@ -82,7 +81,6 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
 {
        enum mtk_instance_type inst_type = *((unsigned int *)priv);
        struct platform_device *plat_dev;
-       unsigned long size = mem->size;
        int id;
 
        if (inst_type == MTK_INST_ENCODER) {
@@ -98,15 +96,15 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
        }
 
        if (!mem->va) {
-               mtk_v4l2_err(plat_dev, "%s dma_free size=%ld failed!",
-                            __func__, size);
+               mtk_v4l2_err(plat_dev, "%s dma_free size=0x%zx failed!",
+                            __func__, mem->size);
                return;
        }
 
-       mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%lx", id, mem->va,
-                      (unsigned long)mem->dma_addr, size);
+       mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%zx", id, mem->va,
+                      (unsigned long)mem->dma_addr, mem->size);
 
-       dma_free_coherent(&plat_dev->dev, size, mem->va, mem->dma_addr);
+       dma_free_coherent(&plat_dev->dev, mem->size, mem->va, mem->dma_addr);
        mem->va = NULL;
        mem->dma_addr = 0;
        mem->size = 0;