Skip to contentSkip to conversation

remoteproc: Constify static struct rproc_ops

PATCH Applied Rikard Falkeborn 4 participants 6 messages Nov 7, 2020 – Nov 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.29.2
#1 lore raw

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.

---
 drivers/remoteproc/ingenic_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/ingenic_rproc.c +1 -1
index 1c2b21a5d178..26e19e6143b7 100644
@@ -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,
Signature · 1 line
2.29.2
maintainer Acked-by on v1 1/2
#2 lore raw

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

Hi,

Quoted 5 lines · Rikard Falkeborn

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.

Cheers,
-Paul

Quoted 21 lines
---
 drivers/remoteproc/ingenic_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/ingenic_rproc.c +1 -1
index 1c2b21a5d178..26e19e6143b7 100644
@@ -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

#3 lore raw

PATCH 2/2 remoteproc: stm32: Constify st_rproc_ops

In reply to Rikard Falkeborn

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.

---
 drivers/remoteproc/stm32_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +1 -1
index d2414cc1d90d..a180aeae9675 100644
@@ -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,
Signature · 1 line
2.29.2
Acked-by on v1 2/2
#4 lore raw

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

Hi Rikard,

Quoted 15 lines · Rikard Falkeborn

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.

---
 drivers/remoteproc/stm32_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +0 -0
index d2414cc1d90d..a180aeae9675 100644

drivers/remoteproc/stm32_rproc.c static void stm32_rproc_kick(struct rproc *rproc, int vqid) · line 547

Quoted 8 lines
drivers/remoteproc/stm32_rproc.c +1 -1
@@ -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,

Thanks,
Arnaud

#5 lore raw
In reply to Rikard Falkeborn
This series was applied to andersson/remoteproc.git (refs/heads/for-next):

Hello:

This series was applied to andersson/remoteproc.git (refs/heads/for-next):

Quoted 8 lines · On Sun, 8 Nov 2020 00:36:28 +0100 you wrote:

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

[...]

Here is the summary with links:
- [1/2] remoteproc: ingenic: Constify ingenic_rproc_ops
https://git.kernel.org/andersson/remoteproc/c/bb7eda7eddf1
- [2/2] remoteproc: stm32: Constify st_rproc_ops

    https://git.kernel.org/andersson/remoteproc/c/0eee3d28ff65

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html