diff options
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r-- | drivers/scsi/constants.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 2893464129b5..0cf43f6e464b 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -1440,19 +1440,54 @@ const char *scsi_driverbyte_string(int result) | |||
1440 | } | 1440 | } |
1441 | EXPORT_SYMBOL(scsi_driverbyte_string); | 1441 | EXPORT_SYMBOL(scsi_driverbyte_string); |
1442 | 1442 | ||
1443 | void scsi_print_result(struct scsi_cmnd *cmd) | 1443 | #ifdef CONFIG_SCSI_CONSTANTS |
1444 | #define scsi_mlreturn_name(result) { result, #result } | ||
1445 | static const struct value_name_pair scsi_mlreturn_arr[] = { | ||
1446 | scsi_mlreturn_name(NEEDS_RETRY), | ||
1447 | scsi_mlreturn_name(SUCCESS), | ||
1448 | scsi_mlreturn_name(FAILED), | ||
1449 | scsi_mlreturn_name(QUEUED), | ||
1450 | scsi_mlreturn_name(SOFT_ERROR), | ||
1451 | scsi_mlreturn_name(ADD_TO_MLQUEUE), | ||
1452 | scsi_mlreturn_name(TIMEOUT_ERROR), | ||
1453 | scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED), | ||
1454 | scsi_mlreturn_name(FAST_IO_FAIL) | ||
1455 | }; | ||
1456 | #endif | ||
1457 | |||
1458 | const char *scsi_mlreturn_string(int result) | ||
1459 | { | ||
1460 | #ifdef CONFIG_SCSI_CONSTANTS | ||
1461 | const struct value_name_pair *arr = scsi_mlreturn_arr; | ||
1462 | int k; | ||
1463 | |||
1464 | for (k = 0; k < ARRAY_SIZE(scsi_mlreturn_arr); ++k, ++arr) { | ||
1465 | if (result == arr->value) | ||
1466 | return arr->name; | ||
1467 | } | ||
1468 | #endif | ||
1469 | return NULL; | ||
1470 | } | ||
1471 | EXPORT_SYMBOL(scsi_mlreturn_string); | ||
1472 | |||
1473 | void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition) | ||
1444 | { | 1474 | { |
1475 | const char *mlret_string = scsi_mlreturn_string(disposition); | ||
1445 | const char *hb_string = scsi_hostbyte_string(cmd->result); | 1476 | const char *hb_string = scsi_hostbyte_string(cmd->result); |
1446 | const char *db_string = scsi_driverbyte_string(cmd->result); | 1477 | const char *db_string = scsi_driverbyte_string(cmd->result); |
1447 | 1478 | ||
1448 | if (hb_string || db_string) | 1479 | if (hb_string || db_string) |
1449 | scmd_printk(KERN_INFO, cmd, | 1480 | scmd_printk(KERN_INFO, cmd, |
1450 | "Result: hostbyte=%s driverbyte=%s", | 1481 | "%s%s Result: hostbyte=%s driverbyte=%s", |
1482 | msg ? msg : "", | ||
1483 | mlret_string ? mlret_string : "UNKNOWN", | ||
1451 | hb_string ? hb_string : "invalid", | 1484 | hb_string ? hb_string : "invalid", |
1452 | db_string ? db_string : "invalid"); | 1485 | db_string ? db_string : "invalid"); |
1453 | else | 1486 | else |
1454 | scmd_printk(KERN_INFO, cmd, | 1487 | scmd_printk(KERN_INFO, cmd, |
1455 | "Result: hostbyte=0x%02x driverbyte=0x%02x", | 1488 | "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x", |
1489 | msg ? msg : "", | ||
1490 | mlret_string ? mlret_string : "UNKNOWN", | ||
1456 | host_byte(cmd->result), driver_byte(cmd->result)); | 1491 | host_byte(cmd->result), driver_byte(cmd->result)); |
1457 | } | 1492 | } |
1458 | EXPORT_SYMBOL(scsi_print_result); | 1493 | EXPORT_SYMBOL(scsi_print_result); |