media: usbtv: constify static structs
authorRikard Falkeborn <rikard.falkeborn@gmail.com>
Sat, 6 Feb 2021 21:21:39 +0000 (22:21 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Mar 2021 10:59:42 +0000 (11:59 +0100)
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>
drivers/media/usb/usbtv/usbtv-video.c

index 3b4a2e76923096e42103e94e5e678696b493a0e6..a714ad77ca8e24ae1ee9d641dc72bf301ab52dfe 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "usbtv.h"
 
-static struct usbtv_norm_params norm_params[] = {
+static const struct usbtv_norm_params norm_params[] = {
        {
                .norm = V4L2_STD_525_60,
                .cap_width = 720,
@@ -63,7 +63,7 @@ static struct usbtv_norm_params norm_params[] = {
 static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)
 {
        int i, ret = 0;
-       struct usbtv_norm_params *params = NULL;
+       const struct usbtv_norm_params *params = NULL;
 
        for (i = 0; i < ARRAY_SIZE(norm_params); i++) {
                if (norm_params[i].norm & norm) {
@@ -685,7 +685,7 @@ static int usbtv_s_input(struct file *file, void *priv, unsigned int i)
        return usbtv_select_input(usbtv, i);
 }
 
-static struct v4l2_ioctl_ops usbtv_ioctl_ops = {
+static const struct v4l2_ioctl_ops usbtv_ioctl_ops = {
        .vidioc_querycap = usbtv_querycap,
        .vidioc_enum_input = usbtv_enum_input,
        .vidioc_enum_fmt_vid_cap = usbtv_enum_fmt_vid_cap,