blob: 20352654201399d78fb7c265285c714694d261f9 [file] [log] [blame]
Steven Haigh03270632006-08-09 07:42:06 +10001/*
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.
5 *
6 * Copyright (c) 2003 John Homppi (SCO, leave this notice here)
7 *
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.
12 *
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)
18 *
19 */
20
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>
Matthias Kaehlcke8293c562007-07-13 21:28:31 +020027#include <linux/mutex.h>
Steven Haigh03270632006-08-09 07:42:06 +100028#include <asm/uaccess.h>
29
30#ifdef CONFIG_USB_DEBUG
31static int debug = 5;
32#else
33static int debug = 1;
34#endif
35
36/* Use our own dbg macro */
37#undef dbg
38#define dbg(lvl, format, arg...) \
39do { \
40 if (debug >= lvl) \
41 printk(KERN_DEBUG __FILE__ " : " format " \n", ## arg); \
42} while (0)
43
44
45/* Version Information */
46#define DRIVER_VERSION "v0.0.13"
47#define DRIVER_AUTHOR "John Homppi"
48#define DRIVER_DESC "adutux (see www.ontrak.net)"
49
50/* Module parameters */
51module_param(debug, int, S_IRUGO | S_IWUSR);
52MODULE_PARM_DESC(debug, "Debug enabled or not");
53
54/* Define these values to match your device */
55#define ADU_VENDOR_ID 0x0a07
56#define ADU_PRODUCT_ID 0x0064
57
58/* table of devices that work with this driver */
59static struct usb_device_id device_table [] = {
60 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */
61 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */
62 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */
63 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+100) }, /* ADU200 */
64 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+108) }, /* ADU208 */
65 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+118) }, /* ADU218 */
66 { }/* Terminating entry */
67};
68
69MODULE_DEVICE_TABLE(usb, device_table);
70
71#ifdef CONFIG_USB_DYNAMIC_MINORS
72#define ADU_MINOR_BASE 0
73#else
74#define ADU_MINOR_BASE 67
75#endif
76
77/* we can have up to this number of device plugged in at once */
78#define MAX_DEVICES 16
79
80#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */
81
Pete Zaitcevf08812d2007-10-31 15:59:30 -070082/*
83 * The locking scheme is a vanilla 3-lock:
84 * adu_device.buflock: A spinlock, covers what IRQs touch.
85 * adutux_mutex: A Static lock to cover open_count. It would also cover
86 * any globals, but we don't have them in 2.6.
87 * adu_device.mtx: A mutex to hold across sleepers like copy_from_user.
88 * It covers all of adu_device, except the open_count
89 * and what .buflock covers.
90 */
91
Steven Haigh03270632006-08-09 07:42:06 +100092/* Structure to hold all of our device specific stuff */
93struct adu_device {
Pete Zaitcevf08812d2007-10-31 15:59:30 -070094 struct mutex mtx;
Steven Haigh03270632006-08-09 07:42:06 +100095 struct usb_device* udev; /* save off the usb device pointer */
96 struct usb_interface* interface;
Pete Zaitcevf08812d2007-10-31 15:59:30 -070097 unsigned int minor; /* the starting minor number for this device */
Steven Haigh03270632006-08-09 07:42:06 +100098 char serial_number[8];
99
100 int open_count; /* number of times this port has been opened */
101
102 char* read_buffer_primary;
103 int read_buffer_length;
104 char* read_buffer_secondary;
105 int secondary_head;
106 int secondary_tail;
107 spinlock_t buflock;
108
109 wait_queue_head_t read_wait;
110 wait_queue_head_t write_wait;
111
112 char* interrupt_in_buffer;
113 struct usb_endpoint_descriptor* interrupt_in_endpoint;
114 struct urb* interrupt_in_urb;
115 int read_urb_finished;
116
117 char* interrupt_out_buffer;
118 struct usb_endpoint_descriptor* interrupt_out_endpoint;
119 struct urb* interrupt_out_urb;
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700120 int out_urb_finished;
Steven Haigh03270632006-08-09 07:42:06 +1000121};
122
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700123static DEFINE_MUTEX(adutux_mutex);
124
Steven Haigh03270632006-08-09 07:42:06 +1000125static struct usb_driver adu_driver;
126
127static void adu_debug_data(int level, const char *function, int size,
128 const unsigned char *data)
129{
130 int i;
131
132 if (debug < level)
133 return;
134
135 printk(KERN_DEBUG __FILE__": %s - length = %d, data = ",
136 function, size);
137 for (i = 0; i < size; ++i)
138 printk("%.2x ", data[i]);
139 printk("\n");
140}
141
142/**
143 * adu_abort_transfers
144 * aborts transfers and frees associated data structures
145 */
146static void adu_abort_transfers(struct adu_device *dev)
147{
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700148 unsigned long flags;
Steven Haigh03270632006-08-09 07:42:06 +1000149
Harvey Harrison441b62c2008-03-03 16:08:34 -0800150 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000151
152 if (dev->udev == NULL) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800153 dbg(1," %s : udev is null", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000154 goto exit;
155 }
156
Steven Haigh03270632006-08-09 07:42:06 +1000157 /* shutdown transfer */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700158
159 /* XXX Anchor these instead */
160 spin_lock_irqsave(&dev->buflock, flags);
161 if (!dev->read_urb_finished) {
162 spin_unlock_irqrestore(&dev->buflock, flags);
163 usb_kill_urb(dev->interrupt_in_urb);
164 } else
165 spin_unlock_irqrestore(&dev->buflock, flags);
166
167 spin_lock_irqsave(&dev->buflock, flags);
168 if (!dev->out_urb_finished) {
169 spin_unlock_irqrestore(&dev->buflock, flags);
170 usb_kill_urb(dev->interrupt_out_urb);
171 } else
172 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000173
174exit:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800175 dbg(2," %s : leave", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000176}
177
178static void adu_delete(struct adu_device *dev)
179{
Harvey Harrison441b62c2008-03-03 16:08:34 -0800180 dbg(2, "%s enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000181
Steven Haigh03270632006-08-09 07:42:06 +1000182 /* free data structures */
183 usb_free_urb(dev->interrupt_in_urb);
184 usb_free_urb(dev->interrupt_out_urb);
185 kfree(dev->read_buffer_primary);
186 kfree(dev->read_buffer_secondary);
187 kfree(dev->interrupt_in_buffer);
188 kfree(dev->interrupt_out_buffer);
189 kfree(dev);
190
Harvey Harrison441b62c2008-03-03 16:08:34 -0800191 dbg(2, "%s : leave", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000192}
193
David Howells7d12e782006-10-05 14:55:46 +0100194static void adu_interrupt_in_callback(struct urb *urb)
Steven Haigh03270632006-08-09 07:42:06 +1000195{
196 struct adu_device *dev = urb->context;
Greg Kroah-Hartman24497a02007-07-18 10:58:02 -0700197 int status = urb->status;
Steven Haigh03270632006-08-09 07:42:06 +1000198
Harvey Harrison441b62c2008-03-03 16:08:34 -0800199 dbg(4," %s : enter, status %d", __func__, status);
200 adu_debug_data(5, __func__, urb->actual_length,
Steven Haigh03270632006-08-09 07:42:06 +1000201 urb->transfer_buffer);
202
203 spin_lock(&dev->buflock);
204
Greg Kroah-Hartman24497a02007-07-18 10:58:02 -0700205 if (status != 0) {
Oliver Neukumf6c1cea2007-08-16 16:02:08 +0200206 if ((status != -ENOENT) && (status != -ECONNRESET) &&
207 (status != -ESHUTDOWN)) {
Steven Haigh03270632006-08-09 07:42:06 +1000208 dbg(1," %s : nonzero status received: %d",
Harvey Harrison441b62c2008-03-03 16:08:34 -0800209 __func__, status);
Steven Haigh03270632006-08-09 07:42:06 +1000210 }
211 goto exit;
212 }
213
214 if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {
215 if (dev->read_buffer_length <
216 (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) -
217 (urb->actual_length)) {
218 memcpy (dev->read_buffer_primary +
219 dev->read_buffer_length,
220 dev->interrupt_in_buffer, urb->actual_length);
221
222 dev->read_buffer_length += urb->actual_length;
Harvey Harrison441b62c2008-03-03 16:08:34 -0800223 dbg(2," %s reading %d ", __func__,
Steven Haigh03270632006-08-09 07:42:06 +1000224 urb->actual_length);
225 } else {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800226 dbg(1," %s : read_buffer overflow", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000227 }
228 }
229
230exit:
231 dev->read_urb_finished = 1;
232 spin_unlock(&dev->buflock);
233 /* always wake up so we recover from errors */
234 wake_up_interruptible(&dev->read_wait);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800235 adu_debug_data(5, __func__, urb->actual_length,
Steven Haigh03270632006-08-09 07:42:06 +1000236 urb->transfer_buffer);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800237 dbg(4," %s : leave, status %d", __func__, status);
Steven Haigh03270632006-08-09 07:42:06 +1000238}
239
David Howells7d12e782006-10-05 14:55:46 +0100240static void adu_interrupt_out_callback(struct urb *urb)
Steven Haigh03270632006-08-09 07:42:06 +1000241{
242 struct adu_device *dev = urb->context;
Greg Kroah-Hartman24497a02007-07-18 10:58:02 -0700243 int status = urb->status;
Steven Haigh03270632006-08-09 07:42:06 +1000244
Harvey Harrison441b62c2008-03-03 16:08:34 -0800245 dbg(4," %s : enter, status %d", __func__, status);
246 adu_debug_data(5,__func__, urb->actual_length, urb->transfer_buffer);
Steven Haigh03270632006-08-09 07:42:06 +1000247
Greg Kroah-Hartman24497a02007-07-18 10:58:02 -0700248 if (status != 0) {
249 if ((status != -ENOENT) &&
250 (status != -ECONNRESET)) {
Steven Haigh03270632006-08-09 07:42:06 +1000251 dbg(1, " %s :nonzero status received: %d",
Harvey Harrison441b62c2008-03-03 16:08:34 -0800252 __func__, status);
Steven Haigh03270632006-08-09 07:42:06 +1000253 }
254 goto exit;
255 }
256
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700257 spin_lock(&dev->buflock);
258 dev->out_urb_finished = 1;
259 wake_up(&dev->write_wait);
260 spin_unlock(&dev->buflock);
Steven Haigh03270632006-08-09 07:42:06 +1000261exit:
262
Harvey Harrison441b62c2008-03-03 16:08:34 -0800263 adu_debug_data(5, __func__, urb->actual_length,
Steven Haigh03270632006-08-09 07:42:06 +1000264 urb->transfer_buffer);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800265 dbg(4," %s : leave, status %d", __func__, status);
Steven Haigh03270632006-08-09 07:42:06 +1000266}
267
268static int adu_open(struct inode *inode, struct file *file)
269{
270 struct adu_device *dev = NULL;
271 struct usb_interface *interface;
272 int subminor;
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700273 int retval;
Steven Haigh03270632006-08-09 07:42:06 +1000274
Harvey Harrison441b62c2008-03-03 16:08:34 -0800275 dbg(2,"%s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000276
277 subminor = iminor(inode);
278
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700279 if ((retval = mutex_lock_interruptible(&adutux_mutex))) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800280 dbg(2, "%s : mutex lock failed", __func__);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700281 goto exit_no_lock;
282 }
283
Steven Haigh03270632006-08-09 07:42:06 +1000284 interface = usb_find_interface(&adu_driver, subminor);
285 if (!interface) {
Greg Kroah-Hartmanfd3f1912008-08-14 09:37:34 -0700286 printk(KERN_ERR "adutux: %s - error, can't find device for "
287 "minor %d\n", __func__, subminor);
Steven Haigh03270632006-08-09 07:42:06 +1000288 retval = -ENODEV;
289 goto exit_no_device;
290 }
291
292 dev = usb_get_intfdata(interface);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700293 if (!dev || !dev->udev) {
Steven Haigh03270632006-08-09 07:42:06 +1000294 retval = -ENODEV;
295 goto exit_no_device;
296 }
297
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700298 /* check that nobody else is using the device */
299 if (dev->open_count) {
300 retval = -EBUSY;
Steven Haigh03270632006-08-09 07:42:06 +1000301 goto exit_no_device;
302 }
303
Steven Haigh03270632006-08-09 07:42:06 +1000304 ++dev->open_count;
Harvey Harrison441b62c2008-03-03 16:08:34 -0800305 dbg(2,"%s : open count %d", __func__, dev->open_count);
Steven Haigh03270632006-08-09 07:42:06 +1000306
307 /* save device in the file's private structure */
308 file->private_data = dev;
309
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700310 /* initialize in direction */
311 dev->read_buffer_length = 0;
Steven Haigh03270632006-08-09 07:42:06 +1000312
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700313 /* fixup first read by having urb waiting for it */
314 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
315 usb_rcvintpipe(dev->udev,
316 dev->interrupt_in_endpoint->bEndpointAddress),
317 dev->interrupt_in_buffer,
318 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
319 adu_interrupt_in_callback, dev,
320 dev->interrupt_in_endpoint->bInterval);
321 dev->read_urb_finished = 0;
322 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL))
323 dev->read_urb_finished = 1;
324 /* we ignore failure */
325 /* end of fixup for first read */
326
327 /* initialize out direction */
328 dev->out_urb_finished = 1;
329
330 retval = 0;
Steven Haigh03270632006-08-09 07:42:06 +1000331
332exit_no_device:
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700333 mutex_unlock(&adutux_mutex);
334exit_no_lock:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800335 dbg(2,"%s : leave, return value %d ", __func__, retval);
Steven Haigh03270632006-08-09 07:42:06 +1000336 return retval;
337}
338
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700339static void adu_release_internal(struct adu_device *dev)
Steven Haigh03270632006-08-09 07:42:06 +1000340{
Harvey Harrison441b62c2008-03-03 16:08:34 -0800341 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000342
Steven Haigh03270632006-08-09 07:42:06 +1000343 /* decrement our usage count for the device */
344 --dev->open_count;
Harvey Harrison441b62c2008-03-03 16:08:34 -0800345 dbg(2," %s : open count %d", __func__, dev->open_count);
Steven Haigh03270632006-08-09 07:42:06 +1000346 if (dev->open_count <= 0) {
347 adu_abort_transfers(dev);
348 dev->open_count = 0;
349 }
350
Harvey Harrison441b62c2008-03-03 16:08:34 -0800351 dbg(2," %s : leave", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000352}
353
354static int adu_release(struct inode *inode, struct file *file)
355{
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700356 struct adu_device *dev;
Steven Haigh03270632006-08-09 07:42:06 +1000357 int retval = 0;
358
Harvey Harrison441b62c2008-03-03 16:08:34 -0800359 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000360
361 if (file == NULL) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800362 dbg(1," %s : file is NULL", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000363 retval = -ENODEV;
364 goto exit;
365 }
366
367 dev = file->private_data;
Steven Haigh03270632006-08-09 07:42:06 +1000368 if (dev == NULL) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800369 dbg(1," %s : object is NULL", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000370 retval = -ENODEV;
371 goto exit;
372 }
373
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700374 mutex_lock(&adutux_mutex); /* not interruptible */
Steven Haigh03270632006-08-09 07:42:06 +1000375
376 if (dev->open_count <= 0) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800377 dbg(1," %s : device not opened", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000378 retval = -ENODEV;
Jiri Slaby46c98442009-03-11 21:47:38 +0100379 goto unlock;
Steven Haigh03270632006-08-09 07:42:06 +1000380 }
381
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700382 adu_release_internal(dev);
Alan Sternd4ead162007-05-22 11:46:41 -0400383 if (dev->udev == NULL) {
384 /* the device was unplugged before the file was released */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700385 if (!dev->open_count) /* ... and we're the last user */
386 adu_delete(dev);
Alan Sternd4ead162007-05-22 11:46:41 -0400387 }
Jiri Slaby46c98442009-03-11 21:47:38 +0100388unlock:
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700389 mutex_unlock(&adutux_mutex);
Jiri Slaby46c98442009-03-11 21:47:38 +0100390exit:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800391 dbg(2," %s : leave, return value %d", __func__, retval);
Steven Haigh03270632006-08-09 07:42:06 +1000392 return retval;
393}
394
395static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
396 loff_t *ppos)
397{
398 struct adu_device *dev;
399 size_t bytes_read = 0;
400 size_t bytes_to_read = count;
401 int i;
402 int retval = 0;
403 int timeout = 0;
404 int should_submit = 0;
405 unsigned long flags;
406 DECLARE_WAITQUEUE(wait, current);
407
Harvey Harrison441b62c2008-03-03 16:08:34 -0800408 dbg(2," %s : enter, count = %Zd, file=%p", __func__, count, file);
Steven Haigh03270632006-08-09 07:42:06 +1000409
410 dev = file->private_data;
Harvey Harrison441b62c2008-03-03 16:08:34 -0800411 dbg(2," %s : dev=%p", __func__, dev);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700412
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200413 if (mutex_lock_interruptible(&dev->mtx))
Steven Haigh03270632006-08-09 07:42:06 +1000414 return -ERESTARTSYS;
415
416 /* verify that the device wasn't unplugged */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700417 if (dev->udev == NULL) {
Steven Haigh03270632006-08-09 07:42:06 +1000418 retval = -ENODEV;
Greg Kroah-Hartmanfd3f1912008-08-14 09:37:34 -0700419 printk(KERN_ERR "adutux: No device or device unplugged %d\n",
420 retval);
Steven Haigh03270632006-08-09 07:42:06 +1000421 goto exit;
422 }
423
424 /* verify that some data was requested */
425 if (count == 0) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800426 dbg(1," %s : read request of 0 bytes", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000427 goto exit;
428 }
429
430 timeout = COMMAND_TIMEOUT;
Harvey Harrison441b62c2008-03-03 16:08:34 -0800431 dbg(2," %s : about to start looping", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000432 while (bytes_to_read) {
433 int data_in_secondary = dev->secondary_tail - dev->secondary_head;
434 dbg(2," %s : while, data_in_secondary=%d, status=%d",
Harvey Harrison441b62c2008-03-03 16:08:34 -0800435 __func__, data_in_secondary,
Steven Haigh03270632006-08-09 07:42:06 +1000436 dev->interrupt_in_urb->status);
437
438 if (data_in_secondary) {
439 /* drain secondary buffer */
440 int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;
441 i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount);
442 if (i < 0) {
443 retval = -EFAULT;
444 goto exit;
445 }
446 dev->secondary_head += (amount - i);
447 bytes_read += (amount - i);
448 bytes_to_read -= (amount - i);
449 if (i) {
450 retval = bytes_read ? bytes_read : -EFAULT;
451 goto exit;
452 }
453 } else {
454 /* we check the primary buffer */
455 spin_lock_irqsave (&dev->buflock, flags);
456 if (dev->read_buffer_length) {
457 /* we secure access to the primary */
458 char *tmp;
459 dbg(2," %s : swap, read_buffer_length = %d",
Harvey Harrison441b62c2008-03-03 16:08:34 -0800460 __func__, dev->read_buffer_length);
Steven Haigh03270632006-08-09 07:42:06 +1000461 tmp = dev->read_buffer_secondary;
462 dev->read_buffer_secondary = dev->read_buffer_primary;
463 dev->read_buffer_primary = tmp;
464 dev->secondary_head = 0;
465 dev->secondary_tail = dev->read_buffer_length;
466 dev->read_buffer_length = 0;
467 spin_unlock_irqrestore(&dev->buflock, flags);
468 /* we have a free buffer so use it */
469 should_submit = 1;
470 } else {
471 /* even the primary was empty - we may need to do IO */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700472 if (!dev->read_urb_finished) {
Steven Haigh03270632006-08-09 07:42:06 +1000473 /* somebody is doing IO */
474 spin_unlock_irqrestore(&dev->buflock, flags);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800475 dbg(2," %s : submitted already", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000476 } else {
477 /* we must initiate input */
Harvey Harrison441b62c2008-03-03 16:08:34 -0800478 dbg(2," %s : initiate input", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000479 dev->read_urb_finished = 0;
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700480 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000481
482 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
483 usb_rcvintpipe(dev->udev,
484 dev->interrupt_in_endpoint->bEndpointAddress),
485 dev->interrupt_in_buffer,
486 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
487 adu_interrupt_in_callback,
488 dev,
489 dev->interrupt_in_endpoint->bInterval);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700490 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
491 if (retval) {
492 dev->read_urb_finished = 1;
Steven Haigh03270632006-08-09 07:42:06 +1000493 if (retval == -ENOMEM) {
494 retval = bytes_read ? bytes_read : -ENOMEM;
495 }
Harvey Harrison441b62c2008-03-03 16:08:34 -0800496 dbg(2," %s : submit failed", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000497 goto exit;
498 }
499 }
500
501 /* we wait for I/O to complete */
502 set_current_state(TASK_INTERRUPTIBLE);
503 add_wait_queue(&dev->read_wait, &wait);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700504 spin_lock_irqsave(&dev->buflock, flags);
505 if (!dev->read_urb_finished) {
506 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000507 timeout = schedule_timeout(COMMAND_TIMEOUT);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700508 } else {
509 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000510 set_current_state(TASK_RUNNING);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700511 }
Steven Haigh03270632006-08-09 07:42:06 +1000512 remove_wait_queue(&dev->read_wait, &wait);
513
514 if (timeout <= 0) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800515 dbg(2," %s : timeout", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000516 retval = bytes_read ? bytes_read : -ETIMEDOUT;
517 goto exit;
518 }
519
520 if (signal_pending(current)) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800521 dbg(2," %s : signal pending", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000522 retval = bytes_read ? bytes_read : -EINTR;
523 goto exit;
524 }
525 }
526 }
527 }
528
529 retval = bytes_read;
530 /* if the primary buffer is empty then use it */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700531 spin_lock_irqsave(&dev->buflock, flags);
532 if (should_submit && dev->read_urb_finished) {
533 dev->read_urb_finished = 0;
534 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000535 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
536 usb_rcvintpipe(dev->udev,
537 dev->interrupt_in_endpoint->bEndpointAddress),
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700538 dev->interrupt_in_buffer,
539 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
540 adu_interrupt_in_callback,
541 dev,
542 dev->interrupt_in_endpoint->bInterval);
543 if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL) != 0)
544 dev->read_urb_finished = 1;
Steven Haigh03270632006-08-09 07:42:06 +1000545 /* we ignore failure */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700546 } else {
547 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000548 }
549
550exit:
551 /* unlock the device */
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200552 mutex_unlock(&dev->mtx);
Steven Haigh03270632006-08-09 07:42:06 +1000553
Harvey Harrison441b62c2008-03-03 16:08:34 -0800554 dbg(2," %s : leave, return value %d", __func__, retval);
Steven Haigh03270632006-08-09 07:42:06 +1000555 return retval;
556}
557
558static ssize_t adu_write(struct file *file, const __user char *buffer,
559 size_t count, loff_t *ppos)
560{
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700561 DECLARE_WAITQUEUE(waita, current);
Steven Haigh03270632006-08-09 07:42:06 +1000562 struct adu_device *dev;
563 size_t bytes_written = 0;
564 size_t bytes_to_write;
565 size_t buffer_size;
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700566 unsigned long flags;
Oliver Neukumebc3ac12007-04-02 15:16:36 +0200567 int retval;
Steven Haigh03270632006-08-09 07:42:06 +1000568
Harvey Harrison441b62c2008-03-03 16:08:34 -0800569 dbg(2," %s : enter, count = %Zd", __func__, count);
Steven Haigh03270632006-08-09 07:42:06 +1000570
571 dev = file->private_data;
572
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200573 retval = mutex_lock_interruptible(&dev->mtx);
Oliver Neukumebc3ac12007-04-02 15:16:36 +0200574 if (retval)
575 goto exit_nolock;
Steven Haigh03270632006-08-09 07:42:06 +1000576
577 /* verify that the device wasn't unplugged */
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700578 if (dev->udev == NULL) {
Steven Haigh03270632006-08-09 07:42:06 +1000579 retval = -ENODEV;
Greg Kroah-Hartmanfd3f1912008-08-14 09:37:34 -0700580 printk(KERN_ERR "adutux: No device or device unplugged %d\n",
581 retval);
Steven Haigh03270632006-08-09 07:42:06 +1000582 goto exit;
583 }
584
585 /* verify that we actually have some data to write */
586 if (count == 0) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800587 dbg(1," %s : write request of 0 bytes", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000588 goto exit;
589 }
590
Steven Haigh03270632006-08-09 07:42:06 +1000591 while (count > 0) {
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700592 add_wait_queue(&dev->write_wait, &waita);
593 set_current_state(TASK_INTERRUPTIBLE);
594 spin_lock_irqsave(&dev->buflock, flags);
595 if (!dev->out_urb_finished) {
596 spin_unlock_irqrestore(&dev->buflock, flags);
Steven Haigh03270632006-08-09 07:42:06 +1000597
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200598 mutex_unlock(&dev->mtx);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700599 if (signal_pending(current)) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800600 dbg(1," %s : interrupted", __func__);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700601 set_current_state(TASK_RUNNING);
602 retval = -EINTR;
603 goto exit_onqueue;
604 }
605 if (schedule_timeout(COMMAND_TIMEOUT) == 0) {
Harvey Harrison441b62c2008-03-03 16:08:34 -0800606 dbg(1, "%s - command timed out.", __func__);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700607 retval = -ETIMEDOUT;
608 goto exit_onqueue;
609 }
610 remove_wait_queue(&dev->write_wait, &waita);
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200611 retval = mutex_lock_interruptible(&dev->mtx);
Oliver Neukumebc3ac12007-04-02 15:16:36 +0200612 if (retval) {
613 retval = bytes_written ? bytes_written : retval;
614 goto exit_nolock;
615 }
Steven Haigh03270632006-08-09 07:42:06 +1000616
Harvey Harrison441b62c2008-03-03 16:08:34 -0800617 dbg(4," %s : in progress, count = %Zd", __func__, count);
Steven Haigh03270632006-08-09 07:42:06 +1000618 } else {
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700619 spin_unlock_irqrestore(&dev->buflock, flags);
620 set_current_state(TASK_RUNNING);
621 remove_wait_queue(&dev->write_wait, &waita);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800622 dbg(4," %s : sending, count = %Zd", __func__, count);
Steven Haigh03270632006-08-09 07:42:06 +1000623
624 /* write the data into interrupt_out_buffer from userspace */
625 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
626 bytes_to_write = count > buffer_size ? buffer_size : count;
627 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
Harvey Harrison441b62c2008-03-03 16:08:34 -0800628 __func__, buffer_size, count, bytes_to_write);
Steven Haigh03270632006-08-09 07:42:06 +1000629
630 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {
631 retval = -EFAULT;
632 goto exit;
633 }
634
635 /* send off the urb */
636 usb_fill_int_urb(
637 dev->interrupt_out_urb,
638 dev->udev,
639 usb_sndintpipe(dev->udev, dev->interrupt_out_endpoint->bEndpointAddress),
640 dev->interrupt_out_buffer,
641 bytes_to_write,
642 adu_interrupt_out_callback,
643 dev,
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700644 dev->interrupt_out_endpoint->bInterval);
Steven Haigh03270632006-08-09 07:42:06 +1000645 dev->interrupt_out_urb->actual_length = bytes_to_write;
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700646 dev->out_urb_finished = 0;
Steven Haigh03270632006-08-09 07:42:06 +1000647 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
648 if (retval < 0) {
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700649 dev->out_urb_finished = 1;
Greg Kroah-Hartmanfd3f1912008-08-14 09:37:34 -0700650 dev_err(&dev->udev->dev, "Couldn't submit "
651 "interrupt_out_urb %d\n", retval);
Steven Haigh03270632006-08-09 07:42:06 +1000652 goto exit;
653 }
654
655 buffer += bytes_to_write;
656 count -= bytes_to_write;
657
658 bytes_written += bytes_to_write;
659 }
660 }
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700661 mutex_unlock(&dev->mtx);
662 return bytes_written;
Steven Haigh03270632006-08-09 07:42:06 +1000663
664exit:
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200665 mutex_unlock(&dev->mtx);
Oliver Neukumebc3ac12007-04-02 15:16:36 +0200666exit_nolock:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800667 dbg(2," %s : leave, return value %d", __func__, retval);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700668 return retval;
Steven Haigh03270632006-08-09 07:42:06 +1000669
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700670exit_onqueue:
671 remove_wait_queue(&dev->write_wait, &waita);
Steven Haigh03270632006-08-09 07:42:06 +1000672 return retval;
673}
674
675/* file operations needed when we register this driver */
Arjan van de Ven00977a52007-02-12 00:55:34 -0800676static const struct file_operations adu_fops = {
Steven Haigh03270632006-08-09 07:42:06 +1000677 .owner = THIS_MODULE,
678 .read = adu_read,
679 .write = adu_write,
680 .open = adu_open,
681 .release = adu_release,
682};
683
684/*
685 * usb class driver info in order to get a minor number from the usb core,
686 * and to have the device registered with devfs and the driver core
687 */
688static struct usb_class_driver adu_class = {
689 .name = "usb/adutux%d",
690 .fops = &adu_fops,
691 .minor_base = ADU_MINOR_BASE,
692};
693
694/**
695 * adu_probe
696 *
697 * Called by the usb core when a new device is connected that it thinks
698 * this driver might be interested in.
699 */
700static int adu_probe(struct usb_interface *interface,
701 const struct usb_device_id *id)
702{
703 struct usb_device *udev = interface_to_usbdev(interface);
704 struct adu_device *dev = NULL;
705 struct usb_host_interface *iface_desc;
706 struct usb_endpoint_descriptor *endpoint;
707 int retval = -ENODEV;
708 int in_end_size;
709 int out_end_size;
710 int i;
711
Harvey Harrison441b62c2008-03-03 16:08:34 -0800712 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000713
714 if (udev == NULL) {
715 dev_err(&interface->dev, "udev is NULL.\n");
716 goto exit;
717 }
718
719 /* allocate memory for our device state and intialize it */
720 dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL);
721 if (dev == NULL) {
722 dev_err(&interface->dev, "Out of memory\n");
723 retval = -ENOMEM;
724 goto exit;
725 }
726
Matthias Kaehlcke8293c562007-07-13 21:28:31 +0200727 mutex_init(&dev->mtx);
Steven Haigh03270632006-08-09 07:42:06 +1000728 spin_lock_init(&dev->buflock);
729 dev->udev = udev;
730 init_waitqueue_head(&dev->read_wait);
731 init_waitqueue_head(&dev->write_wait);
732
733 iface_desc = &interface->altsetting[0];
734
735 /* set up the endpoint information */
736 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
737 endpoint = &iface_desc->endpoint[i].desc;
738
739 if (usb_endpoint_is_int_in(endpoint))
740 dev->interrupt_in_endpoint = endpoint;
741
742 if (usb_endpoint_is_int_out(endpoint))
743 dev->interrupt_out_endpoint = endpoint;
744 }
745 if (dev->interrupt_in_endpoint == NULL) {
746 dev_err(&interface->dev, "interrupt in endpoint not found\n");
747 goto error;
748 }
749 if (dev->interrupt_out_endpoint == NULL) {
750 dev_err(&interface->dev, "interrupt out endpoint not found\n");
751 goto error;
752 }
753
754 in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
755 out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
756
757 dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
758 if (!dev->read_buffer_primary) {
759 dev_err(&interface->dev, "Couldn't allocate read_buffer_primary\n");
760 retval = -ENOMEM;
761 goto error;
762 }
763
764 /* debug code prime the buffer */
765 memset(dev->read_buffer_primary, 'a', in_end_size);
766 memset(dev->read_buffer_primary + in_end_size, 'b', in_end_size);
767 memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size);
768 memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size);
769
770 dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);
771 if (!dev->read_buffer_secondary) {
772 dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary\n");
773 retval = -ENOMEM;
774 goto error;
775 }
776
777 /* debug code prime the buffer */
778 memset(dev->read_buffer_secondary, 'e', in_end_size);
779 memset(dev->read_buffer_secondary + in_end_size, 'f', in_end_size);
780 memset(dev->read_buffer_secondary + (2 * in_end_size), 'g', in_end_size);
781 memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size);
782
783 dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL);
784 if (!dev->interrupt_in_buffer) {
785 dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
786 goto error;
787 }
788
789 /* debug code prime the buffer */
790 memset(dev->interrupt_in_buffer, 'i', in_end_size);
791
792 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
793 if (!dev->interrupt_in_urb) {
794 dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb\n");
795 goto error;
796 }
797 dev->interrupt_out_buffer = kmalloc(out_end_size, GFP_KERNEL);
798 if (!dev->interrupt_out_buffer) {
799 dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
800 goto error;
801 }
802 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
803 if (!dev->interrupt_out_urb) {
804 dev_err(&interface->dev, "Couldn't allocate interrupt_out_urb\n");
805 goto error;
806 }
807
808 if (!usb_string(udev, udev->descriptor.iSerialNumber, dev->serial_number,
809 sizeof(dev->serial_number))) {
810 dev_err(&interface->dev, "Could not retrieve serial number\n");
811 goto error;
812 }
Harvey Harrison441b62c2008-03-03 16:08:34 -0800813 dbg(2," %s : serial_number=%s", __func__, dev->serial_number);
Steven Haigh03270632006-08-09 07:42:06 +1000814
815 /* we can register the device now, as it is ready */
816 usb_set_intfdata(interface, dev);
817
818 retval = usb_register_dev(interface, &adu_class);
819
820 if (retval) {
821 /* something prevented us from registering this driver */
822 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
823 usb_set_intfdata(interface, NULL);
824 goto error;
825 }
826
827 dev->minor = interface->minor;
828
829 /* let the user know what node this device is now attached to */
Joe Perches898eb712007-10-18 03:06:30 -0700830 dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d\n",
Steven Haigh03270632006-08-09 07:42:06 +1000831 udev->descriptor.idProduct, dev->serial_number,
832 (dev->minor - ADU_MINOR_BASE));
833exit:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800834 dbg(2," %s : leave, return value %p (dev)", __func__, dev);
Steven Haigh03270632006-08-09 07:42:06 +1000835
836 return retval;
837
838error:
839 adu_delete(dev);
840 return retval;
841}
842
843/**
844 * adu_disconnect
845 *
846 * Called by the usb core when the device is removed from the system.
847 */
848static void adu_disconnect(struct usb_interface *interface)
849{
850 struct adu_device *dev;
851 int minor;
852
Harvey Harrison441b62c2008-03-03 16:08:34 -0800853 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000854
Steven Haigh03270632006-08-09 07:42:06 +1000855 dev = usb_get_intfdata(interface);
Steven Haigh03270632006-08-09 07:42:06 +1000856
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700857 mutex_lock(&dev->mtx); /* not interruptible */
858 dev->udev = NULL; /* poison */
Steven Haigh03270632006-08-09 07:42:06 +1000859 minor = dev->minor;
Steven Haigh03270632006-08-09 07:42:06 +1000860 usb_deregister_dev(interface, &adu_class);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700861 mutex_unlock(&dev->mtx);
Steven Haigh03270632006-08-09 07:42:06 +1000862
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700863 mutex_lock(&adutux_mutex);
864 usb_set_intfdata(interface, NULL);
Alan Sternd4ead162007-05-22 11:46:41 -0400865
Steven Haigh03270632006-08-09 07:42:06 +1000866 /* if the device is not opened, then we clean up right now */
Harvey Harrison441b62c2008-03-03 16:08:34 -0800867 dbg(2," %s : open count %d", __func__, dev->open_count);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700868 if (!dev->open_count)
Steven Haigh03270632006-08-09 07:42:06 +1000869 adu_delete(dev);
Pete Zaitcevf08812d2007-10-31 15:59:30 -0700870
871 mutex_unlock(&adutux_mutex);
Steven Haigh03270632006-08-09 07:42:06 +1000872
Joe Perches898eb712007-10-18 03:06:30 -0700873 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n",
Steven Haigh03270632006-08-09 07:42:06 +1000874 (minor - ADU_MINOR_BASE));
875
Harvey Harrison441b62c2008-03-03 16:08:34 -0800876 dbg(2," %s : leave", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000877}
878
879/* usb specific object needed to register this driver with the usb subsystem */
880static struct usb_driver adu_driver = {
881 .name = "adutux",
882 .probe = adu_probe,
883 .disconnect = adu_disconnect,
884 .id_table = device_table,
885};
886
887static int __init adu_init(void)
888{
889 int result;
890
Harvey Harrison441b62c2008-03-03 16:08:34 -0800891 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000892
893 /* register this driver with the USB subsystem */
894 result = usb_register(&adu_driver);
895 if (result < 0) {
Greg Kroah-Hartmanfd3f1912008-08-14 09:37:34 -0700896 printk(KERN_ERR "usb_register failed for the "__FILE__
897 " driver. Error number %d\n", result);
Steven Haigh03270632006-08-09 07:42:06 +1000898 goto exit;
899 }
900
Greg Kroah-Hartman1b29a372008-08-18 13:21:04 -0700901 printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n");
902 printk(KERN_INFO "adutux is an experimental driver. "
903 "Use at your own risk\n");
Steven Haigh03270632006-08-09 07:42:06 +1000904
905exit:
Harvey Harrison441b62c2008-03-03 16:08:34 -0800906 dbg(2," %s : leave, return value %d", __func__, result);
Steven Haigh03270632006-08-09 07:42:06 +1000907
908 return result;
909}
910
911static void __exit adu_exit(void)
912{
Harvey Harrison441b62c2008-03-03 16:08:34 -0800913 dbg(2," %s : enter", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000914 /* deregister this driver with the USB subsystem */
915 usb_deregister(&adu_driver);
Harvey Harrison441b62c2008-03-03 16:08:34 -0800916 dbg(2," %s : leave", __func__);
Steven Haigh03270632006-08-09 07:42:06 +1000917}
918
919module_init(adu_init);
920module_exit(adu_exit);
921
922MODULE_AUTHOR(DRIVER_AUTHOR);
923MODULE_DESCRIPTION(DRIVER_DESC);
924MODULE_LICENSE("GPL");