• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/usb/storage/

Lines Matching refs:us

97  * sets the machine state and the ABORTING bit in us->dflags to prevent
99 * below, which atomically tests-and-clears the URB_ACTIVE bit in us->dflags
104 * When a disconnect occurs, the DISCONNECTING bit in us->dflags is set to
127 /* This is the completion handler which will wake us up when an URB
143 static int usb_stor_msg_common(struct us_data *us, int timeout)
150 if (test_bit(US_FLIDX_ABORTING, &us->dflags))
157 us->current_urb->context = &urb_done;
158 us->current_urb->transfer_flags = 0;
160 /* we assume that if transfer_buffer isn't us->iobuf then it
162 * easier than always having the caller tell us whether the
164 if (us->current_urb->transfer_buffer == us->iobuf)
165 us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
166 us->current_urb->transfer_dma = us->iobuf_dma;
169 status = usb_submit_urb(us->current_urb, GFP_NOIO);
177 set_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
180 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
183 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
185 usb_unlink_urb(us->current_urb);
193 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
198 usb_kill_urb(us->current_urb);
202 return us->current_urb->status;
209 int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
220 us->cr->bRequestType = requesttype;
221 us->cr->bRequest = request;
222 us->cr->wValue = cpu_to_le16(value);
223 us->cr->wIndex = cpu_to_le16(index);
224 us->cr->wLength = cpu_to_le16(size);
227 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,
228 (unsigned char*) us->cr, data, size,
230 status = usb_stor_msg_common(us, timeout);
234 status = us->current_urb->actual_length;
251 int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
259 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
265 usb_reset_endpoint(us->pusb_dev, endp);
280 static int interpret_urb_result(struct us_data *us, unsigned int pipe,
308 if (usb_stor_clear_halt(us, pipe) < 0)
343 int usb_stor_ctrl_transfer(struct us_data *us, unsigned int pipe,
354 us->cr->bRequestType = requesttype;
355 us->cr->bRequest = request;
356 us->cr->wValue = cpu_to_le16(value);
357 us->cr->wIndex = cpu_to_le16(index);
358 us->cr->wLength = cpu_to_le16(size);
361 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,
362 (unsigned char*) us->cr, data, size,
364 result = usb_stor_msg_common(us, 0);
366 return interpret_urb_result(us, pipe, size, result,
367 us->current_urb->actual_length);
375 * This routine always uses us->recv_intr_pipe as the pipe and
376 * us->ep_bInterval as the interrupt interval.
378 static int usb_stor_intr_transfer(struct us_data *us, void *buf,
382 unsigned int pipe = us->recv_intr_pipe;
388 maxp = usb_maxpacket(us->pusb_dev, pipe, usb_pipeout(pipe));
393 usb_fill_int_urb(us->current_urb, us->pusb_dev, pipe, buf,
395 us->ep_bInterval);
396 result = usb_stor_msg_common(us, 0);
398 return interpret_urb_result(us, pipe, length, result,
399 us->current_urb->actual_length);
407 int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
415 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,
417 result = usb_stor_msg_common(us, 0);
421 *act_len = us->current_urb->actual_length;
422 return interpret_urb_result(us, pipe, length, result,
423 us->current_urb->actual_length);
433 static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
440 if (test_bit(US_FLIDX_ABORTING, &us->dflags))
449 memcpy(devpath, us->pusb_dev->devpath, 3);
478 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
487 set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
490 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
493 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
495 usb_sg_cancel(&us->current_sg);
500 usb_sg_wait(&us->current_sg);
501 clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
503 result = us->current_sg.status;
505 *act_len = us->current_sg.bytes;
506 return interpret_urb_result(us, pipe, length, result,
507 us->current_sg.bytes);
514 int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
518 int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
536 int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
545 result = usb_stor_bulk_transfer_sglist(us, pipe,
551 result = usb_stor_bulk_transfer_buf(us, pipe, buf,
571 static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
590 if (!us->use_last_sector_hacks)
614 us->use_last_sector_hacks = 0;
625 if (++us->last_sector_retries < 3)
638 us->last_sector_retries = 0;
646 void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
653 result = us->transport(srb, us);
658 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
674 last_sector_hacks(us, srb);
693 if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) &&
717 !(us->fflags & US_FL_SANE_SENSE) &&
718 !(us->fflags & US_FL_BAD_SENSE) &&
721 us->fflags |= US_FL_SANE_SENSE;
744 if (us->fflags & US_FL_SANE_SENSE)
751 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
752 us->subclass == US_SC_CYP_ATACB)
759 temp_result = us->transport(us->srb, us);
764 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
770 us->fflags &= ~US_FL_SANE_SENSE;
771 us->fflags |= US_FL_BAD_SENSE;
785 us->fflags &= ~US_FL_SANE_SENSE;
786 us->fflags |= US_FL_BAD_SENSE;
799 if (!(us->fflags & US_FL_SCM_MULT_TARG))
809 !(us->fflags & US_FL_SANE_SENSE) &&
810 !(us->fflags & US_FL_BAD_SENSE) &&
813 us->fflags |= US_FL_SANE_SENSE;
874 last_sector_hacks(us, srb);
884 scsi_lock(us_to_host(us));
885 set_bit(US_FLIDX_RESETTING, &us->dflags);
886 clear_bit(US_FLIDX_ABORTING, &us->dflags);
887 scsi_unlock(us_to_host(us));
891 mutex_unlock(&us->dev_mutex);
892 result = usb_stor_port_reset(us);
893 mutex_lock(&us->dev_mutex);
896 scsi_lock(us_to_host(us));
897 usb_stor_report_device_reset(us);
898 scsi_unlock(us_to_host(us));
899 us->transport_reset(us);
901 clear_bit(US_FLIDX_RESETTING, &us->dflags);
902 last_sector_hacks(us, srb);
906 void usb_stor_stop_transport(struct us_data *us)
914 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
916 usb_unlink_urb(us->current_urb);
920 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
922 usb_sg_cancel(&us->current_sg);
930 int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
938 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
941 us->ifnum, srb->cmnd, srb->cmd_len);
960 us->recv_bulk_pipe : us->send_bulk_pipe;
961 result = usb_stor_bulk_srb(us, pipe, srb);
976 if (us->protocol != US_PR_CBI)
979 result = usb_stor_intr_transfer(us, us->iobuf, 2);
981 us->iobuf[0], us->iobuf[1]);
985 /* UFI gives us ASC and ASCQ, like a request sense
992 if (us->subclass == US_SC_UFI) {
996 if (us->iobuf[0])
1007 if (us->iobuf[0]) {
1009 us->iobuf[0]);
1015 switch (us->iobuf[1] & 0x0F) {
1028 usb_stor_clear_halt(us, pipe);
1038 int usb_stor_Bulk_max_lun(struct us_data *us)
1043 us->iobuf[0] = 0;
1044 result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
1048 0, us->ifnum, us->iobuf, 1, 10*HZ);
1051 result, us->iobuf[0]);
1055 return us->iobuf[0];
1067 int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1069 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
1070 struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
1082 if (unlikely(us->fflags & US_FL_BULK32)) {
1084 us->iobuf[31] = 0;
1091 bcb->Tag = ++us->tag;
1093 if (us->fflags & US_FL_SCM_MULT_TARG)
1107 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
1116 /* Some USB-IDE converter chips need a 100us delay between the
1119 if (unlikely(us->fflags & US_FL_GO_SLOW))
1124 us->recv_bulk_pipe : us->send_bulk_pipe;
1125 result = usb_stor_bulk_srb(us, pipe, srb);
1131 * amount requested, the spec requires us to transfer
1150 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1159 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1168 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
1187 US_DEBUGP("CSW: us->S 0x%x us->T 0x%x S 0x%x T 0x%x R %u Stat 0x%x\n",
1188 le32_to_cpu(us->bcs_signature), us->tag,
1201 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) ||
1211 if (!us->bcs_signature) {
1212 us->bcs_signature = bcs->Signature;
1213 if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN))
1215 le32_to_cpu(us->bcs_signature));
1216 } else if (bcs->Signature != us->bcs_signature) {
1219 le32_to_cpu(us->bcs_signature));
1224 * was really transferred and what the device tells us */
1225 if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
1237 us->fflags |= US_FL_IGNORE_RESIDUE;
1288 static int usb_stor_reset_common(struct us_data *us,
1295 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1300 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
1310 wait_event_interruptible_timeout(us->delay_wait,
1311 test_bit(US_FLIDX_DISCONNECTING, &us->dflags),
1313 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1319 result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
1322 result2 = usb_stor_clear_halt(us, us->send_bulk_pipe);
1338 int usb_stor_CB_reset(struct us_data *us)
1342 memset(us->iobuf, 0xFF, CB_RESET_CMD_SIZE);
1343 us->iobuf[0] = SEND_DIAGNOSTIC;
1344 us->iobuf[1] = 4;
1345 return usb_stor_reset_common(us, US_CBI_ADSC,
1347 0, us->ifnum, us->iobuf, CB_RESET_CMD_SIZE);
1354 int usb_stor_Bulk_reset(struct us_data *us)
1358 return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
1360 0, us->ifnum, NULL, 0);
1365 * us->dev_mutex.
1367 int usb_stor_port_reset(struct us_data *us)
1372 if (us->pusb_dev->quirks & USB_QUIRK_RESET_MORPHS)
1375 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1380 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
1384 result = usb_reset_device(us->pusb_dev);
1388 usb_unlock_device(us->pusb_dev);