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