Commit fc25307d authored by Matthew Wilcox's avatar Matthew Wilcox Committed by James Bottomley

[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: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 1bfc5d9d
...@@ -1105,7 +1105,7 @@ static const char * const two_byte_msgs[] = { ...@@ -1105,7 +1105,7 @@ static const char * const two_byte_msgs[] = {
static const char * const extended_msgs[] = { static const char * const extended_msgs[] = {
/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request", /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request",
/* 0x04 */ "Parallel Protocol Request" /* 0x04 */ "Parallel Protocol Request", "Modify Bidirectional Data Pointer"
}; };
static void print_nego(const unsigned char *msg, int per, int off, int width) 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,11 +1122,20 @@ static void print_nego(const unsigned char *msg, int per, int off, int width)
printk("width = %d ", 8 << msg[width]); printk("width = %d ", 8 << msg[width]);
} }
static void print_ptr(const unsigned char *msg, int msb, const char *desc)
{
int ptr = (msg[msb] << 24) | (msg[msb+1] << 16) | (msg[msb+2] << 8) |
msg[msb+3];
printk("%s = %d ", desc, ptr);
}
int spi_print_msg(const unsigned char *msg) int spi_print_msg(const unsigned char *msg)
{ {
int len = 0, i; int len = 0, i;
if (msg[0] == EXTENDED_MESSAGE) { if (msg[0] == EXTENDED_MESSAGE) {
len = 3 + msg[1]; len = 2 + msg[1];
if (len == 2)
len += 256;
if (msg[2] < ARRAY_SIZE(extended_msgs)) if (msg[2] < ARRAY_SIZE(extended_msgs))
printk ("%s ", extended_msgs[msg[2]]); printk ("%s ", extended_msgs[msg[2]]);
else else
...@@ -1134,8 +1143,7 @@ int spi_print_msg(const unsigned char *msg) ...@@ -1134,8 +1143,7 @@ int spi_print_msg(const unsigned char *msg)
(int) msg[2]); (int) msg[2]);
switch (msg[2]) { switch (msg[2]) {
case EXTENDED_MODIFY_DATA_POINTER: case EXTENDED_MODIFY_DATA_POINTER:
printk("pointer = %d ", (msg[3] << 24) | print_ptr(msg, 3, "pointer");
(msg[4] << 16) | (msg[5] << 8) | msg[6]);
break; break;
case EXTENDED_SDTR: case EXTENDED_SDTR:
print_nego(msg, 3, 4, 0); print_nego(msg, 3, 4, 0);
...@@ -1146,6 +1154,10 @@ int spi_print_msg(const unsigned char *msg) ...@@ -1146,6 +1154,10 @@ int spi_print_msg(const unsigned char *msg)
case EXTENDED_PPR: case EXTENDED_PPR:
print_nego(msg, 3, 5, 6); print_nego(msg, 3, 5, 6);
break; break;
case EXTENDED_MODIFY_BIDI_DATA_PTR:
print_ptr(msg, 3, "out");
print_ptr(msg, 7, "in");
break;
default: default:
for (i = 2; i < len; ++i) for (i = 2; i < len; ++i)
printk("%02x ", msg[i]); printk("%02x ", msg[i]);
...@@ -1186,7 +1198,9 @@ int spi_print_msg(const unsigned char *msg) ...@@ -1186,7 +1198,9 @@ int spi_print_msg(const unsigned char *msg)
int len = 0, i; int len = 0, i;
if (msg[0] == EXTENDED_MESSAGE) { if (msg[0] == EXTENDED_MESSAGE) {
len = 3 + msg[1]; len = 2 + msg[1];
if (len == 2)
len += 256;
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
printk("%02x ", msg[i]); printk("%02x ", msg[i]);
/* Identify */ /* Identify */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment