2 * adutux - driver for ADU devices from Ontrak Control Systems
3 * This is an experimental driver. Use at your own risk.
4 * This driver is not supported by Ontrak Control Systems.
6 * Copyright (c) 2003 John Homppi (SCO, leave this notice here)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * derived from the Lego USB Tower driver 0.56:
14 * Copyright (c) 2003 David Glance <davidgsf@sourceforge.net>
15 * 2001 Juergen Stuber <stuber@loria.fr>
16 * that was derived from USB Skeleton driver - 0.5
17 * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
23 #include <linux/init.h>
24 #include <linux/slab.h>
25 #include <linux/module.h>
26 #include <linux/usb.h>
27 #include <asm/uaccess.h>
29 #ifdef CONFIG_USB_DEBUG
35 /* Use our own dbg macro */
37 #define dbg(lvl, format, arg...) \
40 printk(KERN_DEBUG __FILE__ " : " format " \n", ## arg); \
44 /* Version Information */
45 #define DRIVER_VERSION "v0.0.13"
46 #define DRIVER_AUTHOR "John Homppi"
47 #define DRIVER_DESC "adutux (see www.ontrak.net)"
49 /* Module parameters */
50 module_param(debug, int, S_IRUGO | S_IWUSR);
51 MODULE_PARM_DESC(debug, "Debug enabled or not");
53 /* Define these values to match your device */
54 #define ADU_VENDOR_ID 0x0a07
55 #define ADU_PRODUCT_ID 0x0064
57 /* table of devices that work with this driver */
58 static struct usb_device_id device_table [] = {
59 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */
60 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */
61 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */
62 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+100) }, /* ADU200 */
63 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+108) }, /* ADU208 */
64 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+118) }, /* ADU218 */
65 { }/* Terminating entry */
68 MODULE_DEVICE_TABLE(usb, device_table);
70 #ifdef CONFIG_USB_DYNAMIC_MINORS
71 #define ADU_MINOR_BASE 0
73 #define ADU_MINOR_BASE 67
76 /* we can have up to this number of device plugged in at once */
77 #define MAX_DEVICES 16
79 #define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */
81 /* Structure to hold all of our device specific stuff */
83 struct semaphore sem; /* locks this structure */
84 struct usb_device* udev; /* save off the usb device pointer */
85 struct usb_interface* interface;
86 unsigned char minor; /* the starting minor number for this device */
87 char serial_number[8];
89 int open_count; /* number of times this port has been opened */
91 char* read_buffer_primary;
92 int read_buffer_length;
93 char* read_buffer_secondary;
98 wait_queue_head_t read_wait;
99 wait_queue_head_t write_wait;
101 char* interrupt_in_buffer;
102 struct usb_endpoint_descriptor* interrupt_in_endpoint;
103 struct urb* interrupt_in_urb;
104 int read_urb_finished;
106 char* interrupt_out_buffer;
107 struct usb_endpoint_descriptor* interrupt_out_endpoint;
108 struct urb* interrupt_out_urb;
111 /* prevent races between open() and disconnect */
112 static DEFINE_MUTEX(disconnect_mutex);
113 static struct usb_driver adu_driver;
115 static void adu_debug_data(int level, const char *function, int size,
116 const unsigned char *data)
123 printk(KERN_DEBUG __FILE__": %s - length = %d, data = ",
125 for (i = 0; i < size; ++i)
126 printk("%.2x ", data[i]);
131 * adu_abort_transfers
132 * aborts transfers and frees associated data structures
134 static void adu_abort_transfers(struct adu_device *dev)
136 dbg(2," %s : enter", __FUNCTION__);
139 dbg(1," %s : dev is null", __FUNCTION__);
143 if (dev->udev == NULL) {
144 dbg(1," %s : udev is null", __FUNCTION__);
148 dbg(2," %s : udev state %d", __FUNCTION__, dev->udev->state);
149 if (dev->udev->state == USB_STATE_NOTATTACHED) {
150 dbg(1," %s : udev is not attached", __FUNCTION__);
154 /* shutdown transfer */
155 usb_unlink_urb(dev->interrupt_in_urb);
156 usb_unlink_urb(dev->interrupt_out_urb);
159 dbg(2," %s : leave", __FUNCTION__);
162 static void adu_delete(struct adu_device *dev)
164 dbg(2, "%s enter", __FUNCTION__);
166 adu_abort_transfers(dev);
168 /* free data structures */
169 usb_free_urb(dev->interrupt_in_urb);
170 usb_free_urb(dev->interrupt_out_urb);
171 kfree(dev->read_buffer_primary);
172 kfree(dev->read_buffer_secondary);
173 kfree(dev->interrupt_in_buffer);
174 kfree(dev->interrupt_out_buffer);
177 dbg(2, "%s : leave", __FUNCTION__);
180 static void adu_interrupt_in_callback(struct urb *urb)
182 struct adu_device *dev = urb->context;
184 dbg(4," %s : enter, status %d", __FUNCTION__, urb->status);
185 adu_debug_data(5, __FUNCTION__, urb->actual_length,
186 urb->transfer_buffer);
188 spin_lock(&dev->buflock);
190 if (urb->status != 0) {
191 if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET)) {
192 dbg(1," %s : nonzero status received: %d",
193 __FUNCTION__, urb->status);
198 if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {
199 if (dev->read_buffer_length <
200 (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) -
201 (urb->actual_length)) {
202 memcpy (dev->read_buffer_primary +
203 dev->read_buffer_length,
204 dev->interrupt_in_buffer, urb->actual_length);
206 dev->read_buffer_length += urb->actual_length;
207 dbg(2," %s reading %d ", __FUNCTION__,
210 dbg(1," %s : read_buffer overflow", __FUNCTION__);
215 dev->read_urb_finished = 1;
216 spin_unlock(&dev->buflock);
217 /* always wake up so we recover from errors */
218 wake_up_interruptible(&dev->read_wait);
219 adu_debug_data(5, __FUNCTION__, urb->actual_length,
220 urb->transfer_buffer);
221 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status);
224 static void adu_interrupt_out_callback(struct urb *urb)
226 struct adu_device *dev = urb->context;
228 dbg(4," %s : enter, status %d", __FUNCTION__, urb->status);
229 adu_debug_data(5,__FUNCTION__, urb->actual_length, urb->transfer_buffer);
231 if (urb->status != 0) {
232 if ((urb->status != -ENOENT) &&
233 (urb->status != -ECONNRESET)) {
234 dbg(1, " %s :nonzero status received: %d",
235 __FUNCTION__, urb->status);
240 wake_up_interruptible(&dev->write_wait);
243 adu_debug_data(5, __FUNCTION__, urb->actual_length,
244 urb->transfer_buffer);
245 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status);
248 static int adu_open(struct inode *inode, struct file *file)
250 struct adu_device *dev = NULL;
251 struct usb_interface *interface;
255 dbg(2,"%s : enter", __FUNCTION__);
257 subminor = iminor(inode);
259 mutex_lock(&disconnect_mutex);
261 interface = usb_find_interface(&adu_driver, subminor);
263 err("%s - error, can't find device for minor %d",
264 __FUNCTION__, subminor);
269 dev = usb_get_intfdata(interface);
275 /* lock this device */
276 if ((retval = down_interruptible(&dev->sem))) {
277 dbg(2, "%s : sem down failed", __FUNCTION__);
281 /* increment our usage count for the device */
283 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count);
285 /* save device in the file's private structure */
286 file->private_data = dev;
288 /* initialize in direction */
289 dev->read_buffer_length = 0;
291 /* fixup first read by having urb waiting for it */
292 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
293 usb_rcvintpipe(dev->udev,
294 dev->interrupt_in_endpoint->bEndpointAddress),
295 dev->interrupt_in_buffer,
296 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
297 adu_interrupt_in_callback, dev,
298 dev->interrupt_in_endpoint->bInterval);
299 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
300 dev->read_urb_finished = 0;
301 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
302 /* we ignore failure */
303 /* end of fixup for first read */
308 mutex_unlock(&disconnect_mutex);
309 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval);
314 static int adu_release_internal(struct adu_device *dev)
318 dbg(2," %s : enter", __FUNCTION__);
320 if (dev->udev == NULL) {
321 /* the device was unplugged before the file was released */
326 /* decrement our usage count for the device */
328 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
329 if (dev->open_count <= 0) {
330 adu_abort_transfers(dev);
335 dbg(2," %s : leave", __FUNCTION__);
339 static int adu_release(struct inode *inode, struct file *file)
341 struct adu_device *dev = NULL;
344 dbg(2," %s : enter", __FUNCTION__);
347 dbg(1," %s : file is NULL", __FUNCTION__);
352 dev = file->private_data;
355 dbg(1," %s : object is NULL", __FUNCTION__);
360 /* lock our device */
361 down(&dev->sem); /* not interruptible */
363 if (dev->open_count <= 0) {
364 dbg(1," %s : device not opened", __FUNCTION__);
370 retval = adu_release_internal(dev);
375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
379 static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
382 struct adu_device *dev;
383 size_t bytes_read = 0;
384 size_t bytes_to_read = count;
388 int should_submit = 0;
390 DECLARE_WAITQUEUE(wait, current);
392 dbg(2," %s : enter, count = %Zd, file=%p", __FUNCTION__, count, file);
394 dev = file->private_data;
395 dbg(2," %s : dev=%p", __FUNCTION__, dev);
396 /* lock this object */
397 if (down_interruptible(&dev->sem))
400 /* verify that the device wasn't unplugged */
401 if (dev->udev == NULL || dev->minor == 0) {
403 err("No device or device unplugged %d", retval);
407 /* verify that some data was requested */
409 dbg(1," %s : read request of 0 bytes", __FUNCTION__);
413 timeout = COMMAND_TIMEOUT;
414 dbg(2," %s : about to start looping", __FUNCTION__);
415 while (bytes_to_read) {
416 int data_in_secondary = dev->secondary_tail - dev->secondary_head;
417 dbg(2," %s : while, data_in_secondary=%d, status=%d",
418 __FUNCTION__, data_in_secondary,
419 dev->interrupt_in_urb->status);
421 if (data_in_secondary) {
422 /* drain secondary buffer */
423 int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;
424 i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount);
429 dev->secondary_head += (amount - i);
430 bytes_read += (amount - i);
431 bytes_to_read -= (amount - i);
433 retval = bytes_read ? bytes_read : -EFAULT;
437 /* we check the primary buffer */
438 spin_lock_irqsave (&dev->buflock, flags);
439 if (dev->read_buffer_length) {
440 /* we secure access to the primary */
442 dbg(2," %s : swap, read_buffer_length = %d",
443 __FUNCTION__, dev->read_buffer_length);
444 tmp = dev->read_buffer_secondary;
445 dev->read_buffer_secondary = dev->read_buffer_primary;
446 dev->read_buffer_primary = tmp;
447 dev->secondary_head = 0;
448 dev->secondary_tail = dev->read_buffer_length;
449 dev->read_buffer_length = 0;
450 spin_unlock_irqrestore(&dev->buflock, flags);
451 /* we have a free buffer so use it */
454 /* even the primary was empty - we may need to do IO */
455 if (dev->interrupt_in_urb->status == -EINPROGRESS) {
456 /* somebody is doing IO */
457 spin_unlock_irqrestore(&dev->buflock, flags);
458 dbg(2," %s : submitted already", __FUNCTION__);
460 /* we must initiate input */
461 dbg(2," %s : initiate input", __FUNCTION__);
462 dev->read_urb_finished = 0;
464 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
465 usb_rcvintpipe(dev->udev,
466 dev->interrupt_in_endpoint->bEndpointAddress),
467 dev->interrupt_in_buffer,
468 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
469 adu_interrupt_in_callback,
471 dev->interrupt_in_endpoint->bInterval);
472 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
474 spin_unlock_irqrestore(&dev->buflock, flags);
475 dbg(2," %s : submitted OK", __FUNCTION__);
477 if (retval == -ENOMEM) {
478 retval = bytes_read ? bytes_read : -ENOMEM;
480 spin_unlock_irqrestore(&dev->buflock, flags);
481 dbg(2," %s : submit failed", __FUNCTION__);
486 /* we wait for I/O to complete */
487 set_current_state(TASK_INTERRUPTIBLE);
488 add_wait_queue(&dev->read_wait, &wait);
489 if (!dev->read_urb_finished)
490 timeout = schedule_timeout(COMMAND_TIMEOUT);
492 set_current_state(TASK_RUNNING);
493 remove_wait_queue(&dev->read_wait, &wait);
496 dbg(2," %s : timeout", __FUNCTION__);
497 retval = bytes_read ? bytes_read : -ETIMEDOUT;
501 if (signal_pending(current)) {
502 dbg(2," %s : signal pending", __FUNCTION__);
503 retval = bytes_read ? bytes_read : -EINTR;
511 /* if the primary buffer is empty then use it */
512 if (should_submit && !dev->interrupt_in_urb->status==-EINPROGRESS) {
513 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
514 usb_rcvintpipe(dev->udev,
515 dev->interrupt_in_endpoint->bEndpointAddress),
516 dev->interrupt_in_buffer,
517 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
518 adu_interrupt_in_callback,
520 dev->interrupt_in_endpoint->bInterval);
521 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
522 dev->read_urb_finished = 0;
523 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
524 /* we ignore failure */
528 /* unlock the device */
531 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
535 static ssize_t adu_write(struct file *file, const __user char *buffer,
536 size_t count, loff_t *ppos)
538 struct adu_device *dev;
539 size_t bytes_written = 0;
540 size_t bytes_to_write;
545 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count);
547 dev = file->private_data;
549 /* lock this object */
550 down_interruptible(&dev->sem);
552 /* verify that the device wasn't unplugged */
553 if (dev->udev == NULL || dev->minor == 0) {
555 err("No device or device unplugged %d", retval);
559 /* verify that we actually have some data to write */
561 dbg(1," %s : write request of 0 bytes", __FUNCTION__);
567 if (dev->interrupt_out_urb->status == -EINPROGRESS) {
568 timeout = COMMAND_TIMEOUT;
570 while (timeout > 0) {
571 if (signal_pending(current)) {
572 dbg(1," %s : interrupted", __FUNCTION__);
577 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout);
578 down_interruptible(&dev->sem);
582 dbg(1," %s : interrupted timeout: %d", __FUNCTION__, timeout);
586 dbg(1," %s : final timeout: %d", __FUNCTION__, timeout);
589 dbg(1, "%s - command timed out.", __FUNCTION__);
594 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
597 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count);
599 /* write the data into interrupt_out_buffer from userspace */
600 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
601 bytes_to_write = count > buffer_size ? buffer_size : count;
602 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
603 __FUNCTION__, buffer_size, count, bytes_to_write);
605 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {
610 /* send off the urb */
612 dev->interrupt_out_urb,
614 usb_sndintpipe(dev->udev, dev->interrupt_out_endpoint->bEndpointAddress),
615 dev->interrupt_out_buffer,
617 adu_interrupt_out_callback,
619 dev->interrupt_in_endpoint->bInterval);
620 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
621 dev->interrupt_out_urb->actual_length = bytes_to_write;
622 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
624 err("Couldn't submit interrupt_out_urb %d", retval);
628 buffer += bytes_to_write;
629 count -= bytes_to_write;
631 bytes_written += bytes_to_write;
635 retval = bytes_written;
638 /* unlock the device */
641 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
646 /* file operations needed when we register this driver */
647 static struct file_operations adu_fops = {
648 .owner = THIS_MODULE,
652 .release = adu_release,
656 * usb class driver info in order to get a minor number from the usb core,
657 * and to have the device registered with devfs and the driver core
659 static struct usb_class_driver adu_class = {
660 .name = "usb/adutux%d",
662 .minor_base = ADU_MINOR_BASE,
668 * Called by the usb core when a new device is connected that it thinks
669 * this driver might be interested in.
671 static int adu_probe(struct usb_interface *interface,
672 const struct usb_device_id *id)
674 struct usb_device *udev = interface_to_usbdev(interface);
675 struct adu_device *dev = NULL;
676 struct usb_host_interface *iface_desc;
677 struct usb_endpoint_descriptor *endpoint;
678 int retval = -ENODEV;
683 dbg(2," %s : enter", __FUNCTION__);
686 dev_err(&interface->dev, "udev is NULL.\n");
690 /* allocate memory for our device state and intialize it */
691 dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL);
693 dev_err(&interface->dev, "Out of memory\n");
698 init_MUTEX(&dev->sem);
699 spin_lock_init(&dev->buflock);
701 init_waitqueue_head(&dev->read_wait);
702 init_waitqueue_head(&dev->write_wait);
704 iface_desc = &interface->altsetting[0];
706 /* set up the endpoint information */
707 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
708 endpoint = &iface_desc->endpoint[i].desc;
710 if (usb_endpoint_is_int_in(endpoint))
711 dev->interrupt_in_endpoint = endpoint;
713 if (usb_endpoint_is_int_out(endpoint))
714 dev->interrupt_out_endpoint = endpoint;
716 if (dev->interrupt_in_endpoint == NULL) {
717 dev_err(&interface->dev, "interrupt in endpoint not found\n");
720 if (dev->interrupt_out_endpoint == NULL) {
721 dev_err(&interface->dev, "interrupt out endpoint not found\n");
725 in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
726 out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
728 dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
729 if (!dev->read_buffer_primary) {
730 dev_err(&interface->dev, "Couldn't allocate read_buffer_primary\n");
735 /* debug code prime the buffer */
736 memset(dev->read_buffer_primary, 'a', in_end_size);
737 memset(dev->read_buffer_primary + in_end_size, 'b', in_end_size);
738 memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size);
739 memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size);
741 dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);
742 if (!dev->read_buffer_secondary) {
743 dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary\n");
748 /* debug code prime the buffer */
749 memset(dev->read_buffer_secondary, 'e', in_end_size);
750 memset(dev->read_buffer_secondary + in_end_size, 'f', in_end_size);
751 memset(dev->read_buffer_secondary + (2 * in_end_size), 'g', in_end_size);
752 memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size);
754 dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL);
755 if (!dev->interrupt_in_buffer) {
756 dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
760 /* debug code prime the buffer */
761 memset(dev->interrupt_in_buffer, 'i', in_end_size);
763 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
764 if (!dev->interrupt_in_urb) {
765 dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb\n");
768 dev->interrupt_out_buffer = kmalloc(out_end_size, GFP_KERNEL);
769 if (!dev->interrupt_out_buffer) {
770 dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
773 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
774 if (!dev->interrupt_out_urb) {
775 dev_err(&interface->dev, "Couldn't allocate interrupt_out_urb\n");
779 if (!usb_string(udev, udev->descriptor.iSerialNumber, dev->serial_number,
780 sizeof(dev->serial_number))) {
781 dev_err(&interface->dev, "Could not retrieve serial number\n");
784 dbg(2," %s : serial_number=%s", __FUNCTION__, dev->serial_number);
786 /* we can register the device now, as it is ready */
787 usb_set_intfdata(interface, dev);
789 retval = usb_register_dev(interface, &adu_class);
792 /* something prevented us from registering this driver */
793 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
794 usb_set_intfdata(interface, NULL);
798 dev->minor = interface->minor;
800 /* let the user know what node this device is now attached to */
801 dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d",
802 udev->descriptor.idProduct, dev->serial_number,
803 (dev->minor - ADU_MINOR_BASE));
805 dbg(2," %s : leave, return value %p (dev)", __FUNCTION__, dev);
817 * Called by the usb core when the device is removed from the system.
819 static void adu_disconnect(struct usb_interface *interface)
821 struct adu_device *dev;
824 dbg(2," %s : enter", __FUNCTION__);
826 mutex_lock(&disconnect_mutex); /* not interruptible */
828 dev = usb_get_intfdata(interface);
829 usb_set_intfdata(interface, NULL);
831 down(&dev->sem); /* not interruptible */
835 /* give back our minor */
836 usb_deregister_dev(interface, &adu_class);
839 /* if the device is not opened, then we clean up right now */
840 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
841 if (!dev->open_count) {
849 mutex_unlock(&disconnect_mutex);
851 dev_info(&interface->dev, "ADU device adutux%d now disconnected",
852 (minor - ADU_MINOR_BASE));
854 dbg(2," %s : leave", __FUNCTION__);
857 /* usb specific object needed to register this driver with the usb subsystem */
858 static struct usb_driver adu_driver = {
861 .disconnect = adu_disconnect,
862 .id_table = device_table,
865 static int __init adu_init(void)
869 dbg(2," %s : enter", __FUNCTION__);
871 /* register this driver with the USB subsystem */
872 result = usb_register(&adu_driver);
874 err("usb_register failed for the "__FILE__" driver. "
875 "Error number %d", result);
879 info("adutux " DRIVER_DESC " " DRIVER_VERSION);
880 info("adutux is an experimental driver. Use at your own risk");
883 dbg(2," %s : leave, return value %d", __FUNCTION__, result);
888 static void __exit adu_exit(void)
890 dbg(2," %s : enter", __FUNCTION__);
891 /* deregister this driver with the USB subsystem */
892 usb_deregister(&adu_driver);
893 dbg(2," %s : leave", __FUNCTION__);
896 module_init(adu_init);
897 module_exit(adu_exit);
899 MODULE_AUTHOR(DRIVER_AUTHOR);
900 MODULE_DESCRIPTION(DRIVER_DESC);
901 MODULE_LICENSE("GPL");