linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups
@ 2025-05-25 16:53 Christophe JAILLET
  2025-05-27 16:33 ` Pratyush Yadav
  2025-07-03 14:55 ` Pratyush Yadav
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-05-25 16:53 UTC (permalink / raw)
  To: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mtd

'struct spi_nor_fixups' are not modified in this driver.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  23304	  13168	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  23560	  12912	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/mtd/spi-nor/micron-st.c | 8 ++++----
 drivers/mtd/spi-nor/spansion.c  | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-st.c
index e6bab2d00c92..187239ccd549 100644
--- a/drivers/mtd/spi-nor/micron-st.c
+++ b/drivers/mtd/spi-nor/micron-st.c
@@ -189,7 +189,7 @@ static int mt25qu512a_post_bfpt_fixup(struct spi_nor *nor,
 	return 0;
 }
 
-static struct spi_nor_fixups mt25qu512a_fixups = {
+static const struct spi_nor_fixups mt25qu512a_fixups = {
 	.post_bfpt = mt25qu512a_post_bfpt_fixup,
 };
 
@@ -225,15 +225,15 @@ static int st_nor_two_die_late_init(struct spi_nor *nor)
 	return spi_nor_set_4byte_addr_mode(nor, true);
 }
 
-static struct spi_nor_fixups n25q00_fixups = {
+static const struct spi_nor_fixups n25q00_fixups = {
 	.late_init = st_nor_four_die_late_init,
 };
 
-static struct spi_nor_fixups mt25q01_fixups = {
+static const struct spi_nor_fixups mt25q01_fixups = {
 	.late_init = st_nor_two_die_late_init,
 };
 
-static struct spi_nor_fixups mt25q02_fixups = {
+static const struct spi_nor_fixups mt25q02_fixups = {
 	.late_init = st_nor_four_die_late_init,
 };
 
diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
index bf08dbf5e742..920bb8dd5dc2 100644
--- a/drivers/mtd/spi-nor/spansion.c
+++ b/drivers/mtd/spi-nor/spansion.c
@@ -578,7 +578,7 @@ static int s25fs256t_late_init(struct spi_nor *nor)
 	return 0;
 }
 
-static struct spi_nor_fixups s25fs256t_fixups = {
+static const struct spi_nor_fixups s25fs256t_fixups = {
 	.post_bfpt = s25fs256t_post_bfpt_fixup,
 	.post_sfdp = s25fs256t_post_sfdp_fixup,
 	.late_init = s25fs256t_late_init,
@@ -650,7 +650,7 @@ static int s25hx_t_late_init(struct spi_nor *nor)
 	return 0;
 }
 
-static struct spi_nor_fixups s25hx_t_fixups = {
+static const struct spi_nor_fixups s25hx_t_fixups = {
 	.post_bfpt = s25hx_t_post_bfpt_fixup,
 	.post_sfdp = s25hx_t_post_sfdp_fixup,
 	.late_init = s25hx_t_late_init,
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups
  2025-05-25 16:53 [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups Christophe JAILLET
@ 2025-05-27 16:33 ` Pratyush Yadav
  2025-07-03 14:55 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2025-05-27 16:33 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-kernel,
	kernel-janitors, linux-mtd

On Sun, May 25 2025, Christophe JAILLET wrote:

> 'struct spi_nor_fixups' are not modified in this driver.
>
> Constifying these structures moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
>
> On a x86_64, with allmodconfig, as an example:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>   23304	  13168	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o
>
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   23560	  12912	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Pratyush Yadav <pratyush@kernel.org>

[...]

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups
  2025-05-25 16:53 [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups Christophe JAILLET
  2025-05-27 16:33 ` Pratyush Yadav
@ 2025-07-03 14:55 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2025-07-03 14:55 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-kernel,
	kernel-janitors, linux-mtd

On Sun, May 25 2025, Christophe JAILLET wrote:

> 'struct spi_nor_fixups' are not modified in this driver.
>
> Constifying these structures moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
>
> On a x86_64, with allmodconfig, as an example:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>   23304	  13168	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o
>
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   23560	  12912	      0	  36472	   8e78	drivers/mtd/spi-nor/micron-st.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to spi-nor/next. Thanks!
[...]

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-03 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 16:53 [PATCH] mtd: spi-nor: Constify struct spi_nor_fixups Christophe JAILLET
2025-05-27 16:33 ` Pratyush Yadav
2025-07-03 14:55 ` Pratyush Yadav

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).