staging: ath6kl: provide hardware version to userspace
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / keucr / usb.c
CommitLineData
126bb03b
AC
1#include <linux/sched.h>
2#include <linux/errno.h>
3#include <linux/freezer.h>
4#include <linux/module.h>
5#include <linux/init.h>
6#include <linux/slab.h>
7#include <linux/kthread.h>
8#include <linux/mutex.h>
9#include <linux/utsname.h>
10
11#include <scsi/scsi.h>
12#include <scsi/scsi_cmnd.h>
13#include <scsi/scsi_device.h>
14
15#include "usb.h"
16#include "scsiglue.h"
17#include "transport.h"
18
19/* Some informational data */
20MODULE_AUTHOR("Domao");
21MODULE_DESCRIPTION("ENE USB Mass Storage driver for Linux");
22MODULE_LICENSE("GPL");
23
a8718692
AC
24static unsigned int delay_use = 1;
25
126bb03b
AC
26static struct usb_device_id eucr_usb_ids [] = {
27 { USB_DEVICE(0x058f, 0x6366) },
28 { USB_DEVICE(0x0cf2, 0x6230) },
29 { USB_DEVICE(0x0cf2, 0x6250) },
30 { } /* Terminating entry */
31};
32MODULE_DEVICE_TABLE (usb, eucr_usb_ids);
33
34
e23f773e 35#ifdef CONFIG_PM
126bb03b
AC
36
37int eucr_suspend(struct usb_interface *iface, pm_message_t message)
38{
39 struct us_data *us = usb_get_intfdata(iface);
871f8477 40 pr_info("--- eucr_suspend ---\n");
126bb03b
AC
41 /* Wait until no command is running */
42 mutex_lock(&us->dev_mutex);
43
44 //US_DEBUGP("%s\n", __func__);
45 if (us->suspend_resume_hook)
46 (us->suspend_resume_hook)(us, US_SUSPEND);
47
48 /* When runtime PM is working, we'll set a flag to indicate
49 * whether we should autoresume when a SCSI request arrives. */
50 // us->Power_IsResum = true;
51 //us->SD_Status.Ready = 0;
52
53 mutex_unlock(&us->dev_mutex);
54 return 0;
55}
56//EXPORT_SYMBOL_GPL(eucr_suspend);
57
58int eucr_resume(struct usb_interface *iface)
59{
60 BYTE tmp = 0;
61
62 struct us_data *us = usb_get_intfdata(iface);
871f8477 63 pr_info("--- eucr_resume---\n");
126bb03b
AC
64 mutex_lock(&us->dev_mutex);
65
66 //US_DEBUGP("%s\n", __func__);
67 if (us->suspend_resume_hook)
68 (us->suspend_resume_hook)(us, US_RESUME);
69
70
71 mutex_unlock(&us->dev_mutex);
72
73
74 us->Power_IsResum = true;
75 //
76 //us->SD_Status.Ready = 0; //??
126bb03b
AC
77 us->MS_Status = *(PMS_STATUS)&tmp;
78 us->SM_Status = *(PSM_STATUS)&tmp;
79
80 return 0;
81}
82//EXPORT_SYMBOL_GPL(eucr_resume);
83int eucr_reset_resume(struct usb_interface *iface)
84{
85 BYTE tmp = 0;
86 struct us_data *us = usb_get_intfdata(iface);
87
871f8477 88 pr_info("--- eucr_reset_resume---\n");
126bb03b
AC
89 //US_DEBUGP("%s\n", __func__);
90
91 /* Report the reset to the SCSI core */
92 usb_stor_report_bus_reset(us);
93
94 /* FIXME: Notify the subdrivers that they need to reinitialize
95 * the device */
96 //ENE_InitMedia(us);
97 us->Power_IsResum = true;
98 //
99 //us->SD_Status.Ready = 0; //??
126bb03b
AC
100 us->MS_Status = *(PMS_STATUS)&tmp;
101 us->SM_Status = *(PSM_STATUS)&tmp;
102 return 0;
103}
104//EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
105
e23f773e
RD
106#else
107
108#define eucr_suspend NULL
109#define eucr_resume NULL
110#define eucr_reset_resume NULL
111
112#endif
113
126bb03b
AC
114//----- eucr_pre_reset() ---------------------
115static int eucr_pre_reset(struct usb_interface *iface)
116{
117 struct us_data *us = usb_get_intfdata(iface);
118
871f8477 119 pr_info("usb --- eucr_pre_reset\n");
126bb03b
AC
120
121 /* Make sure no command runs during the reset */
122 mutex_lock(&us->dev_mutex);
123 return 0;
124}
125
126//----- eucr_post_reset() ---------------------
127static int eucr_post_reset(struct usb_interface *iface)
128{
129 struct us_data *us = usb_get_intfdata(iface);
130
871f8477 131 pr_info("usb --- eucr_post_reset\n");
126bb03b
AC
132
133 /* Report the reset to the SCSI core */
134 usb_stor_report_bus_reset(us);
135
136 mutex_unlock(&us->dev_mutex);
137 return 0;
138}
139
140//----- fill_inquiry_response() ---------------------
141void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len)
142{
871f8477 143 pr_info("usb --- fill_inquiry_response\n");
126bb03b
AC
144 if (data_len<36) // You lose.
145 return;
146
147 if (data[0]&0x20)
148 {
149 memset(data+8,0,28);
150 }
151 else
152 {
153 u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
154 memcpy(data+8, us->unusual_dev->vendorName,
155 strlen(us->unusual_dev->vendorName) > 8 ? 8 :
156 strlen(us->unusual_dev->vendorName));
157 memcpy(data+16, us->unusual_dev->productName,
158 strlen(us->unusual_dev->productName) > 16 ? 16 :
159 strlen(us->unusual_dev->productName));
160 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
161 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
162 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
163 data[35] = 0x30 + ((bcdDevice) & 0x0F);
164 }
165 usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF);
166}
167
168//----- usb_stor_control_thread() ---------------------
169static int usb_stor_control_thread(void * __us)
170{
171 struct us_data *us = (struct us_data *)__us;
172 struct Scsi_Host *host = us_to_host(us);
173
871f8477 174 pr_info("usb --- usb_stor_control_thread\n");
126bb03b
AC
175 for(;;)
176 {
177 if (wait_for_completion_interruptible(&us->cmnd_ready))
178 break;
179
180 /* lock the device pointers */
181 mutex_lock(&(us->dev_mutex));
182
183 /* if the device has disconnected, we are free to exit */
a8718692 184 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
126bb03b
AC
185 mutex_unlock(&us->dev_mutex);
186 break;
a8718692 187 }
126bb03b
AC
188
189 /* lock access to the state */
190 scsi_lock(host);
191
192 /* When we are called with no command pending, we're done */
193 if (us->srb == NULL)
194 {
195 scsi_unlock(host);
196 mutex_unlock(&us->dev_mutex);
197 //US_DEBUGP("-- exiting\n");
198 break;
199 }
200
201 /* has the command timed out *already* ? */
202 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
203 {
204 us->srb->result = DID_ABORT << 16;
205 goto SkipForAbort;
206 }
207
208 scsi_unlock(host);
209
210 if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL)
211 {
212 us->srb->result = DID_ERROR << 16;
213 }
214 else if (us->srb->device->id && !(us->fflags & US_FL_SCM_MULT_TARG))
215 {
216 us->srb->result = DID_BAD_TARGET << 16;
217 }
218 else if (us->srb->device->lun > us->max_lun)
219 {
220 us->srb->result = DID_BAD_TARGET << 16;
221 }
222 else if ((us->srb->cmnd[0] == INQUIRY) && (us->fflags & US_FL_FIX_INQUIRY))
223 {
224 unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00};
225
226 fill_inquiry_response(us, data_ptr, 36);
227 us->srb->result = SAM_STAT_GOOD;
228 }
229 else
230 {
231 us->proto_handler(us->srb, us);
232 }
233
234 /* lock access to the state */
235 scsi_lock(host);
236
237 /* indicate that the command is done */
238 if (us->srb->result != DID_ABORT << 16)
239 {
240 us->srb->scsi_done(us->srb);
241 }
242 else
243 {
244SkipForAbort:
871f8477 245 pr_info("scsi command aborted\n");
126bb03b
AC
246 }
247
248 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
249 {
250 complete(&(us->notify));
251
252 /* Allow USB transfers to resume */
253 clear_bit(US_FLIDX_ABORTING, &us->dflags);
254 clear_bit(US_FLIDX_TIMED_OUT, &us->dflags);
255 }
256
257 /* finished working on this command */
258 us->srb = NULL;
259 scsi_unlock(host);
260
261 /* unlock the device pointers */
262 mutex_unlock(&us->dev_mutex);
263 } /* for (;;) */
264
265 /* Wait until we are told to stop */
266 for (;;)
267 {
268 set_current_state(TASK_INTERRUPTIBLE);
269 if (kthread_should_stop())
270 break;
271 schedule();
272 }
273 __set_current_state(TASK_RUNNING);
274 return 0;
275}
276
277//----- associate_dev() ---------------------
278static int associate_dev(struct us_data *us, struct usb_interface *intf)
279{
871f8477 280 pr_info("usb --- associate_dev\n");
126bb03b
AC
281
282 /* Fill in the device-related fields */
283 us->pusb_dev = interface_to_usbdev(intf);
284 us->pusb_intf = intf;
285 us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
286
287 /* Store our private data in the interface */
288 usb_set_intfdata(intf, us);
289
290 /* Allocate the device-related DMA-mapped buffers */
291 us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma);
292 if (!us->cr)
293 {
871f8477 294 pr_info("usb_ctrlrequest allocation failed\n");
126bb03b
AC
295 return -ENOMEM;
296 }
297
298 us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma);
299 if (!us->iobuf)
300 {
871f8477 301 pr_info("I/O buffer allocation failed\n");
126bb03b
AC
302 return -ENOMEM;
303 }
304
305 us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
306 if (!us->sensebuf)
307 {
871f8477 308 pr_info("Sense buffer allocation failed\n");
126bb03b
AC
309 return -ENOMEM;
310 }
311 return 0;
312}
313
314//----- get_device_info() ---------------------
315static int get_device_info(struct us_data *us, const struct usb_device_id *id)
316{
317 struct usb_device *dev = us->pusb_dev;
318 struct usb_interface_descriptor *idesc = &us->pusb_intf->cur_altsetting->desc;
319
871f8477 320 pr_info("usb --- get_device_info\n");
126bb03b
AC
321
322 us->subclass = idesc->bInterfaceSubClass;
323 us->protocol = idesc->bInterfaceProtocol;
324 us->fflags = USB_US_ORIG_FLAGS(id->driver_info);
325 us->Power_IsResum = false;
326
327 if (us->fflags & US_FL_IGNORE_DEVICE)
328 {
871f8477 329 pr_info("device ignored\n");
126bb03b
AC
330 return -ENODEV;
331 }
332
333 if (dev->speed != USB_SPEED_HIGH)
334 us->fflags &= ~US_FL_GO_SLOW;
335
336 return 0;
337}
338
339//----- get_transport() ---------------------
340static int get_transport(struct us_data *us)
341{
871f8477 342 pr_info("usb --- get_transport\n");
126bb03b 343 switch (us->protocol) {
bceadddd 344 case USB_PR_BULK:
126bb03b
AC
345 us->transport_name = "Bulk";
346 us->transport = usb_stor_Bulk_transport;
347 us->transport_reset = usb_stor_Bulk_reset;
348 break;
349
350 default:
351 return -EIO;
352 }
871f8477 353 /* pr_info("Transport: %s\n", us->transport_name); */
126bb03b
AC
354
355 /* fix for single-lun devices */
356 if (us->fflags & US_FL_SINGLE_LUN)
357 us->max_lun = 0;
358 return 0;
359}
360
361//----- get_protocol() ---------------------
362static int get_protocol(struct us_data *us)
363{
871f8477
CYC
364 pr_info("usb --- get_protocol\n");
365 pr_info("us->pusb_dev->descriptor.idVendor = %x\n",
366 us->pusb_dev->descriptor.idVendor);
367 pr_info("us->pusb_dev->descriptor.idProduct = %x\n",
368 us->pusb_dev->descriptor.idProduct);
126bb03b 369 switch (us->subclass) {
bceadddd 370 case USB_SC_SCSI:
126bb03b
AC
371 us->protocol_name = "Transparent SCSI";
372 if( (us->pusb_dev->descriptor.idVendor == 0x0CF2) && (us->pusb_dev->descriptor.idProduct == 0x6250) )
373 us->proto_handler = ENE_stor_invoke_transport;
374 else
375 us->proto_handler = usb_stor_invoke_transport;
376 break;
377
378 default:
379 return -EIO;
380 }
871f8477 381 /* pr_info("Protocol: %s\n", us->protocol_name); */
126bb03b
AC
382 return 0;
383}
384
385//----- get_pipes() ---------------------
386static int get_pipes(struct us_data *us)
387{
388 struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
389 int i;
390 struct usb_endpoint_descriptor *ep;
391 struct usb_endpoint_descriptor *ep_in = NULL;
392 struct usb_endpoint_descriptor *ep_out = NULL;
393 struct usb_endpoint_descriptor *ep_int = NULL;
394
871f8477 395 pr_info("usb --- get_pipes\n");
126bb03b
AC
396
397 for (i = 0; i < altsetting->desc.bNumEndpoints; i++)
398 {
399 ep = &altsetting->endpoint[i].desc;
400
401 if (usb_endpoint_xfer_bulk(ep))
402 {
403 if (usb_endpoint_dir_in(ep))
404 {
405 if (!ep_in)
406 ep_in = ep;
407 }
408 else
409 {
410 if (!ep_out)
411 ep_out = ep;
412 }
413 }
414 else if (usb_endpoint_is_int_in(ep))
415 {
416 if (!ep_int)
417 ep_int = ep;
418 }
419 }
420
bceadddd 421 if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int))
126bb03b 422 {
871f8477 423 pr_info("Endpoint sanity check failed! Rejecting dev.\n");
126bb03b
AC
424 return -EIO;
425 }
426
427 /* Calculate and store the pipe values */
428 us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
429 us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
430 us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
431 us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
432 if (ep_int)
433 {
434 us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
435 us->ep_bInterval = ep_int->bInterval;
436 }
437 return 0;
438}
439
440//----- usb_stor_acquire_resources() ---------------------
441static int usb_stor_acquire_resources(struct us_data *us)
442{
443 struct task_struct *th;
444
871f8477 445 pr_info("usb --- usb_stor_acquire_resources\n");
126bb03b
AC
446 us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
447 if (!us->current_urb)
448 {
871f8477 449 pr_info("URB allocation failed\n");
126bb03b
AC
450 return -ENOMEM;
451 }
452
453 /* Start up our control thread */
454 th = kthread_run(usb_stor_control_thread, us, "eucr-storage");
455 if (IS_ERR(th))
456 {
871f8477 457 pr_info("Unable to start control thread\n");
126bb03b
AC
458 return PTR_ERR(th);
459 }
460 us->ctl_thread = th;
461
462 return 0;
463}
464
465//----- usb_stor_release_resources() ---------------------
466static void usb_stor_release_resources(struct us_data *us)
467{
871f8477 468 pr_info("usb --- usb_stor_release_resources\n");
126bb03b
AC
469
470 SM_FreeMem();
471
472 complete(&us->cmnd_ready);
473 if (us->ctl_thread)
474 kthread_stop(us->ctl_thread);
475
476 /* Call the destructor routine, if it exists */
477 if (us->extra_destructor)
478 {
871f8477 479 pr_info("-- calling extra_destructor()\n");
126bb03b
AC
480 us->extra_destructor(us->extra);
481 }
482
483 /* Free the extra data and the URB */
484 kfree(us->extra);
485 usb_free_urb(us->current_urb);
486}
487
488//----- dissociate_dev() ---------------------
489static void dissociate_dev(struct us_data *us)
490{
871f8477 491 pr_info("usb --- dissociate_dev\n");
126bb03b
AC
492
493 kfree(us->sensebuf);
494
495 /* Free the device-related DMA-mapped buffers */
496 if (us->cr)
497 usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma);
498 if (us->iobuf)
499 usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
500
501 /* Remove our private data from the interface */
502 usb_set_intfdata(us->pusb_intf, NULL);
503}
504
505//----- quiesce_and_remove_host() ---------------------
506static void quiesce_and_remove_host(struct us_data *us)
507{
508 struct Scsi_Host *host = us_to_host(us);
509
871f8477 510 pr_info("usb --- quiesce_and_remove_host\n");
126bb03b
AC
511
512 /* If the device is really gone, cut short reset delays */
513 if (us->pusb_dev->state == USB_STATE_NOTATTACHED)
514 set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
515
516 /* Prevent SCSI-scanning (if it hasn't started yet)
517 * and wait for the SCSI-scanning thread to stop.
518 */
519 set_bit(US_FLIDX_DONT_SCAN, &us->dflags);
520 wake_up(&us->delay_wait);
521 wait_for_completion(&us->scanning_done);
522
523 /* Removing the host will perform an orderly shutdown: caches
524 * synchronized, disks spun down, etc.
525 */
526 scsi_remove_host(host);
527
528 /* Prevent any new commands from being accepted and cut short
529 * reset delays.
530 */
531 scsi_lock(host);
532 set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
533 scsi_unlock(host);
534 wake_up(&us->delay_wait);
535}
536
537//----- release_everything() ---------------------
538static void release_everything(struct us_data *us)
539{
871f8477 540 pr_info("usb --- release_everything\n");
126bb03b
AC
541
542 usb_stor_release_resources(us);
543 dissociate_dev(us);
544 scsi_host_put(us_to_host(us));
545}
546
547//----- usb_stor_scan_thread() ---------------------
548static int usb_stor_scan_thread(void * __us)
549{
550 struct us_data *us = (struct us_data *)__us;
551
871f8477
CYC
552 pr_info("usb --- usb_stor_scan_thread\n");
553 pr_info("EUCR : device found at %d\n", us->pusb_dev->devnum);
126bb03b 554
a8718692
AC
555 set_freezable();
556 /* Wait for the timeout to expire or for a disconnect */
557 if (delay_use > 0) {
558 wait_event_freezable_timeout(us->delay_wait,
559 test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
560 delay_use * HZ);
561 }
126bb03b
AC
562
563 /* If the device is still connected, perform the scanning */
564 if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags))
565 {
566 /* For bulk-only devices, determine the max LUN value */
bceadddd 567 if (us->protocol == USB_PR_BULK && !(us->fflags & US_FL_SINGLE_LUN))
126bb03b
AC
568 {
569 mutex_lock(&us->dev_mutex);
570 us->max_lun = usb_stor_Bulk_max_lun(us);
571 mutex_unlock(&us->dev_mutex);
572 }
573 scsi_scan_host(us_to_host(us));
871f8477 574 pr_info("EUCR : device scan complete\n");
126bb03b
AC
575 }
576 complete_and_exit(&us->scanning_done, 0);
577}
578
579//----- eucr_probe() ---------------------
580static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id)
581{
582 struct Scsi_Host *host;
583 struct us_data *us;
584 int result;
41e568d1 585 BYTE MiscReg03 = 0;
126bb03b
AC
586 struct task_struct *th;
587
871f8477 588 pr_info("usb --- eucr_probe\n");
126bb03b
AC
589
590 host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
591 if (!host)
592 {
871f8477 593 pr_info("Unable to allocate the scsi host\n");
126bb03b
AC
594 return -ENOMEM;
595 }
596
597 /* Allow 16-byte CDBs and thus > 2TB */
598 host->max_cmd_len = 16;
599 us = host_to_us(host);
600 memset(us, 0, sizeof(struct us_data));
601 mutex_init(&(us->dev_mutex));
602 init_completion(&us->cmnd_ready);
603 init_completion(&(us->notify));
604 init_waitqueue_head(&us->delay_wait);
605 init_completion(&us->scanning_done);
606
607 /* Associate the us_data structure with the USB device */
608 result = associate_dev(us, intf);
609 if (result)
610 goto BadDevice;
611
612 /* Get Device info */
613 result = get_device_info(us, id);
614 if (result)
615 goto BadDevice;
616
617 /* Get the transport, protocol, and pipe settings */
618 result = get_transport(us);
619 if (result)
620 goto BadDevice;
621 result = get_protocol(us);
622 if (result)
623 goto BadDevice;
624 result = get_pipes(us);
625 if (result)
626 goto BadDevice;
627
628 /* Acquire all the other resources and add the host */
629 result = usb_stor_acquire_resources(us);
630 if (result)
631 goto BadDevice;
632
633 result = scsi_add_host(host, &intf->dev);
634 if (result)
635 {
871f8477 636 pr_info("Unable to add the scsi host\n");
126bb03b
AC
637 goto BadDevice;
638 }
639
640 /* Start up the thread for delayed SCSI-device scanning */
641 th = kthread_create(usb_stor_scan_thread, us, "eucr-stor-scan");
642 if (IS_ERR(th))
643 {
871f8477 644 pr_info("Unable to start the device-scanning thread\n");
126bb03b
AC
645 complete(&us->scanning_done);
646 quiesce_and_remove_host(us);
647 result = PTR_ERR(th);
648 goto BadDevice;
649 }
650 wake_up_process(th);
41e568d1 651
652 /* probe card type */
653 result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03);
654 if (result != USB_STOR_XFER_GOOD) {
655 result = USB_STOR_TRANSPORT_ERROR;
656 quiesce_and_remove_host(us);
657 goto BadDevice;
658 }
659
660 if (!(MiscReg03 & 0x02)) {
661 result = -ENODEV;
662 quiesce_and_remove_host(us);
871f8477 663 pr_info("keucr: The driver only supports SM/MS card.\
41e568d1 664 To use SD card, \
665 please build driver/usb/storage/ums-eneub6250.ko\n");
666 goto BadDevice;
667 }
668
126bb03b
AC
669 return 0;
670
671 /* We come here if there are any problems */
672BadDevice:
871f8477 673 pr_info("usb --- eucr_probe failed\n");
126bb03b
AC
674 release_everything(us);
675 return result;
676}
677
678//----- eucr_disconnect() ---------------------
679static void eucr_disconnect(struct usb_interface *intf)
680{
681 struct us_data *us = usb_get_intfdata(intf);
682
871f8477 683 pr_info("usb --- eucr_disconnect\n");
126bb03b
AC
684 quiesce_and_remove_host(us);
685 release_everything(us);
686}
687
688/***********************************************************************
689 * Initialization and registration
690 ***********************************************************************/
691
692//----- usb_storage_driver() ---------------------
693static struct usb_driver usb_storage_driver = {
694 .name = "eucr",
695 .probe = eucr_probe,
696 .suspend = eucr_suspend,
697 .resume = eucr_resume,
698 .reset_resume = eucr_reset_resume,
699 .disconnect = eucr_disconnect,
700 .pre_reset = eucr_pre_reset,
701 .post_reset = eucr_post_reset,
702 .id_table = eucr_usb_ids,
703 .soft_unbind = 1,
704};
705
706//----- usb_stor_init() ---------------------
707static int __init usb_stor_init(void)
708{
709 int retval;
871f8477 710 pr_info("usb --- usb_stor_init start\n");
126bb03b
AC
711
712 retval = usb_register(&usb_storage_driver);
713 if (retval == 0)
871f8477 714 pr_info("ENE USB Mass Storage support registered.\n");
126bb03b
AC
715
716 return retval;
717}
718
719//----- usb_stor_exit() ---------------------
720static void __exit usb_stor_exit(void)
721{
871f8477 722 pr_info("usb --- usb_stor_exit\n");
126bb03b
AC
723
724 usb_deregister(&usb_storage_driver) ;
725}
726
727module_init(usb_stor_init);
728module_exit(usb_stor_exit);