aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/constants.c58
-rw-r--r--include/scsi/scsi_dbg.h2
2 files changed, 46 insertions, 14 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index a84ced0de02b..541a8620929c 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1407,38 +1407,68 @@ static const char * const hostbyte_table[]={
1407"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE", 1407"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", "DID_REQUEUE",
1408"DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE", 1408"DID_TRANSPORT_DISRUPTED", "DID_TRANSPORT_FAILFAST", "DID_TARGET_FAILURE",
1409"DID_NEXUS_FAILURE" }; 1409"DID_NEXUS_FAILURE" };
1410#define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
1411 1410
1412static const char * const driverbyte_table[]={ 1411static const char * const driverbyte_table[]={
1413"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1412"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1414"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1413"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
1415#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
1416 1414
1417void scsi_show_result(int result) 1415#endif
1416
1417const char *scsi_hostbyte_string(int result)
1418{ 1418{
1419 const char *hb_string = NULL;
1420#ifdef CONFIG_SCSI_CONSTANTS
1419 int hb = host_byte(result); 1421 int hb = host_byte(result);
1420 int db = driver_byte(result);
1421 1422
1422 printk("Result: hostbyte=%s driverbyte=%s\n", 1423 if (hb < ARRAY_SIZE(hostbyte_table))
1423 (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"), 1424 hb_string = hostbyte_table[hb];
1424 (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid")); 1425#endif
1426 return hb_string;
1425} 1427}
1428EXPORT_SYMBOL(scsi_hostbyte_string);
1426 1429
1427#else 1430const char *scsi_driverbyte_string(int result)
1431{
1432 const char *db_string = NULL;
1433#ifdef CONFIG_SCSI_CONSTANTS
1434 int db = driver_byte(result);
1435
1436 if (db < ARRAY_SIZE(driverbyte_table))
1437 db_string = driverbyte_table[db];
1438#endif
1439 return db_string;
1440}
1441EXPORT_SYMBOL(scsi_driverbyte_string);
1428 1442
1429void scsi_show_result(int result) 1443void scsi_show_result(int result)
1430{ 1444{
1431 printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n", 1445 const char *hb_string = scsi_hostbyte_string(result);
1432 host_byte(result), driver_byte(result)); 1446 const char *db_string = scsi_driverbyte_string(result);
1433}
1434 1447
1435#endif 1448 if (hb_string || db_string)
1449 printk("Result: hostbyte=%s driverbyte=%s\n",
1450 hb_string ? hb_string : "invalid",
1451 db_string ? db_string : "invalid");
1452 else
1453 printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
1454 host_byte(result), driver_byte(result));
1455}
1436EXPORT_SYMBOL(scsi_show_result); 1456EXPORT_SYMBOL(scsi_show_result);
1437 1457
1438 1458
1439void scsi_print_result(struct scsi_cmnd *cmd) 1459void scsi_print_result(struct scsi_cmnd *cmd)
1440{ 1460{
1441 scmd_printk(KERN_INFO, cmd, " "); 1461 const char *hb_string = scsi_hostbyte_string(cmd->result);
1442 scsi_show_result(cmd->result); 1462 const char *db_string = scsi_driverbyte_string(cmd->result);
1463
1464 if (hb_string || db_string)
1465 scmd_printk(KERN_INFO, cmd,
1466 "Result: hostbyte=%s driverbyte=%s",
1467 hb_string ? hb_string : "invalid",
1468 db_string ? db_string : "invalid");
1469 else
1470 scmd_printk(KERN_INFO, cmd,
1471 "Result: hostbyte=0x%02x driverbyte=0x%02x",
1472 host_byte(cmd->result), driver_byte(cmd->result));
1443} 1473}
1444EXPORT_SYMBOL(scsi_print_result); 1474EXPORT_SYMBOL(scsi_print_result);
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 81d041822229..50f4d8542ece 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -19,6 +19,8 @@ extern void __scsi_print_sense(const struct scsi_device *, const char *name,
19 int sense_len); 19 int sense_len);
20extern void scsi_show_result(int); 20extern void scsi_show_result(int);
21extern void scsi_print_result(struct scsi_cmnd *); 21extern void scsi_print_result(struct scsi_cmnd *);
22extern const char *scsi_hostbyte_string(int);
23extern const char *scsi_driverbyte_string(int);
22extern const char *scsi_sense_key_string(unsigned char); 24extern const char *scsi_sense_key_string(unsigned char);
23extern const char *scsi_extd_sense_format(unsigned char, unsigned char, 25extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
24 const char **); 26 const char **);