Commit c4cb6402 authored by Alan Stern's avatar Alan Stern Committed by James Bottomley

[PATCH] PATCH: (as255) Handle Unit Attention during INQUIRY better

Some buggy USB storage devices can return Unit Attention status for
INQUIRY commands.  The current code in scsi_scan.c checks for ASC = 0x28 =
Not ready to ready transition, but these devices can also return ASC =
0x29 = Power-on or reset occurred.  In addition, the code doesn't retry
the INQUIRY when these codes are received.
parent 4e629872
......@@ -330,6 +330,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
struct scsi_device *sdev = sreq->sr_device; /* a bit ugly */
unsigned char scsi_cmd[MAX_COMMAND_SIZE];
int possible_inq_resp_len;
int count = 0;
*bflags = 0;
repeat_inquiry:
......@@ -350,19 +351,24 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: 1st INQUIRY %s with"
" code 0x%x\n", sreq->sr_result ?
"failed" : "successful", sreq->sr_result));
++count;
if (sreq->sr_result) {
if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) != 0 &&
(sreq->sr_sense_buffer[2] & 0xf) == UNIT_ATTENTION &&
sreq->sr_sense_buffer[12] == 0x28 &&
(sreq->sr_sense_buffer[12] == 0x28 ||
sreq->sr_sense_buffer[12] == 0x29) &&
sreq->sr_sense_buffer[13] == 0) {
/* not-ready to ready transition - good */
/* not-ready to ready transition or power-on - good */
/* dpg: bogus? INQUIRY never returns UNIT_ATTENTION */
} else
/*
* assume no peripheral if any other sort of error
*/
return;
/* Supposedly, but many buggy devices do so anyway */
if (count < 3)
goto repeat_inquiry;
}
/*
* assume no peripheral if any other sort of error
*/
return;
}
/*
......
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