Skip to content

Commit 5dc02c9

Browse files
neuschaefergregkh
authored andcommitted
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 <[email protected]> Reviewed-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 024ad54 commit 5dc02c9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/usb/storage/sddr09.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static inline char *nand_flash_manufacturer(int manuf_id) {
144144
* 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda.
145145
*/
146146

147-
static struct nand_flash_dev nand_flash_ids[] = {
147+
static const struct nand_flash_dev nand_flash_ids[] = {
148148
/* NAND flash */
149149
{ 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */
150150
{ 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */
@@ -169,7 +169,7 @@ static struct nand_flash_dev nand_flash_ids[] = {
169169
{ 0,}
170170
};
171171

172-
static struct nand_flash_dev *
172+
static const struct nand_flash_dev *
173173
nand_find_id(unsigned char id) {
174174
int i;
175175

@@ -1133,9 +1133,9 @@ sddr09_reset(struct us_data *us) {
11331133
}
11341134
#endif
11351135

1136-
static struct nand_flash_dev *
1136+
static const struct nand_flash_dev *
11371137
sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
1138-
struct nand_flash_dev *cardinfo;
1138+
const struct nand_flash_dev *cardinfo;
11391139
unsigned char deviceID[4];
11401140
char blurbtxt[256];
11411141
int result;
@@ -1545,12 +1545,12 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
15451545

15461546
struct sddr09_card_info *info;
15471547

1548-
static unsigned char inquiry_response[8] = {
1548+
static const unsigned char inquiry_response[8] = {
15491549
0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00
15501550
};
15511551

15521552
/* note: no block descriptor support */
1553-
static unsigned char mode_page_01[19] = {
1553+
static const unsigned char mode_page_01[19] = {
15541554
0x00, 0x0F, 0x00, 0x0, 0x0, 0x0, 0x00,
15551555
0x01, 0x0A,
15561556
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -1584,7 +1584,7 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
15841584
}
15851585

15861586
if (srb->cmnd[0] == READ_CAPACITY) {
1587-
struct nand_flash_dev *cardinfo;
1587+
const struct nand_flash_dev *cardinfo;
15881588

15891589
sddr09_get_wp(us, info); /* read WP bit */
15901590

0 commit comments

Comments
 (0)