close_port, kpacket_gen kmalloc oom, formard.c wake_sender/skb receive oom handling...
[cor_2_6_31.git] / drivers / usb / misc / vstusb.c
blobf26ea8dc15773dd8d3393ce25e92238c32fc99c2
1 /*****************************************************************************
2 * File: drivers/usb/misc/vstusb.c
4 * Purpose: Support for the bulk USB Vernier Spectrophotometers
6 * Author: Johnnie Peters
7 * Axian Consulting
8 * Beaverton, OR, USA 97005
10 * Modified by: EQware Engineering, Inc.
11 * Oregon City, OR, USA 97045
13 * Copyright: 2007, 2008
14 * Vernier Software & Technology
15 * Beaverton, OR, USA 97005
17 * Web: www.vernier.com
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License version 2 as
21 * published by the Free Software Foundation.
23 *****************************************************************************/
24 #include <linux/kernel.h>
25 #include <linux/errno.h>
26 #include <linux/init.h>
27 #include <linux/slab.h>
28 #include <linux/module.h>
29 #include <linux/mutex.h>
30 #include <linux/uaccess.h>
31 #include <linux/usb.h>
33 #include <linux/usb/vstusb.h>
35 #define DRIVER_VERSION "VST USB Driver Version 1.5"
36 #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver"
38 #ifdef CONFIG_USB_DYNAMIC_MINORS
39 #define VSTUSB_MINOR_BASE 0
40 #else
41 #define VSTUSB_MINOR_BASE 199
42 #endif
44 #define USB_VENDOR_OCEANOPTICS 0x2457
45 #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */
47 #define USB_PRODUCT_USB2000 0x1002
48 #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */
49 #define USB_PRODUCT_ADC1000 0x1004
50 #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */
51 #define USB_PRODUCT_HR2000 0x100A
52 #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */
53 #define USB_PRODUCT_HR4000 0x1012
54 #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */
55 #define USB_PRODUCT_QE65000 0x1018
56 #define USB_PRODUCT_USB4000 0x1022
57 #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */
59 #define USB_PRODUCT_LABPRO 0x0001
60 #define USB_PRODUCT_LABQUEST 0x0005
62 #define VST_MAXBUFFER (64*1024)
64 static struct usb_device_id id_table[] = {
65 { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)},
66 { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)},
67 { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)},
68 { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)},
69 { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)},
70 { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)},
71 { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)},
72 {},
75 MODULE_DEVICE_TABLE(usb, id_table);
77 struct vstusb_device {
78 struct kref kref;
79 struct mutex lock;
80 struct usb_device *usb_dev;
81 char present;
82 char isopen;
83 struct usb_anchor submitted;
84 int rd_pipe;
85 int rd_timeout_ms;
86 int wr_pipe;
87 int wr_timeout_ms;
89 #define to_vst_dev(d) container_of(d, struct vstusb_device, kref)
91 static struct usb_driver vstusb_driver;
93 static void vstusb_delete(struct kref *kref)
95 struct vstusb_device *vstdev = to_vst_dev(kref);
97 usb_put_dev(vstdev->usb_dev);
98 kfree(vstdev);
101 static int vstusb_open(struct inode *inode, struct file *file)
103 struct vstusb_device *vstdev;
104 struct usb_interface *interface;
106 interface = usb_find_interface(&vstusb_driver, iminor(inode));
108 if (!interface) {
109 printk(KERN_ERR KBUILD_MODNAME
110 ": %s - error, can't find device for minor %d\n",
111 __func__, iminor(inode));
112 return -ENODEV;
115 vstdev = usb_get_intfdata(interface);
117 if (!vstdev)
118 return -ENODEV;
120 /* lock this device */
121 mutex_lock(&vstdev->lock);
123 /* can only open one time */
124 if ((!vstdev->present) || (vstdev->isopen)) {
125 mutex_unlock(&vstdev->lock);
126 return -EBUSY;
129 /* increment our usage count */
130 kref_get(&vstdev->kref);
132 vstdev->isopen = 1;
134 /* save device in the file's private structure */
135 file->private_data = vstdev;
137 dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__);
139 mutex_unlock(&vstdev->lock);
141 return 0;
144 static int vstusb_release(struct inode *inode, struct file *file)
146 struct vstusb_device *vstdev;
148 vstdev = file->private_data;
150 if (vstdev == NULL)
151 return -ENODEV;
153 mutex_lock(&vstdev->lock);
155 vstdev->isopen = 0;
157 dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__);
159 mutex_unlock(&vstdev->lock);
161 kref_put(&vstdev->kref, vstusb_delete);
163 return 0;
166 static void usb_api_blocking_completion(struct urb *urb)
168 struct completion *completeit = urb->context;
170 complete(completeit);
173 static int vstusb_fill_and_send_urb(struct urb *urb,
174 struct usb_device *usb_dev,
175 unsigned int pipe, void *data,
176 unsigned int len, struct completion *done)
178 struct usb_host_endpoint *ep;
179 struct usb_host_endpoint **hostep;
180 unsigned int pipend;
182 int status;
184 hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out;
185 pipend = usb_pipeendpoint(pipe);
186 ep = hostep[pipend];
188 if (!ep || (len == 0))
189 return -EINVAL;
191 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
192 == USB_ENDPOINT_XFER_INT) {
193 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
194 usb_fill_int_urb(urb, usb_dev, pipe, data, len,
195 (usb_complete_t)usb_api_blocking_completion,
196 NULL, ep->desc.bInterval);
197 } else
198 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
199 (usb_complete_t)usb_api_blocking_completion,
200 NULL);
202 init_completion(done);
203 urb->context = done;
204 urb->actual_length = 0;
205 status = usb_submit_urb(urb, GFP_KERNEL);
207 return status;
210 static int vstusb_complete_urb(struct urb *urb, struct completion *done,
211 int timeout, int *actual_length)
213 unsigned long expire;
214 int status;
216 expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
217 if (!wait_for_completion_interruptible_timeout(done, expire)) {
218 usb_kill_urb(urb);
219 status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status;
221 dev_dbg(&urb->dev->dev,
222 "%s timed out on ep%d%s len=%d/%d, urb status = %d\n",
223 current->comm,
224 usb_pipeendpoint(urb->pipe),
225 usb_pipein(urb->pipe) ? "in" : "out",
226 urb->actual_length,
227 urb->transfer_buffer_length,
228 urb->status);
230 } else {
231 if (signal_pending(current)) {
232 /* if really an error */
233 if (urb->status && !((urb->status == -ENOENT) ||
234 (urb->status == -ECONNRESET) ||
235 (urb->status == -ESHUTDOWN))) {
236 status = -EINTR;
237 usb_kill_urb(urb);
238 } else {
239 status = 0;
242 dev_dbg(&urb->dev->dev,
243 "%s: signal pending on ep%d%s len=%d/%d,"
244 "urb status = %d\n",
245 current->comm,
246 usb_pipeendpoint(urb->pipe),
247 usb_pipein(urb->pipe) ? "in" : "out",
248 urb->actual_length,
249 urb->transfer_buffer_length,
250 urb->status);
252 } else {
253 status = urb->status;
257 if (actual_length)
258 *actual_length = urb->actual_length;
260 return status;
263 static ssize_t vstusb_read(struct file *file, char __user *buffer,
264 size_t count, loff_t *ppos)
266 struct vstusb_device *vstdev;
267 int cnt = -1;
268 void *buf;
269 int retval = 0;
271 struct urb *urb;
272 struct usb_device *dev;
273 unsigned int pipe;
274 int timeout;
276 DECLARE_COMPLETION_ONSTACK(done);
278 vstdev = file->private_data;
280 if (vstdev == NULL)
281 return -ENODEV;
283 /* verify that we actually want to read some data */
284 if ((count == 0) || (count > VST_MAXBUFFER))
285 return -EINVAL;
287 /* lock this object */
288 if (mutex_lock_interruptible(&vstdev->lock))
289 return -ERESTARTSYS;
291 /* anyone home */
292 if (!vstdev->present) {
293 mutex_unlock(&vstdev->lock);
294 printk(KERN_ERR KBUILD_MODNAME
295 ": %s: device not present\n", __func__);
296 return -ENODEV;
299 /* pull out the necessary data */
300 dev = vstdev->usb_dev;
301 pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe);
302 timeout = vstdev->rd_timeout_ms;
304 buf = kmalloc(count, GFP_KERNEL);
305 if (buf == NULL) {
306 mutex_unlock(&vstdev->lock);
307 return -ENOMEM;
310 urb = usb_alloc_urb(0, GFP_KERNEL);
311 if (!urb) {
312 kfree(buf);
313 mutex_unlock(&vstdev->lock);
314 return -ENOMEM;
317 usb_anchor_urb(urb, &vstdev->submitted);
318 retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done);
319 mutex_unlock(&vstdev->lock);
320 if (retval) {
321 usb_unanchor_urb(urb);
322 dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n",
323 __func__, retval, pipe);
324 goto exit;
327 retval = vstusb_complete_urb(urb, &done, timeout, &cnt);
328 if (retval) {
329 dev_err(&dev->dev, "%s: error %d completing urb %d\n",
330 __func__, retval, pipe);
331 goto exit;
334 if (copy_to_user(buffer, buf, cnt)) {
335 dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__);
336 retval = -EFAULT;
337 } else {
338 retval = cnt;
339 dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n",
340 __func__, cnt, pipe);
343 exit:
344 usb_free_urb(urb);
345 kfree(buf);
346 return retval;
349 static ssize_t vstusb_write(struct file *file, const char __user *buffer,
350 size_t count, loff_t *ppos)
352 struct vstusb_device *vstdev;
353 int cnt = -1;
354 void *buf;
355 int retval = 0;
357 struct urb *urb;
358 struct usb_device *dev;
359 unsigned int pipe;
360 int timeout;
362 DECLARE_COMPLETION_ONSTACK(done);
364 vstdev = file->private_data;
366 if (vstdev == NULL)
367 return -ENODEV;
369 /* verify that we actually have some data to write */
370 if ((count == 0) || (count > VST_MAXBUFFER))
371 return retval;
373 /* lock this object */
374 if (mutex_lock_interruptible(&vstdev->lock))
375 return -ERESTARTSYS;
377 /* anyone home */
378 if (!vstdev->present) {
379 mutex_unlock(&vstdev->lock);
380 printk(KERN_ERR KBUILD_MODNAME
381 ": %s: device not present\n", __func__);
382 return -ENODEV;
385 /* pull out the necessary data */
386 dev = vstdev->usb_dev;
387 pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe);
388 timeout = vstdev->wr_timeout_ms;
390 buf = kmalloc(count, GFP_KERNEL);
391 if (buf == NULL) {
392 mutex_unlock(&vstdev->lock);
393 return -ENOMEM;
396 urb = usb_alloc_urb(0, GFP_KERNEL);
397 if (!urb) {
398 kfree(buf);
399 mutex_unlock(&vstdev->lock);
400 return -ENOMEM;
403 if (copy_from_user(buf, buffer, count)) {
404 mutex_unlock(&vstdev->lock);
405 dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__);
406 retval = -EFAULT;
407 goto exit;
410 usb_anchor_urb(urb, &vstdev->submitted);
411 retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done);
412 mutex_unlock(&vstdev->lock);
413 if (retval) {
414 usb_unanchor_urb(urb);
415 dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n",
416 __func__, retval, pipe);
417 goto exit;
420 retval = vstusb_complete_urb(urb, &done, timeout, &cnt);
421 if (retval) {
422 dev_err(&dev->dev, "%s: error %d completing urb %d\n",
423 __func__, retval, pipe);
424 goto exit;
425 } else {
426 retval = cnt;
427 dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n",
428 __func__, cnt, pipe);
431 exit:
432 usb_free_urb(urb);
433 kfree(buf);
434 return retval;
437 static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
439 int retval = 0;
440 int cnt = -1;
441 void __user *data = (void __user *)arg;
442 struct vstusb_args usb_data;
444 struct vstusb_device *vstdev;
445 void *buffer = NULL; /* must be initialized. buffer is
446 * referenced on exit but not all
447 * ioctls allocate it */
449 struct urb *urb = NULL; /* must be initialized. urb is
450 * referenced on exit but not all
451 * ioctls allocate it */
452 struct usb_device *dev;
453 unsigned int pipe;
454 int timeout;
456 DECLARE_COMPLETION_ONSTACK(done);
458 vstdev = file->private_data;
460 if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) {
461 dev_warn(&vstdev->usb_dev->dev,
462 "%s: ioctl command %x, bad ioctl magic %x, "
463 "expected %x\n", __func__, cmd,
464 _IOC_TYPE(cmd), VST_IOC_MAGIC);
465 return -EINVAL;
468 if (vstdev == NULL)
469 return -ENODEV;
471 if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) {
472 dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n",
473 __func__);
474 return -EFAULT;
477 /* lock this object */
478 if (mutex_lock_interruptible(&vstdev->lock)) {
479 retval = -ERESTARTSYS;
480 goto exit;
483 /* anyone home */
484 if (!vstdev->present) {
485 mutex_unlock(&vstdev->lock);
486 dev_err(&vstdev->usb_dev->dev, "%s: device not present\n",
487 __func__);
488 retval = -ENODEV;
489 goto exit;
492 /* pull out the necessary data */
493 dev = vstdev->usb_dev;
495 switch (cmd) {
497 case IOCTL_VSTUSB_CONFIG_RW:
499 vstdev->rd_pipe = usb_data.rd_pipe;
500 vstdev->rd_timeout_ms = usb_data.rd_timeout_ms;
501 vstdev->wr_pipe = usb_data.wr_pipe;
502 vstdev->wr_timeout_ms = usb_data.wr_timeout_ms;
504 mutex_unlock(&vstdev->lock);
506 dev_dbg(&dev->dev, "%s: setting pipes/timeouts, "
507 "rdpipe = %d, rdtimeout = %d, "
508 "wrpipe = %d, wrtimeout = %d\n", __func__,
509 vstdev->rd_pipe, vstdev->rd_timeout_ms,
510 vstdev->wr_pipe, vstdev->wr_timeout_ms);
511 break;
513 case IOCTL_VSTUSB_SEND_PIPE:
515 if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) {
516 mutex_unlock(&vstdev->lock);
517 retval = -EINVAL;
518 goto exit;
521 buffer = kmalloc(usb_data.count, GFP_KERNEL);
522 if (buffer == NULL) {
523 mutex_unlock(&vstdev->lock);
524 retval = -ENOMEM;
525 goto exit;
528 urb = usb_alloc_urb(0, GFP_KERNEL);
529 if (!urb) {
530 mutex_unlock(&vstdev->lock);
531 retval = -ENOMEM;
532 goto exit;
535 timeout = usb_data.timeout_ms;
537 pipe = usb_sndbulkpipe(dev, usb_data.pipe);
539 if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) {
540 dev_err(&dev->dev, "%s: can't copy_from_user\n",
541 __func__);
542 mutex_unlock(&vstdev->lock);
543 retval = -EFAULT;
544 goto exit;
547 usb_anchor_urb(urb, &vstdev->submitted);
548 retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer,
549 usb_data.count, &done);
550 mutex_unlock(&vstdev->lock);
551 if (retval) {
552 usb_unanchor_urb(urb);
553 dev_err(&dev->dev,
554 "%s: error %d filling and sending urb %d\n",
555 __func__, retval, pipe);
556 goto exit;
559 retval = vstusb_complete_urb(urb, &done, timeout, &cnt);
560 if (retval) {
561 dev_err(&dev->dev, "%s: error %d completing urb %d\n",
562 __func__, retval, pipe);
565 break;
566 case IOCTL_VSTUSB_RECV_PIPE:
568 if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) {
569 mutex_unlock(&vstdev->lock);
570 retval = -EINVAL;
571 goto exit;
574 buffer = kmalloc(usb_data.count, GFP_KERNEL);
575 if (buffer == NULL) {
576 mutex_unlock(&vstdev->lock);
577 retval = -ENOMEM;
578 goto exit;
581 urb = usb_alloc_urb(0, GFP_KERNEL);
582 if (!urb) {
583 mutex_unlock(&vstdev->lock);
584 retval = -ENOMEM;
585 goto exit;
588 timeout = usb_data.timeout_ms;
590 pipe = usb_rcvbulkpipe(dev, usb_data.pipe);
592 usb_anchor_urb(urb, &vstdev->submitted);
593 retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer,
594 usb_data.count, &done);
595 mutex_unlock(&vstdev->lock);
596 if (retval) {
597 usb_unanchor_urb(urb);
598 dev_err(&dev->dev,
599 "%s: error %d filling and sending urb %d\n",
600 __func__, retval, pipe);
601 goto exit;
604 retval = vstusb_complete_urb(urb, &done, timeout, &cnt);
605 if (retval) {
606 dev_err(&dev->dev, "%s: error %d completing urb %d\n",
607 __func__, retval, pipe);
608 goto exit;
611 if (copy_to_user(usb_data.buffer, buffer, cnt)) {
612 dev_err(&dev->dev, "%s: can't copy_to_user\n",
613 __func__);
614 retval = -EFAULT;
615 goto exit;
618 usb_data.count = cnt;
619 if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) {
620 dev_err(&dev->dev, "%s: can't copy_to_user\n",
621 __func__);
622 retval = -EFAULT;
623 } else {
624 dev_dbg(&dev->dev, "%s: recv %zd bytes from pipe %d\n",
625 __func__, usb_data.count, usb_data.pipe);
628 break;
630 default:
631 mutex_unlock(&vstdev->lock);
632 dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n",
633 cmd);
634 return -EINVAL;
635 break;
637 exit:
638 usb_free_urb(urb);
639 kfree(buffer);
640 return retval;
643 static const struct file_operations vstusb_fops = {
644 .owner = THIS_MODULE,
645 .read = vstusb_read,
646 .write = vstusb_write,
647 .unlocked_ioctl = vstusb_ioctl,
648 .compat_ioctl = vstusb_ioctl,
649 .open = vstusb_open,
650 .release = vstusb_release,
653 static struct usb_class_driver usb_vstusb_class = {
654 .name = "usb/vstusb%d",
655 .fops = &vstusb_fops,
656 .minor_base = VSTUSB_MINOR_BASE,
659 static int vstusb_probe(struct usb_interface *intf,
660 const struct usb_device_id *id)
662 struct usb_device *dev = interface_to_usbdev(intf);
663 struct vstusb_device *vstdev;
664 int i;
665 int retval = 0;
667 /* allocate memory for our device state and intialize it */
669 vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL);
670 if (vstdev == NULL)
671 return -ENOMEM;
673 /* must do usb_get_dev() prior to kref_init() since the kref_put()
674 * release function will do a usb_put_dev() */
675 usb_get_dev(dev);
676 kref_init(&vstdev->kref);
677 mutex_init(&vstdev->lock);
679 i = dev->descriptor.bcdDevice;
681 dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n",
682 (i & 0xF000) >> 12, (i & 0xF00) >> 8,
683 (i & 0xF0) >> 4, (i & 0xF), dev->devnum);
685 vstdev->present = 1;
686 vstdev->isopen = 0;
687 vstdev->usb_dev = dev;
688 init_usb_anchor(&vstdev->submitted);
690 usb_set_intfdata(intf, vstdev);
691 retval = usb_register_dev(intf, &usb_vstusb_class);
692 if (retval) {
693 dev_err(&intf->dev,
694 "%s: Not able to get a minor for this device.\n",
695 __func__);
696 usb_set_intfdata(intf, NULL);
697 kref_put(&vstdev->kref, vstusb_delete);
698 return retval;
701 /* let the user know what node this device is now attached to */
702 dev_info(&intf->dev,
703 "VST USB Device #%d now attached to major %d minor %d\n",
704 (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor);
706 dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION);
708 return retval;
711 static void vstusb_disconnect(struct usb_interface *intf)
713 struct vstusb_device *vstdev = usb_get_intfdata(intf);
715 usb_deregister_dev(intf, &usb_vstusb_class);
716 usb_set_intfdata(intf, NULL);
718 if (vstdev) {
720 mutex_lock(&vstdev->lock);
721 vstdev->present = 0;
723 usb_kill_anchored_urbs(&vstdev->submitted);
725 mutex_unlock(&vstdev->lock);
727 kref_put(&vstdev->kref, vstusb_delete);
732 static int vstusb_suspend(struct usb_interface *intf, pm_message_t message)
734 struct vstusb_device *vstdev = usb_get_intfdata(intf);
735 int time;
736 if (!vstdev)
737 return 0;
739 mutex_lock(&vstdev->lock);
740 time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000);
741 if (!time)
742 usb_kill_anchored_urbs(&vstdev->submitted);
743 mutex_unlock(&vstdev->lock);
745 return 0;
748 static int vstusb_resume(struct usb_interface *intf)
750 return 0;
753 static struct usb_driver vstusb_driver = {
754 .name = "vstusb",
755 .probe = vstusb_probe,
756 .disconnect = vstusb_disconnect,
757 .suspend = vstusb_suspend,
758 .resume = vstusb_resume,
759 .id_table = id_table,
762 static int __init vstusb_init(void)
764 int rc;
766 rc = usb_register(&vstusb_driver);
767 if (rc)
768 printk(KERN_ERR "%s: failed to register (%d)", __func__, rc);
770 return rc;
773 static void __exit vstusb_exit(void)
775 usb_deregister(&vstusb_driver);
778 module_init(vstusb_init);
779 module_exit(vstusb_exit);
781 MODULE_AUTHOR("Dennis O'Brien/Stephen Ware");
782 MODULE_DESCRIPTION(DRIVER_VERSION);
783 MODULE_LICENSE("GPL");