2021-10-12 21:52:44

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH] media: imx: Constify static struct v4l2_m2m_ops

The only usage of m2m_ops is to pass its address to v4l2_m2m_init(),
which takes a pointer to const v4l2_m2m_ops as argument. Make it const
to allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
drivers/staging/media/imx/imx-media-csc-scaler.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index eb6da9b9d8ba..1fd39a2fca98 100644
--- a/drivers/staging/media/imx/imx-media-csc-scaler.c
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -820,7 +820,7 @@ static const struct v4l2_file_operations ipu_csc_scaler_fops = {
.mmap = v4l2_m2m_fop_mmap,
};

-static struct v4l2_m2m_ops m2m_ops = {
+static const struct v4l2_m2m_ops m2m_ops = {
.device_run = device_run,
.job_abort = job_abort,
};
--
2.33.0


2021-10-14 10:49:48

by Philipp Zabel

[permalink] [raw]
Subject: Re: [PATCH] media: imx: Constify static struct v4l2_m2m_ops

Hi Rikard,

On Tue, 2021-10-12 at 23:47 +0200, Rikard Falkeborn wrote:
> The only usage of m2m_ops is to pass its address to v4l2_m2m_init(),
> which takes a pointer to const v4l2_m2m_ops as argument. Make it const
> to allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
> ---
> drivers/staging/media/imx/imx-media-csc-scaler.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
> index eb6da9b9d8ba..1fd39a2fca98 100644
> --- a/drivers/staging/media/imx/imx-media-csc-scaler.c
> +++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
> @@ -820,7 +820,7 @@ static const struct v4l2_file_operations ipu_csc_scaler_fops = {
> .mmap = v4l2_m2m_fop_mmap,
> };
>
> -static struct v4l2_m2m_ops m2m_ops = {
> +static const struct v4l2_m2m_ops m2m_ops = {
> .device_run = device_run,
> .job_abort = job_abort,
> };

Thank you,

Reviewed-by: Philipp Zabel <[email protected]>

regards
Philipp

2021-10-15 19:56:27

by Kieran Bingham

[permalink] [raw]
Subject: Re: [PATCH] media: imx: Constify static struct v4l2_m2m_ops

Quoting Rikard Falkeborn (2021-10-12 22:47:03)
> The only usage of m2m_ops is to pass its address to v4l2_m2m_init(),
> which takes a pointer to const v4l2_m2m_ops as argument. Make it const
> to allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Reviewed-by: Kieran Bingham <[email protected]>

> ---
> drivers/staging/media/imx/imx-media-csc-scaler.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
> index eb6da9b9d8ba..1fd39a2fca98 100644
> --- a/drivers/staging/media/imx/imx-media-csc-scaler.c
> +++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
> @@ -820,7 +820,7 @@ static const struct v4l2_file_operations ipu_csc_scaler_fops = {
> .mmap = v4l2_m2m_fop_mmap,
> };
>
> -static struct v4l2_m2m_ops m2m_ops = {
> +static const struct v4l2_m2m_ops m2m_ops = {
> .device_run = device_run,
> .job_abort = job_abort,
> };
> --
> 2.33.0
>