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

usb: storage: sddr09: Use const for constant arrays

The nand_flash_ids, inquiry_response, and mode_page_01 arrays are only
read, not modified.

Declaring data as const makes it easier to see what's going on, and can
prevent unintended writes through placement in a read-only section.

Signed-off-by: Jonathan Neuschäfer <j.ne@posteo.net>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20250228-misc-const-v3-7-09b417ded9c4@posteo.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jonathan Neuschäfer and committed by
Greg Kroah-Hartman
5dc02c96 024ad542

+7 -7
+7 -7
drivers/usb/storage/sddr09.c
··· 144 144 * 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda. 145 145 */ 146 146 147 - static struct nand_flash_dev nand_flash_ids[] = { 147 + static const struct nand_flash_dev nand_flash_ids[] = { 148 148 /* NAND flash */ 149 149 { 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */ 150 150 { 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */ ··· 169 169 { 0,} 170 170 }; 171 171 172 - static struct nand_flash_dev * 172 + static const struct nand_flash_dev * 173 173 nand_find_id(unsigned char id) { 174 174 int i; 175 175 ··· 1133 1133 } 1134 1134 #endif 1135 1135 1136 - static struct nand_flash_dev * 1136 + static const struct nand_flash_dev * 1137 1137 sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { 1138 - struct nand_flash_dev *cardinfo; 1138 + const struct nand_flash_dev *cardinfo; 1139 1139 unsigned char deviceID[4]; 1140 1140 char blurbtxt[256]; 1141 1141 int result; ··· 1545 1545 1546 1546 struct sddr09_card_info *info; 1547 1547 1548 - static unsigned char inquiry_response[8] = { 1548 + static const unsigned char inquiry_response[8] = { 1549 1549 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 1550 1550 }; 1551 1551 1552 1552 /* note: no block descriptor support */ 1553 - static unsigned char mode_page_01[19] = { 1553 + static const unsigned char mode_page_01[19] = { 1554 1554 0x00, 0x0F, 0x00, 0x0, 0x0, 0x0, 0x00, 1555 1555 0x01, 0x0A, 1556 1556 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ··· 1584 1584 } 1585 1585 1586 1586 if (srb->cmnd[0] == READ_CAPACITY) { 1587 - struct nand_flash_dev *cardinfo; 1587 + const struct nand_flash_dev *cardinfo; 1588 1588 1589 1589 sddr09_get_wp(us, info); /* read WP bit */ 1590 1590