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

[media] drivers: media: i2c: ak881x: 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 used)

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

@ok1@
identifier r1.i;
position p;
struct v4l2_subdev_ops obj;
@@
obj.video=&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_video_ops i;

File size before:
text data bss dec hex filename
1809 872 0 2681 a79 drivers/media/i2c/ak881x.o

File size after:
text data bss dec hex filename
2185 496 0 2681 a79 drivers/media/i2c/ak881x.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Bhumika Goyal and committed by
Mauro Carvalho Chehab
4d7aa5e9 646c3ae9

+3 -3
+3 -3
drivers/media/i2c/ak881x.c
··· 205 205 return 0; 206 206 } 207 207 208 - static struct v4l2_subdev_core_ops ak881x_subdev_core_ops = { 208 + static const struct v4l2_subdev_core_ops ak881x_subdev_core_ops = { 209 209 #ifdef CONFIG_VIDEO_ADV_DEBUG 210 210 .g_register = ak881x_g_register, 211 211 .s_register = ak881x_s_register, 212 212 #endif 213 213 }; 214 214 215 - static struct v4l2_subdev_video_ops ak881x_subdev_video_ops = { 215 + static const struct v4l2_subdev_video_ops ak881x_subdev_video_ops = { 216 216 .s_std_output = ak881x_s_std_output, 217 217 .s_stream = ak881x_s_stream, 218 218 }; ··· 224 224 .get_fmt = ak881x_fill_fmt, 225 225 }; 226 226 227 - static struct v4l2_subdev_ops ak881x_subdev_ops = { 227 + static const struct v4l2_subdev_ops ak881x_subdev_ops = { 228 228 .core = &ak881x_subdev_core_ops, 229 229 .video = &ak881x_subdev_video_ops, 230 230 .pad = &ak881x_subdev_pad_ops,