Lines Matching full:us
67 * sets the machine state and the ABORTING bit in us->dflags to prevent
69 * below, which atomically tests-and-clears the URB_ACTIVE bit in us->dflags
74 * When a disconnect occurs, the DISCONNECTING bit in us->dflags is set to
98 * This is the completion handler which will wake us up when an URB
115 static int usb_stor_msg_common(struct us_data *us, int timeout) in usb_stor_msg_common() argument
122 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) in usb_stor_msg_common()
129 us->current_urb->context = &urb_done; in usb_stor_msg_common()
130 us->current_urb->transfer_flags = 0; in usb_stor_msg_common()
133 * we assume that if transfer_buffer isn't us->iobuf then it in usb_stor_msg_common()
135 * easier than always having the caller tell us whether the in usb_stor_msg_common()
138 if (us->current_urb->transfer_buffer == us->iobuf) in usb_stor_msg_common()
139 us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usb_stor_msg_common()
140 us->current_urb->transfer_dma = us->iobuf_dma; in usb_stor_msg_common()
143 status = usb_submit_urb(us->current_urb, GFP_NOIO); in usb_stor_msg_common()
153 set_bit(US_FLIDX_URB_ACTIVE, &us->dflags); in usb_stor_msg_common()
156 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) { in usb_stor_msg_common()
159 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { in usb_stor_msg_common()
160 usb_stor_dbg(us, "-- cancelling URB\n"); in usb_stor_msg_common()
161 usb_unlink_urb(us->current_urb); in usb_stor_msg_common()
169 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags); in usb_stor_msg_common()
172 usb_stor_dbg(us, "%s -- cancelling URB\n", in usb_stor_msg_common()
174 usb_kill_urb(us->current_urb); in usb_stor_msg_common()
178 return us->current_urb->status; in usb_stor_msg_common()
185 int usb_stor_control_msg(struct us_data *us, unsigned int pipe, in usb_stor_control_msg() argument
191 usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", in usb_stor_control_msg()
195 us->cr->bRequestType = requesttype; in usb_stor_control_msg()
196 us->cr->bRequest = request; in usb_stor_control_msg()
197 us->cr->wValue = cpu_to_le16(value); in usb_stor_control_msg()
198 us->cr->wIndex = cpu_to_le16(index); in usb_stor_control_msg()
199 us->cr->wLength = cpu_to_le16(size); in usb_stor_control_msg()
202 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe, in usb_stor_control_msg()
203 (unsigned char*) us->cr, data, size, in usb_stor_control_msg()
205 status = usb_stor_msg_common(us, timeout); in usb_stor_control_msg()
209 status = us->current_urb->actual_length; in usb_stor_control_msg()
227 int usb_stor_clear_halt(struct us_data *us, unsigned int pipe) in usb_stor_clear_halt() argument
235 result = usb_stor_control_msg(us, us->send_ctrl_pipe, in usb_stor_clear_halt()
241 usb_reset_endpoint(us->pusb_dev, endp); in usb_stor_clear_halt()
243 usb_stor_dbg(us, "result = %d\n", result); in usb_stor_clear_halt()
256 static int interpret_urb_result(struct us_data *us, unsigned int pipe, in interpret_urb_result() argument
259 usb_stor_dbg(us, "Status code %d; transferred %u/%u\n", in interpret_urb_result()
266 usb_stor_dbg(us, "-- short transfer\n"); in interpret_urb_result()
270 usb_stor_dbg(us, "-- transfer complete\n"); in interpret_urb_result()
280 usb_stor_dbg(us, "-- stall on control pipe\n"); in interpret_urb_result()
285 usb_stor_dbg(us, "clearing endpoint halt for pipe 0x%x\n", in interpret_urb_result()
287 if (usb_stor_clear_halt(us, pipe) < 0) in interpret_urb_result()
293 usb_stor_dbg(us, "-- babble\n"); in interpret_urb_result()
298 usb_stor_dbg(us, "-- transfer cancelled\n"); in interpret_urb_result()
303 usb_stor_dbg(us, "-- short read transfer\n"); in interpret_urb_result()
308 usb_stor_dbg(us, "-- abort or disconnect in progress\n"); in interpret_urb_result()
313 usb_stor_dbg(us, "-- unknown error\n"); in interpret_urb_result()
322 int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe, in usb_stor_ctrl_transfer() argument
328 usb_stor_dbg(us, "rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", in usb_stor_ctrl_transfer()
332 us->cr->bRequestType = requesttype; in usb_stor_ctrl_transfer()
333 us->cr->bRequest = request; in usb_stor_ctrl_transfer()
334 us->cr->wValue = cpu_to_le16(value); in usb_stor_ctrl_transfer()
335 us->cr->wIndex = cpu_to_le16(index); in usb_stor_ctrl_transfer()
336 us->cr->wLength = cpu_to_le16(size); in usb_stor_ctrl_transfer()
339 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe, in usb_stor_ctrl_transfer()
340 (unsigned char*) us->cr, data, size, in usb_stor_ctrl_transfer()
342 result = usb_stor_msg_common(us, 0); in usb_stor_ctrl_transfer()
344 return interpret_urb_result(us, pipe, size, result, in usb_stor_ctrl_transfer()
345 us->current_urb->actual_length); in usb_stor_ctrl_transfer()
353 * This routine always uses us->recv_intr_pipe as the pipe and
354 * us->ep_bInterval as the interrupt interval.
356 static int usb_stor_intr_transfer(struct us_data *us, void *buf, in usb_stor_intr_transfer() argument
360 unsigned int pipe = us->recv_intr_pipe; in usb_stor_intr_transfer()
363 usb_stor_dbg(us, "xfer %u bytes\n", length); in usb_stor_intr_transfer()
366 maxp = usb_maxpacket(us->pusb_dev, pipe); in usb_stor_intr_transfer()
371 usb_fill_int_urb(us->current_urb, us->pusb_dev, pipe, buf, in usb_stor_intr_transfer()
373 us->ep_bInterval); in usb_stor_intr_transfer()
374 result = usb_stor_msg_common(us, 0); in usb_stor_intr_transfer()
376 return interpret_urb_result(us, pipe, length, result, in usb_stor_intr_transfer()
377 us->current_urb->actual_length); in usb_stor_intr_transfer()
385 int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe, in usb_stor_bulk_transfer_buf() argument
390 usb_stor_dbg(us, "xfer %u bytes\n", length); in usb_stor_bulk_transfer_buf()
393 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, in usb_stor_bulk_transfer_buf()
395 result = usb_stor_msg_common(us, 0); in usb_stor_bulk_transfer_buf()
399 *act_len = us->current_urb->actual_length; in usb_stor_bulk_transfer_buf()
400 return interpret_urb_result(us, pipe, length, result, in usb_stor_bulk_transfer_buf()
401 us->current_urb->actual_length); in usb_stor_bulk_transfer_buf()
411 static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, in usb_stor_bulk_transfer_sglist() argument
418 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) in usb_stor_bulk_transfer_sglist()
422 usb_stor_dbg(us, "xfer %u bytes, %d entries\n", length, num_sg); in usb_stor_bulk_transfer_sglist()
423 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, in usb_stor_bulk_transfer_sglist()
426 usb_stor_dbg(us, "usb_sg_init returned %d\n", result); in usb_stor_bulk_transfer_sglist()
434 set_bit(US_FLIDX_SG_ACTIVE, &us->dflags); in usb_stor_bulk_transfer_sglist()
437 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) { in usb_stor_bulk_transfer_sglist()
440 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { in usb_stor_bulk_transfer_sglist()
441 usb_stor_dbg(us, "-- cancelling sg request\n"); in usb_stor_bulk_transfer_sglist()
442 usb_sg_cancel(&us->current_sg); in usb_stor_bulk_transfer_sglist()
447 usb_sg_wait(&us->current_sg); in usb_stor_bulk_transfer_sglist()
448 clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags); in usb_stor_bulk_transfer_sglist()
450 result = us->current_sg.status; in usb_stor_bulk_transfer_sglist()
452 *act_len = us->current_sg.bytes; in usb_stor_bulk_transfer_sglist()
453 return interpret_urb_result(us, pipe, length, result, in usb_stor_bulk_transfer_sglist()
454 us->current_sg.bytes); in usb_stor_bulk_transfer_sglist()
466 int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, in usb_stor_bulk_srb() argument
470 int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb), in usb_stor_bulk_srb()
488 int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe, in usb_stor_bulk_transfer_sg() argument
497 result = usb_stor_bulk_transfer_sglist(us, pipe, in usb_stor_bulk_transfer_sg()
503 result = usb_stor_bulk_transfer_buf(us, pipe, buf, in usb_stor_bulk_transfer_sg()
524 static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) in last_sector_hacks() argument
544 if (!us->use_last_sector_hacks) in last_sector_hacks()
569 us->use_last_sector_hacks = 0; in last_sector_hacks()
581 if (++us->last_sector_retries < 3) in last_sector_hacks()
595 us->last_sector_retries = 0; in last_sector_hacks()
604 void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) in usb_stor_invoke_transport() argument
611 result = us->transport(srb, us); in usb_stor_invoke_transport()
617 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in usb_stor_invoke_transport()
618 usb_stor_dbg(us, "-- command was aborted\n"); in usb_stor_invoke_transport()
625 usb_stor_dbg(us, "-- transport indicates error, resetting\n"); in usb_stor_invoke_transport()
633 last_sector_hacks(us, srb); in usb_stor_invoke_transport()
653 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) && in usb_stor_invoke_transport()
655 usb_stor_dbg(us, "-- CB transport device requiring auto-sense\n"); in usb_stor_invoke_transport()
660 if ((us->fflags & US_FL_SENSE_AFTER_SYNC) && in usb_stor_invoke_transport()
662 usb_stor_dbg(us, "-- sense after SYNC CACHE\n"); in usb_stor_invoke_transport()
672 usb_stor_dbg(us, "-- transport indicates command failure\n"); in usb_stor_invoke_transport()
684 !(us->fflags & US_FL_SANE_SENSE) && in usb_stor_invoke_transport()
685 !(us->fflags & US_FL_BAD_SENSE) && in usb_stor_invoke_transport()
687 usb_stor_dbg(us, "-- SAT supported, increasing auto-sense\n"); in usb_stor_invoke_transport()
688 us->fflags |= US_FL_SANE_SENSE; in usb_stor_invoke_transport()
701 usb_stor_dbg(us, "-- unexpectedly short transfer\n"); in usb_stor_invoke_transport()
714 if (us->fflags & US_FL_SANE_SENSE) in usb_stor_invoke_transport()
717 usb_stor_dbg(us, "Issuing auto-REQUEST_SENSE\n"); in usb_stor_invoke_transport()
722 if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI || in usb_stor_invoke_transport()
723 us->subclass == USB_SC_CYP_ATACB) in usb_stor_invoke_transport()
730 temp_result = us->transport(us->srb, us); in usb_stor_invoke_transport()
735 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in usb_stor_invoke_transport()
736 usb_stor_dbg(us, "-- auto-sense aborted\n"); in usb_stor_invoke_transport()
741 us->fflags &= ~US_FL_SANE_SENSE; in usb_stor_invoke_transport()
742 us->fflags |= US_FL_BAD_SENSE; in usb_stor_invoke_transport()
755 usb_stor_dbg(us, "-- auto-sense failure, retry small sense\n"); in usb_stor_invoke_transport()
757 us->fflags &= ~US_FL_SANE_SENSE; in usb_stor_invoke_transport()
758 us->fflags |= US_FL_BAD_SENSE; in usb_stor_invoke_transport()
764 usb_stor_dbg(us, "-- auto-sense failure\n"); in usb_stor_invoke_transport()
772 if (!(us->fflags & US_FL_SCM_MULT_TARG)) in usb_stor_invoke_transport()
783 !(us->fflags & US_FL_SANE_SENSE) && in usb_stor_invoke_transport()
784 !(us->fflags & US_FL_BAD_SENSE) && in usb_stor_invoke_transport()
786 usb_stor_dbg(us, "-- SANE_SENSE support enabled\n"); in usb_stor_invoke_transport()
787 us->fflags |= US_FL_SANE_SENSE; in usb_stor_invoke_transport()
793 usb_stor_dbg(us, "-- Sense data truncated to %i from %i\n", in usb_stor_invoke_transport()
802 usb_stor_dbg(us, "-- Result from auto-sense is %d\n", in usb_stor_invoke_transport()
804 usb_stor_dbg(us, "-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", in usb_stor_invoke_transport()
808 usb_stor_show_sense(us, sshdr.sense_key, sshdr.asc, sshdr.ascq); in usb_stor_invoke_transport()
869 if (unlikely((us->fflags & US_FL_INITIAL_READ10) && in usb_stor_invoke_transport()
872 set_bit(US_FLIDX_READ10_WORKED, &us->dflags); in usb_stor_invoke_transport()
873 } else if (test_bit(US_FLIDX_READ10_WORKED, &us->dflags)) { in usb_stor_invoke_transport()
874 clear_bit(US_FLIDX_READ10_WORKED, &us->dflags); in usb_stor_invoke_transport()
875 set_bit(US_FLIDX_REDO_READ10, &us->dflags); in usb_stor_invoke_transport()
883 if (test_bit(US_FLIDX_REDO_READ10, &us->dflags)) { in usb_stor_invoke_transport()
884 clear_bit(US_FLIDX_REDO_READ10, &us->dflags); in usb_stor_invoke_transport()
895 last_sector_hacks(us, srb); in usb_stor_invoke_transport()
909 scsi_lock(us_to_host(us)); in usb_stor_invoke_transport()
910 set_bit(US_FLIDX_RESETTING, &us->dflags); in usb_stor_invoke_transport()
911 clear_bit(US_FLIDX_ABORTING, &us->dflags); in usb_stor_invoke_transport()
912 scsi_unlock(us_to_host(us)); in usb_stor_invoke_transport()
918 mutex_unlock(&us->dev_mutex); in usb_stor_invoke_transport()
919 result = usb_stor_port_reset(us); in usb_stor_invoke_transport()
920 mutex_lock(&us->dev_mutex); in usb_stor_invoke_transport()
923 scsi_lock(us_to_host(us)); in usb_stor_invoke_transport()
924 usb_stor_report_device_reset(us); in usb_stor_invoke_transport()
925 scsi_unlock(us_to_host(us)); in usb_stor_invoke_transport()
926 us->transport_reset(us); in usb_stor_invoke_transport()
928 clear_bit(US_FLIDX_RESETTING, &us->dflags); in usb_stor_invoke_transport()
929 last_sector_hacks(us, srb); in usb_stor_invoke_transport()
933 void usb_stor_stop_transport(struct us_data *us) in usb_stor_stop_transport() argument
941 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) { in usb_stor_stop_transport()
942 usb_stor_dbg(us, "-- cancelling URB\n"); in usb_stor_stop_transport()
943 usb_unlink_urb(us->current_urb); in usb_stor_stop_transport()
947 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) { in usb_stor_stop_transport()
948 usb_stor_dbg(us, "-- cancelling sg request\n"); in usb_stor_stop_transport()
949 usb_sg_cancel(&us->current_sg); in usb_stor_stop_transport()
957 int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) in usb_stor_CB_transport() argument
967 * Stack may be vmallocated. So no DMA for us. Make a copy. in usb_stor_CB_transport()
969 memcpy(us->iobuf, srb->cmnd, srb->cmd_len); in usb_stor_CB_transport()
970 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, in usb_stor_CB_transport()
973 us->ifnum, us->iobuf, srb->cmd_len); in usb_stor_CB_transport()
976 usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n", in usb_stor_CB_transport()
993 us->recv_bulk_pipe : us->send_bulk_pipe; in usb_stor_CB_transport()
994 result = usb_stor_bulk_srb(us, pipe, srb); in usb_stor_CB_transport()
995 usb_stor_dbg(us, "CBI data stage result is 0x%x\n", result); in usb_stor_CB_transport()
1010 if (us->protocol != USB_PR_CBI) in usb_stor_CB_transport()
1013 result = usb_stor_intr_transfer(us, us->iobuf, 2); in usb_stor_CB_transport()
1014 usb_stor_dbg(us, "Got interrupt data (0x%x, 0x%x)\n", in usb_stor_CB_transport()
1015 us->iobuf[0], us->iobuf[1]); in usb_stor_CB_transport()
1020 * UFI gives us ASC and ASCQ, like a request sense in usb_stor_CB_transport()
1027 if (us->subclass == USB_SC_UFI) { in usb_stor_CB_transport()
1031 if (us->iobuf[0]) in usb_stor_CB_transport()
1043 if (us->iobuf[0]) { in usb_stor_CB_transport()
1044 usb_stor_dbg(us, "CBI IRQ data showed reserved bType 0x%x\n", in usb_stor_CB_transport()
1045 us->iobuf[0]); in usb_stor_CB_transport()
1051 switch (us->iobuf[1] & 0x0F) { in usb_stor_CB_transport()
1065 usb_stor_clear_halt(us, pipe); in usb_stor_CB_transport()
1075 int usb_stor_Bulk_max_lun(struct us_data *us) in usb_stor_Bulk_max_lun() argument
1080 us->iobuf[0] = 0; in usb_stor_Bulk_max_lun()
1081 result = usb_stor_control_msg(us, us->recv_ctrl_pipe, in usb_stor_Bulk_max_lun()
1085 0, us->ifnum, us->iobuf, 1, 10*HZ); in usb_stor_Bulk_max_lun()
1087 usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n", in usb_stor_Bulk_max_lun()
1088 result, us->iobuf[0]); in usb_stor_Bulk_max_lun()
1096 if (us->iobuf[0] < 16) { in usb_stor_Bulk_max_lun()
1097 return us->iobuf[0]; in usb_stor_Bulk_max_lun()
1099 dev_info(&us->pusb_intf->dev, in usb_stor_Bulk_max_lun()
1101 us->iobuf[0]); in usb_stor_Bulk_max_lun()
1115 int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) in usb_stor_Bulk_transport() argument
1117 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in usb_stor_Bulk_transport()
1118 struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; in usb_stor_Bulk_transport()
1127 if (unlikely(us->fflags & US_FL_BULK32)) { in usb_stor_Bulk_transport()
1129 us->iobuf[31] = 0; in usb_stor_Bulk_transport()
1137 bcb->Tag = ++us->tag; in usb_stor_Bulk_transport()
1139 if (us->fflags & US_FL_SCM_MULT_TARG) in usb_stor_Bulk_transport()
1148 usb_stor_dbg(us, "Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", in usb_stor_Bulk_transport()
1153 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in usb_stor_Bulk_transport()
1155 usb_stor_dbg(us, "Bulk command transfer result=%d\n", result); in usb_stor_Bulk_transport()
1163 * Some USB-IDE converter chips need a 100us delay between the in usb_stor_Bulk_transport()
1167 if (unlikely(us->fflags & US_FL_GO_SLOW)) in usb_stor_Bulk_transport()
1172 us->recv_bulk_pipe : us->send_bulk_pipe; in usb_stor_Bulk_transport()
1173 result = usb_stor_bulk_srb(us, pipe, srb); in usb_stor_Bulk_transport()
1174 usb_stor_dbg(us, "Bulk data transfer result 0x%x\n", result); in usb_stor_Bulk_transport()
1180 * amount requested, the spec requires us to transfer in usb_stor_Bulk_transport()
1207 usb_stor_dbg(us, "Device skipped data phase\n"); in usb_stor_Bulk_transport()
1220 usb_stor_dbg(us, "Attempting to get CSW...\n"); in usb_stor_Bulk_transport()
1221 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in usb_stor_Bulk_transport()
1230 usb_stor_dbg(us, "Received 0-length CSW; retrying...\n"); in usb_stor_Bulk_transport()
1231 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in usb_stor_Bulk_transport()
1239 usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n"); in usb_stor_Bulk_transport()
1240 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in usb_stor_Bulk_transport()
1245 usb_stor_dbg(us, "Bulk status result = %d\n", result); in usb_stor_Bulk_transport()
1252 usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", in usb_stor_Bulk_transport()
1255 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) || in usb_stor_Bulk_transport()
1257 usb_stor_dbg(us, "Bulk logical error\n"); in usb_stor_Bulk_transport()
1266 if (!us->bcs_signature) { in usb_stor_Bulk_transport()
1267 us->bcs_signature = bcs->Signature; in usb_stor_Bulk_transport()
1268 if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) in usb_stor_Bulk_transport()
1269 usb_stor_dbg(us, "Learnt BCS signature 0x%08X\n", in usb_stor_Bulk_transport()
1270 le32_to_cpu(us->bcs_signature)); in usb_stor_Bulk_transport()
1271 } else if (bcs->Signature != us->bcs_signature) { in usb_stor_Bulk_transport()
1272 usb_stor_dbg(us, "Signature mismatch: got %08X, expecting %08X\n", in usb_stor_Bulk_transport()
1274 le32_to_cpu(us->bcs_signature)); in usb_stor_Bulk_transport()
1280 * was really transferred and what the device tells us in usb_stor_Bulk_transport()
1282 if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { in usb_stor_Bulk_transport()
1295 us->fflags |= US_FL_IGNORE_RESIDUE; in usb_stor_Bulk_transport()
1347 static int usb_stor_reset_common(struct us_data *us, in usb_stor_reset_common() argument
1354 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { in usb_stor_reset_common()
1355 usb_stor_dbg(us, "No reset during disconnect\n"); in usb_stor_reset_common()
1359 result = usb_stor_control_msg(us, us->send_ctrl_pipe, in usb_stor_reset_common()
1363 usb_stor_dbg(us, "Soft reset failed: %d\n", result); in usb_stor_reset_common()
1371 wait_event_interruptible_timeout(us->delay_wait, in usb_stor_reset_common()
1372 test_bit(US_FLIDX_DISCONNECTING, &us->dflags), in usb_stor_reset_common()
1374 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { in usb_stor_reset_common()
1375 usb_stor_dbg(us, "Reset interrupted by disconnect\n"); in usb_stor_reset_common()
1379 usb_stor_dbg(us, "Soft reset: clearing bulk-in endpoint halt\n"); in usb_stor_reset_common()
1380 result = usb_stor_clear_halt(us, us->recv_bulk_pipe); in usb_stor_reset_common()
1382 usb_stor_dbg(us, "Soft reset: clearing bulk-out endpoint halt\n"); in usb_stor_reset_common()
1383 result2 = usb_stor_clear_halt(us, us->send_bulk_pipe); in usb_stor_reset_common()
1389 usb_stor_dbg(us, "Soft reset failed\n"); in usb_stor_reset_common()
1391 usb_stor_dbg(us, "Soft reset done\n"); in usb_stor_reset_common()
1398 int usb_stor_CB_reset(struct us_data *us) in usb_stor_CB_reset() argument
1400 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE); in usb_stor_CB_reset()
1401 us->iobuf[0] = SEND_DIAGNOSTIC; in usb_stor_CB_reset()
1402 us->iobuf[1] = 4; in usb_stor_CB_reset()
1403 return usb_stor_reset_common(us, US_CBI_ADSC, in usb_stor_CB_reset()
1405 0, us->ifnum, us->iobuf, CB_RESET_CMD_SIZE); in usb_stor_CB_reset()
1413 int usb_stor_Bulk_reset(struct us_data *us) in usb_stor_Bulk_reset() argument
1415 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST, in usb_stor_Bulk_reset()
1417 0, us->ifnum, NULL, 0); in usb_stor_Bulk_reset()
1423 * us->dev_mutex.
1425 int usb_stor_port_reset(struct us_data *us) in usb_stor_port_reset() argument
1430 if (us->pusb_dev->quirks & USB_QUIRK_RESET) in usb_stor_port_reset()
1433 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); in usb_stor_port_reset()
1435 usb_stor_dbg(us, "unable to lock device for reset: %d\n", in usb_stor_port_reset()
1439 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { in usb_stor_port_reset()
1441 usb_stor_dbg(us, "No reset during disconnect\n"); in usb_stor_port_reset()
1443 result = usb_reset_device(us->pusb_dev); in usb_stor_port_reset()
1444 usb_stor_dbg(us, "usb_reset_device returns %d\n", in usb_stor_port_reset()
1447 usb_unlock_device(us->pusb_dev); in usb_stor_port_reset()