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

[media] drivers: media: i2c: ml86v7667: 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_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
@@
v4l2_i2c_subdev_init(...,&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_ops i;

File size before:
text data bss dec hex filename
2732 608 8 3348 d14 drivers/media/i2c/ml86v7667.o

File size after:
text data bss dec hex filename
3100 232 8 3340 d0c drivers/media/i2c/ml86v7667.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
5610ced4 4d7aa5e9

+3 -3
+3 -3
drivers/media/i2c/ml86v7667.c
··· 290 290 .s_ctrl = ml86v7667_s_ctrl, 291 291 }; 292 292 293 - static struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = { 293 + static const struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = { 294 294 .g_std = ml86v7667_g_std, 295 295 .s_std = ml86v7667_s_std, 296 296 .querystd = ml86v7667_querystd, ··· 304 304 .set_fmt = ml86v7667_fill_fmt, 305 305 }; 306 306 307 - static struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = { 307 + static const struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = { 308 308 #ifdef CONFIG_VIDEO_ADV_DEBUG 309 309 .g_register = ml86v7667_g_register, 310 310 .s_register = ml86v7667_s_register, 311 311 #endif 312 312 }; 313 313 314 - static struct v4l2_subdev_ops ml86v7667_subdev_ops = { 314 + static const struct v4l2_subdev_ops ml86v7667_subdev_ops = { 315 315 .core = &ml86v7667_subdev_core_ops, 316 316 .video = &ml86v7667_subdev_video_ops, 317 317 .pad = &ml86v7667_subdev_pad_ops,