diff options
author | Matthew Wilcox <matthew@wil.cx> | 2005-12-15 16:22:01 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-12-15 21:41:13 -0500 |
commit | 410ca5c7c6ed08bda165e8137bff26c3fbee5a1b (patch) | |
tree | 079d028ecb7ea645f0948e3a90a919c7c4f35eee /drivers/scsi/scsi_transport_spi.c | |
parent | 7b16318dea8d9840dac567a2ae8c50ecdea36aea (diff) |
[SCSI] Move scsi_print_msg to SPI class
scsi_print_msg() is an SPI-specific concept. This patch moves it from
constants.c to scsi_transport_spi.c and updates the Kconfig to link in
the SPI class for the drivers which use scsi_print_msg().
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 | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 4002a98ab16f..00a73fc23fcc 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | #include <linux/config.h> | ||
21 | #include <linux/ctype.h> | 22 | #include <linux/ctype.h> |
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -1047,6 +1048,114 @@ void spi_display_xfer_agreement(struct scsi_target *starget) | |||
1047 | } | 1048 | } |
1048 | EXPORT_SYMBOL(spi_display_xfer_agreement); | 1049 | EXPORT_SYMBOL(spi_display_xfer_agreement); |
1049 | 1050 | ||
1051 | #ifdef CONFIG_SCSI_CONSTANTS | ||
1052 | static const char * const one_byte_msgs[] = { | ||
1053 | /* 0x00 */ "Command Complete", NULL, "Save Pointers", | ||
1054 | /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", | ||
1055 | /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error", | ||
1056 | /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag", | ||
1057 | /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", | ||
1058 | /* 0x0f */ "Initiate Recovery", "Release Recovery" | ||
1059 | }; | ||
1060 | #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) | ||
1061 | |||
1062 | static const char * const two_byte_msgs[] = { | ||
1063 | /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag" | ||
1064 | /* 0x23 */ "Ignore Wide Residue" | ||
1065 | }; | ||
1066 | #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) | ||
1067 | |||
1068 | static const char * const extended_msgs[] = { | ||
1069 | /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", | ||
1070 | /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" | ||
1071 | }; | ||
1072 | #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) | ||
1073 | |||
1074 | |||
1075 | int scsi_print_msg (const unsigned char *msg) | ||
1076 | { | ||
1077 | int len = 0, i; | ||
1078 | if (msg[0] == EXTENDED_MESSAGE) { | ||
1079 | len = 3 + msg[1]; | ||
1080 | if (msg[2] < NO_EXTENDED_MSGS) | ||
1081 | printk ("%s ", extended_msgs[msg[2]]); | ||
1082 | else | ||
1083 | printk ("Extended Message, reserved code (0x%02x) ", | ||
1084 | (int) msg[2]); | ||
1085 | switch (msg[2]) { | ||
1086 | case EXTENDED_MODIFY_DATA_POINTER: | ||
1087 | printk("pointer = %d", (int) (msg[3] << 24) | | ||
1088 | (msg[4] << 16) | (msg[5] << 8) | msg[6]); | ||
1089 | break; | ||
1090 | case EXTENDED_SDTR: | ||
1091 | printk("period = %d ns, offset = %d", | ||
1092 | (int) msg[3] * 4, (int) msg[4]); | ||
1093 | break; | ||
1094 | case EXTENDED_WDTR: | ||
1095 | printk("width = 2^%d bytes", msg[3]); | ||
1096 | break; | ||
1097 | default: | ||
1098 | for (i = 2; i < len; ++i) | ||
1099 | printk("%02x ", msg[i]); | ||
1100 | } | ||
1101 | /* Identify */ | ||
1102 | } else if (msg[0] & 0x80) { | ||
1103 | printk("Identify disconnect %sallowed %s %d ", | ||
1104 | (msg[0] & 0x40) ? "" : "not ", | ||
1105 | (msg[0] & 0x20) ? "target routine" : "lun", | ||
1106 | msg[0] & 0x7); | ||
1107 | len = 1; | ||
1108 | /* Normal One byte */ | ||
1109 | } else if (msg[0] < 0x1f) { | ||
1110 | if (msg[0] < NO_ONE_BYTE_MSGS) | ||
1111 | printk(one_byte_msgs[msg[0]]); | ||
1112 | else | ||
1113 | printk("reserved (%02x) ", msg[0]); | ||
1114 | len = 1; | ||
1115 | /* Two byte */ | ||
1116 | } else if (msg[0] <= 0x2f) { | ||
1117 | if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) | ||
1118 | printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], | ||
1119 | msg[1]); | ||
1120 | else | ||
1121 | printk("reserved two byte (%02x %02x) ", | ||
1122 | msg[0], msg[1]); | ||
1123 | len = 2; | ||
1124 | } else | ||
1125 | printk("reserved"); | ||
1126 | return len; | ||
1127 | } | ||
1128 | EXPORT_SYMBOL(scsi_print_msg); | ||
1129 | |||
1130 | #else /* ifndef CONFIG_SCSI_CONSTANTS */ | ||
1131 | |||
1132 | int scsi_print_msg (const unsigned char *msg) | ||
1133 | { | ||
1134 | int len = 0, i; | ||
1135 | |||
1136 | if (msg[0] == EXTENDED_MESSAGE) { | ||
1137 | len = 3 + msg[1]; | ||
1138 | for (i = 0; i < len; ++i) | ||
1139 | printk("%02x ", msg[i]); | ||
1140 | /* Identify */ | ||
1141 | } else if (msg[0] & 0x80) { | ||
1142 | printk("%02x ", msg[0]); | ||
1143 | len = 1; | ||
1144 | /* Normal One byte */ | ||
1145 | } else if (msg[0] < 0x1f) { | ||
1146 | printk("%02x ", msg[0]); | ||
1147 | len = 1; | ||
1148 | /* Two byte */ | ||
1149 | } else if (msg[0] <= 0x2f) { | ||
1150 | printk("%02x %02x", msg[0], msg[1]); | ||
1151 | len = 2; | ||
1152 | } else | ||
1153 | printk("%02x ", msg[0]); | ||
1154 | return len; | ||
1155 | } | ||
1156 | EXPORT_SYMBOL(scsi_print_msg); | ||
1157 | #endif /* ! CONFIG_SCSI_CONSTANTS */ | ||
1158 | |||
1050 | #define SETUP_ATTRIBUTE(field) \ | 1159 | #define SETUP_ATTRIBUTE(field) \ |
1051 | i->private_attrs[count] = class_device_attr_##field; \ | 1160 | i->private_attrs[count] = class_device_attr_##field; \ |
1052 | if (!i->f->set_##field) { \ | 1161 | if (!i->f->set_##field) { \ |