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

media: usbtv: constify static structs

Constify two static structs which are never modified to allow the
compiler to put them in read-only memory.

The only usage of norm_params is only read from it in
usbtv_configure_for_norm(). Making it const shrinks the resulting
ko-file with 300 bytes (tested with gcc 10).

The only usage of usbtv_ioctl_ops is to put its address to the ioctl_ops
field in the video_device struct. Making it const moves ~1kb to
read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Rikard Falkeborn and committed by
Mauro Carvalho Chehab
6a49401e 6b45fbfa

+3 -3
+3 -3
drivers/media/usb/usbtv/usbtv-video.c
··· 47 47 48 48 #include "usbtv.h" 49 49 50 - static struct usbtv_norm_params norm_params[] = { 50 + static const struct usbtv_norm_params norm_params[] = { 51 51 { 52 52 .norm = V4L2_STD_525_60, 53 53 .cap_width = 720, ··· 63 63 static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm) 64 64 { 65 65 int i, ret = 0; 66 - struct usbtv_norm_params *params = NULL; 66 + const struct usbtv_norm_params *params = NULL; 67 67 68 68 for (i = 0; i < ARRAY_SIZE(norm_params); i++) { 69 69 if (norm_params[i].norm & norm) { ··· 685 685 return usbtv_select_input(usbtv, i); 686 686 } 687 687 688 - static struct v4l2_ioctl_ops usbtv_ioctl_ops = { 688 + static const struct v4l2_ioctl_ops usbtv_ioctl_ops = { 689 689 .vidioc_querycap = usbtv_querycap, 690 690 .vidioc_enum_input = usbtv_enum_input, 691 691 .vidioc_enum_fmt_vid_cap = usbtv_enum_fmt_vid_cap,