• Home
  • Raw
  • Download

Lines Matching refs:us

195 	struct us_data *us = usb_get_intfdata(iface);  in storage_suspend()  local
198 mutex_lock(&us->dev_mutex); in storage_suspend()
201 if (us->suspend_resume_hook) in storage_suspend()
202 (us->suspend_resume_hook)(us, US_SUSPEND); in storage_suspend()
207 mutex_unlock(&us->dev_mutex); in storage_suspend()
213 struct us_data *us = usb_get_intfdata(iface); in storage_resume() local
215 mutex_lock(&us->dev_mutex); in storage_resume()
218 if (us->suspend_resume_hook) in storage_resume()
219 (us->suspend_resume_hook)(us, US_RESUME); in storage_resume()
221 mutex_unlock(&us->dev_mutex); in storage_resume()
227 struct us_data *us = usb_get_intfdata(iface); in storage_reset_resume() local
232 usb_stor_report_bus_reset(us); in storage_reset_resume()
248 struct us_data *us = usb_get_intfdata(iface); in storage_pre_reset() local
253 mutex_lock(&us->dev_mutex); in storage_pre_reset()
259 struct us_data *us = usb_get_intfdata(iface); in storage_post_reset() local
264 usb_stor_report_bus_reset(us); in storage_post_reset()
269 mutex_unlock(&us->dev_mutex); in storage_post_reset()
282 void fill_inquiry_response(struct us_data *us, unsigned char *data, in fill_inquiry_response() argument
299 u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); in fill_inquiry_response()
300 memcpy(data+8, us->unusual_dev->vendorName, in fill_inquiry_response()
301 strlen(us->unusual_dev->vendorName) > 8 ? 8 : in fill_inquiry_response()
302 strlen(us->unusual_dev->vendorName)); in fill_inquiry_response()
303 memcpy(data+16, us->unusual_dev->productName, in fill_inquiry_response()
304 strlen(us->unusual_dev->productName) > 16 ? 16 : in fill_inquiry_response()
305 strlen(us->unusual_dev->productName)); in fill_inquiry_response()
312 usb_stor_set_xfer_buf(data, data_len, us->srb); in fill_inquiry_response()
317 struct us_data *us = (struct us_data *)__us; in usb_stor_control_thread() local
318 struct Scsi_Host *host = us_to_host(us); in usb_stor_control_thread()
322 if (wait_for_completion_interruptible(&us->cmnd_ready)) in usb_stor_control_thread()
328 mutex_lock(&(us->dev_mutex)); in usb_stor_control_thread()
334 if (us->srb == NULL) { in usb_stor_control_thread()
336 mutex_unlock(&us->dev_mutex); in usb_stor_control_thread()
342 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in usb_stor_control_thread()
343 us->srb->result = DID_ABORT << 16; in usb_stor_control_thread()
352 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { in usb_stor_control_thread()
354 us->srb->result = DID_ERROR << 16; in usb_stor_control_thread()
360 else if (us->srb->device->id && in usb_stor_control_thread()
361 !(us->fflags & US_FL_SCM_MULT_TARG)) { in usb_stor_control_thread()
363 us->srb->device->id, us->srb->device->lun); in usb_stor_control_thread()
364 us->srb->result = DID_BAD_TARGET << 16; in usb_stor_control_thread()
367 else if (us->srb->device->lun > us->max_lun) { in usb_stor_control_thread()
369 us->srb->device->id, us->srb->device->lun); in usb_stor_control_thread()
370 us->srb->result = DID_BAD_TARGET << 16; in usb_stor_control_thread()
375 else if ((us->srb->cmnd[0] == INQUIRY) && in usb_stor_control_thread()
376 (us->fflags & US_FL_FIX_INQUIRY)) { in usb_stor_control_thread()
382 fill_inquiry_response(us, data_ptr, 36); in usb_stor_control_thread()
383 us->srb->result = SAM_STAT_GOOD; in usb_stor_control_thread()
388 US_DEBUG(usb_stor_show_command(us->srb)); in usb_stor_control_thread()
389 us->proto_handler(us->srb, us); in usb_stor_control_thread()
396 if (us->srb->result != DID_ABORT << 16) { in usb_stor_control_thread()
398 us->srb->result); in usb_stor_control_thread()
399 us->srb->scsi_done(us->srb); in usb_stor_control_thread()
410 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in usb_stor_control_thread()
411 complete(&(us->notify)); in usb_stor_control_thread()
414 clear_bit(US_FLIDX_ABORTING, &us->dflags); in usb_stor_control_thread()
415 clear_bit(US_FLIDX_TIMED_OUT, &us->dflags); in usb_stor_control_thread()
419 us->srb = NULL; in usb_stor_control_thread()
423 mutex_unlock(&us->dev_mutex); in usb_stor_control_thread()
442 static int associate_dev(struct us_data *us, struct usb_interface *intf) in associate_dev() argument
447 us->pusb_dev = interface_to_usbdev(intf); in associate_dev()
448 us->pusb_intf = intf; in associate_dev()
449 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in associate_dev()
451 le16_to_cpu(us->pusb_dev->descriptor.idVendor), in associate_dev()
452 le16_to_cpu(us->pusb_dev->descriptor.idProduct), in associate_dev()
453 le16_to_cpu(us->pusb_dev->descriptor.bcdDevice)); in associate_dev()
459 usb_set_intfdata(intf, us); in associate_dev()
462 us->cr = usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr), in associate_dev()
463 GFP_KERNEL, &us->cr_dma); in associate_dev()
464 if (!us->cr) { in associate_dev()
469 us->iobuf = usb_buffer_alloc(us->pusb_dev, US_IOBUF_SIZE, in associate_dev()
470 GFP_KERNEL, &us->iobuf_dma); in associate_dev()
471 if (!us->iobuf) { in associate_dev()
482 static void adjust_quirks(struct us_data *us) in adjust_quirks() argument
485 u16 vid = le16_to_cpu(us->pusb_dev->descriptor.idVendor); in adjust_quirks()
486 u16 pid = le16_to_cpu(us->pusb_dev->descriptor.idProduct); in adjust_quirks()
548 us->fflags = (us->fflags & ~mask) | f; in adjust_quirks()
549 dev_info(&us->pusb_intf->dev, "Quirks match for " in adjust_quirks()
562 static int get_device_info(struct us_data *us, const struct usb_device_id *id) in get_device_info() argument
564 struct usb_device *dev = us->pusb_dev; in get_device_info()
566 &us->pusb_intf->cur_altsetting->desc; in get_device_info()
570 us->unusual_dev = unusual_dev; in get_device_info()
571 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ? in get_device_info()
574 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? in get_device_info()
577 us->fflags = USB_US_ORIG_FLAGS(id->driver_info); in get_device_info()
578 adjust_quirks(us); in get_device_info()
580 if (us->fflags & US_FL_IGNORE_DEVICE) { in get_device_info()
590 us->fflags &= ~US_FL_GO_SLOW; in get_device_info()
606 us->subclass == idesc->bInterfaceSubClass) in get_device_info()
609 us->protocol == idesc->bInterfaceProtocol) in get_device_info()
611 if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE)) in get_device_info()
632 static int get_transport(struct us_data *us) in get_transport() argument
634 switch (us->protocol) { in get_transport()
636 us->transport_name = "Control/Bulk"; in get_transport()
637 us->transport = usb_stor_CB_transport; in get_transport()
638 us->transport_reset = usb_stor_CB_reset; in get_transport()
639 us->max_lun = 7; in get_transport()
643 us->transport_name = "Control/Bulk/Interrupt"; in get_transport()
644 us->transport = usb_stor_CB_transport; in get_transport()
645 us->transport_reset = usb_stor_CB_reset; in get_transport()
646 us->max_lun = 7; in get_transport()
650 us->transport_name = "Bulk"; in get_transport()
651 us->transport = usb_stor_Bulk_transport; in get_transport()
652 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
657 us->transport_name = "Shuttle USBAT"; in get_transport()
658 us->transport = usbat_transport; in get_transport()
659 us->transport_reset = usb_stor_CB_reset; in get_transport()
660 us->max_lun = 1; in get_transport()
666 us->transport_name = "EUSB/SDDR09"; in get_transport()
667 us->transport = sddr09_transport; in get_transport()
668 us->transport_reset = usb_stor_CB_reset; in get_transport()
669 us->max_lun = 0; in get_transport()
675 us->transport_name = "SDDR55"; in get_transport()
676 us->transport = sddr55_transport; in get_transport()
677 us->transport_reset = sddr55_reset; in get_transport()
678 us->max_lun = 0; in get_transport()
684 us->transport_name = "Control/Bulk-EUSB/SDDR09"; in get_transport()
685 us->transport = dpcm_transport; in get_transport()
686 us->transport_reset = usb_stor_CB_reset; in get_transport()
687 us->max_lun = 1; in get_transport()
693 us->transport_name = "Freecom"; in get_transport()
694 us->transport = freecom_transport; in get_transport()
695 us->transport_reset = usb_stor_freecom_reset; in get_transport()
696 us->max_lun = 0; in get_transport()
702 us->transport_name = "Datafab Bulk-Only"; in get_transport()
703 us->transport = datafab_transport; in get_transport()
704 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
705 us->max_lun = 1; in get_transport()
711 us->transport_name = "Lexar Jumpshot Control/Bulk"; in get_transport()
712 us->transport = jumpshot_transport; in get_transport()
713 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
714 us->max_lun = 1; in get_transport()
720 us->transport_name = "Alauda Control/Bulk"; in get_transport()
721 us->transport = alauda_transport; in get_transport()
722 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
723 us->max_lun = 1; in get_transport()
729 us->transport_name = "Rio Karma/Bulk"; in get_transport()
730 us->transport = rio_karma_transport; in get_transport()
731 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
738 US_DEBUGP("Transport: %s\n", us->transport_name); in get_transport()
741 if (us->fflags & US_FL_SINGLE_LUN) in get_transport()
742 us->max_lun = 0; in get_transport()
747 static int get_protocol(struct us_data *us) in get_protocol() argument
749 switch (us->subclass) { in get_protocol()
751 us->protocol_name = "Reduced Block Commands (RBC)"; in get_protocol()
752 us->proto_handler = usb_stor_transparent_scsi_command; in get_protocol()
756 us->protocol_name = "8020i"; in get_protocol()
757 us->proto_handler = usb_stor_pad12_command; in get_protocol()
758 us->max_lun = 0; in get_protocol()
762 us->protocol_name = "QIC-157"; in get_protocol()
763 us->proto_handler = usb_stor_pad12_command; in get_protocol()
764 us->max_lun = 0; in get_protocol()
768 us->protocol_name = "8070i"; in get_protocol()
769 us->proto_handler = usb_stor_pad12_command; in get_protocol()
770 us->max_lun = 0; in get_protocol()
774 us->protocol_name = "Transparent SCSI"; in get_protocol()
775 us->proto_handler = usb_stor_transparent_scsi_command; in get_protocol()
779 us->protocol_name = "Uniform Floppy Interface (UFI)"; in get_protocol()
780 us->proto_handler = usb_stor_ufi_command; in get_protocol()
785 us->protocol_name = "ISD200 ATA/ATAPI"; in get_protocol()
786 us->proto_handler = isd200_ata_command; in get_protocol()
792 us->protocol_name = "Transparent SCSI with Cypress ATACB"; in get_protocol()
793 us->proto_handler = cypress_atacb_passthrough; in get_protocol()
800 US_DEBUGP("Protocol: %s\n", us->protocol_name); in get_protocol()
805 static int get_pipes(struct us_data *us) in get_pipes() argument
808 us->pusb_intf->cur_altsetting; in get_pipes()
840 if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) { in get_pipes()
846 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); in get_pipes()
847 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); in get_pipes()
848 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, in get_pipes()
850 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, in get_pipes()
853 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, in get_pipes()
855 us->ep_bInterval = ep_int->bInterval; in get_pipes()
861 static int usb_stor_acquire_resources(struct us_data *us) in usb_stor_acquire_resources() argument
866 us->current_urb = usb_alloc_urb(0, GFP_KERNEL); in usb_stor_acquire_resources()
867 if (!us->current_urb) { in usb_stor_acquire_resources()
874 if (us->unusual_dev->initFunction) { in usb_stor_acquire_resources()
875 p = us->unusual_dev->initFunction(us); in usb_stor_acquire_resources()
881 th = kthread_run(usb_stor_control_thread, us, "usb-storage"); in usb_stor_acquire_resources()
887 us->ctl_thread = th; in usb_stor_acquire_resources()
893 static void usb_stor_release_resources(struct us_data *us) in usb_stor_release_resources() argument
902 complete(&us->cmnd_ready); in usb_stor_release_resources()
903 if (us->ctl_thread) in usb_stor_release_resources()
904 kthread_stop(us->ctl_thread); in usb_stor_release_resources()
907 if (us->extra_destructor) { in usb_stor_release_resources()
909 us->extra_destructor(us->extra); in usb_stor_release_resources()
913 kfree(us->extra); in usb_stor_release_resources()
914 usb_free_urb(us->current_urb); in usb_stor_release_resources()
918 static void dissociate_dev(struct us_data *us) in dissociate_dev() argument
923 if (us->cr) in dissociate_dev()
924 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, in dissociate_dev()
925 us->cr_dma); in dissociate_dev()
926 if (us->iobuf) in dissociate_dev()
927 usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, in dissociate_dev()
928 us->iobuf_dma); in dissociate_dev()
931 usb_set_intfdata(us->pusb_intf, NULL); in dissociate_dev()
937 static void quiesce_and_remove_host(struct us_data *us) in quiesce_and_remove_host() argument
939 struct Scsi_Host *host = us_to_host(us); in quiesce_and_remove_host()
942 if (us->pusb_dev->state == USB_STATE_NOTATTACHED) in quiesce_and_remove_host()
943 set_bit(US_FLIDX_DISCONNECTING, &us->dflags); in quiesce_and_remove_host()
948 set_bit(US_FLIDX_DONT_SCAN, &us->dflags); in quiesce_and_remove_host()
949 wake_up(&us->delay_wait); in quiesce_and_remove_host()
950 wait_for_completion(&us->scanning_done); in quiesce_and_remove_host()
961 set_bit(US_FLIDX_DISCONNECTING, &us->dflags); in quiesce_and_remove_host()
963 wake_up(&us->delay_wait); in quiesce_and_remove_host()
967 static void release_everything(struct us_data *us) in release_everything() argument
969 usb_stor_release_resources(us); in release_everything()
970 dissociate_dev(us); in release_everything()
974 scsi_host_put(us_to_host(us)); in release_everything()
980 struct us_data *us = (struct us_data *)__us; in usb_stor_scan_thread() local
983 "usb-storage: device found at %d\n", us->pusb_dev->devnum); in usb_stor_scan_thread()
990 wait_event_freezable_timeout(us->delay_wait, in usb_stor_scan_thread()
991 test_bit(US_FLIDX_DONT_SCAN, &us->dflags), in usb_stor_scan_thread()
996 if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) { in usb_stor_scan_thread()
999 if (us->protocol == US_PR_BULK && in usb_stor_scan_thread()
1000 !(us->fflags & US_FL_SINGLE_LUN)) { in usb_stor_scan_thread()
1001 mutex_lock(&us->dev_mutex); in usb_stor_scan_thread()
1002 us->max_lun = usb_stor_Bulk_max_lun(us); in usb_stor_scan_thread()
1003 mutex_unlock(&us->dev_mutex); in usb_stor_scan_thread()
1005 scsi_scan_host(us_to_host(us)); in usb_stor_scan_thread()
1011 complete_and_exit(&us->scanning_done, 0); in usb_stor_scan_thread()
1020 struct us_data *us; in storage_probe() local
1033 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); in storage_probe()
1044 us = host_to_us(host); in storage_probe()
1045 memset(us, 0, sizeof(struct us_data)); in storage_probe()
1046 mutex_init(&(us->dev_mutex)); in storage_probe()
1047 init_completion(&us->cmnd_ready); in storage_probe()
1048 init_completion(&(us->notify)); in storage_probe()
1049 init_waitqueue_head(&us->delay_wait); in storage_probe()
1050 init_completion(&us->scanning_done); in storage_probe()
1053 result = associate_dev(us, intf); in storage_probe()
1064 result = get_device_info(us, id); in storage_probe()
1069 result = get_transport(us); in storage_probe()
1072 result = get_protocol(us); in storage_probe()
1075 result = get_pipes(us); in storage_probe()
1080 result = usb_stor_acquire_resources(us); in storage_probe()
1091 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan"); in storage_probe()
1095 complete(&us->scanning_done); in storage_probe()
1096 quiesce_and_remove_host(us); in storage_probe()
1108 release_everything(us); in storage_probe()
1115 struct us_data *us = usb_get_intfdata(intf); in storage_disconnect() local
1118 quiesce_and_remove_host(us); in storage_disconnect()
1119 release_everything(us); in storage_disconnect()