diff options
-rw-r--r-- | drivers/scsi/scsi_transport_spi.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 380e1671eb18..46da6fe10ad5 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c | |||
@@ -379,9 +379,7 @@ static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); | |||
379 | 379 | ||
380 | /* Translate the period into ns according to the current spec | 380 | /* Translate the period into ns according to the current spec |
381 | * for SDTR/PPR messages */ | 381 | * for SDTR/PPR messages */ |
382 | static ssize_t | 382 | static int period_to_str(char *buf, int period) |
383 | show_spi_transport_period_helper(struct class_device *cdev, char *buf, | ||
384 | int period) | ||
385 | { | 383 | { |
386 | int len, picosec; | 384 | int len, picosec; |
387 | 385 | ||
@@ -399,6 +397,14 @@ show_spi_transport_period_helper(struct class_device *cdev, char *buf, | |||
399 | len = sprint_frac(buf, picosec, 1000); | 397 | len = sprint_frac(buf, picosec, 1000); |
400 | } | 398 | } |
401 | 399 | ||
400 | return len; | ||
401 | } | ||
402 | |||
403 | static ssize_t | ||
404 | show_spi_transport_period_helper(struct class_device *cdev, char *buf, | ||
405 | int period) | ||
406 | { | ||
407 | int len = period_to_str(buf, period); | ||
402 | buf[len++] = '\n'; | 408 | buf[len++] = '\n'; |
403 | buf[len] = '\0'; | 409 | buf[len] = '\0'; |
404 | return len; | 410 | return len; |
@@ -1065,9 +1071,23 @@ static const char * const two_byte_msgs[] = { | |||
1065 | 1071 | ||
1066 | static const char * const extended_msgs[] = { | 1072 | static const char * const extended_msgs[] = { |
1067 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", | 1073 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", |
1068 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" | 1074 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request", |
1075 | /* 0x04 */ "Parallel Protocol Request" | ||
1069 | }; | 1076 | }; |
1070 | 1077 | ||
1078 | void print_nego(const unsigned char *msg, int per, int off, int width) | ||
1079 | { | ||
1080 | if (per) { | ||
1081 | char buf[20]; | ||
1082 | period_to_str(buf, msg[per]); | ||
1083 | printk("period = %s ns ", buf); | ||
1084 | } | ||
1085 | |||
1086 | if (off) | ||
1087 | printk("offset = %d ", msg[off]); | ||
1088 | if (width) | ||
1089 | printk("width = %d ", 8 << msg[width]); | ||
1090 | } | ||
1071 | 1091 | ||
1072 | int spi_print_msg(const unsigned char *msg) | 1092 | int spi_print_msg(const unsigned char *msg) |
1073 | { | 1093 | { |
@@ -1085,11 +1105,13 @@ int spi_print_msg(const unsigned char *msg) | |||
1085 | (msg[4] << 16) | (msg[5] << 8) | msg[6]); | 1105 | (msg[4] << 16) | (msg[5] << 8) | msg[6]); |
1086 | break; | 1106 | break; |
1087 | case EXTENDED_SDTR: | 1107 | case EXTENDED_SDTR: |
1088 | printk("period = %d ns, offset = %d", | 1108 | print_nego(msg, 3, 4, 0); |
1089 | (int) msg[3] * 4, (int) msg[4]); | ||
1090 | break; | 1109 | break; |
1091 | case EXTENDED_WDTR: | 1110 | case EXTENDED_WDTR: |
1092 | printk("width = 2^%d bytes", msg[3]); | 1111 | print_nego(msg, 0, 0, 3); |
1112 | break; | ||
1113 | case EXTENDED_PPR: | ||
1114 | print_nego(msg, 3, 5, 6); | ||
1093 | break; | 1115 | break; |
1094 | default: | 1116 | default: |
1095 | for (i = 2; i < len; ++i) | 1117 | for (i = 2; i < len; ++i) |