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