Lines Matching refs:us
297 void fill_inquiry_response(struct us_data *us, unsigned char *data, in fill_inquiry_response() argument
304 us->srb.request_bufflen > data_len ? data_len : in fill_inquiry_response()
305 us->srb.request_bufflen; in fill_inquiry_response()
321 memcpy(data+8, us->unusual_dev->vendorName, in fill_inquiry_response()
322 strlen(us->unusual_dev->vendorName) > 8 ? 8 : in fill_inquiry_response()
323 strlen(us->unusual_dev->vendorName)); in fill_inquiry_response()
326 memcpy(data+16, us->unusual_dev->productName, in fill_inquiry_response()
327 strlen(us->unusual_dev->productName) > 16 ? 16 : in fill_inquiry_response()
328 strlen(us->unusual_dev->productName)); in fill_inquiry_response()
331 data[32] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>12) & 0x0F); in fill_inquiry_response()
332 data[33] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>8) & 0x0F); in fill_inquiry_response()
333 data[34] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>4) & 0x0F); in fill_inquiry_response()
334 data[35] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice) & 0x0F); in fill_inquiry_response()
339 if (us->srb.use_sg) in fill_inquiry_response()
345 memset(us->srb.request_buffer, 0, us->srb.request_bufflen); in fill_inquiry_response()
346 memcpy(us->srb.request_buffer, data, len); in fill_inquiry_response()
353 struct us_data *us = (struct us_data *)__us; in usb_stor_control_thread() local
389 if (us->sm_state == US_STATE_ABORTING) in usb_stor_control_thread()
391 us->srb.result = DID_ABORT << 16; in usb_stor_control_thread()
396 us->sm_state = US_STATE_RUNNING; in usb_stor_control_thread()
400 down(&(us->dev_semaphore)); in usb_stor_control_thread()
404 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) in usb_stor_control_thread()
407 us->srb.result = DID_BAD_TARGET << 16; in usb_stor_control_thread()
410 else if (us->srb.sc_data_direction == SCSI_DATA_UNKNOWN) in usb_stor_control_thread()
413 us->srb.result = DID_ERROR << 16; in usb_stor_control_thread()
418 else if (us->srb.device->id && in usb_stor_control_thread()
419 !(us->flags & US_FL_SCM_MULT_TARG)) in usb_stor_control_thread()
422 us->srb.device->id, us->srb.device->lun); in usb_stor_control_thread()
423 us->srb.result = DID_BAD_TARGET << 16; in usb_stor_control_thread()
426 else if (us->srb.device->lun > us->max_lun) in usb_stor_control_thread()
429 us->srb.device->id, us->srb.device->lun); in usb_stor_control_thread()
430 us->srb.result = DID_BAD_TARGET << 16; in usb_stor_control_thread()
434 else if ((us->srb.cmnd[0] == INQUIRY) && in usb_stor_control_thread()
435 (us->flags & US_FL_FIX_INQUIRY)) { in usb_stor_control_thread()
441 fill_inquiry_response(us, data_ptr, 36); in usb_stor_control_thread()
442 us->srb.result = SAM_STAT_GOOD; in usb_stor_control_thread()
449 us->proto_handler(&us->srb, us); in usb_stor_control_thread()
453 up(&(us->dev_semaphore)); in usb_stor_control_thread()
459 if (us->srb.result != DID_ABORT << 16) in usb_stor_control_thread()
462 us->srb.result); in usb_stor_control_thread()
464 if(us->srb.scsi_done != NULL) in usb_stor_control_thread()
465 us->srb.scsi_done(&us->srb); in usb_stor_control_thread()
474 if (us->sm_state == US_STATE_ABORTING) in usb_stor_control_thread()
475 complete(&(us->notify)); in usb_stor_control_thread()
479 us->sm_state = US_STATE_IDLE; in usb_stor_control_thread()
484 complete(&(us->notify)); in usb_stor_control_thread()
489 static int associate_dev(struct us_data *us, struct usb_interface *intf) in associate_dev() argument
494 us->pusb_dev = interface_to_usbdev(intf); in associate_dev()
497 us->pusb_intf = intf; in associate_dev()
500 us->ifnum = intf->altsetting->desc.bInterfaceNumber; in associate_dev()
503 usb_set_intfdata(intf, us); in associate_dev()
504 usb_get_dev(us->pusb_dev); in associate_dev()
507 …us->cr = (struct usb_ctrlrequest*) usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us… in associate_dev()
512 if (!us->cr) in associate_dev()
521 …us->iobuf = (unsigned char*) usb_buffer_alloc(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_… in associate_dev()
525 if (!us->iobuf) { in associate_dev()
536 static void get_device_info(struct us_data *us, int id_index) in get_device_info() argument
542 &us->pusb_intf->altsetting[us->pusb_intf->act_altsetting].desc; in get_device_info()
559 us->unusual_dev = unusual_dev; in get_device_info()
560 us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ? in get_device_info()
563 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? in get_device_info()
566 us->flags = unusual_dev->flags; in get_device_info()
575 us->subclass == idesc->bInterfaceSubClass) in get_device_info()
578 us->protocol == idesc->bInterfaceProtocol) in get_device_info()
583 if (strlen(us->vendor) == 0) { in get_device_info()
585 strncpy(us->vendor, unusual_dev->vendorName, in get_device_info()
586 sizeof(us->vendor)); in get_device_info()
588 strncpy(us->vendor, "Unknown", sizeof(us->vendor)); in get_device_info()
590 if (strlen(us->product) == 0) { in get_device_info()
592 strncpy(us->product, unusual_dev->productName, in get_device_info()
593 sizeof(us->product)); in get_device_info()
595 strncpy(us->product, "Unknown", sizeof(us->product)); in get_device_info()
597 if (strlen(us->serial) == 0) in get_device_info()
598 strncpy(us->serial, "None", sizeof(us->serial)); in get_device_info()
602 static int get_transport(struct us_data *us) in get_transport() argument
604 switch (us->protocol) { in get_transport()
608 us->transport_name = "Control/Bulk"; in get_transport()
609 us->transport = usb_stor_CB_transport; in get_transport()
610 us->transport_reset = usb_stor_CB_reset; in get_transport()
612 us->max_lun = 0; //FIXME, Find some way to get real Max. LUN in get_transport()
617 us->transport_name = "Control/Bulk/Interrupt"; in get_transport()
618 us->transport = usb_stor_CBI_transport; in get_transport()
619 us->transport_reset = usb_stor_CB_reset; in get_transport()
620 us->max_lun = 0; in get_transport()
625 us->transport_name = "Bulk"; in get_transport()
626 us->transport = usb_stor_Bulk_transport; in get_transport()
627 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
634 us->transport_name = "SCM/ATAPI"; in get_transport()
635 us->transport = hp8200e_transport; in get_transport()
636 us->transport_reset = usb_stor_CB_reset; in get_transport()
637 us->max_lun = 1; in get_transport()
645 us->transport_name = "EUSB/SDDR09"; in get_transport()
646 us->transport = sddr09_transport; in get_transport()
647 us->transport_reset = usb_stor_CB_reset; in get_transport()
648 us->max_lun = 0; in get_transport()
656 us->transport_name = "SDDR55"; in get_transport()
657 us->transport = sddr55_transport; in get_transport()
658 us->transport_reset = sddr55_reset; in get_transport()
659 us->max_lun = 0; in get_transport()
667 us->transport_name = "Control/Bulk-EUSB/SDDR09"; in get_transport()
668 us->transport = dpcm_transport; in get_transport()
669 us->transport_reset = usb_stor_CB_reset; in get_transport()
670 us->max_lun = 1; in get_transport()
677 us->transport_name = "Freecom"; in get_transport()
678 us->transport = freecom_transport; in get_transport()
679 us->transport_reset = usb_stor_freecom_reset; in get_transport()
680 us->max_lun = 0; in get_transport()
688 us->transport_name = "Datafab Bulk-Only"; in get_transport()
689 us->transport = datafab_transport; in get_transport()
690 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
691 us->max_lun = 1; in get_transport()
699 us->transport_name = "Lexar Jumpshot Control/Bulk"; in get_transport()
700 us->transport = jumpshot_transport; in get_transport()
701 us->transport_reset = usb_stor_Bulk_reset; in get_transport()
702 us->max_lun = 1; in get_transport()
711 US_DEBUGP("Transport: %s\n", us->transport_name); in get_transport()
714 if (us->flags & US_FL_SINGLE_LUN) in get_transport()
715 us->max_lun = 0; in get_transport()
720 static int get_protocol(struct us_data *us) in get_protocol() argument
722 switch (us->subclass) { in get_protocol()
724 us->protocol_name = "Reduced Block Commands (RBC)"; in get_protocol()
726 us->proto_handler = usb_stor_transparent_scsi_command; in get_protocol()
732 us->protocol_name = "Transparent SCSI"; in get_protocol()
734 us->proto_handler = usb_stor_transparent_scsi_command; in get_protocol()
738 us->protocol_name = "8020i"; in get_protocol()
739 us->proto_handler = usb_stor_transparent_scsi_command; in get_protocol()
740 us->max_lun = 0; in get_protocol()
746 us->protocol_name = "8020i"; in get_protocol()
747 us->proto_handler = usb_stor_ATAPI_command; in get_protocol()
748 us->max_lun = 0; in get_protocol()
753 us->protocol_name = "QIC-157"; in get_protocol()
754 us->proto_handler = usb_stor_qic157_command; in get_protocol()
755 us->max_lun = 0; in get_protocol()
759 us->protocol_name = "8070i"; in get_protocol()
760 us->proto_handler = usb_stor_ATAPI_command; in get_protocol()
761 us->max_lun = 0; in get_protocol()
766 us->protocol_name = "Uniform Floppy Interface (UFI)"; in get_protocol()
767 us->proto_handler = usb_stor_ufi_command; in get_protocol()
773 us->protocol_name = "ISD200 ATA/ATAPI"; in get_protocol()
774 us->proto_handler = isd200_ata_command; in get_protocol()
782 US_DEBUGP("Protocol: %s\n", us->protocol_name); in get_protocol()
788 static int get_pipes(struct us_data *us) in get_pipes() argument
791 struct usb_host_interface *altsetting = &us->pusb_intf->altsetting[us->pusb_intf->act_altsetting]; in get_pipes()
843 if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) in get_pipes()
852 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); in get_pipes()
855 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); in get_pipes()
858 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, in get_pipes()
862 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, in get_pipes()
869 us->recv_intr_pipe = usb_rcvbulkpipe(us->pusb_dev, in get_pipes()
873 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, in get_pipes()
877 us->ep_bInterval = ep_int->bInterval; in get_pipes()
884 static int usb_stor_acquire_resources(struct us_data *us) in usb_stor_acquire_resources() argument
889 us->current_urb = usb_alloc_urb(0, GFP_KERNEL); in usb_stor_acquire_resources()
890 if (!us->current_urb) { in usb_stor_acquire_resources()
894 us->data_urb = usb_alloc_urb(0, GFP_KERNEL); in usb_stor_acquire_resources()
895 if (!us->data_urb) { in usb_stor_acquire_resources()
899 us->status_urb = usb_alloc_urb(0, GFP_KERNEL); in usb_stor_acquire_resources()
900 if (!us->status_urb) { in usb_stor_acquire_resources()
906 down(&us->dev_semaphore); in usb_stor_acquire_resources()
909 if (us->protocol == US_PR_BULK) in usb_stor_acquire_resources()
910 us->max_lun = usb_stor_Bulk_max_lun(us); in usb_stor_acquire_resources()
913 …us->Mass_stor_device=(struct LUN_Device*)kmalloc(sizeof(struct LUN_Device)*(us->max_lun+1), GFP_KE… in usb_stor_acquire_resources()
914 memset(us->Mass_stor_device,0 , sizeof(struct LUN_Device)*(us->max_lun+1)); in usb_stor_acquire_resources()
917 if (us->unusual_dev->initFunction) in usb_stor_acquire_resources()
918 us->unusual_dev->initFunction(us); in usb_stor_acquire_resources()
920 up(&us->dev_semaphore); in usb_stor_acquire_resources()
923 us->sm_state = US_STATE_IDLE; in usb_stor_acquire_resources()
953 static void dissociate_dev(struct us_data *us) in dissociate_dev() argument
958 down(&us->dev_semaphore); in dissociate_dev()
961 if (us->cr) { in dissociate_dev()
962 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, in dissociate_dev()
963 us->cr_dma); in dissociate_dev()
964 us->cr = NULL; in dissociate_dev()
967 if (us->iobuf) { in dissociate_dev()
968 usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, in dissociate_dev()
969 us->iobuf_dma); in dissociate_dev()
970 us->iobuf = NULL; in dissociate_dev()
974 usb_set_intfdata(us->pusb_intf, NULL); in dissociate_dev()
975 usb_put_dev(us->pusb_dev); in dissociate_dev()
978 us->pusb_dev = NULL; in dissociate_dev()
979 us->pusb_intf = NULL; in dissociate_dev()
980 up(&us->dev_semaphore); in dissociate_dev()
984 void usb_stor_release_resources(struct us_data *us) in usb_stor_release_resources() argument
1009 if (us->extra_destructor) { in usb_stor_release_resources()
1011 us->extra_destructor(us->extra); in usb_stor_release_resources()
1015 if (us->extra) in usb_stor_release_resources()
1016 kfree(us->extra); in usb_stor_release_resources()
1017 if (us->current_urb) in usb_stor_release_resources()
1018 usb_free_urb(us->current_urb); in usb_stor_release_resources()
1019 if (us->data_urb) in usb_stor_release_resources()
1020 usb_free_urb(us->data_urb); in usb_stor_release_resources()
1021 if (us->status_urb) in usb_stor_release_resources()
1022 usb_free_urb(us->status_urb); in usb_stor_release_resources()
1029 if (Mass_stor_us[ii] == us) in usb_stor_release_resources()
1037 if (us->Mass_stor_device) in usb_stor_release_resources()
1038 kfree(us->Mass_stor_device); in usb_stor_release_resources()
1040 kfree(us); in usb_stor_release_resources()
1069 struct us_data *us; in storage_probe() local
1081 us = (struct us_data *) kmalloc(sizeof(*us), GFP_KERNEL); in storage_probe()
1082 if (!us) in storage_probe()
1084 US_DEBUGP("Out of memory %d\n", us); in storage_probe()
1089 memset(us, 0, sizeof(struct us_data)); in storage_probe()
1091 init_MUTEX(&(us->dev_semaphore)); in storage_probe()
1093 init_MUTEX_LOCKED(&(us->sema)); in storage_probe()
1095 init_completion(&(us->notify)); in storage_probe()
1098 result = associate_dev(us, intf); in storage_probe()
1104 get_device_info(us, id_index); in storage_probe()
1108 if (us->protocol == US_PR_EUSB_SDDR09 || us->protocol == US_PR_DPCM_USB) in storage_probe()
1111 result = usb_set_configuration(us->pusb_dev, 1); in storage_probe()
1132 result = get_transport(us); in storage_probe()
1137 result = get_protocol(us); in storage_probe()
1142 result = get_pipes(us); in storage_probe()
1148 result = usb_stor_acquire_resources(us); in storage_probe()
1159 Mass_stor_us[i] = us; in storage_probe()
1160 us->ustor_id = (unsigned char)i; in storage_probe()
1169 for(i = 0; i<=us->max_lun; i++) in storage_probe()
1170 us->Mass_stor_device[i].bDeviceReady = FALSE; in storage_probe()
1175 US_DEBUGP("USB Mass Storage device found at %d\n", us->pusb_dev->devnum); in storage_probe()
1184 dissociate_dev(us); in storage_probe()
1186 usb_stor_release_resources(us); in storage_probe()
1195 struct us_data *us = (struct us_data*) usb_get_intfdata(intf); in storage_disconnect() local
1198 diag_printf("storage_disconnect() : ustor_id: %d \n", us->ustor_id); in storage_disconnect()
1209 set_bit(US_FLIDX_DISCONNECTING, &us->flags, unsigned long); in storage_disconnect()
1210 usb_stor_stop_transport(us); in storage_disconnect()
1213 dissociate_dev(us); in storage_disconnect()
1225 usb_stor_release_resources(us); in storage_disconnect()