Commit d811b848 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

scsi: use sdev as argument for sense code printing

We should be using the standard dev_printk() variants for
sense code printing.

[hch: remove __scsi_print_sense call in xen-scsiback, Acked by Juergen]
[hch: folded bracing fix from Dan Carpenter]
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarRobert Elliott <elliott@hp.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 22e0d994
...@@ -602,7 +602,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, ...@@ -602,7 +602,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
#ifdef NCR_700_DEBUG #ifdef NCR_700_DEBUG
printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n", printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",
SCp, SCp->cmnd[7], result); SCp, SCp->cmnd[7], result);
scsi_print_sense("53c700", SCp); scsi_print_sense(SCp);
#endif #endif
dma_unmap_single(hostdata->dev, slot->dma_handle, dma_unmap_single(hostdata->dev, slot->dma_handle,
......
...@@ -206,7 +206,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, ...@@ -206,7 +206,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
DPRINTK("result: 0x%x\n",result); DPRINTK("result: 0x%x\n",result);
if (driver_byte(result) & DRIVER_SENSE) { if (driver_byte(result) & DRIVER_SENSE) {
if (debug) if (debug)
scsi_print_sense_hdr(ch->name, &sshdr); scsi_print_sense_hdr(ch->device, ch->name, &sshdr);
errno = ch_find_errno(&sshdr); errno = ch_find_errno(&sshdr);
switch(sshdr.sense_key) { switch(sshdr.sense_key) {
......
...@@ -1292,18 +1292,19 @@ static const struct error_info additional[] = ...@@ -1292,18 +1292,19 @@ static const struct error_info additional[] =
struct error_info2 { struct error_info2 {
unsigned char code1, code2_min, code2_max; unsigned char code1, code2_min, code2_max;
const char * str;
const char * fmt; const char * fmt;
}; };
static const struct error_info2 additional2[] = static const struct error_info2 additional2[] =
{ {
{0x40, 0x00, 0x7f, "Ram failure (%x)"}, {0x40, 0x00, 0x7f, "Ram failure", ""},
{0x40, 0x80, 0xff, "Diagnostic failure on component (%x)"}, {0x40, 0x80, 0xff, "Diagnostic failure on component", ""},
{0x41, 0x00, 0xff, "Data path failure (%x)"}, {0x41, 0x00, 0xff, "Data path failure", ""},
{0x42, 0x00, 0xff, "Power-on or self-test failure (%x)"}, {0x42, 0x00, 0xff, "Power-on or self-test failure", ""},
{0x4D, 0x00, 0xff, "Tagged overlapped commands (task tag %x)"}, {0x4D, 0x00, 0xff, "Tagged overlapped commands", "task tag "},
{0x70, 0x00, 0xff, "Decompression exception short algorithm id of %x"}, {0x70, 0x00, 0xff, "Decompression exception", "short algorithm id of "},
{0, 0, 0, NULL} {0, 0, 0, NULL, NULL}
}; };
/* description of the sense key values */ /* description of the sense key values */
...@@ -1349,7 +1350,8 @@ EXPORT_SYMBOL(scsi_sense_key_string); ...@@ -1349,7 +1350,8 @@ EXPORT_SYMBOL(scsi_sense_key_string);
* This string may contain a "%x" and should be printed with ascq as arg. * This string may contain a "%x" and should be printed with ascq as arg.
*/ */
const char * const char *
scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
{
#ifdef CONFIG_SCSI_CONSTANTS #ifdef CONFIG_SCSI_CONSTANTS
int i; int i;
unsigned short code = ((asc << 8) | ascq); unsigned short code = ((asc << 8) | ascq);
...@@ -1360,8 +1362,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { ...@@ -1360,8 +1362,10 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
for (i = 0; additional2[i].fmt; i++) { for (i = 0; additional2[i].fmt; i++) {
if (additional2[i].code1 == asc && if (additional2[i].code1 == asc &&
ascq >= additional2[i].code2_min && ascq >= additional2[i].code2_min &&
ascq <= additional2[i].code2_max) ascq <= additional2[i].code2_max) {
return additional2[i].fmt; *fmt = additional2[i].fmt;
return additional2[i].str;
}
} }
#endif #endif
return NULL; return NULL;
...@@ -1369,49 +1373,53 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) { ...@@ -1369,49 +1373,53 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
EXPORT_SYMBOL(scsi_extd_sense_format); EXPORT_SYMBOL(scsi_extd_sense_format);
void void
scsi_show_extd_sense(unsigned char asc, unsigned char ascq) scsi_show_extd_sense(const struct scsi_device *sdev, const char *name,
unsigned char asc, unsigned char ascq)
{ {
const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq); const char *extd_sense_fmt = NULL;
const char *extd_sense_str = scsi_extd_sense_format(asc, ascq,
if (extd_sense_fmt) { &extd_sense_fmt);
if (strstr(extd_sense_fmt, "%x")) {
printk("Add. Sense: "); if (extd_sense_str) {
printk(extd_sense_fmt, ascq); if (extd_sense_fmt)
} else sdev_prefix_printk(KERN_INFO, sdev, name,
printk("Add. Sense: %s", extd_sense_fmt); "Add. Sense: %s (%s%x)",
} else { extd_sense_str, extd_sense_fmt,
if (asc >= 0x80)
printk("<<vendor>> ASC=0x%x ASCQ=0x%x", asc,
ascq);
if (ascq >= 0x80)
printk("ASC=0x%x <<vendor>> ASCQ=0x%x", asc,
ascq); ascq);
else else
printk("ASC=0x%x ASCQ=0x%x", asc, ascq); sdev_prefix_printk(KERN_INFO, sdev, name,
} "Add. Sense: %s", extd_sense_str);
printk("\n"); } else {
sdev_prefix_printk(KERN_INFO, sdev, name,
"%sASC=0x%x %sASCQ=0x%x\n",
asc >= 0x80 ? "<<vendor>> " : "", asc,
ascq >= 0x80 ? "<<vendor>> " : "", ascq);
}
} }
EXPORT_SYMBOL(scsi_show_extd_sense); EXPORT_SYMBOL(scsi_show_extd_sense);
void void
scsi_show_sense_hdr(struct scsi_sense_hdr *sshdr) scsi_show_sense_hdr(const struct scsi_device *sdev, const char *name,
const struct scsi_sense_hdr *sshdr)
{ {
const char *sense_txt; const char *sense_txt;
sense_txt = scsi_sense_key_string(sshdr->sense_key); sense_txt = scsi_sense_key_string(sshdr->sense_key);
if (sense_txt) if (sense_txt)
printk("Sense Key : %s ", sense_txt); sdev_prefix_printk(KERN_INFO, sdev, name,
"Sense Key : %s [%s]%s\n", sense_txt,
scsi_sense_is_deferred(sshdr) ?
"deferred" : "current",
sshdr->response_code >= 0x72 ?
" [descriptor]" : "");
else else
printk("Sense Key : 0x%x ", sshdr->sense_key); sdev_prefix_printk(KERN_INFO, sdev, name,
"Sense Key : 0x%x [%s]%s", sshdr->sense_key,
printk("%s", scsi_sense_is_deferred(sshdr) ? "[deferred] " : scsi_sense_is_deferred(sshdr) ?
"[current] "); "deferred" : "current",
sshdr->response_code >= 0x72 ?
if (sshdr->response_code >= 0x72) " [descriptor]" : "");
printk("[descriptor]");
printk("\n");
} }
EXPORT_SYMBOL(scsi_show_sense_hdr); EXPORT_SYMBOL(scsi_show_sense_hdr);
...@@ -1419,12 +1427,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr); ...@@ -1419,12 +1427,11 @@ EXPORT_SYMBOL(scsi_show_sense_hdr);
* Print normalized SCSI sense header with a prefix. * Print normalized SCSI sense header with a prefix.
*/ */
void void
scsi_print_sense_hdr(const char *name, struct scsi_sense_hdr *sshdr) scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name,
const struct scsi_sense_hdr *sshdr)
{ {
printk(KERN_INFO "%s: ", name); scsi_show_sense_hdr(sdev, name, sshdr);
scsi_show_sense_hdr(sshdr); scsi_show_extd_sense(sdev, name, sshdr->asc, sshdr->ascq);
printk(KERN_INFO "%s: ", name);
scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
} }
EXPORT_SYMBOL(scsi_print_sense_hdr); EXPORT_SYMBOL(scsi_print_sense_hdr);
...@@ -1513,33 +1520,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len, ...@@ -1513,33 +1520,26 @@ scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
} }
/* Normalize and print sense buffer with name prefix */ /* Normalize and print sense buffer with name prefix */
void __scsi_print_sense(const char *name, const unsigned char *sense_buffer, void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
int sense_len) const unsigned char *sense_buffer, int sense_len)
{ {
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
printk(KERN_INFO "%s: ", name);
scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
scsi_show_sense_hdr(&sshdr); scsi_show_sense_hdr(sdev, name, &sshdr);
scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
printk(KERN_INFO "%s: ", name); scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
} }
EXPORT_SYMBOL(__scsi_print_sense); EXPORT_SYMBOL(__scsi_print_sense);
/* Normalize and print sense buffer in SCSI command */ /* Normalize and print sense buffer in SCSI command */
void scsi_print_sense(char *name, struct scsi_cmnd *cmd) void scsi_print_sense(const struct scsi_cmnd *cmd)
{ {
struct scsi_sense_hdr sshdr; struct gendisk *disk = cmd->request->rq_disk;
const char *disk_name = disk ? disk->disk_name : NULL;
scmd_printk(KERN_INFO, cmd, " "); __scsi_print_sense(cmd->device, disk_name, cmd->sense_buffer,
scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, SCSI_SENSE_BUFFERSIZE);
&sshdr);
scsi_show_sense_hdr(&sshdr);
scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
&sshdr);
scmd_printk(KERN_INFO, cmd, " ");
scsi_show_extd_sense(sshdr.asc, sshdr.ascq);
} }
EXPORT_SYMBOL(scsi_print_sense); EXPORT_SYMBOL(scsi_print_sense);
......
...@@ -261,7 +261,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt) ...@@ -261,7 +261,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n",
name, scode, sense[12], sense[13]); name, scode, sense[12], sense[13]);
if (cmdstatp->have_sense) if (cmdstatp->have_sense)
__scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); __scsi_print_sense(STp->device, name,
SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
} }
else else
#endif #endif
...@@ -275,7 +276,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt) ...@@ -275,7 +276,8 @@ static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */
if (cmdstatp->have_sense) { if (cmdstatp->have_sense) {
printk(KERN_WARNING "%s:W: Command with sense data:\n", name); printk(KERN_WARNING "%s:W: Command with sense data:\n", name);
__scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); __scsi_print_sense(STp->device, name,
SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
} }
else { else {
static int notyetprinted = 1; static int notyetprinted = 1;
......
...@@ -606,7 +606,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) ...@@ -606,7 +606,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
scsi_print_result(cmd); scsi_print_result(cmd);
scsi_print_command(cmd); scsi_print_command(cmd);
if (status_byte(cmd->result) & CHECK_CONDITION) if (status_byte(cmd->result) & CHECK_CONDITION)
scsi_print_sense("", cmd); scsi_print_sense(cmd);
if (level > 3) if (level > 3)
scmd_printk(KERN_INFO, cmd, scmd_printk(KERN_INFO, cmd,
"scsi host busy %d failed %d\n", "scsi host busy %d failed %d\n",
......
...@@ -1180,7 +1180,7 @@ int scsi_eh_get_sense(struct list_head *work_q, ...@@ -1180,7 +1180,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
"sense requested for %p result %x\n", "sense requested for %p result %x\n",
scmd, scmd->result)); scmd, scmd->result));
SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd)); SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense(scmd));
rtn = scsi_decide_disposition(scmd); rtn = scsi_decide_disposition(scmd);
......
...@@ -126,7 +126,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, ...@@ -126,7 +126,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
sdev_printk(KERN_INFO, sdev, sdev_printk(KERN_INFO, sdev,
"ioctl_internal_command return code = %x\n", "ioctl_internal_command return code = %x\n",
result); result);
scsi_print_sense_hdr(" ", &sshdr); scsi_print_sense_hdr(sdev, NULL, &sshdr);
break; break;
} }
} }
......
...@@ -912,7 +912,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) ...@@ -912,7 +912,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d)) if ((sshdr.asc == 0x0) && (sshdr.ascq == 0x1d))
; ;
else if (!(req->cmd_flags & REQ_QUIET)) else if (!(req->cmd_flags & REQ_QUIET))
scsi_print_sense("", cmd); scsi_print_sense(cmd);
result = 0; result = 0;
/* BLOCK_PC may have set error */ /* BLOCK_PC may have set error */
error = 0; error = 0;
...@@ -1041,7 +1041,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) ...@@ -1041,7 +1041,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
if (!(req->cmd_flags & REQ_QUIET)) { if (!(req->cmd_flags & REQ_QUIET)) {
scsi_print_result(cmd); scsi_print_result(cmd);
if (driver_byte(result) & DRIVER_SENSE) if (driver_byte(result) & DRIVER_SENSE)
scsi_print_sense("", cmd); scsi_print_sense(cmd);
scsi_print_command(cmd); scsi_print_command(cmd);
} }
if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0)) if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
......
...@@ -3336,10 +3336,11 @@ module_exit(exit_sd); ...@@ -3336,10 +3336,11 @@ module_exit(exit_sd);
static void sd_print_sense_hdr(struct scsi_disk *sdkp, static void sd_print_sense_hdr(struct scsi_disk *sdkp,
struct scsi_sense_hdr *sshdr) struct scsi_sense_hdr *sshdr)
{ {
sd_printk(KERN_INFO, sdkp, " "); scsi_show_sense_hdr(sdkp->device,
scsi_show_sense_hdr(sshdr); sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr);
sd_printk(KERN_INFO, sdkp, " "); scsi_show_extd_sense(sdkp->device,
scsi_show_extd_sense(sshdr->asc, sshdr->ascq); sdkp->disk ? sdkp->disk->disk_name : NULL,
sshdr->asc, sshdr->ascq);
} }
static void sd_print_result(struct scsi_disk *sdkp, int result) static void sd_print_result(struct scsi_disk *sdkp, int result)
......
...@@ -1365,7 +1365,7 @@ sg_rq_end_io(struct request *rq, int uptodate) ...@@ -1365,7 +1365,7 @@ sg_rq_end_io(struct request *rq, int uptodate)
if ((sdp->sgdebug > 0) && if ((sdp->sgdebug > 0) &&
((CHECK_CONDITION == srp->header.masked_status) || ((CHECK_CONDITION == srp->header.masked_status) ||
(COMMAND_TERMINATED == srp->header.masked_status))) (COMMAND_TERMINATED == srp->header.masked_status)))
__scsi_print_sense(__func__, sense, __scsi_print_sense(sdp->device, __func__, sense,
SCSI_SENSE_BUFFERSIZE); SCSI_SENSE_BUFFERSIZE);
/* Following if statement is a patch supplied by Eric Youngdale */ /* Following if statement is a patch supplied by Eric Youngdale */
......
...@@ -246,7 +246,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -246,7 +246,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
"CDROM not ready. Make sure there " "CDROM not ready. Make sure there "
"is a disc in the drive.\n"); "is a disc in the drive.\n");
#ifdef DEBUG #ifdef DEBUG
scsi_print_sense_hdr("sr", &sshdr); scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
#endif #endif
err = -ENOMEDIUM; err = -ENOMEDIUM;
break; break;
...@@ -258,14 +258,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -258,14 +258,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
err = -EDRIVE_CANT_DO_THIS; err = -EDRIVE_CANT_DO_THIS;
#ifdef DEBUG #ifdef DEBUG
__scsi_print_command(cgc->cmd); __scsi_print_command(cgc->cmd);
scsi_print_sense_hdr("sr", &sshdr); scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
#endif #endif
break; break;
default: default:
sr_printk(KERN_ERR, cd, sr_printk(KERN_ERR, cd,
"CDROM (ioctl) error, command: "); "CDROM (ioctl) error, command: ");
__scsi_print_command(cgc->cmd); __scsi_print_command(cgc->cmd);
scsi_print_sense_hdr("sr", &sshdr); scsi_print_sense_hdr(cd->device, cd->cdi.name, &sshdr);
err = -EIO; err = -EIO;
} }
} }
......
...@@ -381,7 +381,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) ...@@ -381,7 +381,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
if (cmdstatp->have_sense) if (cmdstatp->have_sense)
__scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); __scsi_print_sense(STp->device, name,
SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
} ) /* end DEB */ } ) /* end DEB */
if (!debugging) { /* Abnormal conditions for tape */ if (!debugging) { /* Abnormal conditions for tape */
if (!cmdstatp->have_sense) if (!cmdstatp->have_sense)
...@@ -397,7 +398,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) ...@@ -397,7 +398,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
SRpnt->cmd[0] != MODE_SENSE && SRpnt->cmd[0] != MODE_SENSE &&
SRpnt->cmd[0] != TEST_UNIT_READY) { SRpnt->cmd[0] != TEST_UNIT_READY) {
__scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); __scsi_print_sense(STp->device, name,
SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
} }
} }
......
...@@ -1097,7 +1097,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request) ...@@ -1097,7 +1097,8 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
if (scmnd->result) { if (scmnd->result) {
if (scsi_normalize_sense(scmnd->sense_buffer, if (scsi_normalize_sense(scmnd->sense_buffer,
SCSI_SENSE_BUFFERSIZE, &sense_hdr)) SCSI_SENSE_BUFFERSIZE, &sense_hdr))
scsi_print_sense_hdr("storvsc", &sense_hdr); scsi_print_sense_hdr(scmnd->device, "storvsc",
&sense_hdr);
} }
if (vm_srb->srb_status != SRB_STATUS_SUCCESS) if (vm_srb->srb_status != SRB_STATUS_SUCCESS)
......
...@@ -4710,8 +4710,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, ...@@ -4710,8 +4710,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
"START_STOP failed for power mode: %d\n", pwr_mode); "START_STOP failed for power mode: %d\n", pwr_mode);
scsi_show_result(ret); scsi_show_result(ret);
if (driver_byte(ret) & DRIVER_SENSE) { if (driver_byte(ret) & DRIVER_SENSE) {
scsi_show_sense_hdr(&sshdr); scsi_show_sense_hdr(sdp, NULL, &sshdr);
scsi_show_extd_sense(sshdr.asc, sshdr.ascq); scsi_show_extd_sense(sdp, NULL, sshdr.asc, sshdr.ascq);
} }
} }
......
...@@ -164,10 +164,10 @@ void usb_stor_show_sense(const struct us_data *us, ...@@ -164,10 +164,10 @@ void usb_stor_show_sense(const struct us_data *us,
unsigned char asc, unsigned char asc,
unsigned char ascq) unsigned char ascq)
{ {
const char *what, *keystr; const char *what, *keystr, *fmt;
keystr = scsi_sense_key_string(key); keystr = scsi_sense_key_string(key);
what = scsi_extd_sense_format(asc, ascq); what = scsi_extd_sense_format(asc, ascq, &fmt);
if (keystr == NULL) if (keystr == NULL)
keystr = "(Unknown Key)"; keystr = "(Unknown Key)";
...@@ -175,8 +175,10 @@ void usb_stor_show_sense(const struct us_data *us, ...@@ -175,8 +175,10 @@ void usb_stor_show_sense(const struct us_data *us,
what = "(unknown ASC/ASCQ)"; what = "(unknown ASC/ASCQ)";
usb_stor_dbg(us, "%s: ", keystr); usb_stor_dbg(us, "%s: ", keystr);
US_DEBUGPX(what, ascq); if (fmt)
US_DEBUGPX("\n"); US_DEBUGPX("%s (%s%x)\n", what, fmt, ascq);
else
US_DEBUGPX("%s\n", what);
} }
int usb_stor_dbg(const struct us_data *us, const char *fmt, ...) int usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
......
...@@ -274,10 +274,6 @@ static void scsiback_print_status(char *sense_buffer, int errors, ...@@ -274,10 +274,6 @@ static void scsiback_print_status(char *sense_buffer, int errors,
tpg->tport->tport_name, pending_req->v2p->lun, tpg->tport->tport_name, pending_req->v2p->lun,
pending_req->cmnd[0], status_byte(errors), msg_byte(errors), pending_req->cmnd[0], status_byte(errors), msg_byte(errors),
host_byte(errors), driver_byte(errors)); host_byte(errors), driver_byte(errors));
if (CHECK_CONDITION & status_byte(errors))
__scsi_print_sense("xen-pvscsi", sense_buffer,
SCSI_SENSE_BUFFERSIZE);
} }
static void scsiback_fast_flush_area(struct vscsibk_pend *req) static void scsiback_fast_flush_area(struct vscsibk_pend *req)
......
...@@ -2,21 +2,26 @@ ...@@ -2,21 +2,26 @@
#define _SCSI_SCSI_DBG_H #define _SCSI_SCSI_DBG_H
struct scsi_cmnd; struct scsi_cmnd;
struct scsi_device;
struct scsi_sense_hdr; struct scsi_sense_hdr;
extern void scsi_print_command(struct scsi_cmnd *); extern void scsi_print_command(struct scsi_cmnd *);
extern void __scsi_print_command(unsigned char *); extern void __scsi_print_command(unsigned char *);
extern void scsi_show_extd_sense(unsigned char, unsigned char); extern void scsi_show_extd_sense(const struct scsi_device *, const char *,
extern void scsi_show_sense_hdr(struct scsi_sense_hdr *); unsigned char, unsigned char);
extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); extern void scsi_show_sense_hdr(const struct scsi_device *, const char *,
extern void scsi_print_sense(char *, struct scsi_cmnd *); const struct scsi_sense_hdr *);
extern void __scsi_print_sense(const char *name, extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
const struct scsi_sense_hdr *);
extern void scsi_print_sense(const struct scsi_cmnd *);
extern void __scsi_print_sense(const struct scsi_device *, const char *name,
const unsigned char *sense_buffer, const unsigned char *sense_buffer,
int sense_len); int sense_len);
extern void scsi_show_result(int); extern void scsi_show_result(int);
extern void scsi_print_result(struct scsi_cmnd *); extern void scsi_print_result(struct scsi_cmnd *);
extern void scsi_print_status(unsigned char); extern void scsi_print_status(unsigned char);
extern const char *scsi_sense_key_string(unsigned char); extern const char *scsi_sense_key_string(unsigned char);
extern const char *scsi_extd_sense_format(unsigned char, unsigned char); extern const char *scsi_extd_sense_format(unsigned char, unsigned char,
const char **);
#endif /* _SCSI_SCSI_DBG_H */ #endif /* _SCSI_SCSI_DBG_H */
...@@ -47,7 +47,7 @@ extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, ...@@ -47,7 +47,7 @@ extern int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd, extern int scsi_command_normalize_sense(struct scsi_cmnd *cmd,
struct scsi_sense_hdr *sshdr); struct scsi_sense_hdr *sshdr);
static inline int scsi_sense_is_deferred(struct scsi_sense_hdr *sshdr) static inline int scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
{ {
return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1)); return ((sshdr->response_code >= 0x70) && (sshdr->response_code & 1));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment