* [PATCH] media: i2c: rdacm20: Constify static structs
@ 2020-11-19 22:22 Rikard Falkeborn
2020-11-20 9:31 ` Jacopo Mondi
2020-11-20 11:39 ` Kieran Bingham
0 siblings, 2 replies; 3+ messages in thread
From: Rikard Falkeborn @ 2020-11-19 22:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
Niklas Söderlund, linux-media, linux-kernel,
Rikard Falkeborn
The only usage of rdacm20_video_ops is to assign it to the video field
in the v4l2_subdev_ops struct which is a pointer to const, and the only
usage of rdacm20_subdev_ops is to pass its address to
v4l2_i2c_subdev_init() which accepts a pointer to const. Make them const
to allow the compiler to put them in read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/media/i2c/rdacm20.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
index 1ed928c4ca70..ac00a6743623 100644
--- a/drivers/media/i2c/rdacm20.c
+++ b/drivers/media/i2c/rdacm20.c
@@ -435,7 +435,7 @@ static int rdacm20_get_fmt(struct v4l2_subdev *sd,
return 0;
}
-static struct v4l2_subdev_video_ops rdacm20_video_ops = {
+static const struct v4l2_subdev_video_ops rdacm20_video_ops = {
.s_stream = rdacm20_s_stream,
};
@@ -445,7 +445,7 @@ static const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = {
.set_fmt = rdacm20_get_fmt,
};
-static struct v4l2_subdev_ops rdacm20_subdev_ops = {
+static const struct v4l2_subdev_ops rdacm20_subdev_ops = {
.video = &rdacm20_video_ops,
.pad = &rdacm20_subdev_pad_ops,
};
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: i2c: rdacm20: Constify static structs
2020-11-19 22:22 [PATCH] media: i2c: rdacm20: Constify static structs Rikard Falkeborn
@ 2020-11-20 9:31 ` Jacopo Mondi
2020-11-20 11:39 ` Kieran Bingham
1 sibling, 0 replies; 3+ messages in thread
From: Jacopo Mondi @ 2020-11-20 9:31 UTC (permalink / raw)
To: Rikard Falkeborn
Cc: Mauro Carvalho Chehab, Jacopo Mondi, Kieran Bingham,
Laurent Pinchart, Niklas Söderlund, linux-media,
linux-kernel
Hi Rikard,
On Thu, Nov 19, 2020 at 11:22:48PM +0100, Rikard Falkeborn wrote:
> The only usage of rdacm20_video_ops is to assign it to the video field
> in the v4l2_subdev_ops struct which is a pointer to const, and the only
> usage of rdacm20_subdev_ops is to pass its address to
> v4l2_i2c_subdev_init() which accepts a pointer to const. Make them const
> to allow the compiler to put them in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Thanks
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
> drivers/media/i2c/rdacm20.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
> index 1ed928c4ca70..ac00a6743623 100644
> --- a/drivers/media/i2c/rdacm20.c
> +++ b/drivers/media/i2c/rdacm20.c
> @@ -435,7 +435,7 @@ static int rdacm20_get_fmt(struct v4l2_subdev *sd,
> return 0;
> }
>
> -static struct v4l2_subdev_video_ops rdacm20_video_ops = {
> +static const struct v4l2_subdev_video_ops rdacm20_video_ops = {
> .s_stream = rdacm20_s_stream,
> };
>
> @@ -445,7 +445,7 @@ static const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = {
> .set_fmt = rdacm20_get_fmt,
> };
>
> -static struct v4l2_subdev_ops rdacm20_subdev_ops = {
> +static const struct v4l2_subdev_ops rdacm20_subdev_ops = {
> .video = &rdacm20_video_ops,
> .pad = &rdacm20_subdev_pad_ops,
> };
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: i2c: rdacm20: Constify static structs
2020-11-19 22:22 [PATCH] media: i2c: rdacm20: Constify static structs Rikard Falkeborn
2020-11-20 9:31 ` Jacopo Mondi
@ 2020-11-20 11:39 ` Kieran Bingham
1 sibling, 0 replies; 3+ messages in thread
From: Kieran Bingham @ 2020-11-20 11:39 UTC (permalink / raw)
To: Rikard Falkeborn, Mauro Carvalho Chehab
Cc: Jacopo Mondi, Laurent Pinchart, Niklas Söderlund,
linux-media, linux-kernel
Hi Rikard,
Thank you for the fix.
On 19/11/2020 22:22, Rikard Falkeborn wrote:
> The only usage of rdacm20_video_ops is to assign it to the video field
> in the v4l2_subdev_ops struct which is a pointer to const, and the only
> usage of rdacm20_subdev_ops is to pass its address to
> v4l2_i2c_subdev_init() which accepts a pointer to const. Make them const
> to allow the compiler to put them in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
> drivers/media/i2c/rdacm20.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
> index 1ed928c4ca70..ac00a6743623 100644
> --- a/drivers/media/i2c/rdacm20.c
> +++ b/drivers/media/i2c/rdacm20.c
> @@ -435,7 +435,7 @@ static int rdacm20_get_fmt(struct v4l2_subdev *sd,
> return 0;
> }
>
> -static struct v4l2_subdev_video_ops rdacm20_video_ops = {
> +static const struct v4l2_subdev_video_ops rdacm20_video_ops = {
> .s_stream = rdacm20_s_stream,
> };
>
> @@ -445,7 +445,7 @@ static const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = {
> .set_fmt = rdacm20_get_fmt,
> };
>
> -static struct v4l2_subdev_ops rdacm20_subdev_ops = {
> +static const struct v4l2_subdev_ops rdacm20_subdev_ops = {
> .video = &rdacm20_video_ops,
> .pad = &rdacm20_subdev_pad_ops,
> };
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-20 11:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 22:22 [PATCH] media: i2c: rdacm20: Constify static structs Rikard Falkeborn
2020-11-20 9:31 ` Jacopo Mondi
2020-11-20 11:39 ` Kieran Bingham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).