2017-07-01 11:27:27

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH] media: vb2 dma-contig: Constify dma_buf_ops structures.

dma_buf_ops are not supposed to change at runtime. All functions
working with dma_buf_ops provided by <linux/dma-buf.h> work with
const dma_buf_ops. So mark the non-const structs as const.

File size before:
text data bss dec hex filename
6035 272 0 6307 18a3 drivers/media/v4l2-core/videobuf2-dma-contig.o

File size After adding 'const':
text data bss dec hex filename
6155 160 0 6315 18ab drivers/media/v4l2-core/videobuf2-dma-contig.o

Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/media/v4l2-core/videobuf2-dma-contig.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 4f246d1..5b90a66 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -352,7 +352,7 @@ static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf,
return vb2_dc_mmap(dbuf->priv, vma);
}

-static struct dma_buf_ops vb2_dc_dmabuf_ops = {
+static const struct dma_buf_ops vb2_dc_dmabuf_ops = {
.attach = vb2_dc_dmabuf_ops_attach,
.detach = vb2_dc_dmabuf_ops_detach,
.map_dma_buf = vb2_dc_dmabuf_ops_map,
--
2.7.4


2017-07-04 05:22:59

by Marek Szyprowski

[permalink] [raw]
Subject: Re: [PATCH] media: vb2 dma-contig: Constify dma_buf_ops structures.

Hi Arvind,

On 2017-07-01 13:27, Arvind Yadav wrote:
> dma_buf_ops are not supposed to change at runtime. All functions
> working with dma_buf_ops provided by <linux/dma-buf.h> work with
> const dma_buf_ops. So mark the non-const structs as const.
>
> File size before:
> text data bss dec hex filename
> 6035 272 0 6307 18a3 drivers/media/v4l2-core/videobuf2-dma-contig.o
>
> File size After adding 'const':
> text data bss dec hex filename
> 6155 160 0 6315 18ab drivers/media/v4l2-core/videobuf2-dma-contig.o
>
> Signed-off-by: Arvind Yadav <[email protected]>

Thanks!
Acked-by: Marek Szyprowski <[email protected]>

> ---
> drivers/media/v4l2-core/videobuf2-dma-contig.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> index 4f246d1..5b90a66 100644
> --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
> @@ -352,7 +352,7 @@ static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf,
> return vb2_dc_mmap(dbuf->priv, vma);
> }
>
> -static struct dma_buf_ops vb2_dc_dmabuf_ops = {
> +static const struct dma_buf_ops vb2_dc_dmabuf_ops = {
> .attach = vb2_dc_dmabuf_ops_attach,
> .detach = vb2_dc_dmabuf_ops_detach,
> .map_dma_buf = vb2_dc_dmabuf_ops_map,

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland