]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: cx231xx: constify videobuf_queue_ops structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Fri, 4 Aug 2017 12:09:46 +0000 (08:09 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sun, 20 Aug 2017 12:06:58 +0000 (08:06 -0400)
These videobuf_queue_ops structures are only passed as the second
argument to videobuf_queue_vmalloc_init, which is declared as const.
Thus the videobuf_queue_ops structures themselves can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct videobuf_queue_ops i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@
videobuf_queue_vmalloc_init(e1,&i@p,...)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct videobuf_queue_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct videobuf_queue_ops i = { ... };
// </smpl>

In the first case, there is a second commented call to
videobuf_queue_sg_init with the structure as the second argument.  If that
code will be uncommented, the const will remain correct, because the second
parameter of that function is also const.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/usb/cx231xx/cx231xx-417.c
drivers/media/usb/cx231xx/cx231xx-video.c

index 8d5eb99deacbf00d8947ee76eb2210e66ef09ee2..d538fa4077429a6f8dd95714d61ccb9824e58890 100644 (file)
@@ -1490,7 +1490,7 @@ static void bb_buf_release(struct videobuf_queue *q,
        free_buffer(q, buf);
 }
 
-static struct videobuf_queue_ops cx231xx_qops = {
+static const struct videobuf_queue_ops cx231xx_qops = {
        .buf_setup    = bb_buf_setup,
        .buf_prepare  = bb_buf_prepare,
        .buf_queue    = bb_buf_queue,
index f67f868766253b8690b422f51fe2da60d10dd2ea..179b8481a870d5fb44076183359b05dc65530690 100644 (file)
@@ -859,7 +859,7 @@ static void buffer_release(struct videobuf_queue *vq,
        free_buffer(vq, buf);
 }
 
-static struct videobuf_queue_ops cx231xx_video_qops = {
+static const struct videobuf_queue_ops cx231xx_video_qops = {
        .buf_setup = buffer_setup,
        .buf_prepare = buffer_prepare,
        .buf_queue = buffer_queue,