summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/constants.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-10-24 14:27:01 +0200
committerChristoph Hellwig <hch@lst.de>2014-11-12 11:16:05 +0100
commitc11c004b1c052fae77d3d0d14462d1f3a4e88d06 (patch)
tree8d04177220b7da556c33f10d1193f19b304f292c /drivers/scsi/constants.c
parentscsi: remove scsi_show_result() (diff)
downloadlinux-c11c004b1c052fae77d3d0d14462d1f3a4e88d06.tar.xz
linux-c11c004b1c052fae77d3d0d14462d1f3a4e88d06.zip
scsi: simplify scsi_log_(send|completion)
Simplify scsi_log_(send|completion) by externalizing scsi_mlreturn_string() and always print the command address. 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.c41
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)
}
EXPORT_SYMBOL(scsi_driverbyte_string);
-void scsi_print_result(struct scsi_cmnd *cmd)
+#ifdef CONFIG_SCSI_CONSTANTS
+#define scsi_mlreturn_name(result) { result, #result }
+static const struct value_name_pair scsi_mlreturn_arr[] = {
+ scsi_mlreturn_name(NEEDS_RETRY),
+ scsi_mlreturn_name(SUCCESS),
+ scsi_mlreturn_name(FAILED),
+ scsi_mlreturn_name(QUEUED),
+ scsi_mlreturn_name(SOFT_ERROR),
+ scsi_mlreturn_name(ADD_TO_MLQUEUE),
+ scsi_mlreturn_name(TIMEOUT_ERROR),
+ scsi_mlreturn_name(SCSI_RETURN_NOT_HANDLED),
+ scsi_mlreturn_name(FAST_IO_FAIL)
+};
+#endif
+
+const char *scsi_mlreturn_string(int result)
+{
+#ifdef CONFIG_SCSI_CONSTANTS
+ const struct value_name_pair *arr = scsi_mlreturn_arr;
+ int k;
+
+ for (k = 0; k < ARRAY_SIZE(scsi_mlreturn_arr); ++k, ++arr) {
+ if (result == arr->value)
+ return arr->name;
+ }
+#endif
+ return NULL;
+}
+EXPORT_SYMBOL(scsi_mlreturn_string);
+
+void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition)
{
+ const char *mlret_string = scsi_mlreturn_string(disposition);
const char *hb_string = scsi_hostbyte_string(cmd->result);
const char *db_string = scsi_driverbyte_string(cmd->result);
if (hb_string || db_string)
scmd_printk(KERN_INFO, cmd,
- "Result: hostbyte=%s driverbyte=%s",
+ "%s%s Result: hostbyte=%s driverbyte=%s",
+ msg ? msg : "",
+ mlret_string ? mlret_string : "UNKNOWN",
hb_string ? hb_string : "invalid",
db_string ? db_string : "invalid");
else
scmd_printk(KERN_INFO, cmd,
- "Result: hostbyte=0x%02x driverbyte=0x%02x",
+ "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x",
+ msg ? msg : "",
+ mlret_string ? mlret_string : "UNKNOWN",
host_byte(cmd->result), driver_byte(cmd->result));
}
EXPORT_SYMBOL(scsi_print_result);