aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_transport_spi.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 8cc5dffc04bf..380e1671eb18 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -1057,19 +1057,16 @@ static const char * const one_byte_msgs[] = {
1057/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", 1057/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue",
1058/* 0x0f */ "Initiate Recovery", "Release Recovery" 1058/* 0x0f */ "Initiate Recovery", "Release Recovery"
1059}; 1059};
1060#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *))
1061 1060
1062static const char * const two_byte_msgs[] = { 1061static const char * const two_byte_msgs[] = {
1063/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag", 1062/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag",
1064/* 0x23 */ "Ignore Wide Residue" 1063/* 0x23 */ "Ignore Wide Residue"
1065}; 1064};
1066#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
1067 1065
1068static const char * const extended_msgs[] = { 1066static const char * const extended_msgs[] = {
1069/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", 1067/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
1070/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" 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
1075int spi_print_msg(const unsigned char *msg) 1072int spi_print_msg(const unsigned char *msg)
@@ -1077,7 +1074,7 @@ int spi_print_msg(const unsigned char *msg)
1077 int len = 0, i; 1074 int len = 0, i;
1078 if (msg[0] == EXTENDED_MESSAGE) { 1075 if (msg[0] == EXTENDED_MESSAGE) {
1079 len = 3 + msg[1]; 1076 len = 3 + msg[1];
1080 if (msg[2] < NO_EXTENDED_MSGS) 1077 if (msg[2] < ARRAY_SIZE(extended_msgs))
1081 printk ("%s ", extended_msgs[msg[2]]); 1078 printk ("%s ", extended_msgs[msg[2]]);
1082 else 1079 else
1083 printk ("Extended Message, reserved code (0x%02x) ", 1080 printk ("Extended Message, reserved code (0x%02x) ",
@@ -1107,14 +1104,14 @@ int spi_print_msg(const unsigned char *msg)
1107 len = 1; 1104 len = 1;
1108 /* Normal One byte */ 1105 /* Normal One byte */
1109 } else if (msg[0] < 0x1f) { 1106 } else if (msg[0] < 0x1f) {
1110 if (msg[0] < NO_ONE_BYTE_MSGS) 1107 if (msg[0] < ARRAY_SIZE(one_byte_msgs))
1111 printk(one_byte_msgs[msg[0]]); 1108 printk(one_byte_msgs[msg[0]]);
1112 else 1109 else
1113 printk("reserved (%02x) ", msg[0]); 1110 printk("reserved (%02x) ", msg[0]);
1114 len = 1; 1111 len = 1;
1115 /* Two byte */ 1112 /* Two byte */
1116 } else if (msg[0] <= 0x2f) { 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 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], 1115 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
1119 msg[1]); 1116 msg[1]);
1120 else 1117 else