2017-08-08 11:24:05

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/6] constify video_subdev structures

The structures of type v4l2_subdev_ops are only passed as the second
argument of v4l2_subdev_init or as the third argument of
v4l2_i2c_subdev_init, both of which are const. The structures of type
v4l2_subdev_core_ops, v4l2_subdev_pad_ops, v4l2_subdev_sensor_ops,
v4l2_subdev_video_ops are only stored in fields of v4l2_subdev_ops
structures, all of which are const. Thus all of these structures can be
declared as const as well.

Done with the help of Coccinelle.

---

drivers/media/i2c/mt9m111.c | 6 +++---
drivers/media/i2c/mt9t001.c | 8 ++++----
drivers/media/platform/exynos4-is/fimc-isp.c | 2 +-
drivers/media/platform/exynos4-is/fimc-lite.c | 2 +-
drivers/media/platform/vimc/vimc-debayer.c | 2 +-
drivers/media/platform/vimc/vimc-scaler.c | 2 +-
drivers/media/platform/vimc/vimc-sensor.c | 2 +-
drivers/media/usb/uvc/uvc_entity.c | 2 +-
drivers/staging/media/atomisp/i2c/ap1302.c | 2 +-
drivers/staging/media/atomisp/i2c/mt9m114.c | 2 +-
10 files changed, 15 insertions(+), 15 deletions(-)


2017-08-08 11:24:06

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/6] [media] media: mt9m111: constify video_subdev structures

The v4l2_subdev_ops structure is only passed as the third argument
of v4l2_i2c_subdev_init, which is const, so the v4l2_subdev_ops
structure can be const as well. The other structures are only
stored in the v4l2_subdev_ops structure, all the fields of which are
const, so these structures can also be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/i2c/mt9m111.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 72e71b7..99b992e 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -835,7 +835,7 @@ static int mt9m111_s_power(struct v4l2_subdev *sd, int on)
.s_ctrl = mt9m111_s_ctrl,
};

-static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
.s_power = mt9m111_s_power,
#ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = mt9m111_g_register,
@@ -865,7 +865,7 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
return 0;
}

-static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
.g_mbus_config = mt9m111_g_mbus_config,
};

@@ -877,7 +877,7 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
.set_fmt = mt9m111_set_fmt,
};

-static struct v4l2_subdev_ops mt9m111_subdev_ops = {
+static const struct v4l2_subdev_ops mt9m111_subdev_ops = {
.core = &mt9m111_subdev_core_ops,
.video = &mt9m111_subdev_video_ops,
.pad = &mt9m111_subdev_pad_ops,

2017-08-08 11:24:04

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/6] [media] v4l: mt9t001: constify video_subdev structures

The v4l2_subdev_ops structure is only passed as the third argument of
v4l2_i2c_subdev_init, which is const, so the v4l2_subdev_ops structure
can be const as well. The other structures are only stored in the
v4l2_subdev_ops structure, all the fields of which are const, so these
structures can also be const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/i2c/mt9t001.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 842017f..9d981d9 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -822,15 +822,15 @@ static int mt9t001_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
return mt9t001_set_power(subdev, 0);
}

-static struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
.s_power = mt9t001_set_power,
};

-static struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
.s_stream = mt9t001_s_stream,
};

-static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
.enum_mbus_code = mt9t001_enum_mbus_code,
.enum_frame_size = mt9t001_enum_frame_size,
.get_fmt = mt9t001_get_format,
@@ -839,7 +839,7 @@ static int mt9t001_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
.set_selection = mt9t001_set_selection,
};

-static struct v4l2_subdev_ops mt9t001_subdev_ops = {
+static const struct v4l2_subdev_ops mt9t001_subdev_ops = {
.core = &mt9t001_subdev_core_ops,
.video = &mt9t001_subdev_video_ops,
.pad = &mt9t001_subdev_pad_ops,

2017-08-08 11:24:41

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 5/6] [media] exynos4-is: constify video_subdev structures

The v4l2_subdev_ops structures are only passed as the second
argument of v4l2_subdev_init, which is const, so the
v4l2_subdev_ops structures can be const as well.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/platform/exynos4-is/fimc-isp.c | 2 +-
drivers/media/platform/exynos4-is/fimc-lite.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c
index 8efe916..fd793d3 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp.c
@@ -433,7 +433,7 @@ static void fimc_isp_subdev_unregistered(struct v4l2_subdev *sd)
.s_power = fimc_isp_subdev_s_power,
};

-static struct v4l2_subdev_ops fimc_is_subdev_ops = {
+static const struct v4l2_subdev_ops fimc_is_subdev_ops = {
.core = &fimc_is_core_ops,
.video = &fimc_is_subdev_video_ops,
.pad = &fimc_is_subdev_pad_ops,
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 7d3ec5c..30282c5 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1361,7 +1361,7 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd)
.log_status = fimc_lite_log_status,
};

-static struct v4l2_subdev_ops fimc_lite_subdev_ops = {
+static const struct v4l2_subdev_ops fimc_lite_subdev_ops = {
.core = &fimc_lite_core_ops,
.video = &fimc_lite_subdev_video_ops,
.pad = &fimc_lite_subdev_pad_ops,

2017-08-08 11:25:34

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 6/6] [media] uvcvideo: constify video_subdev structures

uvc_subdev_ops is only passed as the second argument of
v4l2_subdev_init, which is const, so uvc_subdev_ops can be
const as well.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/usb/uvc/uvc_entity.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
index ac386bb..554063c 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -61,7 +61,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,
return 0;
}

-static struct v4l2_subdev_ops uvc_subdev_ops = {
+static const struct v4l2_subdev_ops uvc_subdev_ops = {
};

void uvc_mc_cleanup_entity(struct uvc_entity *entity)

2017-08-08 11:26:28

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/6] [media] vimc: constify video_subdev structures

These structures are all only stored in fields of v4l2_subdev_ops
structures, all of which are const, so these structures can be const
as well.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/platform/vimc/vimc-debayer.c | 2 +-
drivers/media/platform/vimc/vimc-scaler.c | 2 +-
drivers/media/platform/vimc/vimc-sensor.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c
index 033a131..4d663e8 100644
--- a/drivers/media/platform/vimc/vimc-debayer.c
+++ b/drivers/media/platform/vimc/vimc-debayer.c
@@ -373,7 +373,7 @@ static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable)
return 0;
}

-static struct v4l2_subdev_video_ops vimc_deb_video_ops = {
+static const struct v4l2_subdev_video_ops vimc_deb_video_ops = {
.s_stream = vimc_deb_s_stream,
};

diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c
index 0a3e086..e1602e0 100644
--- a/drivers/media/platform/vimc/vimc-scaler.c
+++ b/drivers/media/platform/vimc/vimc-scaler.c
@@ -267,7 +267,7 @@ static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable)
return 0;
}

-static struct v4l2_subdev_video_ops vimc_sca_video_ops = {
+static const struct v4l2_subdev_video_ops vimc_sca_video_ops = {
.s_stream = vimc_sca_s_stream,
};

diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
index 615c2b1..02e68c8 100644
--- a/drivers/media/platform/vimc/vimc-sensor.c
+++ b/drivers/media/platform/vimc/vimc-sensor.c
@@ -282,7 +282,7 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
return 0;
}

-static struct v4l2_subdev_video_ops vimc_sen_video_ops = {
+static const struct v4l2_subdev_video_ops vimc_sen_video_ops = {
.s_stream = vimc_sen_s_stream,
};


2017-08-08 11:26:26

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/6] staging: atomisp: constify video_subdev structures

These structures are both stored in fields of v4l2_subdev_ops
structures, all of which are const, so these structures can be
const as well.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/media/atomisp/i2c/ap1302.c | 2 +-
drivers/staging/media/atomisp/i2c/mt9m114.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/ap1302.c b/drivers/staging/media/atomisp/i2c/ap1302.c
index bacffbe..de687c6 100644
--- a/drivers/staging/media/atomisp/i2c/ap1302.c
+++ b/drivers/staging/media/atomisp/i2c/ap1302.c
@@ -1098,7 +1098,7 @@ static long ap1302_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
},
};

-static struct v4l2_subdev_sensor_ops ap1302_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops ap1302_sensor_ops = {
.g_skip_frames = ap1302_g_skip_frames,
};

diff --git a/drivers/staging/media/atomisp/i2c/mt9m114.c b/drivers/staging/media/atomisp/i2c/mt9m114.c
index 448e072..36a0636 100644
--- a/drivers/staging/media/atomisp/i2c/mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/mt9m114.c
@@ -1806,7 +1806,7 @@ static int mt9m114_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
.g_frame_interval = mt9m114_g_frame_interval,
};

-static struct v4l2_subdev_sensor_ops mt9m114_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9m114_sensor_ops = {
.g_skip_frames = mt9m114_g_skip_frames,
};


2017-08-08 12:37:15

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: [PATCH 5/6] [media] exynos4-is: constify video_subdev structures

On 08/08/2017 12:58 PM, Julia Lawall wrote:
> The v4l2_subdev_ops structures are only passed as the second
> argument of v4l2_subdev_init, which is const, so the
> v4l2_subdev_ops structures can be const as well.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall<[email protected]>

Reviewed-by: Sylwester Nawrocki <[email protected]>

2017-08-08 12:48:51

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 6/6] [media] uvcvideo: constify video_subdev structures

Hi Julia,

Thank you for the patch.

On Tuesday 08 Aug 2017 12:58:32 Julia Lawall wrote:
> uvc_subdev_ops is only passed as the second argument of
> v4l2_subdev_init, which is const, so uvc_subdev_ops can be
> const as well.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

and applied to my tree (with the first word of the commit message after the
prefix capitalized to match the rest of the driver's commit messages, let me
know if that's a problem :-)).
>
> ---
> drivers/media/usb/uvc/uvc_entity.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_entity.c
> b/drivers/media/usb/uvc/uvc_entity.c index ac386bb..554063c 100644
> --- a/drivers/media/usb/uvc/uvc_entity.c
> +++ b/drivers/media/usb/uvc/uvc_entity.c
> @@ -61,7 +61,7 @@ static int uvc_mc_create_links(struct uvc_video_chain
> *chain, return 0;
> }
>
> -static struct v4l2_subdev_ops uvc_subdev_ops = {
> +static const struct v4l2_subdev_ops uvc_subdev_ops = {
> };
>
> void uvc_mc_cleanup_entity(struct uvc_entity *entity)

--
Regards,

Laurent Pinchart

2017-08-08 12:49:58

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 6/6] [media] uvcvideo: constify video_subdev structures



On Tue, 8 Aug 2017, Laurent Pinchart wrote:

> Hi Julia,
>
> Thank you for the patch.
>
> On Tuesday 08 Aug 2017 12:58:32 Julia Lawall wrote:
> > uvc_subdev_ops is only passed as the second argument of
> > v4l2_subdev_init, which is const, so uvc_subdev_ops can be
> > const as well.
> >
> > Done with the help of Coccinelle.
> >
> > Signed-off-by: Julia Lawall <[email protected]>
>
> Reviewed-by: Laurent Pinchart <[email protected]>
>
> and applied to my tree (with the first word of the commit message after the
> prefix capitalized to match the rest of the driver's commit messages, let me
> know if that's a problem :-)).

No, of course not. I will try to watch out for that in the future.

julia

> >
> > ---
> > drivers/media/usb/uvc/uvc_entity.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/uvc/uvc_entity.c
> > b/drivers/media/usb/uvc/uvc_entity.c index ac386bb..554063c 100644
> > --- a/drivers/media/usb/uvc/uvc_entity.c
> > +++ b/drivers/media/usb/uvc/uvc_entity.c
> > @@ -61,7 +61,7 @@ static int uvc_mc_create_links(struct uvc_video_chain
> > *chain, return 0;
> > }
> >
> > -static struct v4l2_subdev_ops uvc_subdev_ops = {
> > +static const struct v4l2_subdev_ops uvc_subdev_ops = {
> > };
> >
> > void uvc_mc_cleanup_entity(struct uvc_entity *entity)
>
> --
> Regards,
>
> Laurent Pinchart
>
>

2017-08-08 22:07:19

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 1/6] [media] v4l: mt9t001: constify video_subdev structures

Hi Julia,

Thank you for the patch.

On Tuesday 08 Aug 2017 12:58:27 Julia Lawall wrote:
> The v4l2_subdev_ops structure is only passed as the third argument of
> v4l2_i2c_subdev_init, which is const, so the v4l2_subdev_ops structure
> can be const as well. The other structures are only stored in the
> v4l2_subdev_ops structure, all the fields of which are const, so these
> structures can also be const.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

> ---
> drivers/media/i2c/mt9t001.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
> index 842017f..9d981d9 100644
> --- a/drivers/media/i2c/mt9t001.c
> +++ b/drivers/media/i2c/mt9t001.c
> @@ -822,15 +822,15 @@ static int mt9t001_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) return mt9t001_set_power(subdev, 0);
> }
>
> -static struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
> +static const struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
> .s_power = mt9t001_set_power,
> };
>
> -static struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
> +static const struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
> .s_stream = mt9t001_s_stream,
> };
>
> -static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
> +static const struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
> .enum_mbus_code = mt9t001_enum_mbus_code,
> .enum_frame_size = mt9t001_enum_frame_size,
> .get_fmt = mt9t001_get_format,
> @@ -839,7 +839,7 @@ static int mt9t001_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) .set_selection = mt9t001_set_selection,
> };
>
> -static struct v4l2_subdev_ops mt9t001_subdev_ops = {
> +static const struct v4l2_subdev_ops mt9t001_subdev_ops = {
> .core = &mt9t001_subdev_core_ops,
> .video = &mt9t001_subdev_video_ops,
> .pad = &mt9t001_subdev_pad_ops,

--
Regards,

Laurent Pinchart