]> err.no Git - linux-2.6/blob - drivers/usb/serial/visor.c
0ac0377e8683c3426da2cef2533fa5394bccb4b4
[linux-2.6] / drivers / usb / serial / visor.c
1 /*
2  * USB HandSpring Visor, Palm m50x, and Sony Clie driver
3  * (supports all of the Palm OS USB devices)
4  *
5  *      Copyright (C) 1999 - 2004
6  *          Greg Kroah-Hartman (greg@kroah.com)
7  *
8  *      This program is free software; you can redistribute it and/or modify
9  *      it under the terms of the GNU General Public License as published by
10  *      the Free Software Foundation; either version 2 of the License, or
11  *      (at your option) any later version.
12  *
13  * See Documentation/usb/usb-serial.txt for more information on using this driver
14  *
15  * (06/03/2003) Judd Montgomery <judd at jpilot.org>
16  *     Added support for module parameter options for untested/unknown
17  *     devices.
18  *
19  * (03/09/2003) gkh
20  *      Added support for the Sony Clie NZ90V device.  Thanks to Martin Brachtl
21  *      <brachtl@redgrep.cz> for the information.
22  *
23  * (03/05/2003) gkh
24  *      Think Treo support is now working.
25  *
26  * (04/03/2002) gkh
27  *      Added support for the Sony OS 4.1 devices.  Thanks to Hiroyuki ARAKI
28  *      <hiro@zob.ne.jp> for the information.
29  *
30  * (03/27/2002) gkh
31  *      Removed assumptions that port->tty was always valid (is not true
32  *      for usb serial console devices.)
33  *
34  * (03/23/2002) gkh
35  *      Added support for the Palm i705 device, thanks to Thomas Riemer
36  *      <tom@netmech.com> for the information.
37  *
38  * (03/21/2002) gkh
39  *      Added support for the Palm m130 device, thanks to Udo Eisenbarth
40  *      <udo.eisenbarth@web.de> for the information.
41  *
42  * (02/27/2002) gkh
43  *      Reworked the urb handling logic.  We have no more pool, but dynamically
44  *      allocate the urb and the transfer buffer on the fly.  In testing this
45  *      does not incure any measurable overhead.  This also relies on the fact
46  *      that we have proper reference counting logic for urbs.
47  *
48  * (02/21/2002) SilaS
49  *  Added initial support for the Palm m515 devices.
50  *
51  * (02/14/2002) gkh
52  *      Added support for the Clie S-360 device.
53  *
54  * (12/18/2001) gkh
55  *      Added better Clie support for 3.5 devices.  Thanks to Geoffrey Levand
56  *      for the patch.
57  *
58  * (11/11/2001) gkh
59  *      Added support for the m125 devices, and added check to prevent oopses
60  *      for CliĆ© devices that lie about the number of ports they have.
61  *
62  * (08/30/2001) gkh
63  *      Added support for the Clie devices, both the 3.5 and 4.0 os versions.
64  *      Many thanks to Daniel Burke, and Bryan Payne for helping with this.
65  *
66  * (08/23/2001) gkh
67  *      fixed a few potential bugs pointed out by Oliver Neukum.
68  *
69  * (05/30/2001) gkh
70  *      switched from using spinlock to a semaphore, which fixes lots of problems.
71  *
72  * (05/28/2000) gkh
73  *      Added initial support for the Palm m500 and Palm m505 devices.
74  *
75  * (04/08/2001) gb
76  *      Identify version on module load.
77  *
78  * (01/21/2000) gkh
79  *      Added write_room and chars_in_buffer, as they were previously using the
80  *      generic driver versions which is all wrong now that we are using an urb
81  *      pool.  Thanks to Wolfgang Grandegger for pointing this out to me.
82  *      Removed count assignment in the write function, which was not needed anymore
83  *      either.  Thanks to Al Borchers for pointing this out.
84  *
85  * (12/12/2000) gkh
86  *      Moved MOD_DEC to end of visor_close to be nicer, as the final write 
87  *      message can sleep.
88  * 
89  * (11/12/2000) gkh
90  *      Fixed bug with data being dropped on the floor by forcing tty->low_latency
91  *      to be on.  Hopefully this fixes the OHCI issue!
92  *
93  * (11/01/2000) Adam J. Richter
94  *      usb_device_id table support
95  * 
96  * (10/05/2000) gkh
97  *      Fixed bug with urb->dev not being set properly, now that the usb
98  *      core needs it.
99  * 
100  * (09/11/2000) gkh
101  *      Got rid of always calling kmalloc for every urb we wrote out to the
102  *      device.
103  *      Added visor_read_callback so we can keep track of bytes in and out for
104  *      those people who like to know the speed of their device.
105  *      Removed DEBUG #ifdefs with call to usb_serial_debug_data
106  *
107  * (09/06/2000) gkh
108  *      Fixed oops in visor_exit.  Need to uncomment usb_unlink_urb call _after_
109  *      the host controller drivers set urb->dev = NULL when the urb is finished.
110  *
111  * (08/28/2000) gkh
112  *      Added locks for SMP safeness.
113  *
114  * (08/08/2000) gkh
115  *      Fixed endian problem in visor_startup.
116  *      Fixed MOD_INC and MOD_DEC logic and the ability to open a port more 
117  *      than once.
118  * 
119  * (07/23/2000) gkh
120  *      Added pool of write urbs to speed up transfers to the visor.
121  * 
122  * (07/19/2000) gkh
123  *      Added module_init and module_exit functions to handle the fact that this
124  *      driver is a loadable module now.
125  *
126  * (07/03/2000) gkh
127  *      Added visor_set_ioctl and visor_set_termios functions (they don't do much
128  *      of anything, but are good for debugging.)
129  * 
130  * (06/25/2000) gkh
131  *      Fixed bug in visor_unthrottle that should help with the disconnect in PPP
132  *      bug that people have been reporting.
133  *
134  * (06/23/2000) gkh
135  *      Cleaned up debugging statements in a quest to find UHCI timeout bug.
136  *
137  * (04/27/2000) Ryan VanderBijl
138  *      Fixed memory leak in visor_close
139  *
140  * (03/26/2000) gkh
141  *      Split driver up into device specific pieces.
142  * 
143  */
144
145 #include <linux/config.h>
146 #include <linux/kernel.h>
147 #include <linux/errno.h>
148 #include <linux/init.h>
149 #include <linux/slab.h>
150 #include <linux/tty.h>
151 #include <linux/tty_driver.h>
152 #include <linux/tty_flip.h>
153 #include <linux/module.h>
154 #include <linux/moduleparam.h>
155 #include <linux/spinlock.h>
156 #include <asm/uaccess.h>
157 #include <linux/usb.h>
158 #include "usb-serial.h"
159 #include "visor.h"
160
161 /*
162  * Version Information
163  */
164 #define DRIVER_VERSION "v2.1"
165 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
166 #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
167
168 /* function prototypes for a handspring visor */
169 static int  visor_open          (struct usb_serial_port *port, struct file *filp);
170 static void visor_close         (struct usb_serial_port *port, struct file *filp);
171 static int  visor_write         (struct usb_serial_port *port, const unsigned char *buf, int count);
172 static int  visor_write_room            (struct usb_serial_port *port);
173 static int  visor_chars_in_buffer       (struct usb_serial_port *port);
174 static void visor_throttle      (struct usb_serial_port *port);
175 static void visor_unthrottle    (struct usb_serial_port *port);
176 static int  visor_probe         (struct usb_serial *serial, const struct usb_device_id *id);
177 static int  visor_calc_num_ports(struct usb_serial *serial);
178 static void visor_shutdown      (struct usb_serial *serial);
179 static int  visor_ioctl         (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
180 static void visor_set_termios   (struct usb_serial_port *port, struct termios *old_termios);
181 static void visor_write_bulk_callback   (struct urb *urb, struct pt_regs *regs);
182 static void visor_read_bulk_callback    (struct urb *urb, struct pt_regs *regs);
183 static void visor_read_int_callback     (struct urb *urb, struct pt_regs *regs);
184 static int  clie_3_5_startup    (struct usb_serial *serial);
185 static int  treo_attach         (struct usb_serial *serial);
186 static int clie_5_attach (struct usb_serial *serial);
187 static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id);
188 static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id);
189
190 /* Parameters that may be passed into the module. */
191 static int debug;
192 static __u16 vendor;
193 static __u16 product;
194
195 static struct usb_device_id id_table [] = {
196         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID),
197                 .driver_info = (kernel_ulong_t)&palm_os_3_probe },
198         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO_ID),
199                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
200         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO600_ID),
201                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
202         { USB_DEVICE(PALM_VENDOR_ID, PALM_M500_ID),
203                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
204         { USB_DEVICE(PALM_VENDOR_ID, PALM_M505_ID),
205                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
206         { USB_DEVICE(PALM_VENDOR_ID, PALM_M515_ID),
207                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
208         { USB_DEVICE(PALM_VENDOR_ID, PALM_I705_ID),
209                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
210         { USB_DEVICE(PALM_VENDOR_ID, PALM_M100_ID),
211                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
212         { USB_DEVICE(PALM_VENDOR_ID, PALM_M125_ID),
213                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
214         { USB_DEVICE(PALM_VENDOR_ID, PALM_M130_ID),
215                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
216         { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID),
217                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
218         { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650),
219                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
220         { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID),
221                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
222         { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID),
223                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
224         { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID),
225                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
226         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_0_ID),
227                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
228         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_S360_ID),
229                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
230         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID),
231                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
232         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID),
233                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
234         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID),
235                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
236         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID),
237                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
238         { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 
239                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
240         { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 
241                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
242         { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID),
243                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
244         { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 
245                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
246         { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID),
247                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
248         { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_7135_ID),
249                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
250         { USB_DEVICE(FOSSIL_VENDOR_ID, FOSSIL_ABACUS_ID),
251                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
252         { },                                    /* optional parameter entry */
253         { }                                     /* Terminating entry */
254 };
255
256 static struct usb_device_id clie_id_5_table [] = {
257         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_UX50_ID),
258                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
259         { },                                    /* optional parameter entry */
260         { }                                     /* Terminating entry */
261 };
262
263 static struct usb_device_id clie_id_3_5_table [] = {
264         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_3_5_ID) },
265         { }                                     /* Terminating entry */
266 };
267
268 static struct usb_device_id id_table_combined [] = {
269         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID) },
270         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO_ID) },
271         { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_TREO600_ID) },
272         { USB_DEVICE(PALM_VENDOR_ID, PALM_M500_ID) },
273         { USB_DEVICE(PALM_VENDOR_ID, PALM_M505_ID) },
274         { USB_DEVICE(PALM_VENDOR_ID, PALM_M515_ID) },
275         { USB_DEVICE(PALM_VENDOR_ID, PALM_I705_ID) },
276         { USB_DEVICE(PALM_VENDOR_ID, PALM_M100_ID) },
277         { USB_DEVICE(PALM_VENDOR_ID, PALM_M125_ID) },
278         { USB_DEVICE(PALM_VENDOR_ID, PALM_M130_ID) },
279         { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_T_ID) },
280         { USB_DEVICE(PALM_VENDOR_ID, PALM_TREO_650) },
281         { USB_DEVICE(PALM_VENDOR_ID, PALM_TUNGSTEN_Z_ID) },
282         { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE31_ID) },
283         { USB_DEVICE(PALM_VENDOR_ID, PALM_ZIRE_ID) },
284         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_3_5_ID) },
285         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_0_ID) },
286         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_S360_ID) },
287         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
288         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID) },
289         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID) },
290         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_UX50_ID) },
291         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID) },
292         { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) },
293         { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID) },
294         { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID) },
295         { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) },
296         { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID) },
297         { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_7135_ID) },
298         { USB_DEVICE(FOSSIL_VENDOR_ID, FOSSIL_ABACUS_ID) },
299         { },                                    /* optional parameter entry */
300         { }                                     /* Terminating entry */
301 };
302
303 MODULE_DEVICE_TABLE (usb, id_table_combined);
304
305 static struct usb_driver visor_driver = {
306         .owner =        THIS_MODULE,
307         .name =         "visor",
308         .probe =        usb_serial_probe,
309         .disconnect =   usb_serial_disconnect,
310         .id_table =     id_table_combined,
311 };
312
313 /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
314 static struct usb_serial_driver handspring_device = {
315         .driver = {
316                 .owner =        THIS_MODULE,
317         },
318         .name =                 "Handspring Visor / Palm OS",
319         .short_name =           "visor",
320         .id_table =             id_table,
321         .num_interrupt_in =     NUM_DONT_CARE,
322         .num_bulk_in =          2,
323         .num_bulk_out =         2,
324         .num_ports =            2,
325         .open =                 visor_open,
326         .close =                visor_close,
327         .throttle =             visor_throttle,
328         .unthrottle =           visor_unthrottle,
329         .attach =               treo_attach,
330         .probe =                visor_probe,
331         .calc_num_ports =       visor_calc_num_ports,
332         .shutdown =             visor_shutdown,
333         .ioctl =                visor_ioctl,
334         .set_termios =          visor_set_termios,
335         .write =                visor_write,
336         .write_room =           visor_write_room,
337         .chars_in_buffer =      visor_chars_in_buffer,
338         .write_bulk_callback =  visor_write_bulk_callback,
339         .read_bulk_callback =   visor_read_bulk_callback,
340         .read_int_callback =    visor_read_int_callback,
341 };
342
343 /* All of the device info needed for the Clie UX50, TH55 Palm 5.0 devices */
344 static struct usb_serial_driver clie_5_device = {
345         .driver = {
346                 .owner =        THIS_MODULE,
347         },
348         .name =                 "Sony Clie 5.0",
349         .short_name =           "clie_5",
350         .id_table =             clie_id_5_table,
351         .num_interrupt_in =     NUM_DONT_CARE,
352         .num_bulk_in =          2,
353         .num_bulk_out =         2,
354         .num_ports =            2,
355         .open =                 visor_open,
356         .close =                visor_close,
357         .throttle =             visor_throttle,
358         .unthrottle =           visor_unthrottle,
359         .attach =               clie_5_attach,
360         .probe =                visor_probe,
361         .calc_num_ports =       visor_calc_num_ports,
362         .shutdown =             visor_shutdown,
363         .ioctl =                visor_ioctl,
364         .set_termios =          visor_set_termios,
365         .write =                visor_write,
366         .write_room =           visor_write_room,
367         .chars_in_buffer =      visor_chars_in_buffer,
368         .write_bulk_callback =  visor_write_bulk_callback,
369         .read_bulk_callback =   visor_read_bulk_callback,
370         .read_int_callback =    visor_read_int_callback,
371 };
372
373 /* device info for the Sony Clie OS version 3.5 */
374 static struct usb_serial_driver clie_3_5_device = {
375         .driver = {
376                 .owner =        THIS_MODULE,
377         },
378         .name =                 "Sony Clie 3.5",
379         .short_name =           "clie_3.5",
380         .id_table =             clie_id_3_5_table,
381         .num_interrupt_in =     0,
382         .num_bulk_in =          1,
383         .num_bulk_out =         1,
384         .num_ports =            1,
385         .open =                 visor_open,
386         .close =                visor_close,
387         .throttle =             visor_throttle,
388         .unthrottle =           visor_unthrottle,
389         .attach =               clie_3_5_startup,
390         .ioctl =                visor_ioctl,
391         .set_termios =          visor_set_termios,
392         .write =                visor_write,
393         .write_room =           visor_write_room,
394         .chars_in_buffer =      visor_chars_in_buffer,
395         .write_bulk_callback =  visor_write_bulk_callback,
396         .read_bulk_callback =   visor_read_bulk_callback,
397 };
398
399 struct visor_private {
400         spinlock_t lock;
401         int bytes_in;
402         int bytes_out;
403         int outstanding_urbs;
404         int throttled;
405 };
406
407 /* number of outstanding urbs to prevent userspace DoS from happening */
408 #define URB_UPPER_LIMIT 42
409
410 static int stats;
411
412 /******************************************************************************
413  * Handspring Visor specific driver functions
414  ******************************************************************************/
415 static int visor_open (struct usb_serial_port *port, struct file *filp)
416 {
417         struct usb_serial *serial = port->serial;
418         struct visor_private *priv = usb_get_serial_port_data(port);
419         unsigned long flags;
420         int result = 0;
421
422         dbg("%s - port %d", __FUNCTION__, port->number);
423
424         if (!port->read_urb) {
425                 /* this is needed for some brain dead Sony devices */
426                 dev_err(&port->dev, "Device lied about number of ports, please use a lower one.\n");
427                 return -ENODEV;
428         }
429
430         spin_lock_irqsave(&priv->lock, flags);
431         priv->bytes_in = 0;
432         priv->bytes_out = 0;
433         priv->outstanding_urbs = 0;
434         priv->throttled = 0;
435         spin_unlock_irqrestore(&priv->lock, flags);
436
437         /*
438          * Force low_latency on so that our tty_push actually forces the data
439          * through, otherwise it is scheduled, and with high data rates (like
440          * with OHCI) data can get lost.
441          */
442         if (port->tty)
443                 port->tty->low_latency = 1;
444
445         /* Start reading from the device */
446         usb_fill_bulk_urb (port->read_urb, serial->dev,
447                            usb_rcvbulkpipe (serial->dev, 
448                                             port->bulk_in_endpointAddress),
449                            port->read_urb->transfer_buffer,
450                            port->read_urb->transfer_buffer_length,
451                            visor_read_bulk_callback, port);
452         result = usb_submit_urb(port->read_urb, GFP_KERNEL);
453         if (result) {
454                 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n",
455                         __FUNCTION__, result);
456                 goto exit;
457         }
458         
459         if (port->interrupt_in_urb) {
460                 dbg("%s - adding interrupt input for treo", __FUNCTION__);
461                 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
462                 if (result)
463                         dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n",
464                                 __FUNCTION__, result);
465         }
466 exit:   
467         return result;
468 }
469
470
471 static void visor_close (struct usb_serial_port *port, struct file * filp)
472 {
473         struct visor_private *priv = usb_get_serial_port_data(port);
474         unsigned char *transfer_buffer;
475
476         dbg("%s - port %d", __FUNCTION__, port->number);
477                          
478         /* shutdown our urbs */
479         usb_kill_urb(port->read_urb);
480         if (port->interrupt_in_urb)
481                 usb_kill_urb(port->interrupt_in_urb);
482
483         /* Try to send shutdown message, if the device is gone, this will just fail. */
484         transfer_buffer =  kmalloc (0x12, GFP_KERNEL);
485         if (transfer_buffer) {
486                 usb_control_msg (port->serial->dev,
487                                  usb_rcvctrlpipe(port->serial->dev, 0),
488                                  VISOR_CLOSE_NOTIFICATION, 0xc2,
489                                  0x0000, 0x0000, 
490                                  transfer_buffer, 0x12, 300);
491                 kfree (transfer_buffer);
492         }
493
494         if (stats)
495                 dev_info(&port->dev, "Bytes In = %d  Bytes Out = %d\n",
496                          priv->bytes_in, priv->bytes_out);
497 }
498
499
500 static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count)
501 {
502         struct visor_private *priv = usb_get_serial_port_data(port);
503         struct usb_serial *serial = port->serial;
504         struct urb *urb;
505         unsigned char *buffer;
506         unsigned long flags;
507         int status;
508
509         dbg("%s - port %d", __FUNCTION__, port->number);
510
511         spin_lock_irqsave(&priv->lock, flags);
512         if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
513                 spin_unlock_irqrestore(&priv->lock, flags);
514                 dbg("%s - write limit hit\n", __FUNCTION__);
515                 return 0;
516         }
517         spin_unlock_irqrestore(&priv->lock, flags);
518
519         buffer = kmalloc (count, GFP_ATOMIC);
520         if (!buffer) {
521                 dev_err(&port->dev, "out of memory\n");
522                 return -ENOMEM;
523         }
524
525         urb = usb_alloc_urb(0, GFP_ATOMIC);
526         if (!urb) {
527                 dev_err(&port->dev, "no more free urbs\n");
528                 kfree (buffer);
529                 return -ENOMEM;
530         }
531
532         memcpy (buffer, buf, count);
533
534         usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer);
535
536         usb_fill_bulk_urb (urb, serial->dev,
537                            usb_sndbulkpipe (serial->dev,
538                                             port->bulk_out_endpointAddress),
539                            buffer, count, 
540                            visor_write_bulk_callback, port);
541
542         /* send it down the pipe */
543         status = usb_submit_urb(urb, GFP_ATOMIC);
544         if (status) {
545                 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
546                         __FUNCTION__, status);
547                 count = status;
548                 kfree (buffer);
549         } else {
550                 spin_lock_irqsave(&priv->lock, flags);
551                 ++priv->outstanding_urbs;
552                 priv->bytes_out += count;
553                 spin_unlock_irqrestore(&priv->lock, flags);
554         }
555
556         /* we are done with this urb, so let the host driver
557          * really free it when it is finished with it */
558         usb_free_urb (urb);
559
560         return count;
561 }
562
563
564 static int visor_write_room (struct usb_serial_port *port)
565 {
566         dbg("%s - port %d", __FUNCTION__, port->number);
567
568         /*
569          * We really can take anything the user throws at us
570          * but let's pick a nice big number to tell the tty
571          * layer that we have lots of free space
572          */
573         return 2048;
574 }
575
576
577 static int visor_chars_in_buffer (struct usb_serial_port *port)
578 {
579         dbg("%s - port %d", __FUNCTION__, port->number);
580
581         /* 
582          * We can't really account for how much data we
583          * have sent out, but hasn't made it through to the
584          * device, so just tell the tty layer that everything
585          * is flushed.
586          */
587         return 0;
588 }
589
590
591 static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
592 {
593         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
594         struct visor_private *priv = usb_get_serial_port_data(port);
595         unsigned long flags;
596
597         /* free up the transfer buffer, as usb_free_urb() does not do this */
598         kfree (urb->transfer_buffer);
599
600         dbg("%s - port %d", __FUNCTION__, port->number);
601         
602         if (urb->status)
603                 dbg("%s - nonzero write bulk status received: %d",
604                     __FUNCTION__, urb->status);
605
606         spin_lock_irqsave(&priv->lock, flags);
607         --priv->outstanding_urbs;
608         spin_unlock_irqrestore(&priv->lock, flags);
609
610         schedule_work(&port->work);
611 }
612
613
614 static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
615 {
616         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
617         struct visor_private *priv = usb_get_serial_port_data(port);
618         unsigned char *data = urb->transfer_buffer;
619         struct tty_struct *tty;
620         unsigned long flags;
621         int i;
622         int throttled;
623         int result;
624
625         dbg("%s - port %d", __FUNCTION__, port->number);
626
627         if (urb->status) {
628                 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
629                 return;
630         }
631
632         usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
633
634         tty = port->tty;
635         if (tty && urb->actual_length) {
636                 for (i = 0; i < urb->actual_length ; ++i) {
637                         /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
638                         if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
639                                 tty_flip_buffer_push(tty);
640                         }
641                         /* this doesn't actually push the data through unless tty->low_latency is set */
642                         tty_insert_flip_char(tty, data[i], 0);
643                 }
644                 tty_flip_buffer_push(tty);
645         }
646         spin_lock_irqsave(&priv->lock, flags);
647         priv->bytes_in += urb->actual_length;
648         throttled = priv->throttled;
649         spin_unlock_irqrestore(&priv->lock, flags);
650
651         /* Continue trying to always read if we should */
652         if (!throttled) {
653                 usb_fill_bulk_urb (port->read_urb, port->serial->dev,
654                                    usb_rcvbulkpipe(port->serial->dev,
655                                                    port->bulk_in_endpointAddress),
656                                    port->read_urb->transfer_buffer,
657                                    port->read_urb->transfer_buffer_length,
658                                    visor_read_bulk_callback, port);
659                 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
660                 if (result)
661                         dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
662         }
663         return;
664 }
665
666 static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs)
667 {
668         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
669         int result;
670
671         switch (urb->status) {
672         case 0:
673                 /* success */
674                 break;
675         case -ECONNRESET:
676         case -ENOENT:
677         case -ESHUTDOWN:
678                 /* this urb is terminated, clean up */
679                 dbg("%s - urb shutting down with status: %d",
680                     __FUNCTION__, urb->status);
681                 return;
682         default:
683                 dbg("%s - nonzero urb status received: %d",
684                     __FUNCTION__, urb->status);
685                 goto exit;
686         }
687
688         /*
689          * This information is still unknown what it can be used for.
690          * If anyone has an idea, please let the author know...
691          *
692          * Rumor has it this endpoint is used to notify when data
693          * is ready to be read from the bulk ones.
694          */
695         usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
696                               urb->actual_length, urb->transfer_buffer);
697
698 exit:
699         result = usb_submit_urb (urb, GFP_ATOMIC);
700         if (result)
701                 dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
702                         __FUNCTION__, result);
703 }
704
705 static void visor_throttle (struct usb_serial_port *port)
706 {
707         struct visor_private *priv = usb_get_serial_port_data(port);
708         unsigned long flags;
709
710         dbg("%s - port %d", __FUNCTION__, port->number);
711         spin_lock_irqsave(&priv->lock, flags);
712         priv->throttled = 1;
713         spin_unlock_irqrestore(&priv->lock, flags);
714 }
715
716
717 static void visor_unthrottle (struct usb_serial_port *port)
718 {
719         struct visor_private *priv = usb_get_serial_port_data(port);
720         unsigned long flags;
721         int result;
722
723         dbg("%s - port %d", __FUNCTION__, port->number);
724         spin_lock_irqsave(&priv->lock, flags);
725         priv->throttled = 0;
726         spin_unlock_irqrestore(&priv->lock, flags);
727
728         port->read_urb->dev = port->serial->dev;
729         result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
730         if (result)
731                 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
732 }
733
734 static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id)
735 {
736         struct device *dev = &serial->dev->dev;
737         struct visor_connection_info *connection_info;
738         unsigned char *transfer_buffer;
739         char *string;
740         int retval = 0;
741         int i;
742         int num_ports = 0;
743
744         dbg("%s", __FUNCTION__);
745
746         transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
747         if (!transfer_buffer) {
748                 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
749                         sizeof(*connection_info));
750                 return -ENOMEM;
751         }
752
753         /* send a get connection info request */
754         retval = usb_control_msg (serial->dev,
755                                   usb_rcvctrlpipe(serial->dev, 0),
756                                   VISOR_GET_CONNECTION_INFORMATION,
757                                   0xc2, 0x0000, 0x0000, transfer_buffer,
758                                   sizeof(*connection_info), 300);
759         if (retval < 0) {
760                 dev_err(dev, "%s - error %d getting connection information\n",
761                         __FUNCTION__, retval);
762                 goto exit;
763         }
764
765         if (retval == sizeof(*connection_info)) {
766                 connection_info = (struct visor_connection_info *)transfer_buffer;
767
768                 num_ports = le16_to_cpu(connection_info->num_ports);
769                 for (i = 0; i < num_ports; ++i) {
770                         switch (connection_info->connections[i].port_function_id) {
771                                 case VISOR_FUNCTION_GENERIC:
772                                         string = "Generic";
773                                         break;
774                                 case VISOR_FUNCTION_DEBUGGER:
775                                         string = "Debugger";
776                                         break;
777                                 case VISOR_FUNCTION_HOTSYNC:
778                                         string = "HotSync";
779                                         break;
780                                 case VISOR_FUNCTION_CONSOLE:
781                                         string = "Console";
782                                         break;
783                                 case VISOR_FUNCTION_REMOTE_FILE_SYS:
784                                         string = "Remote File System";
785                                         break;
786                                 default:
787                                         string = "unknown";
788                                         break;
789                         }
790                         dev_info(dev, "%s: port %d, is for %s use\n",
791                                 serial->type->name,
792                                 connection_info->connections[i].port, string);
793                 }
794         }
795         /*
796         * Handle devices that report invalid stuff here.
797         */
798         if (num_ports == 0 || num_ports > 2) {
799                 dev_warn (dev, "%s: No valid connect info available\n",
800                         serial->type->name);
801                 num_ports = 2;
802         }
803   
804         dev_info(dev, "%s: Number of ports: %d\n", serial->type->name,
805                 num_ports);
806
807         /*
808          * save off our num_ports info so that we can use it in the
809          * calc_num_ports callback
810          */
811         usb_set_serial_data(serial, (void *)(long)num_ports);
812
813         /* ask for the number of bytes available, but ignore the response as it is broken */
814         retval = usb_control_msg (serial->dev,
815                                   usb_rcvctrlpipe(serial->dev, 0),
816                                   VISOR_REQUEST_BYTES_AVAILABLE,
817                                   0xc2, 0x0000, 0x0005, transfer_buffer,
818                                   0x02, 300);
819         if (retval < 0)
820                 dev_err(dev, "%s - error %d getting bytes available request\n",
821                         __FUNCTION__, retval);
822         retval = 0;
823
824 exit:
825         kfree (transfer_buffer);
826
827         return retval;
828 }
829
830 static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id)
831 {
832         struct device *dev = &serial->dev->dev;
833         struct palm_ext_connection_info *connection_info;
834         unsigned char *transfer_buffer;
835         int retval;
836
837         dbg("%s", __FUNCTION__);
838
839         transfer_buffer =  kmalloc (sizeof (*connection_info), GFP_KERNEL);
840         if (!transfer_buffer) {
841                 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
842                         sizeof(*connection_info));
843                 return -ENOMEM;
844         }
845
846         retval = usb_control_msg (serial->dev,
847                                   usb_rcvctrlpipe(serial->dev, 0), 
848                                   PALM_GET_EXT_CONNECTION_INFORMATION,
849                                   0xc2, 0x0000, 0x0000, transfer_buffer,
850                                   sizeof (*connection_info), 300);
851         if (retval < 0)
852                 dev_err(dev, "%s - error %d getting connection info\n",
853                         __FUNCTION__, retval);
854         else
855                 usb_serial_debug_data(debug, &serial->dev->dev, __FUNCTION__,
856                                       retval, transfer_buffer);
857
858         kfree (transfer_buffer);
859         return 0;
860 }
861
862
863 static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id)
864 {
865         int retval = 0;
866         int (*startup) (struct usb_serial *serial, const struct usb_device_id *id);
867
868         dbg("%s", __FUNCTION__);
869
870         if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
871                 err("active config #%d != 1 ??",
872                         serial->dev->actconfig->desc.bConfigurationValue);
873                 return -ENODEV;
874         }
875
876         if (id->driver_info) {
877                 startup = (void *)id->driver_info;
878                 retval = startup(serial, id);
879         }
880
881         return retval;
882 }
883
884 static int visor_calc_num_ports (struct usb_serial *serial)
885 {
886         int num_ports = (int)(long)(usb_get_serial_data(serial));
887
888         if (num_ports)
889                 usb_set_serial_data(serial, NULL);
890
891         return num_ports;
892 }
893
894 static int generic_startup(struct usb_serial *serial)
895 {
896         struct visor_private *priv;
897         int i;
898
899         for (i = 0; i < serial->num_ports; ++i) {
900                 priv = kmalloc (sizeof(*priv), GFP_KERNEL);
901                 if (!priv)
902                         return -ENOMEM;
903                 memset (priv, 0x00, sizeof(*priv));
904                 spin_lock_init(&priv->lock);
905                 usb_set_serial_port_data(serial->port[i], priv);
906         }
907         return 0;
908 }
909
910 static int clie_3_5_startup (struct usb_serial *serial)
911 {
912         struct device *dev = &serial->dev->dev;
913         int result;
914         u8 data;
915
916         dbg("%s", __FUNCTION__);
917
918         /*
919          * Note that PEG-300 series devices expect the following two calls.
920          */
921
922         /* get the config number */
923         result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
924                                   USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
925                                   0, 0, &data, 1, 3000);
926         if (result < 0) {
927                 dev_err(dev, "%s: get config number failed: %d\n", __FUNCTION__, result);
928                 return result;
929         }
930         if (result != 1) {
931                 dev_err(dev, "%s: get config number bad return length: %d\n", __FUNCTION__, result);
932                 return -EIO;
933         }
934
935         /* get the interface number */
936         result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
937                                   USB_REQ_GET_INTERFACE, 
938                                   USB_DIR_IN | USB_RECIP_INTERFACE,
939                                   0, 0, &data, 1, 3000);
940         if (result < 0) {
941                 dev_err(dev, "%s: get interface number failed: %d\n", __FUNCTION__, result);
942                 return result;
943         }
944         if (result != 1) {
945                 dev_err(dev, "%s: get interface number bad return length: %d\n", __FUNCTION__, result);
946                 return -EIO;
947         }
948
949         return generic_startup(serial);
950 }
951  
952 static int treo_attach (struct usb_serial *serial)
953 {
954         struct usb_serial_port *swap_port;
955
956         /* Only do this endpoint hack for the Handspring devices with
957          * interrupt in endpoints, which for now are the Treo devices. */
958         if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) ||
959               (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) ||
960             (serial->num_interrupt_in == 0))
961                 goto generic_startup;
962
963         dbg("%s", __FUNCTION__);
964
965         /*
966         * It appears that Treos and Kyoceras want to use the 
967         * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, 
968         * so let's swap the 1st and 2nd bulk in and interrupt endpoints.  
969         * Note that swapping the bulk out endpoints would break lots of 
970         * apps that want to communicate on the second port.
971         */
972 #define COPY_PORT(dest, src)                                            \
973         dest->read_urb = src->read_urb;                                 \
974         dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;   \
975         dest->bulk_in_buffer = src->bulk_in_buffer;                     \
976         dest->interrupt_in_urb = src->interrupt_in_urb;                 \
977         dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \
978         dest->interrupt_in_buffer = src->interrupt_in_buffer;
979
980         swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
981         if (!swap_port)
982                 return -ENOMEM;
983         COPY_PORT(swap_port, serial->port[0]);
984         COPY_PORT(serial->port[0], serial->port[1]);
985         COPY_PORT(serial->port[1], swap_port);
986         kfree(swap_port);
987
988 generic_startup:
989         return generic_startup(serial);
990 }
991
992 static int clie_5_attach (struct usb_serial *serial)
993 {
994         dbg("%s", __FUNCTION__);
995
996         /* TH55 registers 2 ports. 
997            Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 
998            Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1 
999            
1000            Lets do a quick and dirty mapping
1001          */
1002         
1003         /* some sanity check */
1004         if (serial->num_ports < 2)
1005                 return -1;
1006                 
1007         /* port 0 now uses the modified endpoint Address */
1008         serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress;
1009
1010         return generic_startup(serial);
1011 }
1012
1013 static void visor_shutdown (struct usb_serial *serial)
1014 {
1015         dbg("%s", __FUNCTION__);
1016 }
1017
1018 static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
1019 {
1020         dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
1021
1022         return -ENOIOCTLCMD;
1023 }
1024
1025
1026 /* This function is all nice and good, but we don't change anything based on it :) */
1027 static void visor_set_termios (struct usb_serial_port *port, struct termios *old_termios)
1028 {
1029         unsigned int cflag;
1030
1031         dbg("%s - port %d", __FUNCTION__, port->number);
1032
1033         if ((!port->tty) || (!port->tty->termios)) {
1034                 dbg("%s - no tty structures", __FUNCTION__);
1035                 return;
1036         }
1037
1038         cflag = port->tty->termios->c_cflag;
1039         /* check that they really want us to change something */
1040         if (old_termios) {
1041                 if ((cflag == old_termios->c_cflag) &&
1042                     (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
1043                         dbg("%s - nothing to change...", __FUNCTION__);
1044                         return;
1045                 }
1046         }
1047
1048         /* get the byte size */
1049         switch (cflag & CSIZE) {
1050                 case CS5:       dbg("%s - data bits = 5", __FUNCTION__);   break;
1051                 case CS6:       dbg("%s - data bits = 6", __FUNCTION__);   break;
1052                 case CS7:       dbg("%s - data bits = 7", __FUNCTION__);   break;
1053                 default:
1054                 case CS8:       dbg("%s - data bits = 8", __FUNCTION__);   break;
1055         }
1056         
1057         /* determine the parity */
1058         if (cflag & PARENB)
1059                 if (cflag & PARODD)
1060                         dbg("%s - parity = odd", __FUNCTION__);
1061                 else
1062                         dbg("%s - parity = even", __FUNCTION__);
1063         else
1064                 dbg("%s - parity = none", __FUNCTION__);
1065
1066         /* figure out the stop bits requested */
1067         if (cflag & CSTOPB)
1068                 dbg("%s - stop bits = 2", __FUNCTION__);
1069         else
1070                 dbg("%s - stop bits = 1", __FUNCTION__);
1071
1072         
1073         /* figure out the flow control settings */
1074         if (cflag & CRTSCTS)
1075                 dbg("%s - RTS/CTS is enabled", __FUNCTION__);
1076         else
1077                 dbg("%s - RTS/CTS is disabled", __FUNCTION__);
1078         
1079         /* determine software flow control */
1080         if (I_IXOFF(port->tty))
1081                 dbg("%s - XON/XOFF is enabled, XON = %2x, XOFF = %2x",
1082                     __FUNCTION__, START_CHAR(port->tty), STOP_CHAR(port->tty));
1083         else
1084                 dbg("%s - XON/XOFF is disabled", __FUNCTION__);
1085
1086         /* get the baud rate wanted */
1087         dbg("%s - baud rate = %d", __FUNCTION__, tty_get_baud_rate(port->tty));
1088
1089         return;
1090 }
1091
1092
1093 static int __init visor_init (void)
1094 {
1095         int i, retval;
1096         /* Only if parameters were passed to us */
1097         if ((vendor>0) && (product>0)) {
1098                 struct usb_device_id usb_dev_temp[]=
1099                         {{USB_DEVICE(vendor, product),
1100                         .driver_info = (kernel_ulong_t)&palm_os_4_probe }};
1101
1102                 /* Find the last entry in id_table */
1103                 for (i=0; ; i++) {
1104                         if (id_table[i].idVendor==0) {
1105                                 id_table[i] = usb_dev_temp[0];
1106                                 break;
1107                         }
1108                 }
1109                 /* Find the last entry in id_table_combined */
1110                 for (i=0; ; i++) {
1111                         if (id_table_combined[i].idVendor==0) {
1112                                 id_table_combined[i] = usb_dev_temp[0];
1113                                 break;
1114                         }
1115                 }
1116                 info("Untested USB device specified at time of module insertion");
1117                 info("Warning: This is not guaranteed to work");
1118                 info("Using a newer kernel is preferred to this method");
1119                 info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
1120                         vendor, product);
1121         }
1122         retval = usb_serial_register(&handspring_device);
1123         if (retval)
1124                 goto failed_handspring_register;
1125         retval = usb_serial_register(&clie_3_5_device);
1126         if (retval)
1127                 goto failed_clie_3_5_register;
1128         retval = usb_serial_register(&clie_5_device);
1129         if (retval)
1130                 goto failed_clie_5_register;
1131         retval = usb_register(&visor_driver);
1132         if (retval) 
1133                 goto failed_usb_register;
1134         info(DRIVER_DESC " " DRIVER_VERSION);
1135
1136         return 0;
1137 failed_usb_register:
1138         usb_serial_deregister(&clie_5_device);
1139 failed_clie_5_register:
1140         usb_serial_deregister(&clie_3_5_device);
1141 failed_clie_3_5_register:
1142         usb_serial_deregister(&handspring_device);
1143 failed_handspring_register:
1144         return retval;
1145 }
1146
1147
1148 static void __exit visor_exit (void)
1149 {
1150         usb_deregister (&visor_driver);
1151         usb_serial_deregister (&handspring_device);
1152         usb_serial_deregister (&clie_3_5_device);
1153         usb_serial_deregister (&clie_5_device);
1154 }
1155
1156
1157 module_init(visor_init);
1158 module_exit(visor_exit);
1159
1160 MODULE_AUTHOR( DRIVER_AUTHOR );
1161 MODULE_DESCRIPTION( DRIVER_DESC );
1162 MODULE_LICENSE("GPL");
1163
1164 module_param(debug, bool, S_IRUGO | S_IWUSR);
1165 MODULE_PARM_DESC(debug, "Debug enabled or not");
1166 module_param(stats, bool, S_IRUGO | S_IWUSR);
1167 MODULE_PARM_DESC(stats, "Enables statistics or not");
1168
1169 module_param(vendor, ushort, 0);
1170 MODULE_PARM_DESC(vendor, "User specified vendor ID");
1171 module_param(product, ushort, 0);
1172 MODULE_PARM_DESC(product, "User specified product ID");
1173