Staging: media: radio-bcm2048: constify v4l2_ioctl_ops structure
authorBhumika Goyal <bhumirks@gmail.com>
Sun, 9 Oct 2016 10:35:23 +0000 (16:05 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Oct 2016 08:25:01 +0000 (10:25 +0200)
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>
drivers/staging/media/bcm2048/radio-bcm2048.c

index ea15cc6380970e159addcf91ce18c431b1cb1ef0..fe637ce8f4e7f82030f23205fcfd70ecd5b4f9b9 100644 (file)
@@ -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,