X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fstorage%2Ftransport.c;h=42f784321607a216d04cdbdfa4e2a4b727a93092;hb=3ec04f3d2903fdf6d9849a8633af59b8628164a5;hp=08d3a96bbf92eb74ff13074e6892f70d0fdd169e;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 08d3a96bb..42f784321 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -537,7 +537,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) /* if the command gets aborted by the higher layers, we need to * short-circuit all other processing */ - if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { + if (us->sm_state == US_STATE_ABORTING) { US_DEBUGP("-- command was aborted\n"); goto Handle_Abort; } @@ -665,7 +665,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) srb->cmd_len = old_cmd_len; memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE); - if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) { + if (us->sm_state == US_STATE_ABORTING) { US_DEBUGP("-- auto-sense aborted\n"); goto Handle_Abort; } @@ -911,6 +911,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us) int result; /* issue the command */ + us->iobuf[0] = 0; result = usb_stor_control_msg(us, us->recv_ctrl_pipe, US_BULK_GET_MAX_LUN, USB_DIR_IN | USB_TYPE_CLASS | @@ -921,7 +922,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us) result, us->iobuf[0]); /* if we have a successful request, return the result */ - if (result > 0) + if (result >= 0) return us->iobuf[0]; /* @@ -933,16 +934,13 @@ int usb_stor_Bulk_max_lun(struct us_data *us) if (result == -EPIPE) { usb_stor_clear_halt(us, us->recv_bulk_pipe); usb_stor_clear_halt(us, us->send_bulk_pipe); + /* return the default -- no LUNs */ + return 0; } - /* - * Some devices don't like GetMaxLUN. They may STALL the control - * pipe, they may return a zero-length result, they may do nothing at - * all and timeout, or they may fail in even more bizarrely creative - * ways. In these cases the best approach is to use the default - * value: only one LUN. - */ - return 0; + /* An answer or a STALL are the only valid responses. If we get + * something else, return an indication of error */ + return -1; } int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) @@ -1057,13 +1055,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) /* try to compute the actual residue, based on how much data * was really transferred and what the device tells us */ - if (residue) { - if (!(us->flags & US_FL_IGNORE_RESIDUE) || - srb->sc_data_direction == DMA_TO_DEVICE) { - residue = min(residue, transfer_length); - srb->resid = max(srb->resid, (int) residue); - } - } + residue = min(residue, transfer_length); + srb->resid = max(srb->resid, (int) residue); /* based on the status code, we report good or bad */ switch (bcs->Status) {