diff options
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r-- | drivers/scsi/constants.c | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 30a335349cee..d92d5040a9fe 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -13,9 +13,9 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | 14 | ||
15 | #include <scsi/scsi.h> | 15 | #include <scsi/scsi.h> |
16 | #include <scsi/scsi_cmnd.h> | ||
16 | #include <scsi/scsi_device.h> | 17 | #include <scsi/scsi_device.h> |
17 | #include <scsi/scsi_host.h> | 18 | #include <scsi/scsi_host.h> |
18 | #include <scsi/scsi_request.h> | ||
19 | #include <scsi/scsi_eh.h> | 19 | #include <scsi/scsi_eh.h> |
20 | #include <scsi/scsi_dbg.h> | 20 | #include <scsi/scsi_dbg.h> |
21 | 21 | ||
@@ -114,8 +114,7 @@ static const struct value_name_pair maint_in_arr[] = { | |||
114 | {0xd, "Report supported task management functions"}, | 114 | {0xd, "Report supported task management functions"}, |
115 | {0xe, "Report priority"}, | 115 | {0xe, "Report priority"}, |
116 | }; | 116 | }; |
117 | #define MAINT_IN_SZ \ | 117 | #define MAINT_IN_SZ ARRAY_SIZE(maint_in_arr) |
118 | (int)(sizeof(maint_in_arr) / sizeof(maint_in_arr[0])) | ||
119 | 118 | ||
120 | static const struct value_name_pair maint_out_arr[] = { | 119 | static const struct value_name_pair maint_out_arr[] = { |
121 | {0x6, "Set device identifier"}, | 120 | {0x6, "Set device identifier"}, |
@@ -123,34 +122,29 @@ static const struct value_name_pair maint_out_arr[] = { | |||
123 | {0xb, "Change aliases"}, | 122 | {0xb, "Change aliases"}, |
124 | {0xe, "Set priority"}, | 123 | {0xe, "Set priority"}, |
125 | }; | 124 | }; |
126 | #define MAINT_OUT_SZ \ | 125 | #define MAINT_OUT_SZ ARRAY_SIZE(maint_out_arr) |
127 | (int)(sizeof(maint_out_arr) / sizeof(maint_out_arr[0])) | ||
128 | 126 | ||
129 | static const struct value_name_pair serv_in12_arr[] = { | 127 | static const struct value_name_pair serv_in12_arr[] = { |
130 | {0x1, "Read media serial number"}, | 128 | {0x1, "Read media serial number"}, |
131 | }; | 129 | }; |
132 | #define SERV_IN12_SZ \ | 130 | #define SERV_IN12_SZ ARRAY_SIZE(serv_in12_arr) |
133 | (int)(sizeof(serv_in12_arr) / sizeof(serv_in12_arr[0])) | ||
134 | 131 | ||
135 | static const struct value_name_pair serv_out12_arr[] = { | 132 | static const struct value_name_pair serv_out12_arr[] = { |
136 | {-1, "dummy entry"}, | 133 | {-1, "dummy entry"}, |
137 | }; | 134 | }; |
138 | #define SERV_OUT12_SZ \ | 135 | #define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr) |
139 | (int)(sizeof(serv_out12_arr) / sizeof(serv_in12_arr[0])) | ||
140 | 136 | ||
141 | static const struct value_name_pair serv_in16_arr[] = { | 137 | static const struct value_name_pair serv_in16_arr[] = { |
142 | {0x10, "Read capacity(16)"}, | 138 | {0x10, "Read capacity(16)"}, |
143 | {0x11, "Read long(16)"}, | 139 | {0x11, "Read long(16)"}, |
144 | }; | 140 | }; |
145 | #define SERV_IN16_SZ \ | 141 | #define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr) |
146 | (int)(sizeof(serv_in16_arr) / sizeof(serv_in16_arr[0])) | ||
147 | 142 | ||
148 | static const struct value_name_pair serv_out16_arr[] = { | 143 | static const struct value_name_pair serv_out16_arr[] = { |
149 | {0x11, "Write long(16)"}, | 144 | {0x11, "Write long(16)"}, |
150 | {0x1f, "Notify data transfer device(16)"}, | 145 | {0x1f, "Notify data transfer device(16)"}, |
151 | }; | 146 | }; |
152 | #define SERV_OUT16_SZ \ | 147 | #define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr) |
153 | (int)(sizeof(serv_out16_arr) / sizeof(serv_in16_arr[0])) | ||
154 | 148 | ||
155 | static const struct value_name_pair variable_length_arr[] = { | 149 | static const struct value_name_pair variable_length_arr[] = { |
156 | {0x1, "Rebuild(32)"}, | 150 | {0x1, "Rebuild(32)"}, |
@@ -190,8 +184,7 @@ static const struct value_name_pair variable_length_arr[] = { | |||
190 | {0x8f7e, "Perform SCSI command (osd)"}, | 184 | {0x8f7e, "Perform SCSI command (osd)"}, |
191 | {0x8f7f, "Perform task management function (osd)"}, | 185 | {0x8f7f, "Perform task management function (osd)"}, |
192 | }; | 186 | }; |
193 | #define VARIABLE_LENGTH_SZ \ | 187 | #define VARIABLE_LENGTH_SZ ARRAY_SIZE(variable_length_arr) |
194 | (int)(sizeof(variable_length_arr) / sizeof(variable_length_arr[0])) | ||
195 | 188 | ||
196 | static const char * get_sa_name(const struct value_name_pair * arr, | 189 | static const char * get_sa_name(const struct value_name_pair * arr, |
197 | int arr_sz, int service_action) | 190 | int arr_sz, int service_action) |
@@ -1268,16 +1261,6 @@ void scsi_print_sense(const char *devclass, struct scsi_cmnd *cmd) | |||
1268 | } | 1261 | } |
1269 | EXPORT_SYMBOL(scsi_print_sense); | 1262 | EXPORT_SYMBOL(scsi_print_sense); |
1270 | 1263 | ||
1271 | void scsi_print_req_sense(const char *devclass, struct scsi_request *sreq) | ||
1272 | { | ||
1273 | const char *name = devclass; | ||
1274 | |||
1275 | if (sreq->sr_request->rq_disk) | ||
1276 | name = sreq->sr_request->rq_disk->disk_name; | ||
1277 | __scsi_print_sense(name, sreq->sr_sense_buffer, SCSI_SENSE_BUFFERSIZE); | ||
1278 | } | ||
1279 | EXPORT_SYMBOL(scsi_print_req_sense); | ||
1280 | |||
1281 | void scsi_print_command(struct scsi_cmnd *cmd) | 1264 | void scsi_print_command(struct scsi_cmnd *cmd) |
1282 | { | 1265 | { |
1283 | /* Assume appended output (i.e. not at start of line) */ | 1266 | /* Assume appended output (i.e. not at start of line) */ |
@@ -1290,10 +1273,10 @@ EXPORT_SYMBOL(scsi_print_command); | |||
1290 | #ifdef CONFIG_SCSI_CONSTANTS | 1273 | #ifdef CONFIG_SCSI_CONSTANTS |
1291 | 1274 | ||
1292 | static const char * const hostbyte_table[]={ | 1275 | static const char * const hostbyte_table[]={ |
1293 | "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", | 1276 | "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", |
1294 | "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", | 1277 | "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", |
1295 | "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; | 1278 | "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; |
1296 | #define NUM_HOSTBYTE_STRS (sizeof(hostbyte_table) / sizeof(const char *)) | 1279 | #define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table) |
1297 | 1280 | ||
1298 | void scsi_print_hostbyte(int scsiresult) | 1281 | void scsi_print_hostbyte(int scsiresult) |
1299 | { | 1282 | { |
@@ -1303,7 +1286,7 @@ void scsi_print_hostbyte(int scsiresult) | |||
1303 | if (hb < NUM_HOSTBYTE_STRS) | 1286 | if (hb < NUM_HOSTBYTE_STRS) |
1304 | printk("(%s) ", hostbyte_table[hb]); | 1287 | printk("(%s) ", hostbyte_table[hb]); |
1305 | else | 1288 | else |
1306 | printk("is invalid "); | 1289 | printk("is invalid "); |
1307 | } | 1290 | } |
1308 | #else | 1291 | #else |
1309 | void scsi_print_hostbyte(int scsiresult) | 1292 | void scsi_print_hostbyte(int scsiresult) |
@@ -1315,14 +1298,14 @@ void scsi_print_hostbyte(int scsiresult) | |||
1315 | #ifdef CONFIG_SCSI_CONSTANTS | 1298 | #ifdef CONFIG_SCSI_CONSTANTS |
1316 | 1299 | ||
1317 | static const char * const driverbyte_table[]={ | 1300 | static const char * const driverbyte_table[]={ |
1318 | "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", | 1301 | "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", |
1319 | "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; | 1302 | "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; |
1320 | #define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *)) | 1303 | #define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table) |
1321 | 1304 | ||
1322 | static const char * const driversuggest_table[]={"SUGGEST_OK", | 1305 | static const char * const driversuggest_table[]={"SUGGEST_OK", |
1323 | "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", | 1306 | "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", |
1324 | "SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; | 1307 | "SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; |
1325 | #define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *)) | 1308 | #define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table) |
1326 | 1309 | ||
1327 | void scsi_print_driverbyte(int scsiresult) | 1310 | void scsi_print_driverbyte(int scsiresult) |
1328 | { | 1311 | { |