diff options
author | Matthew Wilcox <matthew@wil.cx> | 2006-02-18 22:52:31 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-02-28 00:26:56 -0500 |
commit | fc25307d06f524d6c04b371b236dc9e62186058c (patch) | |
tree | f90d3f873c6ffc6644512fc21d058f2159cff1b0 /drivers/scsi/scsi_transport_spi.c | |
parent | 1bfc5d9d5eb8e1a2efacc306bc55c248ed259a8e (diff) |
[SCSI] Improve message printing code
Fix a bug where we would consume one byte too many in the message
printing code.
Add support for 256-byte long messages.
Add support for the Modify Bidirectional Data Pointer message.
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/scsi_transport_spi.c')
-rw-r--r-- | drivers/scsi/scsi_transport_spi.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index c63adff15afa..0b29ee9989a4 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c | |||
@@ -1105,7 +1105,7 @@ static const char * const two_byte_msgs[] = { | |||
1105 | static const char * const extended_msgs[] = { | 1105 | static const char * const extended_msgs[] = { |
1106 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", | 1106 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", |
1107 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request", | 1107 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request", |
1108 | /* 0x04 */ "Parallel Protocol Request" | 1108 | /* 0x04 */ "Parallel Protocol Request", "Modify Bidirectional Data Pointer" |
1109 | }; | 1109 | }; |
1110 | 1110 | ||
1111 | static void print_nego(const unsigned char *msg, int per, int off, int width) | 1111 | static void print_nego(const unsigned char *msg, int per, int off, int width) |
@@ -1122,11 +1122,20 @@ static void print_nego(const unsigned char *msg, int per, int off, int width) | |||
1122 | printk("width = %d ", 8 << msg[width]); | 1122 | printk("width = %d ", 8 << msg[width]); |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | static void print_ptr(const unsigned char *msg, int msb, const char *desc) | ||
1126 | { | ||
1127 | int ptr = (msg[msb] << 24) | (msg[msb+1] << 16) | (msg[msb+2] << 8) | | ||
1128 | msg[msb+3]; | ||
1129 | printk("%s = %d ", desc, ptr); | ||
1130 | } | ||
1131 | |||
1125 | int spi_print_msg(const unsigned char *msg) | 1132 | int spi_print_msg(const unsigned char *msg) |
1126 | { | 1133 | { |
1127 | int len = 0, i; | 1134 | int len = 0, i; |
1128 | if (msg[0] == EXTENDED_MESSAGE) { | 1135 | if (msg[0] == EXTENDED_MESSAGE) { |
1129 | len = 3 + msg[1]; | 1136 | len = 2 + msg[1]; |
1137 | if (len == 2) | ||
1138 | len += 256; | ||
1130 | if (msg[2] < ARRAY_SIZE(extended_msgs)) | 1139 | if (msg[2] < ARRAY_SIZE(extended_msgs)) |
1131 | printk ("%s ", extended_msgs[msg[2]]); | 1140 | printk ("%s ", extended_msgs[msg[2]]); |
1132 | else | 1141 | else |
@@ -1134,8 +1143,7 @@ int spi_print_msg(const unsigned char *msg) | |||
1134 | (int) msg[2]); | 1143 | (int) msg[2]); |
1135 | switch (msg[2]) { | 1144 | switch (msg[2]) { |
1136 | case EXTENDED_MODIFY_DATA_POINTER: | 1145 | case EXTENDED_MODIFY_DATA_POINTER: |
1137 | printk("pointer = %d ", (msg[3] << 24) | | 1146 | print_ptr(msg, 3, "pointer"); |
1138 | (msg[4] << 16) | (msg[5] << 8) | msg[6]); | ||
1139 | break; | 1147 | break; |
1140 | case EXTENDED_SDTR: | 1148 | case EXTENDED_SDTR: |
1141 | print_nego(msg, 3, 4, 0); | 1149 | print_nego(msg, 3, 4, 0); |
@@ -1146,6 +1154,10 @@ int spi_print_msg(const unsigned char *msg) | |||
1146 | case EXTENDED_PPR: | 1154 | case EXTENDED_PPR: |
1147 | print_nego(msg, 3, 5, 6); | 1155 | print_nego(msg, 3, 5, 6); |
1148 | break; | 1156 | break; |
1157 | case EXTENDED_MODIFY_BIDI_DATA_PTR: | ||
1158 | print_ptr(msg, 3, "out"); | ||
1159 | print_ptr(msg, 7, "in"); | ||
1160 | break; | ||
1149 | default: | 1161 | default: |
1150 | for (i = 2; i < len; ++i) | 1162 | for (i = 2; i < len; ++i) |
1151 | printk("%02x ", msg[i]); | 1163 | printk("%02x ", msg[i]); |
@@ -1186,7 +1198,9 @@ int spi_print_msg(const unsigned char *msg) | |||
1186 | int len = 0, i; | 1198 | int len = 0, i; |
1187 | 1199 | ||
1188 | if (msg[0] == EXTENDED_MESSAGE) { | 1200 | if (msg[0] == EXTENDED_MESSAGE) { |
1189 | len = 3 + msg[1]; | 1201 | len = 2 + msg[1]; |
1202 | if (len == 2) | ||
1203 | len += 256; | ||
1190 | for (i = 0; i < len; ++i) | 1204 | for (i = 0; i < len; ++i) |
1191 | printk("%02x ", msg[i]); | 1205 | printk("%02x ", msg[i]); |
1192 | /* Identify */ | 1206 | /* Identify */ |