diff options
-rw-r--r-- | drivers/scsi/constants.c | 22 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_logging.c | 59 | ||||
-rw-r--r-- | include/scsi/scsi_dbg.h | 2 |
4 files changed, 61 insertions, 24 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index a23ef75533d6..956fbdd38681 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -1316,25 +1316,3 @@ const char *scsi_mlreturn_string(int result) | |||
1316 | return NULL; | 1316 | return NULL; |
1317 | } | 1317 | } |
1318 | EXPORT_SYMBOL(scsi_mlreturn_string); | 1318 | EXPORT_SYMBOL(scsi_mlreturn_string); |
1319 | |||
1320 | void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition) | ||
1321 | { | ||
1322 | const char *mlret_string = scsi_mlreturn_string(disposition); | ||
1323 | const char *hb_string = scsi_hostbyte_string(cmd->result); | ||
1324 | const char *db_string = scsi_driverbyte_string(cmd->result); | ||
1325 | |||
1326 | if (hb_string || db_string) | ||
1327 | scmd_printk(KERN_INFO, cmd, | ||
1328 | "%s%s Result: hostbyte=%s driverbyte=%s", | ||
1329 | msg ? msg : "", | ||
1330 | mlret_string ? mlret_string : "UNKNOWN", | ||
1331 | hb_string ? hb_string : "invalid", | ||
1332 | db_string ? db_string : "invalid"); | ||
1333 | else | ||
1334 | scmd_printk(KERN_INFO, cmd, | ||
1335 | "%s%s Result: hostbyte=0x%02x driverbyte=0x%02x", | ||
1336 | msg ? msg : "", | ||
1337 | mlret_string ? mlret_string : "UNKNOWN", | ||
1338 | host_byte(cmd->result), driver_byte(cmd->result)); | ||
1339 | } | ||
1340 | EXPORT_SYMBOL(scsi_print_result); | ||
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index e02885451425..7f028cb1d099 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -572,7 +572,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) | |||
572 | SCSI_LOG_MLCOMPLETE_BITS); | 572 | SCSI_LOG_MLCOMPLETE_BITS); |
573 | if (((level > 0) && (cmd->result || disposition != SUCCESS)) || | 573 | if (((level > 0) && (cmd->result || disposition != SUCCESS)) || |
574 | (level > 1)) { | 574 | (level > 1)) { |
575 | scsi_print_result(cmd, "Done: ", disposition); | 575 | scsi_print_result(cmd, "Done", disposition); |
576 | scsi_print_command(cmd); | 576 | scsi_print_command(cmd); |
577 | if (status_byte(cmd->result) & CHECK_CONDITION) | 577 | if (status_byte(cmd->result) & CHECK_CONDITION) |
578 | scsi_print_sense(cmd); | 578 | scsi_print_sense(cmd); |
diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c index c7cba3113f31..6128303f9c50 100644 --- a/drivers/scsi/scsi_logging.c +++ b/drivers/scsi/scsi_logging.c | |||
@@ -428,3 +428,62 @@ void scsi_print_sense(const struct scsi_cmnd *cmd) | |||
428 | cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); | 428 | cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); |
429 | } | 429 | } |
430 | EXPORT_SYMBOL(scsi_print_sense); | 430 | EXPORT_SYMBOL(scsi_print_sense); |
431 | |||
432 | void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, | ||
433 | int disposition) | ||
434 | { | ||
435 | char *logbuf; | ||
436 | size_t off, logbuf_len; | ||
437 | const char *mlret_string = scsi_mlreturn_string(disposition); | ||
438 | const char *hb_string = scsi_hostbyte_string(cmd->result); | ||
439 | const char *db_string = scsi_driverbyte_string(cmd->result); | ||
440 | |||
441 | logbuf = scsi_log_reserve_buffer(&logbuf_len); | ||
442 | if (!logbuf) | ||
443 | return; | ||
444 | |||
445 | off = sdev_format_header(logbuf, logbuf_len, | ||
446 | scmd_name(cmd), cmd->request->tag); | ||
447 | |||
448 | if (off >= logbuf_len) | ||
449 | goto out_printk; | ||
450 | |||
451 | if (msg) { | ||
452 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
453 | "%s: ", msg); | ||
454 | if (WARN_ON(off >= logbuf_len)) | ||
455 | goto out_printk; | ||
456 | } | ||
457 | if (mlret_string) | ||
458 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
459 | "%s ", mlret_string); | ||
460 | else | ||
461 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
462 | "UNKNOWN(0x%02x) ", disposition); | ||
463 | if (WARN_ON(off >= logbuf_len)) | ||
464 | goto out_printk; | ||
465 | |||
466 | off += scnprintf(logbuf + off, logbuf_len - off, "Result: "); | ||
467 | if (WARN_ON(off >= logbuf_len)) | ||
468 | goto out_printk; | ||
469 | |||
470 | if (hb_string) | ||
471 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
472 | "hostbyte=%s ", hb_string); | ||
473 | else | ||
474 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
475 | "hostbyte=0x%02x ", host_byte(cmd->result)); | ||
476 | if (WARN_ON(off >= logbuf_len)) | ||
477 | goto out_printk; | ||
478 | |||
479 | if (db_string) | ||
480 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
481 | "driverbyte=%s", db_string); | ||
482 | else | ||
483 | off += scnprintf(logbuf + off, logbuf_len - off, | ||
484 | "driverbyte=0x%02x", driver_byte(cmd->result)); | ||
485 | out_printk: | ||
486 | dev_printk(KERN_INFO, &cmd->device->sdev_gendev, logbuf); | ||
487 | scsi_log_release_buffer(logbuf); | ||
488 | } | ||
489 | EXPORT_SYMBOL(scsi_print_result); | ||
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index c7ed7b81b338..365b6745dc10 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h | |||
@@ -21,7 +21,7 @@ extern void scsi_print_sense(const struct scsi_cmnd *); | |||
21 | extern void __scsi_print_sense(const struct scsi_device *, const char *name, | 21 | extern void __scsi_print_sense(const struct scsi_device *, const char *name, |
22 | const unsigned char *sense_buffer, | 22 | const unsigned char *sense_buffer, |
23 | int sense_len); | 23 | int sense_len); |
24 | extern void scsi_print_result(struct scsi_cmnd *, const char *, int); | 24 | extern void scsi_print_result(const struct scsi_cmnd *, const char *, int); |
25 | extern const char *scsi_hostbyte_string(int); | 25 | extern const char *scsi_hostbyte_string(int); |
26 | extern const char *scsi_driverbyte_string(int); | 26 | extern const char *scsi_driverbyte_string(int); |
27 | extern const char *scsi_mlreturn_string(int); | 27 | extern const char *scsi_mlreturn_string(int); |