2020-11-07 23:38:21

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 0/2] remoteproc: Constify static struct rproc_ops

Constify two static struct rproc_ops which are never modified. These two
changes makes all static instances of rproc_ops in the kernel const.

Rikard Falkeborn (2):
remoteproc: ingenic: Constify ingenic_rproc_ops
remoteproc: stm32: Constify st_rproc_ops

drivers/remoteproc/ingenic_rproc.c | 2 +-
drivers/remoteproc/stm32_rproc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

--
2.29.2


2020-11-07 23:38:24

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 2/2] remoteproc: stm32: Constify st_rproc_ops

The only usage of st_rproc_ops is to pass its address to rproc_alloc()
which accepts a const pointer. Make it const to allow the compiler to
put it in read-only memory.

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

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index d2414cc1d90d..a180aeae9675 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -541,7 +541,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
}
}

-static struct rproc_ops st_rproc_ops = {
+static const struct rproc_ops st_rproc_ops = {
.start = stm32_rproc_start,
.stop = stm32_rproc_stop,
.attach = stm32_rproc_attach,
--
2.29.2

2020-11-07 23:39:32

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH 1/2] remoteproc: ingenic: Constify ingenic_rproc_ops

The only usage of ingenic_rproc_ops is to pass its address to
devm_rproc_alloc(), which accepts a const pointer. Make it const to
allow the compiler to put it in read-only memory.

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

diff --git a/drivers/remoteproc/ingenic_rproc.c b/drivers/remoteproc/ingenic_rproc.c
index 1c2b21a5d178..26e19e6143b7 100644
--- a/drivers/remoteproc/ingenic_rproc.c
+++ b/drivers/remoteproc/ingenic_rproc.c
@@ -135,7 +135,7 @@ static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
return (__force void *)va;
}

-static struct rproc_ops ingenic_rproc_ops = {
+static const struct rproc_ops ingenic_rproc_ops = {
.prepare = ingenic_rproc_prepare,
.unprepare = ingenic_rproc_unprepare,
.start = ingenic_rproc_start,
--
2.29.2

2020-11-09 13:51:32

by Arnaud POULIQUEN

[permalink] [raw]
Subject: Re: [Linux-stm32] [PATCH 2/2] remoteproc: stm32: Constify st_rproc_ops

Hi Rikard,

On 11/8/20 12:36 AM, Rikard Falkeborn wrote:
> The only usage of st_rproc_ops is to pass its address to rproc_alloc()
> which accepts a const pointer. Make it const to allow the compiler to
> put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
> ---
> drivers/remoteproc/stm32_rproc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index d2414cc1d90d..a180aeae9675 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -541,7 +541,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
> }
> }
>
> -static struct rproc_ops st_rproc_ops = {
> +static const struct rproc_ops st_rproc_ops = {
> .start = stm32_rproc_start,
> .stop = stm32_rproc_stop,
> .attach = stm32_rproc_attach,
>

acked-by: Arnaud Pouliquen <[email protected]>

Thanks,
Arnaud

2020-11-09 22:51:41

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH 1/2] remoteproc: ingenic: Constify ingenic_rproc_ops

Hi,

Le dim. 8 nov. 2020 ? 0:36, Rikard Falkeborn
<[email protected]> a ?crit :
> The only usage of ingenic_rproc_ops is to pass its address to
> devm_rproc_alloc(), which accepts a const pointer. Make it const to
> allow the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>

Acked-by: Paul Cercueil <[email protected]>

Cheers,
-Paul

> ---
> drivers/remoteproc/ingenic_rproc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/ingenic_rproc.c
> b/drivers/remoteproc/ingenic_rproc.c
> index 1c2b21a5d178..26e19e6143b7 100644
> --- a/drivers/remoteproc/ingenic_rproc.c
> +++ b/drivers/remoteproc/ingenic_rproc.c
> @@ -135,7 +135,7 @@ static void *ingenic_rproc_da_to_va(struct rproc
> *rproc, u64 da, size_t len)
> return (__force void *)va;
> }
>
> -static struct rproc_ops ingenic_rproc_ops = {
> +static const struct rproc_ops ingenic_rproc_ops = {
> .prepare = ingenic_rproc_prepare,
> .unprepare = ingenic_rproc_unprepare,
> .start = ingenic_rproc_start,
> --
> 2.29.2
>