1 #include <linux/sched.h>
2 #include <linux/errno.h>
4 #include <linux/module.h>
6 #include <linux/slab.h>
9 #include <linux/utsname.h>
11 #include <scsi/scsi.h>
25 static unsigned int delay_use = 1;
28 { USB_DEVICE(0x058f, 0x6366) },
29 { USB_DEVICE(0x0cf2, 0x6230) },
30 { USB_DEVICE(0x0cf2, 0x6250) },
40 struct us_data *us = usb_get_intfdata(iface);
41 pr_info(
"--- eucr_suspend ---\n");
46 if (us->suspend_resume_hook)
63 struct us_data *us = usb_get_intfdata(iface);
64 pr_info(
"--- eucr_resume---\n");
68 if (us->suspend_resume_hook)
86 struct us_data *us = usb_get_intfdata(iface);
88 pr_info(
"--- eucr_reset_resume---\n");
107 #define eucr_suspend NULL
108 #define eucr_resume NULL
109 #define eucr_reset_resume NULL
116 struct us_data *us = usb_get_intfdata(iface);
118 pr_info(
"usb --- eucr_pre_reset\n");
128 struct us_data *us = usb_get_intfdata(iface);
130 pr_info(
"usb --- eucr_post_reset\n");
142 pr_info(
"usb --- fill_inquiry_response\n");
159 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
160 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
161 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
162 data[35] = 0x30 + ((bcdDevice) & 0x0F);
168 static int usb_stor_control_thread(
void * __us)
173 pr_info(
"usb --- usb_stor_control_thread\n");
213 else if (us->
srb->device->id && !(us->
fflags & US_FL_SCM_MULT_TARG))
223 unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00};
239 us->
srb->scsi_done(us->
srb);
244 pr_info(
"scsi command aborted\n");
279 pr_info(
"usb --- associate_dev\n");
282 us->
pusb_dev = interface_to_usbdev(intf);
284 us->
ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
287 usb_set_intfdata(intf, us);
293 pr_info(
"usb_ctrlrequest allocation failed\n");
300 pr_info(
"I/O buffer allocation failed\n");
307 pr_info(
"Sense buffer allocation failed\n");
319 pr_info(
"usb --- get_device_info\n");
323 us->
fflags =
id->driver_info;
326 if (us->
fflags & US_FL_IGNORE_DEVICE)
333 us->
fflags &= ~US_FL_GO_SLOW;
339 static int get_transport(
struct us_data *us)
341 pr_info(
"usb --- get_transport\n");
355 if (us->
fflags & US_FL_SINGLE_LUN)
361 static int get_protocol(
struct us_data *us)
363 pr_info(
"usb --- get_protocol\n");
364 pr_info(
"us->pusb_dev->descriptor.idVendor = %x\n",
366 pr_info(
"us->pusb_dev->descriptor.idProduct = %x\n",
367 us->
pusb_dev->descriptor.idProduct);
371 if( (us->
pusb_dev->descriptor.idVendor == 0x0CF2) && (us->
pusb_dev->descriptor.idProduct == 0x6250) )
385 static int get_pipes(
struct us_data *us)
387 struct usb_host_interface *altsetting = us->
pusb_intf->cur_altsetting;
394 pr_info(
"usb --- get_pipes\n");
396 for (i = 0; i < altsetting->desc.bNumEndpoints; i++)
398 ep = &altsetting->endpoint[
i].desc;
400 if (usb_endpoint_xfer_bulk(ep))
402 if (usb_endpoint_dir_in(ep))
413 else if (usb_endpoint_is_int_in(ep))
422 pr_info(
"Endpoint sanity check failed! Rejecting dev.\n");
440 static int usb_stor_acquire_resources(
struct us_data *us)
444 pr_info(
"usb --- usb_stor_acquire_resources\n");
448 pr_info(
"URB allocation failed\n");
453 th =
kthread_run(usb_stor_control_thread, us,
"eucr-storage");
456 pr_info(
"Unable to start control thread\n");
465 static void usb_stor_release_resources(
struct us_data *us)
467 pr_info(
"usb --- usb_stor_release_resources\n");
478 pr_info(
"-- calling extra_destructor()\n");
488 static void dissociate_dev(
struct us_data *us)
490 pr_info(
"usb --- dissociate_dev\n");
505 static void quiesce_and_remove_host(
struct us_data *us)
509 pr_info(
"usb --- quiesce_and_remove_host\n");
537 static void release_everything(
struct us_data *us)
539 pr_info(
"usb --- release_everything\n");
541 usb_stor_release_resources(us);
547 static int usb_stor_scan_thread(
void * __us)
551 pr_info(
"usb --- usb_stor_scan_thread\n");
573 pr_info(
"EUCR : device scan complete\n");
587 pr_info(
"usb --- eucr_probe\n");
592 pr_info(
"Unable to allocate the scsi host\n");
598 us = host_to_us(host);
602 init_completion(&(us->
notify));
607 result = associate_dev(us, intf);
612 result = get_device_info(us,
id);
617 result = get_transport(us);
620 result = get_protocol(us);
623 result = get_pipes(us);
628 result = usb_stor_acquire_resources(us);
632 result = scsi_add_host(host, &intf->dev);
635 pr_info(
"Unable to add the scsi host\n");
642 pr_info(
"Unable to start the device-scanning thread\n");
644 quiesce_and_remove_host(us);
645 result = PTR_ERR(th);
654 quiesce_and_remove_host(us);
658 if (!(MiscReg03 & 0x02)) {
660 quiesce_and_remove_host(us);
661 pr_info(
"keucr: The driver only supports SM/MS card.\
663 please build driver/usb/storage/ums-eneub6250.ko\n");
671 pr_info(
"usb --- eucr_probe failed\n");
672 release_everything(us);
679 struct us_data *us = usb_get_intfdata(intf);
681 pr_info(
"usb --- eucr_disconnect\n");
682 quiesce_and_remove_host(us);
683 release_everything(us);
691 static struct usb_driver usb_storage_driver = {
697 .disconnect = eucr_disconnect,
698 .pre_reset = eucr_pre_reset,
699 .post_reset = eucr_post_reset,
700 .id_table = eucr_usb_ids,