aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/constants.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r--drivers/scsi/constants.c275
1 files changed, 29 insertions, 246 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index e2068a2621c4..fa09d4be2b53 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -18,14 +18,10 @@
18#include <scsi/scsi_eh.h> 18#include <scsi/scsi_eh.h>
19#include <scsi/scsi_dbg.h> 19#include <scsi/scsi_dbg.h>
20 20
21
22
23/* Commands with service actions that change the command name */ 21/* Commands with service actions that change the command name */
24#define THIRD_PARTY_COPY_OUT 0x83 22#define THIRD_PARTY_COPY_OUT 0x83
25#define THIRD_PARTY_COPY_IN 0x84 23#define THIRD_PARTY_COPY_IN 0x84
26 24
27#define VENDOR_SPECIFIC_CDB 0xc0
28
29struct sa_name_list { 25struct sa_name_list {
30 int opcode; 26 int opcode;
31 const struct value_name_pair *arr; 27 const struct value_name_pair *arr;
@@ -37,7 +33,6 @@ struct value_name_pair {
37 const char * name; 33 const char * name;
38}; 34};
39 35
40#ifdef CONFIG_SCSI_CONSTANTS
41static const char * cdb_byte0_names[] = { 36static const char * cdb_byte0_names[] = {
42/* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense", 37/* 00-03 */ "Test Unit Ready", "Rezero Unit/Rewind", NULL, "Request Sense",
43/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, 38/* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL,
@@ -261,28 +256,8 @@ static struct sa_name_list sa_names_arr[] = {
261 {0, NULL, 0}, 256 {0, NULL, 0},
262}; 257};
263 258
264#else /* ifndef CONFIG_SCSI_CONSTANTS */ 259bool scsi_opcode_sa_name(int opcode, int service_action,
265static const char *cdb_byte0_names[0]; 260 const char **cdb_name, const char **sa_name)
266
267static struct sa_name_list sa_names_arr[] = {
268 {VARIABLE_LENGTH_CMD, NULL, 0},
269 {MAINTENANCE_IN, NULL, 0},
270 {MAINTENANCE_OUT, NULL, 0},
271 {PERSISTENT_RESERVE_IN, NULL, 0},
272 {PERSISTENT_RESERVE_OUT, NULL, 0},
273 {SERVICE_ACTION_IN_12, NULL, 0},
274 {SERVICE_ACTION_OUT_12, NULL, 0},
275 {SERVICE_ACTION_BIDIRECTIONAL, NULL, 0},
276 {SERVICE_ACTION_IN_16, NULL, 0},
277 {SERVICE_ACTION_OUT_16, NULL, 0},
278 {THIRD_PARTY_COPY_IN, NULL, 0},
279 {THIRD_PARTY_COPY_OUT, NULL, 0},
280 {0, NULL, 0},
281};
282#endif /* CONFIG_SCSI_CONSTANTS */
283
284static bool scsi_opcode_sa_name(int opcode, int service_action,
285 const char **cdb_name, const char **sa_name)
286{ 261{
287 struct sa_name_list *sa_name_ptr; 262 struct sa_name_list *sa_name_ptr;
288 const struct value_name_pair *arr = NULL; 263 const struct value_name_pair *arr = NULL;
@@ -315,76 +290,6 @@ static bool scsi_opcode_sa_name(int opcode, int service_action,
315 return true; 290 return true;
316} 291}
317 292
318static void print_opcode_name(const unsigned char *cdbp, size_t cdb_len)
319{
320 int sa, cdb0;
321 const char *cdb_name = NULL, *sa_name = NULL;
322
323 cdb0 = cdbp[0];
324 if (cdb0 == VARIABLE_LENGTH_CMD) {
325 if (cdb_len < 10) {
326 printk("short variable length command, len=%zu",
327 cdb_len);
328 return;
329 }
330 sa = (cdbp[8] << 8) + cdbp[9];
331 } else
332 sa = cdbp[1] & 0x1f;
333
334 if (!scsi_opcode_sa_name(cdb0, sa, &cdb_name, &sa_name)) {
335 if (cdb_name)
336 printk("%s", cdb_name);
337 else if (cdb0 >= VENDOR_SPECIFIC_CDB)
338 printk("cdb[0]=0x%x (vendor)", cdb0);
339 else if (cdb0 >= 0x60 && cdb0 < 0x7e)
340 printk("cdb[0]=0x%x (reserved)", cdb0);
341 else
342 printk("cdb[0]=0x%x", cdb0);
343 } else {
344 if (sa_name)
345 printk("%s", sa_name);
346 else if (cdb_name)
347 printk("%s, sa=0x%x", cdb_name, sa);
348 else
349 printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
350 }
351}
352
353void __scsi_print_command(const unsigned char *cdb, size_t cdb_len)
354{
355 int k, len;
356
357 print_opcode_name(cdb, cdb_len);
358 len = scsi_command_size(cdb);
359 if (cdb_len < len)
360 len = cdb_len;
361 /* print out all bytes in cdb */
362 for (k = 0; k < len; ++k)
363 printk(" %02x", cdb[k]);
364 printk("\n");
365}
366EXPORT_SYMBOL(__scsi_print_command);
367
368void scsi_print_command(struct scsi_cmnd *cmd)
369{
370 int k;
371
372 if (cmd->cmnd == NULL)
373 return;
374
375 scmd_printk(KERN_INFO, cmd, "CDB: ");
376 print_opcode_name(cmd->cmnd, cmd->cmd_len);
377
378 /* print out all bytes in cdb */
379 printk(":");
380 for (k = 0; k < cmd->cmd_len; ++k)
381 printk(" %02x", cmd->cmnd[k]);
382 printk("\n");
383}
384EXPORT_SYMBOL(scsi_print_command);
385
386#ifdef CONFIG_SCSI_CONSTANTS
387
388struct error_info { 293struct error_info {
389 unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */ 294 unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
390 const char * text; 295 const char * text;
@@ -392,7 +297,7 @@ struct error_info {
392 297
393/* 298/*
394 * The canonical list of T10 Additional Sense Codes is available at: 299 * The canonical list of T10 Additional Sense Codes is available at:
395 * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] 300 * http://www.t10.org/lists/asc-num.txt [most recent: 20141221]
396 */ 301 */
397 302
398static const struct error_info additional[] = 303static const struct error_info additional[] =
@@ -421,6 +326,7 @@ static const struct error_info additional[] =
421 {0x001E, "Conflicting SA creation request"}, 326 {0x001E, "Conflicting SA creation request"},
422 {0x001F, "Logical unit transitioning to another power condition"}, 327 {0x001F, "Logical unit transitioning to another power condition"},
423 {0x0020, "Extended copy information available"}, 328 {0x0020, "Extended copy information available"},
329 {0x0021, "Atomic command aborted due to ACA"},
424 330
425 {0x0100, "No index/sector signal"}, 331 {0x0100, "No index/sector signal"},
426 332
@@ -446,6 +352,7 @@ static const struct error_info additional[] =
446 {0x040C, "Logical unit not accessible, target port in unavailable " 352 {0x040C, "Logical unit not accessible, target port in unavailable "
447 "state"}, 353 "state"},
448 {0x040D, "Logical unit not ready, structure check required"}, 354 {0x040D, "Logical unit not ready, structure check required"},
355 {0x040E, "Logical unit not ready, security session in progress"},
449 {0x0410, "Logical unit not ready, auxiliary memory not accessible"}, 356 {0x0410, "Logical unit not ready, auxiliary memory not accessible"},
450 {0x0411, "Logical unit not ready, notify (enable spinup) required"}, 357 {0x0411, "Logical unit not ready, notify (enable spinup) required"},
451 {0x0412, "Logical unit not ready, offline"}, 358 {0x0412, "Logical unit not ready, offline"},
@@ -462,6 +369,11 @@ static const struct error_info additional[] =
462 {0x041C, "Logical unit not ready, additional power use not yet " 369 {0x041C, "Logical unit not ready, additional power use not yet "
463 "granted"}, 370 "granted"},
464 {0x041D, "Logical unit not ready, configuration in progress"}, 371 {0x041D, "Logical unit not ready, configuration in progress"},
372 {0x041E, "Logical unit not ready, microcode activation required"},
373 {0x041F, "Logical unit not ready, microcode download required"},
374 {0x0420, "Logical unit not ready, logical unit reset required"},
375 {0x0421, "Logical unit not ready, hard reset required"},
376 {0x0422, "Logical unit not ready, power cycle required"},
465 377
466 {0x0500, "Logical unit does not respond to selection"}, 378 {0x0500, "Logical unit does not respond to selection"},
467 379
@@ -480,6 +392,7 @@ static const struct error_info additional[] =
480 {0x0902, "Focus servo failure"}, 392 {0x0902, "Focus servo failure"},
481 {0x0903, "Spindle servo failure"}, 393 {0x0903, "Spindle servo failure"},
482 {0x0904, "Head select fault"}, 394 {0x0904, "Head select fault"},
395 {0x0905, "Vibration induced tracking error"},
483 396
484 {0x0A00, "Error log overflow"}, 397 {0x0A00, "Error log overflow"},
485 398
@@ -510,6 +423,7 @@ static const struct error_info additional[] =
510 {0x0C0D, "Write error - not enough unsolicited data"}, 423 {0x0C0D, "Write error - not enough unsolicited data"},
511 {0x0C0E, "Multiple write errors"}, 424 {0x0C0E, "Multiple write errors"},
512 {0x0C0F, "Defects in error window"}, 425 {0x0C0F, "Defects in error window"},
426 {0x0C10, "Incomplete multiple atomic write operations"},
513 427
514 {0x0D00, "Error detected by third party temporary initiator"}, 428 {0x0D00, "Error detected by third party temporary initiator"},
515 {0x0D01, "Third party device failure"}, 429 {0x0D01, "Third party device failure"},
@@ -635,6 +549,10 @@ static const struct error_info additional[] =
635 {0x2101, "Invalid element address"}, 549 {0x2101, "Invalid element address"},
636 {0x2102, "Invalid address for write"}, 550 {0x2102, "Invalid address for write"},
637 {0x2103, "Invalid write crossing layer jump"}, 551 {0x2103, "Invalid write crossing layer jump"},
552 {0x2104, "Unaligned write command"},
553 {0x2105, "Write boundary violation"},
554 {0x2106, "Attempt to read invalid data"},
555 {0x2107, "Read boundary violation"},
638 556
639 {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"}, 557 {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"},
640 558
@@ -691,6 +609,7 @@ static const struct error_info additional[] =
691 {0x2705, "Permanent write protect"}, 609 {0x2705, "Permanent write protect"},
692 {0x2706, "Conditional write protect"}, 610 {0x2706, "Conditional write protect"},
693 {0x2707, "Space allocation failed write protect"}, 611 {0x2707, "Space allocation failed write protect"},
612 {0x2708, "Zone is read only"},
694 613
695 {0x2800, "Not ready to ready change, medium may have changed"}, 614 {0x2800, "Not ready to ready change, medium may have changed"},
696 {0x2801, "Import or export element accessed"}, 615 {0x2801, "Import or export element accessed"},
@@ -743,10 +662,15 @@ static const struct error_info additional[] =
743 {0x2C0A, "Partition or collection contains user objects"}, 662 {0x2C0A, "Partition or collection contains user objects"},
744 {0x2C0B, "Not reserved"}, 663 {0x2C0B, "Not reserved"},
745 {0x2C0C, "Orwrite generation does not match"}, 664 {0x2C0C, "Orwrite generation does not match"},
665 {0x2C0D, "Reset write pointer not allowed"},
666 {0x2C0E, "Zone is offline"},
746 667
747 {0x2D00, "Overwrite error on update in place"}, 668 {0x2D00, "Overwrite error on update in place"},
748 669
749 {0x2E00, "Insufficient time for operation"}, 670 {0x2E00, "Insufficient time for operation"},
671 {0x2E01, "Command timeout before processing"},
672 {0x2E02, "Command timeout during processing"},
673 {0x2E03, "Command timeout during processing due to error recovery"},
750 674
751 {0x2F00, "Commands cleared by another initiator"}, 675 {0x2F00, "Commands cleared by another initiator"},
752 {0x2F01, "Commands cleared by power loss notification"}, 676 {0x2F01, "Commands cleared by power loss notification"},
@@ -868,6 +792,7 @@ static const struct error_info additional[] =
868 {0x3F13, "iSCSI IP address removed"}, 792 {0x3F13, "iSCSI IP address removed"},
869 {0x3F14, "iSCSI IP address changed"}, 793 {0x3F14, "iSCSI IP address changed"},
870 {0x3F15, "Inspect referrals sense descriptors"}, 794 {0x3F15, "Inspect referrals sense descriptors"},
795 {0x3F16, "Microcode has been changed without reset"},
871/* 796/*
872 * {0x40NN, "Ram failure"}, 797 * {0x40NN, "Ram failure"},
873 * {0x40NN, "Diagnostic failure on component nn"}, 798 * {0x40NN, "Diagnostic failure on component nn"},
@@ -946,6 +871,11 @@ static const struct error_info additional[] =
946 {0x5306, "Volume identifier missing"}, 871 {0x5306, "Volume identifier missing"},
947 {0x5307, "Duplicate volume identifier"}, 872 {0x5307, "Duplicate volume identifier"},
948 {0x5308, "Element status unknown"}, 873 {0x5308, "Element status unknown"},
874 {0x5309, "Data transfer device error - load failed"},
875 {0x530a, "Data transfer device error - unload failed"},
876 {0x530b, "Data transfer device error - unload missing"},
877 {0x530c, "Data transfer device error - eject failed"},
878 {0x530d, "Data transfer device error - library communication failed"},
949 879
950 {0x5400, "Scsi to host system interface failure"}, 880 {0x5400, "Scsi to host system interface failure"},
951 881
@@ -963,6 +893,7 @@ static const struct error_info additional[] =
963 {0x550B, "Insufficient power for operation"}, 893 {0x550B, "Insufficient power for operation"},
964 {0x550C, "Insufficient resources to create rod"}, 894 {0x550C, "Insufficient resources to create rod"},
965 {0x550D, "Insufficient resources to create rod token"}, 895 {0x550D, "Insufficient resources to create rod token"},
896 {0x550E, "Insufficient zone resources"},
966 897
967 {0x5700, "Unable to recover table-of-contents"}, 898 {0x5700, "Unable to recover table-of-contents"},
968 899
@@ -1247,15 +1178,12 @@ static const char * const snstext[] = {
1247 "Completed", /* F: command completed sense data reported, 1178 "Completed", /* F: command completed sense data reported,
1248 may occur for successful command */ 1179 may occur for successful command */
1249}; 1180};
1250#endif
1251 1181
1252/* Get sense key string or NULL if not available */ 1182/* Get sense key string or NULL if not available */
1253const char * 1183const char *
1254scsi_sense_key_string(unsigned char key) { 1184scsi_sense_key_string(unsigned char key) {
1255#ifdef CONFIG_SCSI_CONSTANTS
1256 if (key <= 0xE) 1185 if (key <= 0xE)
1257 return snstext[key]; 1186 return snstext[key];
1258#endif
1259 return NULL; 1187 return NULL;
1260} 1188}
1261EXPORT_SYMBOL(scsi_sense_key_string); 1189EXPORT_SYMBOL(scsi_sense_key_string);
@@ -1267,7 +1195,6 @@ EXPORT_SYMBOL(scsi_sense_key_string);
1267const char * 1195const char *
1268scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) 1196scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
1269{ 1197{
1270#ifdef CONFIG_SCSI_CONSTANTS
1271 int i; 1198 int i;
1272 unsigned short code = ((asc << 8) | ascq); 1199 unsigned short code = ((asc << 8) | ascq);
1273 1200
@@ -1283,122 +1210,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
1283 return additional2[i].str; 1210 return additional2[i].str;
1284 } 1211 }
1285 } 1212 }
1286#else
1287 *fmt = NULL;
1288#endif
1289 return NULL; 1213 return NULL;
1290} 1214}
1291EXPORT_SYMBOL(scsi_extd_sense_format); 1215EXPORT_SYMBOL(scsi_extd_sense_format);
1292 1216
1293void
1294scsi_show_extd_sense(const struct scsi_device *sdev, const char *name,
1295 unsigned char asc, unsigned char ascq)
1296{
1297 const char *extd_sense_fmt = NULL;
1298 const char *extd_sense_str = scsi_extd_sense_format(asc, ascq,
1299 &extd_sense_fmt);
1300
1301 if (extd_sense_str) {
1302 if (extd_sense_fmt)
1303 sdev_prefix_printk(KERN_INFO, sdev, name,
1304 "Add. Sense: %s (%s%x)",
1305 extd_sense_str, extd_sense_fmt,
1306 ascq);
1307 else
1308 sdev_prefix_printk(KERN_INFO, sdev, name,
1309 "Add. Sense: %s", extd_sense_str);
1310
1311 } else {
1312 sdev_prefix_printk(KERN_INFO, sdev, name,
1313 "%sASC=0x%x %sASCQ=0x%x\n",
1314 asc >= 0x80 ? "<<vendor>> " : "", asc,
1315 ascq >= 0x80 ? "<<vendor>> " : "", ascq);
1316 }
1317}
1318EXPORT_SYMBOL(scsi_show_extd_sense);
1319
1320void
1321scsi_show_sense_hdr(const struct scsi_device *sdev, const char *name,
1322 const struct scsi_sense_hdr *sshdr)
1323{
1324 const char *sense_txt;
1325
1326 sense_txt = scsi_sense_key_string(sshdr->sense_key);
1327 if (sense_txt)
1328 sdev_prefix_printk(KERN_INFO, sdev, name,
1329 "Sense Key : %s [%s]%s\n", sense_txt,
1330 scsi_sense_is_deferred(sshdr) ?
1331 "deferred" : "current",
1332 sshdr->response_code >= 0x72 ?
1333 " [descriptor]" : "");
1334 else
1335 sdev_prefix_printk(KERN_INFO, sdev, name,
1336 "Sense Key : 0x%x [%s]%s", sshdr->sense_key,
1337 scsi_sense_is_deferred(sshdr) ?
1338 "deferred" : "current",
1339 sshdr->response_code >= 0x72 ?
1340 " [descriptor]" : "");
1341}
1342EXPORT_SYMBOL(scsi_show_sense_hdr);
1343
1344/*
1345 * Print normalized SCSI sense header with a prefix.
1346 */
1347void
1348scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name,
1349 const struct scsi_sense_hdr *sshdr)
1350{
1351 scsi_show_sense_hdr(sdev, name, sshdr);
1352 scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq);
1353}
1354EXPORT_SYMBOL(scsi_print_sense_hdr);
1355
1356static void
1357scsi_dump_sense_buffer(const unsigned char *sense_buffer, int sense_len)
1358{
1359 int k, num;
1360
1361 num = (sense_len < 32) ? sense_len : 32;
1362 printk("Unrecognized sense data (in hex):");
1363 for (k = 0; k < num; ++k) {
1364 if (0 == (k % 16)) {
1365 printk("\n");
1366 printk(KERN_INFO " ");
1367 }
1368 printk("%02x ", sense_buffer[k]);
1369 }
1370 printk("\n");
1371 return;
1372}
1373
1374/* Normalize and print sense buffer with name prefix */
1375void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
1376 const unsigned char *sense_buffer, int sense_len)
1377{
1378 struct scsi_sense_hdr sshdr;
1379
1380 if (!scsi_normalize_sense(sense_buffer, sense_len, &sshdr)) {
1381 scsi_dump_sense_buffer(sense_buffer, sense_len);
1382 return;
1383 }
1384 scsi_show_sense_hdr(sdev, name, &sshdr);
1385 scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
1386}
1387EXPORT_SYMBOL(__scsi_print_sense);
1388
1389/* Normalize and print sense buffer in SCSI command */
1390void scsi_print_sense(const struct scsi_cmnd *cmd)
1391{
1392 struct gendisk *disk = cmd->request->rq_disk;
1393 const char *disk_name = disk ? disk->disk_name : NULL;
1394
1395 __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
1396 SCSI_SENSE_BUFFERSIZE);
1397}
1398EXPORT_SYMBOL(scsi_print_sense);
1399
1400#ifdef CONFIG_SCSI_CONSTANTS
1401
1402static const char * const hostbyte_table[]={ 1217static const char * const hostbyte_table[]={
1403"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", 1218"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1404"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", 1219"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
@@ -1410,17 +1225,13 @@ static const char * const driverbyte_table[]={
1410"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1225"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1411"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1226"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
1412 1227
1413#endif
1414
1415const char *scsi_hostbyte_string(int result) 1228const char *scsi_hostbyte_string(int result)
1416{ 1229{
1417 const char *hb_string = NULL; 1230 const char *hb_string = NULL;
1418#ifdef CONFIG_SCSI_CONSTANTS
1419 int hb = host_byte(result); 1231 int hb = host_byte(result);
1420 1232
1421 if (hb < ARRAY_SIZE(hostbyte_table)) 1233 if (hb < ARRAY_SIZE(hostbyte_table))
1422 hb_string = hostbyte_table[hb]; 1234 hb_string = hostbyte_table[hb];
1423#endif
1424 return hb_string; 1235 return hb_string;
1425} 1236}
1426EXPORT_SYMBOL(scsi_hostbyte_string); 1237EXPORT_SYMBOL(scsi_hostbyte_string);
@@ -1428,17 +1239,14 @@ EXPORT_SYMBOL(scsi_hostbyte_string);
1428const char *scsi_driverbyte_string(int result) 1239const char *scsi_driverbyte_string(int result)
1429{ 1240{
1430 const char *db_string = NULL; 1241 const char *db_string = NULL;
1431#ifdef CONFIG_SCSI_CONSTANTS
1432 int db = driver_byte(result); 1242 int db = driver_byte(result);
1433 1243
1434 if (db < ARRAY_SIZE(driverbyte_table)) 1244 if (db < ARRAY_SIZE(driverbyte_table))
1435 db_string = driverbyte_table[db]; 1245 db_string = driverbyte_table[db];
1436#endif
1437 return db_string; 1246 return db_string;
1438} 1247}
1439EXPORT_SYMBOL(scsi_driverbyte_string); 1248EXPORT_SYMBOL(scsi_driverbyte_string);
1440 1249
1441#ifdef CONFIG_SCSI_CONSTANTS
1442#define scsi_mlreturn_name(result) { result, #result } 1250#define scsi_mlreturn_name(result) { result, #result }
1443static const struct value_name_pair scsi_mlreturn_arr[] = { 1251static const struct value_name_pair scsi_mlreturn_arr[] = {
1444 scsi_mlreturn_name(NEEDS_RETRY), 1252 scsi_mlreturn_name(NEEDS_RETRY),
@@ -1451,11 +1259,9 @@ static const struct value_name_pair scsi_mlreturn_arr[] = {
1451 scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED), 1259 scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED),
1452 scsi_mlreturn_name(FAST_IO_FAIL) 1260 scsi_mlreturn_name(FAST_IO_FAIL)
1453}; 1261};
1454#endif
1455 1262
1456const char *scsi_mlreturn_string(int result) 1263const char *scsi_mlreturn_string(int result)
1457{ 1264{
1458#ifdef CONFIG_SCSI_CONSTANTS
1459 const struct value_name_pair *arr = scsi_mlreturn_arr; 1265 const struct value_name_pair *arr = scsi_mlreturn_arr;
1460 int k; 1266 int k;
1461 1267
@@ -1463,29 +1269,6 @@ const char *scsi_mlreturn_string(int result)
1463 if (result == arr->value) 1269 if (result == arr->value)
1464 return arr->name; 1270 return arr->name;
1465 } 1271 }
1466#endif
1467 return NULL; 1272 return NULL;
1468} 1273}
1469EXPORT_SYMBOL(scsi_mlreturn_string); 1274EXPORT_SYMBOL(scsi_mlreturn_string);
1470
1471void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition)
1472{
1473 const char *mlret_string = scsi_mlreturn_string(disposition);
1474 const char *hb_string = scsi_hostbyte_string(cmd->result);
1475 const char *db_string = scsi_driverbyte_string(cmd->result);
1476
1477 if (hb_string || db_string)
1478 scmd_printk(KERN_INFO, cmd,
1479 "%s%s Result: hostbyte=%s driverbyte=%s",
1480 msg ? msg : "",
1481 mlret_string ? mlret_string : "UNKNOWN",
1482 hb_string ? hb_string : "invalid",
1483 db_string ? db_string : "invalid");
1484 else
1485 scmd_printk(KERN_INFO, cmd,
1486 "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x",
1487 msg ? msg : "",
1488 mlret_string ? mlret_string : "UNKNOWN",
1489 host_byte(cmd->result), driver_byte(cmd->result));
1490}
1491EXPORT_SYMBOL(scsi_print_result);