Browse Source

Staging: media: radio-bcm2048: constify v4l2_ioctl_ops structure

Declare the structure v4l2_ioctl_ops as const as it is only stored in
the ioctl_ops field of video_device structure. As this field is of type
const struct v4l2_ioctl_ops *, so v4l2_ioctl_ops structures having this
property can also be made const.
Done using coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct v4l2_ioctl_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct video_device s;
@@
s.ioctl_ops=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct v4l2_ioctl_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct v4l2_ioctl_ops i;

File size before:
   text	   data	    bss	    dec	    hex	filename
  20465	   3220	     32	  23717	   5ca5
drivers/staging/media/bcm2048/radio-bcm2048.o

File size after:
   text	   data	    bss	    dec	    hex	filename
  21425	   2260	     32	  23717	   5ca5
drivers/staging/media/bcm2048/radio-bcm2048.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bhumika Goyal 8 years ago
parent
commit
7f140181b4
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/staging/media/bcm2048/radio-bcm2048.c

+ 1 - 1
drivers/staging/media/bcm2048/radio-bcm2048.c

@@ -2540,7 +2540,7 @@ static int bcm2048_vidioc_s_hw_freq_seek(struct file *file, void *priv,
 	return err;
 }
 
-static struct v4l2_ioctl_ops bcm2048_ioctl_ops = {
+static const struct v4l2_ioctl_ops bcm2048_ioctl_ops = {
 	.vidioc_querycap	= bcm2048_vidioc_querycap,
 	.vidioc_g_input		= bcm2048_vidioc_g_input,
 	.vidioc_s_input		= bcm2048_vidioc_s_input,