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

[media] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures

v4l2_subdev_{core/pad/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
6170 2752 144 9066 236a media/platform/xilinx/xilinx-tpg.o

File size after:
text data bss dec hex filename
6666 2384 8 9058 2362 media/platform/xilinx/xilinx-tpg.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Bhumika Goyal and committed by
Mauro Carvalho Chehab
cebb31c8 8726650a

+4 -4
+4 -4
drivers/media/platform/xilinx/xilinx-tpg.c
··· 460 460 .s_ctrl = xtpg_s_ctrl, 461 461 }; 462 462 463 - static struct v4l2_subdev_core_ops xtpg_core_ops = { 463 + static const struct v4l2_subdev_core_ops xtpg_core_ops = { 464 464 }; 465 465 466 - static struct v4l2_subdev_video_ops xtpg_video_ops = { 466 + static const struct v4l2_subdev_video_ops xtpg_video_ops = { 467 467 .s_stream = xtpg_s_stream, 468 468 }; 469 469 470 - static struct v4l2_subdev_pad_ops xtpg_pad_ops = { 470 + static const struct v4l2_subdev_pad_ops xtpg_pad_ops = { 471 471 .enum_mbus_code = xvip_enum_mbus_code, 472 472 .enum_frame_size = xtpg_enum_frame_size, 473 473 .get_fmt = xtpg_get_format, 474 474 .set_fmt = xtpg_set_format, 475 475 }; 476 476 477 - static struct v4l2_subdev_ops xtpg_ops = { 477 + static const struct v4l2_subdev_ops xtpg_ops = { 478 478 .core = &xtpg_core_ops, 479 479 .video = &xtpg_video_ops, 480 480 .pad = &xtpg_pad_ops,