Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: spi-nor: Constify struct spi_nor_fixups

'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>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Link: https://lore.kernel.org/r/aa641732ba707ce3690217825c3ca7373ffde4f9.1748191985.git.christophe.jaillet@wanadoo.fr

authored by

Christophe JAILLET and committed by
Pratyush Yadav
d8b73ce1 19272b37

+6 -6
+4 -4
drivers/mtd/spi-nor/micron-st.c
··· 189 189 return 0; 190 190 } 191 191 192 - static struct spi_nor_fixups mt25qu512a_fixups = { 192 + static const struct spi_nor_fixups mt25qu512a_fixups = { 193 193 .post_bfpt = mt25qu512a_post_bfpt_fixup, 194 194 }; 195 195 ··· 225 225 return spi_nor_set_4byte_addr_mode(nor, true); 226 226 } 227 227 228 - static struct spi_nor_fixups n25q00_fixups = { 228 + static const struct spi_nor_fixups n25q00_fixups = { 229 229 .late_init = st_nor_four_die_late_init, 230 230 }; 231 231 232 - static struct spi_nor_fixups mt25q01_fixups = { 232 + static const struct spi_nor_fixups mt25q01_fixups = { 233 233 .late_init = st_nor_two_die_late_init, 234 234 }; 235 235 236 - static struct spi_nor_fixups mt25q02_fixups = { 236 + static const struct spi_nor_fixups mt25q02_fixups = { 237 237 .late_init = st_nor_four_die_late_init, 238 238 }; 239 239
+2 -2
drivers/mtd/spi-nor/spansion.c
··· 578 578 return 0; 579 579 } 580 580 581 - static struct spi_nor_fixups s25fs256t_fixups = { 581 + static const struct spi_nor_fixups s25fs256t_fixups = { 582 582 .post_bfpt = s25fs256t_post_bfpt_fixup, 583 583 .post_sfdp = s25fs256t_post_sfdp_fixup, 584 584 .late_init = s25fs256t_late_init, ··· 650 650 return 0; 651 651 } 652 652 653 - static struct spi_nor_fixups s25hx_t_fixups = { 653 + static const struct spi_nor_fixups s25hx_t_fixups = { 654 654 .post_bfpt = s25hx_t_post_bfpt_fixup, 655 655 .post_sfdp = s25hx_t_post_sfdp_fixup, 656 656 .late_init = s25hx_t_late_init,