diff options
author | Hannes Reinecke <hare@suse.de> | 2014-10-24 08:26:59 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-12 05:16:04 -0500 |
commit | 3cc958cc19278de5fa090f3f7f1ed48b0170980a (patch) | |
tree | 479e1481ed6fcfb6e1556dbfbb75d0557fd38bb0 /drivers/scsi/constants.c | |
parent | 1fa6b5fbba8c7d4d0cbc428efc4838b813046420 (diff) |
scsi: separate out scsi_(host|driver)byte_string()
Export functions for later use.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/constants.c')
-rw-r--r-- | drivers/scsi/constants.c | 58 |
1 files changed, 44 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 | ||
1412 | static const char * const driverbyte_table[]={ | 1411 | static 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 | ||
1417 | void scsi_show_result(int result) | 1415 | #endif |
1416 | |||
1417 | const 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 | } |
1428 | EXPORT_SYMBOL(scsi_hostbyte_string); | ||
1426 | 1429 | ||
1427 | #else | 1430 | const 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 | } | ||
1441 | EXPORT_SYMBOL(scsi_driverbyte_string); | ||
1428 | 1442 | ||
1429 | void scsi_show_result(int result) | 1443 | void 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 | } | ||
1436 | EXPORT_SYMBOL(scsi_show_result); | 1456 | EXPORT_SYMBOL(scsi_show_result); |
1437 | 1457 | ||
1438 | 1458 | ||
1439 | void scsi_print_result(struct scsi_cmnd *cmd) | 1459 | void 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 | } |
1444 | EXPORT_SYMBOL(scsi_print_result); | 1474 | EXPORT_SYMBOL(scsi_print_result); |