diff options
Diffstat (limited to 'drivers/usb/storage/transport.c')
| -rw-r--r-- | drivers/usb/storage/transport.c | 244 |
1 files changed, 137 insertions, 107 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 00418995d8e..22c7d4360fa 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -46,6 +46,7 @@ #include <linux/sched.h> #include <linux/gfp.h> #include <linux/errno.h> +#include <linux/export.h> #include <linux/usb/quirks.h> @@ -165,7 +166,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) /* cancel the URB, if it hasn't been cancelled already */ if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { - US_DEBUGP("-- cancelling URB\n"); + usb_stor_dbg(us, "-- cancelling URB\n"); usb_unlink_urb(us->current_urb); } } @@ -177,8 +178,8 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags); if (timeleft <= 0) { - US_DEBUGP("%s -- cancelling URB\n", - timeleft == 0 ? "Timeout" : "Signal"); + usb_stor_dbg(us, "%s -- cancelling URB\n", + timeleft == 0 ? "Timeout" : "Signal"); usb_kill_urb(us->current_urb); } @@ -196,9 +197,8 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe, { int status; - US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", - __func__, request, requesttype, - value, index, size); + usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", + request, requesttype, value, index, size); /* fill in the devrequest structure */ us->cr->bRequestType = requesttype; @@ -248,7 +248,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe) if (result >= 0) usb_reset_endpoint(us->pusb_dev, endp); - US_DEBUGP("%s: result = %d\n", __func__, result); + usb_stor_dbg(us, "result = %d\n", result); return result; } EXPORT_SYMBOL_GPL(usb_stor_clear_halt); @@ -264,18 +264,18 @@ EXPORT_SYMBOL_GPL(usb_stor_clear_halt); static int interpret_urb_result(struct us_data *us, unsigned int pipe, unsigned int length, int result, unsigned int partial) { - US_DEBUGP("Status code %d; transferred %u/%u\n", - result, partial, length); + usb_stor_dbg(us, "Status code %d; transferred %u/%u\n", + result, partial, length); switch (result) { /* no error code; did we send all the data? */ case 0: if (partial != length) { - US_DEBUGP("-- short transfer\n"); + usb_stor_dbg(us, "-- short transfer\n"); return USB_STOR_XFER_SHORT; } - US_DEBUGP("-- transfer complete\n"); + usb_stor_dbg(us, "-- transfer complete\n"); return USB_STOR_XFER_GOOD; /* stalled */ @@ -283,39 +283,40 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe, /* for control endpoints, (used by CB[I]) a stall indicates * a failed command */ if (usb_pipecontrol(pipe)) { - US_DEBUGP("-- stall on control pipe\n"); + usb_stor_dbg(us, "-- stall on control pipe\n"); return USB_STOR_XFER_STALLED; } /* for other sorts of endpoint, clear the stall */ - US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); + usb_stor_dbg(us, "clearing endpoint halt for pipe 0x%x\n", + pipe); if (usb_stor_clear_halt(us, pipe) < 0) return USB_STOR_XFER_ERROR; return USB_STOR_XFER_STALLED; /* babble - the device tried to send more than we wanted to read */ case -EOVERFLOW: - US_DEBUGP("-- babble\n"); + usb_stor_dbg(us, "-- babble\n"); return USB_STOR_XFER_LONG; /* the transfer was cancelled by abort, disconnect, or timeout */ case -ECONNRESET: - US_DEBUGP("-- transfer cancelled\n"); + usb_stor_dbg(us, "-- transfer cancelled\n"); return USB_STOR_XFER_ERROR; /* short scatter-gather read transfer */ case -EREMOTEIO: - US_DEBUGP("-- short read transfer\n"); + usb_stor_dbg(us, "-- short read transfer\n"); return USB_STOR_XFER_SHORT; /* abort or disconnect in progress */ case -EIO: - US_DEBUGP("-- abort or disconnect in progress\n"); + usb_stor_dbg(us, "-- abort or disconnect in progress\n"); return USB_STOR_XFER_ERROR; /* the catch-all error case */ default: - US_DEBUGP("-- unknown error\n"); + usb_stor_dbg(us, "-- unknown error\n"); return USB_STOR_XFER_ERROR; } } @@ -330,9 +331,8 @@ int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe, { int result; - US_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", - __func__, request, requesttype, - value, index, size); + usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", + request, requesttype, value, index, size); /* fill in the devrequest structure */ us->cr->bRequestType = requesttype; @@ -366,7 +366,7 @@ static int usb_stor_intr_transfer(struct us_data *us, void *buf, unsigned int pipe = us->recv_intr_pipe; unsigned int maxp; - US_DEBUGP("%s: xfer %u bytes\n", __func__, length); + usb_stor_dbg(us, "xfer %u bytes\n", length); /* calculate the max packet size */ maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe)); @@ -393,7 +393,7 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe, { int result; - US_DEBUGP("%s: xfer %u bytes\n", __func__, length); + usb_stor_dbg(us, "xfer %u bytes\n", length); /* fill and submit the URB */ usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, @@ -425,12 +425,11 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, return USB_STOR_XFER_ERROR; /* initialize the scatter-gather request block */ - US_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, - length, num_sg); + usb_stor_dbg(us, "xfer %u bytes, %d entries\n", length, num_sg); result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, sg, num_sg, length, GFP_NOIO); if (result) { - US_DEBUGP("usb_sg_init returned %d\n", result); + usb_stor_dbg(us, "usb_sg_init returned %d\n", result); return USB_STOR_XFER_ERROR; } @@ -443,7 +442,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, /* cancel the request, if it hasn't been cancelled already */ if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { - US_DEBUGP("-- cancelling sg request\n"); + usb_stor_dbg(us, "-- cancelling sg request\n"); usb_sg_cancel(&us->current_sg); } } @@ -608,14 +607,14 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) * short-circuit all other processing */ if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { - US_DEBUGP("-- command was aborted\n"); + usb_stor_dbg(us, "-- command was aborted\n"); srb->result = DID_ABORT << 16; goto Handle_Errors; } /* if there is a transport error, reset and don't auto-sense */ if (result == USB_STOR_TRANSPORT_ERROR) { - US_DEBUGP("-- transport indicates error, resetting\n"); + usb_stor_dbg(us, "-- transport indicates error, resetting\n"); srb->result = DID_ERROR << 16; goto Handle_Errors; } @@ -644,7 +643,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) */ if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) && srb->sc_data_direction != DMA_FROM_DEVICE) { - US_DEBUGP("-- CB transport device requiring auto-sense\n"); + usb_stor_dbg(us, "-- CB transport device requiring auto-sense\n"); need_auto_sense = 1; } @@ -654,7 +653,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) * "failure" and an "error" in the transport mechanism. */ if (result == USB_STOR_TRANSPORT_FAILED) { - US_DEBUGP("-- transport indicates command failure\n"); + usb_stor_dbg(us, "-- transport indicates command failure\n"); need_auto_sense = 1; } @@ -669,7 +668,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) !(us->fflags & US_FL_SANE_SENSE) && !(us->fflags & US_FL_BAD_SENSE) && !(srb->cmnd[2] & 0x20))) { - US_DEBUGP("-- SAT supported, increasing auto-sense\n"); + usb_stor_dbg(us, "-- SAT supported, increasing auto-sense\n"); us->fflags |= US_FL_SANE_SENSE; } @@ -683,7 +682,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) (srb->cmnd[0] == MODE_SENSE) || (srb->cmnd[0] == LOG_SENSE) || (srb->cmnd[0] == MODE_SENSE_10))) { - US_DEBUGP("-- unexpectedly short transfer\n"); + usb_stor_dbg(us, "-- unexpectedly short transfer\n"); } /* Now, if we need to do the auto-sense, let's do it */ @@ -691,12 +690,15 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) int temp_result; struct scsi_eh_save ses; int sense_size = US_SENSE_SIZE; + struct scsi_sense_hdr sshdr; + const u8 *scdd; + u8 fm_ili; /* device supports and needs bigger sense buffer */ if (us->fflags & US_FL_SANE_SENSE) sense_size = ~0; Retry_Sense: - US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); + usb_stor_dbg(us, "Issuing auto-REQUEST_SENSE\n"); scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size); @@ -715,7 +717,7 @@ Retry_Sense: scsi_eh_restore_cmnd(srb, &ses); if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { - US_DEBUGP("-- auto-sense aborted\n"); + usb_stor_dbg(us, "-- auto-sense aborted\n"); srb->result = DID_ABORT << 16; /* If SANE_SENSE caused this problem, disable it */ @@ -733,7 +735,7 @@ Retry_Sense: */ if (temp_result == USB_STOR_TRANSPORT_FAILED && sense_size != US_SENSE_SIZE) { - US_DEBUGP("-- auto-sense failure, retry small sense\n"); + usb_stor_dbg(us, "-- auto-sense failure, retry small sense\n"); sense_size = US_SENSE_SIZE; us->fflags &= ~US_FL_SANE_SENSE; us->fflags |= US_FL_BAD_SENSE; @@ -742,7 +744,7 @@ Retry_Sense: /* Other failures */ if (temp_result != USB_STOR_TRANSPORT_GOOD) { - US_DEBUGP("-- auto-sense failure\n"); + usb_stor_dbg(us, "-- auto-sense failure\n"); /* we skip the reset if this happens to be a * multi-target device, since failure of an @@ -762,44 +764,43 @@ Retry_Sense: !(us->fflags & US_FL_SANE_SENSE) && !(us->fflags & US_FL_BAD_SENSE) && (srb->sense_buffer[0] & 0x7C) == 0x70) { - US_DEBUGP("-- SANE_SENSE support enabled\n"); + usb_stor_dbg(us, "-- SANE_SENSE support enabled\n"); us->fflags |= US_FL_SANE_SENSE; /* Indicate to the user that we truncated their sense * because we didn't know it supported larger sense. */ - US_DEBUGP("-- Sense data truncated to %i from %i\n", - US_SENSE_SIZE, - srb->sense_buffer[7] + 8); + usb_stor_dbg(us, "-- Sense data truncated to %i from %i\n", + US_SENSE_SIZE, + srb->sense_buffer[7] + 8); srb->sense_buffer[7] = (US_SENSE_SIZE - 8); } - US_DEBUGP("-- Result from auto-sense is %d\n", temp_result); - US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", - srb->sense_buffer[0], - srb->sense_buffer[2] & 0xf, - srb->sense_buffer[12], - srb->sense_buffer[13]); + scsi_normalize_sense(srb->sense_buffer, SCSI_SENSE_BUFFERSIZE, + &sshdr); + + usb_stor_dbg(us, "-- Result from auto-sense is %d\n", + temp_result); + usb_stor_dbg(us, "-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", + sshdr.response_code, sshdr.sense_key, + sshdr.asc, sshdr.ascq); #ifdef CONFIG_USB_STORAGE_DEBUG - usb_stor_show_sense( - srb->sense_buffer[2] & 0xf, - srb->sense_buffer[12], - srb->sense_buffer[13]); + usb_stor_show_sense(us, sshdr.sense_key, sshdr.asc, sshdr.ascq); #endif /* set the result so the higher layers expect this data */ srb->result = SAM_STAT_CHECK_CONDITION; + scdd = scsi_sense_desc_find(srb->sense_buffer, + SCSI_SENSE_BUFFERSIZE, 4); + fm_ili = (scdd ? scdd[3] : srb->sense_buffer[2]) & 0xA0; + /* We often get empty sense data. This could indicate that * everything worked or that there was an unspecified * problem. We have to decide which. */ - if ( /* Filemark 0, ignore EOM, ILI 0, no sense */ - (srb->sense_buffer[2] & 0xaf) == 0 && - /* No ASC or ASCQ */ - srb->sense_buffer[12] == 0 && - srb->sense_buffer[13] == 0) { - + if (sshdr.sense_key == 0 && sshdr.asc == 0 && sshdr.ascq == 0 && + fm_ili == 0) { /* If things are really okay, then let's show that. * Zero out the sense buffer so the higher layers * won't realize we did an unsolicited auto-sense. @@ -814,11 +815,43 @@ Retry_Sense: */ } else { srb->result = DID_ERROR << 16; - srb->sense_buffer[2] = HARDWARE_ERROR; + if ((sshdr.response_code & 0x72) == 0x72) + srb->sense_buffer[1] = HARDWARE_ERROR; + else + srb->sense_buffer[2] = HARDWARE_ERROR; } } } + /* + * Some devices don't work or return incorrect data the first + * time they get a READ(10) command, or for the first READ(10) + * after a media change. If the INITIAL_READ10 flag is set, + * keep track of whether READ(10) commands succeed. If the + * previous one succeeded and this one failed, set the REDO_READ10 + * flag to force a retry. + */ + if (unlikely((us->fflags & US_FL_INITIAL_READ10) && + srb->cmnd[0] == READ_10)) { + if (srb->result == SAM_STAT_GOOD) { + set_bit(US_FLIDX_READ10_WORKED, &us->dflags); + } else if (test_bit(US_FLIDX_READ10_WORKED, &us->dflags)) { + clear_bit(US_FLIDX_READ10_WORKED, &us->dflags); + set_bit(US_FLIDX_REDO_READ10, &us->dflags); + } + + /* + * Next, if the REDO_READ10 flag is set, return a result + * code that will cause the SCSI core to retry the READ(10) + * command immediately. + */ + if (test_bit(US_FLIDX_REDO_READ10, &us->dflags)) { + clear_bit(US_FLIDX_REDO_READ10, &us->dflags); + srb->result = DID_IMM_RETRY << 16; + srb->sense_buffer[0] = 0; + } + } + /* Did we transfer less than the minimum amount required? */ if ((srb->result == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) && scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) @@ -858,20 +891,18 @@ Retry_Sense: /* Stop the current URB transfer */ void usb_stor_stop_transport(struct us_data *us) { - US_DEBUGP("%s called\n", __func__); - /* If the state machine is blocked waiting for an URB, * let's wake it up. The test_and_clear_bit() call * guarantees that if a URB has just been submitted, * it won't be cancelled more than once. */ if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { - US_DEBUGP("-- cancelling URB\n"); + usb_stor_dbg(us, "-- cancelling URB\n"); usb_unlink_urb(us->current_urb); } /* If we are waiting for a scatter-gather operation, cancel it. */ if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { - US_DEBUGP("-- cancelling sg request\n"); + usb_stor_dbg(us, "-- cancelling sg request\n"); usb_sg_cancel(&us->current_sg); } } @@ -894,7 +925,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) us->ifnum, srb->cmnd, srb->cmd_len); /* check the return code for the command */ - US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result); + usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n", + result); /* if we stalled the command, it means command failed */ if (result == USB_STOR_XFER_STALLED) { @@ -912,7 +944,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; result = usb_stor_bulk_srb(us, pipe, srb); - US_DEBUGP("CBI data stage result is 0x%x\n", result); + usb_stor_dbg(us, "CBI data stage result is 0x%x\n", result); /* if we stalled the data transfer it means command failed */ if (result == USB_STOR_XFER_STALLED) @@ -930,8 +962,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) return USB_STOR_TRANSPORT_GOOD; result = usb_stor_intr_transfer(us, us->iobuf, 2); - US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", - us->iobuf[0], us->iobuf[1]); + usb_stor_dbg(us, "Got interrupt data (0x%x, 0x%x)\n", + us->iobuf[0], us->iobuf[1]); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -958,8 +990,8 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) * into the first byte -- so if it's non-zero, call it a failure. */ if (us->iobuf[0]) { - US_DEBUGP("CBI IRQ data showed reserved bType 0x%x\n", - us->iobuf[0]); + usb_stor_dbg(us, "CBI IRQ data showed reserved bType 0x%x\n", + us->iobuf[0]); goto Failed; } @@ -1000,8 +1032,8 @@ int usb_stor_Bulk_max_lun(struct us_data *us) USB_RECIP_INTERFACE, 0, us->ifnum, us->iobuf, 1, 10*HZ); - US_DEBUGP("GetMaxLUN command result is %d, data is %d\n", - result, us->iobuf[0]); + usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n", + result, us->iobuf[0]); /* if we have a successful request, return the result */ if (result > 0) @@ -1037,7 +1069,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) /* set up the command wrapper */ bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); bcb->DataTransferLength = cpu_to_le32(transfer_length); - bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; + bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? + US_BULK_FLAG_IN : 0; bcb->Tag = ++us->tag; bcb->Lun = srb->device->lun; if (us->fflags & US_FL_SCM_MULT_TARG) @@ -1049,14 +1082,14 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) memcpy(bcb->CDB, srb->cmnd, bcb->Length); /* send it to out endpoint */ - US_DEBUGP("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", - le32_to_cpu(bcb->Signature), bcb->Tag, - le32_to_cpu(bcb->DataTransferLength), bcb->Flags, - (bcb->Lun >> 4), (bcb->Lun & 0x0F), - bcb->Length); + usb_stor_dbg(us, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", + le32_to_cpu(bcb->Signature), bcb->Tag, + le32_to_cpu(bcb->DataTransferLength), bcb->Flags, + (bcb->Lun >> 4), (bcb->Lun & 0x0F), + bcb->Length); result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, cbwlen, NULL); - US_DEBUGP("Bulk command transfer result=%d\n", result); + usb_stor_dbg(us, "Bulk command transfer result=%d\n", result); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -1073,7 +1106,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; result = usb_stor_bulk_srb(us, pipe, srb); - US_DEBUGP("Bulk data transfer result 0x%x\n", result); + usb_stor_dbg(us, "Bulk data transfer result 0x%x\n", result); if (result == USB_STOR_XFER_ERROR) return USB_STOR_TRANSPORT_ERROR; @@ -1092,7 +1125,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) */ /* get CSW for device status */ - US_DEBUGP("Attempting to get CSW...\n"); + usb_stor_dbg(us, "Attempting to get CSW...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); @@ -1101,7 +1134,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) * CSWs. If we encounter such a thing, try to read the CSW again. */ if (result == USB_STOR_XFER_SHORT && cswlen == 0) { - US_DEBUGP("Received 0-length CSW; retrying...\n"); + usb_stor_dbg(us, "Received 0-length CSW; retrying...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); } @@ -1110,24 +1143,24 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) if (result == USB_STOR_XFER_STALLED) { /* get the status again */ - US_DEBUGP("Attempting to get CSW (2nd try)...\n"); + usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); } /* if we still have a failure at this point, we're in trouble */ - US_DEBUGP("Bulk status result = %d\n", result); + usb_stor_dbg(us, "Bulk status result = %d\n", result); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; /* check bulk status */ residue = le32_to_cpu(bcs->Residue); - US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", - le32_to_cpu(bcs->Signature), bcs->Tag, - residue, bcs->Status); + usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", + le32_to_cpu(bcs->Signature), bcs->Tag, + residue, bcs->Status); if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) || bcs->Status > US_BULK_STAT_PHASE) { - US_DEBUGP("Bulk logical error\n"); + usb_stor_dbg(us, "Bulk logical error\n"); return USB_STOR_TRANSPORT_ERROR; } @@ -1138,12 +1171,12 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) if (!us->bcs_signature) { us->bcs_signature = bcs->Signature; if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) - US_DEBUGP("Learnt BCS signature 0x%08X\n", - le32_to_cpu(us->bcs_signature)); + usb_stor_dbg(us, "Learnt BCS signature 0x%08X\n", + le32_to_cpu(us->bcs_signature)); } else if (bcs->Signature != us->bcs_signature) { - US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n", - le32_to_cpu(bcs->Signature), - le32_to_cpu(us->bcs_signature)); + usb_stor_dbg(us, "Signature mismatch: got %08X, expecting %08X\n", + le32_to_cpu(bcs->Signature), + le32_to_cpu(us->bcs_signature)); return USB_STOR_TRANSPORT_ERROR; } @@ -1220,7 +1253,7 @@ static int usb_stor_reset_common(struct us_data *us, int result2; if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { - US_DEBUGP("No reset during disconnect\n"); + usb_stor_dbg(us, "No reset during disconnect\n"); return -EIO; } @@ -1228,7 +1261,7 @@ static int usb_stor_reset_common(struct us_data *us, request, requesttype, value, index, data, size, 5*HZ); if (result < 0) { - US_DEBUGP("Soft reset failed: %d\n", result); + usb_stor_dbg(us, "Soft reset failed: %d\n", result); return result; } @@ -1238,23 +1271,23 @@ static int usb_stor_reset_common(struct us_data *us, test_bit(US_FLIDX_DISCONNECTING, &us->dflags), HZ*6); if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { - US_DEBUGP("Reset interrupted by disconnect\n"); + usb_stor_dbg(us, "Reset interrupted by disconnect\n"); return -EIO; } - US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n"); + usb_stor_dbg(us, "Soft reset: clearing bulk-in endpoint halt\n"); result = usb_stor_clear_halt(us, us->recv_bulk_pipe); - US_DEBUGP("Soft reset: clearing bulk-out endpoint halt\n"); + usb_stor_dbg(us, "Soft reset: clearing bulk-out endpoint halt\n"); result2 = usb_stor_clear_halt(us, us->send_bulk_pipe); /* return a result code based on the result of the clear-halts */ if (result >= 0) result = result2; if (result < 0) - US_DEBUGP("Soft reset failed\n"); + usb_stor_dbg(us, "Soft reset failed\n"); else - US_DEBUGP("Soft reset done\n"); + usb_stor_dbg(us, "Soft reset done\n"); return result; } @@ -1264,8 +1297,6 @@ static int usb_stor_reset_common(struct us_data *us, int usb_stor_CB_reset(struct us_data *us) { - US_DEBUGP("%s called\n", __func__); - memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); us->iobuf[0] = SEND_DIAGNOSTIC; us->iobuf[1] = 4; @@ -1280,8 +1311,6 @@ EXPORT_SYMBOL_GPL(usb_stor_CB_reset); */ int usb_stor_Bulk_reset(struct us_data *us) { - US_DEBUGP("%s called\n", __func__); - return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, us->ifnum, NULL, 0); @@ -1296,21 +1325,22 @@ int usb_stor_port_reset(struct us_data *us) int result; /*for these devices we must use the class specific method */ - if (us->pusb_dev->quirks & USB_QUIRK_RESET_MORPHS) + if (us->pusb_dev->quirks & USB_QUIRK_RESET) return -EPERM; result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); if (result < 0) - US_DEBUGP("unable to lock device for reset: %d\n", result); + usb_stor_dbg(us, "unable to lock device for reset: %d\n", + result); else { /* Were we disconnected while waiting for the lock? */ if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { result = -EIO; - US_DEBUGP("No reset during disconnect\n"); + usb_stor_dbg(us, "No reset during disconnect\n"); } else { result = usb_reset_device(us->pusb_dev); - US_DEBUGP("usb_reset_device returns %d\n", - result); + usb_stor_dbg(us, "usb_reset_device returns %d\n", + result); } usb_unlock_device(us->pusb_dev); } |
