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