Commit b32aaffcdc694650d299a59501c5b3e267fca343
Committed by
James Bottomley
1 parent
4797215389
Exists in
master
and in
7 other branches
[SCSI] Use ARRAY_SIZE in spi_print_msg
Replace the custom NO_*_MSGS definitions with uses of ARRAY_SIZE. This fixes a bug in the definition of NO_EXTENDED_MSGS. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Showing 1 changed file with 3 additions and 6 deletions Side-by-side Diff
drivers/scsi/scsi_transport_spi.c
... | ... | @@ -1057,19 +1057,16 @@ |
1057 | 1057 | /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", |
1058 | 1058 | /* 0x0f */ "Initiate Recovery", "Release Recovery" |
1059 | 1059 | }; |
1060 | -#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) | |
1061 | 1060 | |
1062 | 1061 | static const char * const two_byte_msgs[] = { |
1063 | 1062 | /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag", |
1064 | 1063 | /* 0x23 */ "Ignore Wide Residue" |
1065 | 1064 | }; |
1066 | -#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) | |
1067 | 1065 | |
1068 | 1066 | static const char * const extended_msgs[] = { |
1069 | 1067 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", |
1070 | 1068 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" |
1071 | 1069 | }; |
1072 | -#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) | |
1073 | 1070 | |
1074 | 1071 | |
1075 | 1072 | int spi_print_msg(const unsigned char *msg) |
... | ... | @@ -1077,7 +1074,7 @@ |
1077 | 1074 | int len = 0, i; |
1078 | 1075 | if (msg[0] == EXTENDED_MESSAGE) { |
1079 | 1076 | len = 3 + msg[1]; |
1080 | - if (msg[2] < NO_EXTENDED_MSGS) | |
1077 | + if (msg[2] < ARRAY_SIZE(extended_msgs)) | |
1081 | 1078 | printk ("%s ", extended_msgs[msg[2]]); |
1082 | 1079 | else |
1083 | 1080 | printk ("Extended Message, reserved code (0x%02x) ", |
1084 | 1081 | |
... | ... | @@ -1107,14 +1104,14 @@ |
1107 | 1104 | len = 1; |
1108 | 1105 | /* Normal One byte */ |
1109 | 1106 | } else if (msg[0] < 0x1f) { |
1110 | - if (msg[0] < NO_ONE_BYTE_MSGS) | |
1107 | + if (msg[0] < ARRAY_SIZE(one_byte_msgs)) | |
1111 | 1108 | printk(one_byte_msgs[msg[0]]); |
1112 | 1109 | else |
1113 | 1110 | printk("reserved (%02x) ", msg[0]); |
1114 | 1111 | len = 1; |
1115 | 1112 | /* Two byte */ |
1116 | 1113 | } else if (msg[0] <= 0x2f) { |
1117 | - if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) | |
1114 | + if ((msg[0] - 0x20) < ARRAY_SIZE(two_byte_msgs)) | |
1118 | 1115 | printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], |
1119 | 1116 | msg[1]); |
1120 | 1117 | else |