Commit ef72582e7a02e1069c6e6bf5eecf6f388b1467c6
Committed by
James Bottomley
1 parent
b32aaffcdc
Exists in
master
and in
7 other branches
[SCSI] Add PPR support to spi_print_msg
Introduce a new helper, print_nego() to handle SDTR/WDTR/PPR. Split out the guts of show_spi_transport_period_helper() into period_to_str() and use it in print_nego to get the period factor conversion right. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Showing 1 changed file with 29 additions and 7 deletions Side-by-side Diff
drivers/scsi/scsi_transport_spi.c
... | ... | @@ -379,9 +379,7 @@ |
379 | 379 | |
380 | 380 | /* Translate the period into ns according to the current spec |
381 | 381 | * for SDTR/PPR messages */ |
382 | -static ssize_t | |
383 | -show_spi_transport_period_helper(struct class_device *cdev, char *buf, | |
384 | - int period) | |
382 | +static int period_to_str(char *buf, int period) | |
385 | 383 | { |
386 | 384 | int len, picosec; |
387 | 385 | |
... | ... | @@ -399,6 +397,14 @@ |
399 | 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 | 408 | buf[len++] = '\n'; |
403 | 409 | buf[len] = '\0'; |
404 | 410 | return len; |
405 | 411 | |
406 | 412 | |
... | ... | @@ -1065,10 +1071,24 @@ |
1065 | 1071 | |
1066 | 1072 | static const char * const extended_msgs[] = { |
1067 | 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 | + } | |
1071 | 1085 | |
1086 | + if (off) | |
1087 | + printk("offset = %d ", msg[off]); | |
1088 | + if (width) | |
1089 | + printk("width = %d ", 8 << msg[width]); | |
1090 | +} | |
1091 | + | |
1072 | 1092 | int spi_print_msg(const unsigned char *msg) |
1073 | 1093 | { |
1074 | 1094 | int len = 0, i; |
1075 | 1095 | |
... | ... | @@ -1085,11 +1105,13 @@ |
1085 | 1105 | (msg[4] << 16) | (msg[5] << 8) | msg[6]); |
1086 | 1106 | break; |
1087 | 1107 | case EXTENDED_SDTR: |
1088 | - printk("period = %d ns, offset = %d", | |
1089 | - (int) msg[3] * 4, (int) msg[4]); | |
1108 | + print_nego(msg, 3, 4, 0); | |
1090 | 1109 | break; |
1091 | 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 | 1115 | break; |
1094 | 1116 | default: |
1095 | 1117 | for (i = 2; i < len; ++i) |