Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: platform: soc_camera_platform : constify v4l2_subdev_* structures

v4l2_subdev_{core/video}_ops structures are stored in the
fields of the v4l2_subdev_ops structure which are of type const.
Also, v4l2_subdev_ops structure is passed to a function
having its argument of type const. As these structures are never
modified, so declare them as const.
Done using Coccinelle:(One of the scripts)

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

@ok1@
identifier r1.i;
position p;
struct v4l2_subdev_ops obj;
@@
obj.core=&i@p;

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

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

File size before:
text data bss dec hex filename
858 576 0 1434 59a soc_camera/soc_camera_platform.o

File size after:
text data bss dec hex filename
1234 192 0 1426 592 soc_camera/soc_camera_platform.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Bhumika Goyal and committed by
Mauro Carvalho Chehab
32dd9e87 a5bc63f2

+3 -3
+3 -3
drivers/media/platform/soc_camera/soc_camera_platform.c
··· 59 59 return soc_camera_set_power(p->icd->control, &p->icd->sdesc->subdev_desc, NULL, on); 60 60 } 61 61 62 - static struct v4l2_subdev_core_ops platform_subdev_core_ops = { 62 + static const struct v4l2_subdev_core_ops platform_subdev_core_ops = { 63 63 .s_power = soc_camera_platform_s_power, 64 64 }; 65 65 ··· 110 110 return 0; 111 111 } 112 112 113 - static struct v4l2_subdev_video_ops platform_subdev_video_ops = { 113 + static const struct v4l2_subdev_video_ops platform_subdev_video_ops = { 114 114 .s_stream = soc_camera_platform_s_stream, 115 115 .g_mbus_config = soc_camera_platform_g_mbus_config, 116 116 }; ··· 122 122 .set_fmt = soc_camera_platform_fill_fmt, 123 123 }; 124 124 125 - static struct v4l2_subdev_ops platform_subdev_ops = { 125 + static const struct v4l2_subdev_ops platform_subdev_ops = { 126 126 .core = &platform_subdev_core_ops, 127 127 .video = &platform_subdev_video_ops, 128 128 .pad = &platform_subdev_pad_ops,