Commit 3de2a218 authored by Fei Shao's avatar Fei Shao Committed by Mauro Carvalho Chehab

media: mediatek: vcodec: Drop unnecessary variable

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: default avatarFei Shao <fshao@chromium.org>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: default avatarSebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent c742a195
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment