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

memstick: Constify struct memstick_device_id

'struct memstick_device_id' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increases overall security.

Update memstick_dev_match(), memstick_bus_match() and struct
memstick_driver accordingly.

On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
74055 3455 88 77598 12f1e drivers/memstick/core/ms_block.o

After:
=====
text data bss dec hex filename
74087 3423 88 77598 12f1e drivers/memstick/core/ms_block.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6509d6f6ed64193f04e747a98ccea7492c976ca8.1727540434.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Christophe JAILLET and committed by
Ulf Hansson
5bb798cf d61366cd

+5 -5
+2 -2
drivers/memstick/core/memstick.c
··· 26 26 static DEFINE_SPINLOCK(memstick_host_lock); 27 27 28 28 static int memstick_dev_match(struct memstick_dev *card, 29 - struct memstick_device_id *id) 29 + const struct memstick_device_id *id) 30 30 { 31 31 if (id->match_flags & MEMSTICK_MATCH_ALL) { 32 32 if ((id->type == card->id.type) ··· 44 44 dev); 45 45 const struct memstick_driver *ms_drv = container_of_const(drv, struct memstick_driver, 46 46 driver); 47 - struct memstick_device_id *ids = ms_drv->id_table; 47 + const struct memstick_device_id *ids = ms_drv->id_table; 48 48 49 49 if (ids) { 50 50 while (ids->match_flags) {
+1 -1
drivers/memstick/core/ms_block.c
··· 2279 2279 2280 2280 #endif /* CONFIG_PM */ 2281 2281 2282 - static struct memstick_device_id msb_id_tbl[] = { 2282 + static const struct memstick_device_id msb_id_tbl[] = { 2283 2283 {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_LEGACY, MEMSTICK_CATEGORY_STORAGE, 2284 2284 MEMSTICK_CLASS_FLASH}, 2285 2285
+1 -1
drivers/memstick/core/mspro_block.c
··· 1349 1349 1350 1350 #endif /* CONFIG_PM */ 1351 1351 1352 - static struct memstick_device_id mspro_block_id_tbl[] = { 1352 + static const struct memstick_device_id mspro_block_id_tbl[] = { 1353 1353 {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO, 1354 1354 MEMSTICK_CLASS_DUO}, 1355 1355 {}
+1 -1
include/linux/memstick.h
··· 293 293 }; 294 294 295 295 struct memstick_driver { 296 - struct memstick_device_id *id_table; 296 + const struct memstick_device_id *id_table; 297 297 int (*probe)(struct memstick_dev *card); 298 298 void (*remove)(struct memstick_dev *card); 299 299 int (*suspend)(struct memstick_dev *card,