diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-23 13:10:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-23 13:10:23 -0400 |
commit | a4e0d9af403d099e751797f6cc69e4a8e2d78ef1 (patch) | |
tree | 6f4afdffe5dbaad7529be987b8c3259a07395031 /drivers/usb/serial/kl5kusb105.c | |
parent | c60f2b5c1defb6b1345968e1c65c2008c221d57d (diff) | |
parent | c010b2f76c3032e48097a6eef291d8593d5d79a6 (diff) |
Merge ../linux-2.6
Diffstat (limited to 'drivers/usb/serial/kl5kusb105.c')
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 417 |
1 files changed, 208 insertions, 209 deletions
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index f328948d74e3..b84dddc71124 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -15,12 +15,12 @@ | |||
15 | * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided | 15 | * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided |
16 | * information that was not already available. | 16 | * information that was not already available. |
17 | * | 17 | * |
18 | * It seems that KLSI bought some silicon-design information from ScanLogic, | 18 | * It seems that KLSI bought some silicon-design information from ScanLogic, |
19 | * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. | 19 | * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI. |
20 | * KLSI has firmware available for their devices; it is probable that the | 20 | * KLSI has firmware available for their devices; it is probable that the |
21 | * firmware differs from that used by KLSI in their products. If you have an | 21 | * firmware differs from that used by KLSI in their products. If you have an |
22 | * original KLSI device and can provide some information on it, I would be | 22 | * original KLSI device and can provide some information on it, I would be |
23 | * most interested in adding support for it here. If you have any information | 23 | * most interested in adding support for it here. If you have any information |
24 | * on the protocol used (or find errors in my reverse-engineered stuff), please | 24 | * on the protocol used (or find errors in my reverse-engineered stuff), please |
25 | * let me know. | 25 | * let me know. |
26 | * | 26 | * |
@@ -40,7 +40,7 @@ | |||
40 | * 0.2 - TIOCMGET works, so autopilot(1) can be used! | 40 | * 0.2 - TIOCMGET works, so autopilot(1) can be used! |
41 | * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l | 41 | * 0.1 - can be used to to pilot-xfer -p /dev/ttyUSB0 -l |
42 | * | 42 | * |
43 | * The driver skeleton is mainly based on mct_u232.c and various other | 43 | * The driver skeleton is mainly based on mct_u232.c and various other |
44 | * pieces of code shamelessly copied from the drivers/usb/serial/ directory. | 44 | * pieces of code shamelessly copied from the drivers/usb/serial/ directory. |
45 | */ | 45 | */ |
46 | 46 | ||
@@ -53,7 +53,7 @@ | |||
53 | #include <linux/tty_driver.h> | 53 | #include <linux/tty_driver.h> |
54 | #include <linux/tty_flip.h> | 54 | #include <linux/tty_flip.h> |
55 | #include <linux/module.h> | 55 | #include <linux/module.h> |
56 | #include <asm/uaccess.h> | 56 | #include <linux/uaccess.h> |
57 | #include <asm/unaligned.h> | 57 | #include <asm/unaligned.h> |
58 | #include <linux/usb.h> | 58 | #include <linux/usb.h> |
59 | #include <linux/usb/serial.h> | 59 | #include <linux/usb/serial.h> |
@@ -72,33 +72,25 @@ static int debug; | |||
72 | /* | 72 | /* |
73 | * Function prototypes | 73 | * Function prototypes |
74 | */ | 74 | */ |
75 | static int klsi_105_startup (struct usb_serial *serial); | 75 | static int klsi_105_startup(struct usb_serial *serial); |
76 | static void klsi_105_shutdown (struct usb_serial *serial); | 76 | static void klsi_105_shutdown(struct usb_serial *serial); |
77 | static int klsi_105_open (struct usb_serial_port *port, | 77 | static int klsi_105_open(struct tty_struct *tty, |
78 | struct file *filp); | 78 | struct usb_serial_port *port, struct file *filp); |
79 | static void klsi_105_close (struct usb_serial_port *port, | 79 | static void klsi_105_close(struct tty_struct *tty, |
80 | struct file *filp); | 80 | struct usb_serial_port *port, struct file *filp); |
81 | static int klsi_105_write (struct usb_serial_port *port, | 81 | static int klsi_105_write(struct tty_struct *tty, |
82 | const unsigned char *buf, | 82 | struct usb_serial_port *port, const unsigned char *buf, int count); |
83 | int count); | 83 | static void klsi_105_write_bulk_callback(struct urb *urb); |
84 | static void klsi_105_write_bulk_callback (struct urb *urb); | 84 | static int klsi_105_chars_in_buffer(struct tty_struct *tty); |
85 | static int klsi_105_chars_in_buffer (struct usb_serial_port *port); | 85 | static int klsi_105_write_room(struct tty_struct *tty); |
86 | static int klsi_105_write_room (struct usb_serial_port *port); | 86 | static void klsi_105_read_bulk_callback(struct urb *urb); |
87 | 87 | static void klsi_105_set_termios(struct tty_struct *tty, | |
88 | static void klsi_105_read_bulk_callback (struct urb *urb); | 88 | struct usb_serial_port *port, struct ktermios *old); |
89 | static void klsi_105_set_termios (struct usb_serial_port *port, | 89 | static void klsi_105_throttle(struct tty_struct *tty); |
90 | struct ktermios *old); | 90 | static void klsi_105_unthrottle(struct tty_struct *tty); |
91 | static void klsi_105_throttle (struct usb_serial_port *port); | 91 | static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file); |
92 | static void klsi_105_unthrottle (struct usb_serial_port *port); | 92 | static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, |
93 | /* | 93 | unsigned int set, unsigned int clear); |
94 | static void klsi_105_break_ctl (struct usb_serial_port *port, | ||
95 | int break_state ); | ||
96 | */ | ||
97 | static int klsi_105_tiocmget (struct usb_serial_port *port, | ||
98 | struct file *file); | ||
99 | static int klsi_105_tiocmset (struct usb_serial_port *port, | ||
100 | struct file *file, unsigned int set, | ||
101 | unsigned int clear); | ||
102 | 94 | ||
103 | /* | 95 | /* |
104 | * All of the device info needed for the KLSI converters. | 96 | * All of the device info needed for the KLSI converters. |
@@ -109,7 +101,7 @@ static struct usb_device_id id_table [] = { | |||
109 | { } /* Terminating entry */ | 101 | { } /* Terminating entry */ |
110 | }; | 102 | }; |
111 | 103 | ||
112 | MODULE_DEVICE_TABLE (usb, id_table); | 104 | MODULE_DEVICE_TABLE(usb, id_table); |
113 | 105 | ||
114 | static struct usb_driver kl5kusb105d_driver = { | 106 | static struct usb_driver kl5kusb105d_driver = { |
115 | .name = "kl5kusb105d", | 107 | .name = "kl5kusb105d", |
@@ -134,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
134 | .write_bulk_callback = klsi_105_write_bulk_callback, | 126 | .write_bulk_callback = klsi_105_write_bulk_callback, |
135 | .chars_in_buffer = klsi_105_chars_in_buffer, | 127 | .chars_in_buffer = klsi_105_chars_in_buffer, |
136 | .write_room = klsi_105_write_room, | 128 | .write_room = klsi_105_write_room, |
137 | .read_bulk_callback =klsi_105_read_bulk_callback, | 129 | .read_bulk_callback = klsi_105_read_bulk_callback, |
138 | .set_termios = klsi_105_set_termios, | 130 | .set_termios = klsi_105_set_termios, |
139 | /*.break_ctl = klsi_105_break_ctl,*/ | 131 | /*.break_ctl = klsi_105_break_ctl,*/ |
140 | .tiocmget = klsi_105_tiocmget, | 132 | .tiocmget = klsi_105_tiocmget, |
@@ -161,7 +153,7 @@ struct klsi_105_private { | |||
161 | struct ktermios termios; | 153 | struct ktermios termios; |
162 | unsigned long line_state; /* modem line settings */ | 154 | unsigned long line_state; /* modem line settings */ |
163 | /* write pool */ | 155 | /* write pool */ |
164 | struct urb * write_urb_pool[NUM_URBS]; | 156 | struct urb *write_urb_pool[NUM_URBS]; |
165 | spinlock_t lock; | 157 | spinlock_t lock; |
166 | unsigned long bytes_in; | 158 | unsigned long bytes_in; |
167 | unsigned long bytes_out; | 159 | unsigned long bytes_out; |
@@ -180,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
180 | { | 172 | { |
181 | int rc; | 173 | int rc; |
182 | 174 | ||
183 | rc = usb_control_msg(port->serial->dev, | 175 | rc = usb_control_msg(port->serial->dev, |
184 | usb_sndctrlpipe(port->serial->dev, 0), | 176 | usb_sndctrlpipe(port->serial->dev, 0), |
185 | KL5KUSB105A_SIO_SET_DATA, | 177 | KL5KUSB105A_SIO_SET_DATA, |
186 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, | 178 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, |
187 | 0, /* value */ | 179 | 0, /* value */ |
188 | 0, /* index */ | 180 | 0, /* index */ |
189 | settings, | 181 | settings, |
190 | sizeof(struct klsi_105_port_settings), | 182 | sizeof(struct klsi_105_port_settings), |
191 | KLSI_TIMEOUT); | 183 | KLSI_TIMEOUT); |
192 | if (rc < 0) | 184 | if (rc < 0) |
193 | err("Change port settings failed (error = %d)", rc); | 185 | err("Change port settings failed (error = %d)", rc); |
194 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", | 186 | info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d", |
@@ -196,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, | |||
196 | settings->pktlen, | 188 | settings->pktlen, |
197 | settings->baudrate, settings->databits, | 189 | settings->baudrate, settings->databits, |
198 | settings->unknown1, settings->unknown2); | 190 | settings->unknown1, settings->unknown2); |
199 | return rc; | 191 | return rc; |
200 | } /* klsi_105_chg_port_settings */ | 192 | } /* klsi_105_chg_port_settings */ |
201 | 193 | ||
202 | /* translate a 16-bit status value from the device to linux's TIO bits */ | 194 | /* translate a 16-bit status value from the device to linux's TIO bits */ |
@@ -210,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status) | |||
210 | 202 | ||
211 | return res; | 203 | return res; |
212 | } | 204 | } |
213 | /* | 205 | /* |
214 | * Read line control via vendor command and return result through | 206 | * Read line control via vendor command and return result through |
215 | * *line_state_p | 207 | * *line_state_p |
216 | */ | 208 | */ |
217 | /* It seems that the status buffer has always only 2 bytes length */ | 209 | /* It seems that the status buffer has always only 2 bytes length */ |
218 | #define KLSI_STATUSBUF_LEN 2 | 210 | #define KLSI_STATUSBUF_LEN 2 |
@@ -220,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
220 | unsigned long *line_state_p) | 212 | unsigned long *line_state_p) |
221 | { | 213 | { |
222 | int rc; | 214 | int rc; |
223 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1}; | 215 | __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1}; |
224 | __u16 status; | 216 | __u16 status; |
225 | 217 | ||
226 | info("%s - sending SIO Poll request", __func__); | 218 | info("%s - sending SIO Poll request", __func__); |
227 | rc = usb_control_msg(port->serial->dev, | 219 | rc = usb_control_msg(port->serial->dev, |
228 | usb_rcvctrlpipe(port->serial->dev, 0), | 220 | usb_rcvctrlpipe(port->serial->dev, 0), |
229 | KL5KUSB105A_SIO_POLL, | 221 | KL5KUSB105A_SIO_POLL, |
230 | USB_TYPE_VENDOR | USB_DIR_IN, | 222 | USB_TYPE_VENDOR | USB_DIR_IN, |
231 | 0, /* value */ | 223 | 0, /* value */ |
232 | 0, /* index */ | 224 | 0, /* index */ |
233 | status_buf, KLSI_STATUSBUF_LEN, | 225 | status_buf, KLSI_STATUSBUF_LEN, |
@@ -236,15 +228,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
236 | if (rc < 0) | 228 | if (rc < 0) |
237 | err("Reading line status failed (error = %d)", rc); | 229 | err("Reading line status failed (error = %d)", rc); |
238 | else { | 230 | else { |
239 | status = le16_to_cpu(get_unaligned((__le16 *)status_buf)); | 231 | status = get_unaligned_le16(status_buf); |
240 | 232 | ||
241 | info("%s - read status %x %x", __func__, | 233 | info("%s - read status %x %x", __func__, |
242 | status_buf[0], status_buf[1]); | 234 | status_buf[0], status_buf[1]); |
243 | 235 | ||
244 | *line_state_p = klsi_105_status2linestate(status); | 236 | *line_state_p = klsi_105_status2linestate(status); |
245 | } | 237 | } |
246 | 238 | return rc; | |
247 | return rc; | ||
248 | } | 239 | } |
249 | 240 | ||
250 | 241 | ||
@@ -252,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, | |||
252 | * Driver's tty interface functions | 243 | * Driver's tty interface functions |
253 | */ | 244 | */ |
254 | 245 | ||
255 | static int klsi_105_startup (struct usb_serial *serial) | 246 | static int klsi_105_startup(struct usb_serial *serial) |
256 | { | 247 | { |
257 | struct klsi_105_private *priv; | 248 | struct klsi_105_private *priv; |
258 | int i, j; | 249 | int i, j; |
@@ -262,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
262 | */ | 253 | */ |
263 | 254 | ||
264 | /* allocate the private data structure */ | 255 | /* allocate the private data structure */ |
265 | for (i=0; i<serial->num_ports; i++) { | 256 | for (i = 0; i < serial->num_ports; i++) { |
266 | priv = kmalloc(sizeof(struct klsi_105_private), | 257 | priv = kmalloc(sizeof(struct klsi_105_private), |
267 | GFP_KERNEL); | 258 | GFP_KERNEL); |
268 | if (!priv) { | 259 | if (!priv) { |
@@ -283,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
283 | priv->bytes_out = 0; | 274 | priv->bytes_out = 0; |
284 | usb_set_serial_port_data(serial->port[i], priv); | 275 | usb_set_serial_port_data(serial->port[i], priv); |
285 | 276 | ||
286 | spin_lock_init (&priv->lock); | 277 | spin_lock_init(&priv->lock); |
287 | for (j=0; j<NUM_URBS; j++) { | 278 | for (j = 0; j < NUM_URBS; j++) { |
288 | struct urb* urb = usb_alloc_urb(0, GFP_KERNEL); | 279 | struct urb *urb = usb_alloc_urb(0, GFP_KERNEL); |
289 | 280 | ||
290 | priv->write_urb_pool[j] = urb; | 281 | priv->write_urb_pool[j] = urb; |
291 | if (urb == NULL) { | 282 | if (urb == NULL) { |
@@ -293,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
293 | goto err_cleanup; | 284 | goto err_cleanup; |
294 | } | 285 | } |
295 | 286 | ||
296 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, | 287 | urb->transfer_buffer = |
297 | GFP_KERNEL); | 288 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
298 | if (!urb->transfer_buffer) { | 289 | if (!urb->transfer_buffer) { |
299 | err("%s - out of memory for urb buffers.", __func__); | 290 | err("%s - out of memory for urb buffers.", |
291 | __func__); | ||
300 | goto err_cleanup; | 292 | goto err_cleanup; |
301 | } | 293 | } |
302 | } | 294 | } |
@@ -304,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial) | |||
304 | /* priv->termios is left uninitalized until port opening */ | 296 | /* priv->termios is left uninitalized until port opening */ |
305 | init_waitqueue_head(&serial->port[i]->write_wait); | 297 | init_waitqueue_head(&serial->port[i]->write_wait); |
306 | } | 298 | } |
307 | 299 | ||
308 | return 0; | 300 | return 0; |
309 | 301 | ||
310 | err_cleanup: | 302 | err_cleanup: |
311 | for (; i >= 0; i--) { | 303 | for (; i >= 0; i--) { |
312 | priv = usb_get_serial_port_data(serial->port[i]); | 304 | priv = usb_get_serial_port_data(serial->port[i]); |
313 | for (j=0; j < NUM_URBS; j++) { | 305 | for (j = 0; j < NUM_URBS; j++) { |
314 | if (priv->write_urb_pool[j]) { | 306 | if (priv->write_urb_pool[j]) { |
315 | kfree(priv->write_urb_pool[j]->transfer_buffer); | 307 | kfree(priv->write_urb_pool[j]->transfer_buffer); |
316 | usb_free_urb(priv->write_urb_pool[j]); | 308 | usb_free_urb(priv->write_urb_pool[j]); |
@@ -322,22 +314,23 @@ err_cleanup: | |||
322 | } /* klsi_105_startup */ | 314 | } /* klsi_105_startup */ |
323 | 315 | ||
324 | 316 | ||
325 | static void klsi_105_shutdown (struct usb_serial *serial) | 317 | static void klsi_105_shutdown(struct usb_serial *serial) |
326 | { | 318 | { |
327 | int i; | 319 | int i; |
328 | 320 | ||
329 | dbg("%s", __func__); | 321 | dbg("%s", __func__); |
330 | 322 | ||
331 | /* stop reads and writes on all ports */ | 323 | /* stop reads and writes on all ports */ |
332 | for (i=0; i < serial->num_ports; ++i) { | 324 | for (i = 0; i < serial->num_ports; ++i) { |
333 | struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]); | 325 | struct klsi_105_private *priv = |
326 | usb_get_serial_port_data(serial->port[i]); | ||
334 | unsigned long flags; | 327 | unsigned long flags; |
335 | 328 | ||
336 | if (priv) { | 329 | if (priv) { |
337 | /* kill our write urb pool */ | 330 | /* kill our write urb pool */ |
338 | int j; | 331 | int j; |
339 | struct urb **write_urbs = priv->write_urb_pool; | 332 | struct urb **write_urbs = priv->write_urb_pool; |
340 | spin_lock_irqsave(&priv->lock,flags); | 333 | spin_lock_irqsave(&priv->lock, flags); |
341 | 334 | ||
342 | for (j = 0; j < NUM_URBS; j++) { | 335 | for (j = 0; j < NUM_URBS; j++) { |
343 | if (write_urbs[j]) { | 336 | if (write_urbs[j]) { |
@@ -349,19 +342,18 @@ static void klsi_105_shutdown (struct usb_serial *serial) | |||
349 | * oopses. */ | 342 | * oopses. */ |
350 | /* usb_kill_urb(write_urbs[j]); */ | 343 | /* usb_kill_urb(write_urbs[j]); */ |
351 | kfree(write_urbs[j]->transfer_buffer); | 344 | kfree(write_urbs[j]->transfer_buffer); |
352 | usb_free_urb (write_urbs[j]); | 345 | usb_free_urb(write_urbs[j]); |
353 | } | 346 | } |
354 | } | 347 | } |
355 | 348 | spin_unlock_irqrestore(&priv->lock, flags); | |
356 | spin_unlock_irqrestore (&priv->lock, flags); | ||
357 | |||
358 | kfree(priv); | 349 | kfree(priv); |
359 | usb_set_serial_port_data(serial->port[i], NULL); | 350 | usb_set_serial_port_data(serial->port[i], NULL); |
360 | } | 351 | } |
361 | } | 352 | } |
362 | } /* klsi_105_shutdown */ | 353 | } /* klsi_105_shutdown */ |
363 | 354 | ||
364 | static int klsi_105_open (struct usb_serial_port *port, struct file *filp) | 355 | static int klsi_105_open(struct tty_struct *tty, |
356 | struct usb_serial_port *port, struct file *filp) | ||
365 | { | 357 | { |
366 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 358 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
367 | int retval = 0; | 359 | int retval = 0; |
@@ -375,11 +367,11 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) | |||
375 | 367 | ||
376 | /* force low_latency on so that our tty_push actually forces | 368 | /* force low_latency on so that our tty_push actually forces |
377 | * the data through | 369 | * the data through |
378 | * port->tty->low_latency = 1; */ | 370 | * tty->low_latency = 1; */ |
379 | 371 | ||
380 | /* Do a defined restart: | 372 | /* Do a defined restart: |
381 | * Set up sane default baud rate and send the 'READ_ON' | 373 | * Set up sane default baud rate and send the 'READ_ON' |
382 | * vendor command. | 374 | * vendor command. |
383 | * FIXME: set modem line control (how?) | 375 | * FIXME: set modem line control (how?) |
384 | * Then read the modem line control and store values in | 376 | * Then read the modem line control and store values in |
385 | * priv->line_state. | 377 | * priv->line_state. |
@@ -390,24 +382,24 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) | |||
390 | cfg.unknown1 = 0; | 382 | cfg.unknown1 = 0; |
391 | cfg.unknown2 = 1; | 383 | cfg.unknown2 = 1; |
392 | klsi_105_chg_port_settings(port, &cfg); | 384 | klsi_105_chg_port_settings(port, &cfg); |
393 | 385 | ||
394 | /* set up termios structure */ | 386 | /* set up termios structure */ |
395 | spin_lock_irqsave (&priv->lock, flags); | 387 | spin_lock_irqsave(&priv->lock, flags); |
396 | priv->termios.c_iflag = port->tty->termios->c_iflag; | 388 | priv->termios.c_iflag = tty->termios->c_iflag; |
397 | priv->termios.c_oflag = port->tty->termios->c_oflag; | 389 | priv->termios.c_oflag = tty->termios->c_oflag; |
398 | priv->termios.c_cflag = port->tty->termios->c_cflag; | 390 | priv->termios.c_cflag = tty->termios->c_cflag; |
399 | priv->termios.c_lflag = port->tty->termios->c_lflag; | 391 | priv->termios.c_lflag = tty->termios->c_lflag; |
400 | for (i=0; i<NCCS; i++) | 392 | for (i = 0; i < NCCS; i++) |
401 | priv->termios.c_cc[i] = port->tty->termios->c_cc[i]; | 393 | priv->termios.c_cc[i] = tty->termios->c_cc[i]; |
402 | priv->cfg.pktlen = cfg.pktlen; | 394 | priv->cfg.pktlen = cfg.pktlen; |
403 | priv->cfg.baudrate = cfg.baudrate; | 395 | priv->cfg.baudrate = cfg.baudrate; |
404 | priv->cfg.databits = cfg.databits; | 396 | priv->cfg.databits = cfg.databits; |
405 | priv->cfg.unknown1 = cfg.unknown1; | 397 | priv->cfg.unknown1 = cfg.unknown1; |
406 | priv->cfg.unknown2 = cfg.unknown2; | 398 | priv->cfg.unknown2 = cfg.unknown2; |
407 | spin_unlock_irqrestore (&priv->lock, flags); | 399 | spin_unlock_irqrestore(&priv->lock, flags); |
408 | 400 | ||
409 | /* READ_ON and urb submission */ | 401 | /* READ_ON and urb submission */ |
410 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 402 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
411 | usb_rcvbulkpipe(port->serial->dev, | 403 | usb_rcvbulkpipe(port->serial->dev, |
412 | port->bulk_in_endpointAddress), | 404 | port->bulk_in_endpointAddress), |
413 | port->read_urb->transfer_buffer, | 405 | port->read_urb->transfer_buffer, |
@@ -423,7 +415,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) | |||
423 | } | 415 | } |
424 | 416 | ||
425 | rc = usb_control_msg(port->serial->dev, | 417 | rc = usb_control_msg(port->serial->dev, |
426 | usb_sndctrlpipe(port->serial->dev,0), | 418 | usb_sndctrlpipe(port->serial->dev, 0), |
427 | KL5KUSB105A_SIO_CONFIGURE, | 419 | KL5KUSB105A_SIO_CONFIGURE, |
428 | USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, | 420 | USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, |
429 | KL5KUSB105A_SIO_CONFIGURE_READ_ON, | 421 | KL5KUSB105A_SIO_CONFIGURE_READ_ON, |
@@ -434,14 +426,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) | |||
434 | if (rc < 0) { | 426 | if (rc < 0) { |
435 | err("Enabling read failed (error = %d)", rc); | 427 | err("Enabling read failed (error = %d)", rc); |
436 | retval = rc; | 428 | retval = rc; |
437 | } else | 429 | } else |
438 | dbg("%s - enabled reading", __func__); | 430 | dbg("%s - enabled reading", __func__); |
439 | 431 | ||
440 | rc = klsi_105_get_line_state(port, &line_state); | 432 | rc = klsi_105_get_line_state(port, &line_state); |
441 | if (rc >= 0) { | 433 | if (rc >= 0) { |
442 | spin_lock_irqsave (&priv->lock, flags); | 434 | spin_lock_irqsave(&priv->lock, flags); |
443 | priv->line_state = line_state; | 435 | priv->line_state = line_state; |
444 | spin_unlock_irqrestore (&priv->lock, flags); | 436 | spin_unlock_irqrestore(&priv->lock, flags); |
445 | dbg("%s - read line state 0x%lx", __func__, line_state); | 437 | dbg("%s - read line state 0x%lx", __func__, line_state); |
446 | retval = 0; | 438 | retval = 0; |
447 | } else | 439 | } else |
@@ -452,7 +444,8 @@ exit: | |||
452 | } /* klsi_105_open */ | 444 | } /* klsi_105_open */ |
453 | 445 | ||
454 | 446 | ||
455 | static void klsi_105_close (struct usb_serial_port *port, struct file *filp) | 447 | static void klsi_105_close(struct tty_struct *tty, |
448 | struct usb_serial_port *port, struct file *filp) | ||
456 | { | 449 | { |
457 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 450 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
458 | int rc; | 451 | int rc; |
@@ -462,14 +455,14 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) | |||
462 | mutex_lock(&port->serial->disc_mutex); | 455 | mutex_lock(&port->serial->disc_mutex); |
463 | if (!port->serial->disconnected) { | 456 | if (!port->serial->disconnected) { |
464 | /* send READ_OFF */ | 457 | /* send READ_OFF */ |
465 | rc = usb_control_msg (port->serial->dev, | 458 | rc = usb_control_msg(port->serial->dev, |
466 | usb_sndctrlpipe(port->serial->dev, 0), | 459 | usb_sndctrlpipe(port->serial->dev, 0), |
467 | KL5KUSB105A_SIO_CONFIGURE, | 460 | KL5KUSB105A_SIO_CONFIGURE, |
468 | USB_TYPE_VENDOR | USB_DIR_OUT, | 461 | USB_TYPE_VENDOR | USB_DIR_OUT, |
469 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, | 462 | KL5KUSB105A_SIO_CONFIGURE_READ_OFF, |
470 | 0, /* index */ | 463 | 0, /* index */ |
471 | NULL, 0, | 464 | NULL, 0, |
472 | KLSI_TIMEOUT); | 465 | KLSI_TIMEOUT); |
473 | if (rc < 0) | 466 | if (rc < 0) |
474 | err("Disabling read failed (error = %d)", rc); | 467 | err("Disabling read failed (error = %d)", rc); |
475 | } | 468 | } |
@@ -482,23 +475,24 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) | |||
482 | /* FIXME */ | 475 | /* FIXME */ |
483 | /* wgg - do I need this? I think so. */ | 476 | /* wgg - do I need this? I think so. */ |
484 | usb_kill_urb(port->interrupt_in_urb); | 477 | usb_kill_urb(port->interrupt_in_urb); |
485 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out); | 478 | info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", |
479 | priv->bytes_in, priv->bytes_out); | ||
486 | } /* klsi_105_close */ | 480 | } /* klsi_105_close */ |
487 | 481 | ||
488 | 482 | ||
489 | /* We need to write a complete 64-byte data block and encode the | 483 | /* We need to write a complete 64-byte data block and encode the |
490 | * number actually sent in the first double-byte, LSB-order. That | 484 | * number actually sent in the first double-byte, LSB-order. That |
491 | * leaves at most 62 bytes of payload. | 485 | * leaves at most 62 bytes of payload. |
492 | */ | 486 | */ |
493 | #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ | 487 | #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ |
494 | 488 | ||
495 | 489 | ||
496 | static int klsi_105_write (struct usb_serial_port *port, | 490 | static int klsi_105_write(struct tty_struct *tty, |
497 | const unsigned char *buf, int count) | 491 | struct usb_serial_port *port, const unsigned char *buf, int count) |
498 | { | 492 | { |
499 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 493 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
500 | int result, size; | 494 | int result, size; |
501 | int bytes_sent=0; | 495 | int bytes_sent = 0; |
502 | 496 | ||
503 | dbg("%s - port %d", __func__, port->number); | 497 | dbg("%s - port %d", __func__, port->number); |
504 | 498 | ||
@@ -507,34 +501,37 @@ static int klsi_105_write (struct usb_serial_port *port, | |||
507 | struct urb *urb = NULL; | 501 | struct urb *urb = NULL; |
508 | unsigned long flags; | 502 | unsigned long flags; |
509 | int i; | 503 | int i; |
510 | /* since the pool is per-port we might not need the spin lock !? */ | 504 | /* since the pool is per-port we might not need |
511 | spin_lock_irqsave (&priv->lock, flags); | 505 | the spin lock !? */ |
512 | for (i=0; i<NUM_URBS; i++) { | 506 | spin_lock_irqsave(&priv->lock, flags); |
507 | for (i = 0; i < NUM_URBS; i++) { | ||
513 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { | 508 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { |
514 | urb = priv->write_urb_pool[i]; | 509 | urb = priv->write_urb_pool[i]; |
515 | dbg("%s - using pool URB %d", __func__, i); | 510 | dbg("%s - using pool URB %d", __func__, i); |
516 | break; | 511 | break; |
517 | } | 512 | } |
518 | } | 513 | } |
519 | spin_unlock_irqrestore (&priv->lock, flags); | 514 | spin_unlock_irqrestore(&priv->lock, flags); |
520 | 515 | ||
521 | if (urb==NULL) { | 516 | if (urb == NULL) { |
522 | dbg("%s - no more free urbs", __func__); | 517 | dbg("%s - no more free urbs", __func__); |
523 | goto exit; | 518 | goto exit; |
524 | } | 519 | } |
525 | 520 | ||
526 | if (urb->transfer_buffer == NULL) { | 521 | if (urb->transfer_buffer == NULL) { |
527 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | 522 | urb->transfer_buffer = |
523 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | ||
528 | if (urb->transfer_buffer == NULL) { | 524 | if (urb->transfer_buffer == NULL) { |
529 | err("%s - no more kernel memory...", __func__); | 525 | err("%s - no more kernel memory...", __func__); |
530 | goto exit; | 526 | goto exit; |
531 | } | 527 | } |
532 | } | 528 | } |
533 | 529 | ||
534 | size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET); | 530 | size = min(count, port->bulk_out_size - KLSI_105_DATA_OFFSET); |
535 | size = min (size, URB_TRANSFER_BUFFER_SIZE - KLSI_105_DATA_OFFSET); | 531 | size = min(size, URB_TRANSFER_BUFFER_SIZE - |
532 | KLSI_105_DATA_OFFSET); | ||
536 | 533 | ||
537 | memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); | 534 | memcpy(urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size); |
538 | 535 | ||
539 | /* write payload size into transfer buffer */ | 536 | /* write payload size into transfer buffer */ |
540 | ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF); | 537 | ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF); |
@@ -552,7 +549,8 @@ static int klsi_105_write (struct usb_serial_port *port, | |||
552 | /* send the data out the bulk port */ | 549 | /* send the data out the bulk port */ |
553 | result = usb_submit_urb(urb, GFP_ATOMIC); | 550 | result = usb_submit_urb(urb, GFP_ATOMIC); |
554 | if (result) { | 551 | if (result) { |
555 | err("%s - failed submitting write urb, error %d", __func__, result); | 552 | err("%s - failed submitting write urb, error %d", |
553 | __func__, result); | ||
556 | goto exit; | 554 | goto exit; |
557 | } | 555 | } |
558 | buf += size; | 556 | buf += size; |
@@ -561,12 +559,12 @@ static int klsi_105_write (struct usb_serial_port *port, | |||
561 | } | 559 | } |
562 | exit: | 560 | exit: |
563 | /* lockless, but it's for debug info only... */ | 561 | /* lockless, but it's for debug info only... */ |
564 | priv->bytes_out+=bytes_sent; | 562 | priv->bytes_out += bytes_sent; |
565 | 563 | ||
566 | return bytes_sent; /* that's how much we wrote */ | 564 | return bytes_sent; /* that's how much we wrote */ |
567 | } /* klsi_105_write */ | 565 | } /* klsi_105_write */ |
568 | 566 | ||
569 | static void klsi_105_write_bulk_callback ( struct urb *urb) | 567 | static void klsi_105_write_bulk_callback(struct urb *urb) |
570 | { | 568 | { |
571 | struct usb_serial_port *port = urb->context; | 569 | struct usb_serial_port *port = urb->context; |
572 | int status = urb->status; | 570 | int status = urb->status; |
@@ -584,50 +582,50 @@ static void klsi_105_write_bulk_callback ( struct urb *urb) | |||
584 | 582 | ||
585 | 583 | ||
586 | /* return number of characters currently in the writing process */ | 584 | /* return number of characters currently in the writing process */ |
587 | static int klsi_105_chars_in_buffer (struct usb_serial_port *port) | 585 | static int klsi_105_chars_in_buffer(struct tty_struct *tty) |
588 | { | 586 | { |
587 | struct usb_serial_port *port = tty->driver_data; | ||
589 | int chars = 0; | 588 | int chars = 0; |
590 | int i; | 589 | int i; |
591 | unsigned long flags; | 590 | unsigned long flags; |
592 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 591 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
593 | 592 | ||
594 | spin_lock_irqsave (&priv->lock, flags); | 593 | spin_lock_irqsave(&priv->lock, flags); |
595 | 594 | ||
596 | for (i = 0; i < NUM_URBS; ++i) { | 595 | for (i = 0; i < NUM_URBS; ++i) { |
597 | if (priv->write_urb_pool[i]->status == -EINPROGRESS) { | 596 | if (priv->write_urb_pool[i]->status == -EINPROGRESS) |
598 | chars += URB_TRANSFER_BUFFER_SIZE; | 597 | chars += URB_TRANSFER_BUFFER_SIZE; |
599 | } | ||
600 | } | 598 | } |
601 | 599 | ||
602 | spin_unlock_irqrestore (&priv->lock, flags); | 600 | spin_unlock_irqrestore(&priv->lock, flags); |
603 | 601 | ||
604 | dbg("%s - returns %d", __func__, chars); | 602 | dbg("%s - returns %d", __func__, chars); |
605 | return (chars); | 603 | return chars; |
606 | } | 604 | } |
607 | 605 | ||
608 | static int klsi_105_write_room (struct usb_serial_port *port) | 606 | static int klsi_105_write_room(struct tty_struct *tty) |
609 | { | 607 | { |
608 | struct usb_serial_port *port = tty->driver_data; | ||
610 | unsigned long flags; | 609 | unsigned long flags; |
611 | int i; | 610 | int i; |
612 | int room = 0; | 611 | int room = 0; |
613 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 612 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
614 | 613 | ||
615 | spin_lock_irqsave (&priv->lock, flags); | 614 | spin_lock_irqsave(&priv->lock, flags); |
616 | for (i = 0; i < NUM_URBS; ++i) { | 615 | for (i = 0; i < NUM_URBS; ++i) { |
617 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) { | 616 | if (priv->write_urb_pool[i]->status != -EINPROGRESS) |
618 | room += URB_TRANSFER_BUFFER_SIZE; | 617 | room += URB_TRANSFER_BUFFER_SIZE; |
619 | } | ||
620 | } | 618 | } |
621 | 619 | ||
622 | spin_unlock_irqrestore (&priv->lock, flags); | 620 | spin_unlock_irqrestore(&priv->lock, flags); |
623 | 621 | ||
624 | dbg("%s - returns %d", __func__, room); | 622 | dbg("%s - returns %d", __func__, room); |
625 | return (room); | 623 | return room; |
626 | } | 624 | } |
627 | 625 | ||
628 | 626 | ||
629 | 627 | ||
630 | static void klsi_105_read_bulk_callback (struct urb *urb) | 628 | static void klsi_105_read_bulk_callback(struct urb *urb) |
631 | { | 629 | { |
632 | struct usb_serial_port *port = urb->context; | 630 | struct usb_serial_port *port = urb->context; |
633 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 631 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
@@ -660,13 +658,13 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
660 | } else { | 658 | } else { |
661 | int bytes_sent = ((__u8 *) data)[0] + | 659 | int bytes_sent = ((__u8 *) data)[0] + |
662 | ((unsigned int) ((__u8 *) data)[1] << 8); | 660 | ((unsigned int) ((__u8 *) data)[1] << 8); |
663 | tty = port->tty; | 661 | tty = port->port.tty; |
664 | /* we should immediately resubmit the URB, before attempting | 662 | /* we should immediately resubmit the URB, before attempting |
665 | * to pass the data on to the tty layer. But that needs locking | 663 | * to pass the data on to the tty layer. But that needs locking |
666 | * against re-entry an then mixed-up data because of | 664 | * against re-entry an then mixed-up data because of |
667 | * intermixed tty_flip_buffer_push()s | 665 | * intermixed tty_flip_buffer_push()s |
668 | * FIXME | 666 | * FIXME |
669 | */ | 667 | */ |
670 | usb_serial_debug_data(debug, &port->dev, __func__, | 668 | usb_serial_debug_data(debug, &port->dev, __func__, |
671 | urb->actual_length, data); | 669 | urb->actual_length, data); |
672 | 670 | ||
@@ -686,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
686 | priv->bytes_in += bytes_sent; | 684 | priv->bytes_in += bytes_sent; |
687 | } | 685 | } |
688 | /* Continue trying to always read */ | 686 | /* Continue trying to always read */ |
689 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 687 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
690 | usb_rcvbulkpipe(port->serial->dev, | 688 | usb_rcvbulkpipe(port->serial->dev, |
691 | port->bulk_in_endpointAddress), | 689 | port->bulk_in_endpointAddress), |
692 | port->read_urb->transfer_buffer, | 690 | port->read_urb->transfer_buffer, |
@@ -695,15 +693,16 @@ static void klsi_105_read_bulk_callback (struct urb *urb) | |||
695 | port); | 693 | port); |
696 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 694 | rc = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
697 | if (rc) | 695 | if (rc) |
698 | err("%s - failed resubmitting read urb, error %d", __func__, rc); | 696 | err("%s - failed resubmitting read urb, error %d", |
697 | __func__, rc); | ||
699 | } /* klsi_105_read_bulk_callback */ | 698 | } /* klsi_105_read_bulk_callback */ |
700 | 699 | ||
701 | 700 | ||
702 | static void klsi_105_set_termios (struct usb_serial_port *port, | 701 | static void klsi_105_set_termios(struct tty_struct *tty, |
703 | struct ktermios *old_termios) | 702 | struct usb_serial_port *port, |
703 | struct ktermios *old_termios) | ||
704 | { | 704 | { |
705 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 705 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
706 | struct tty_struct *tty = port->tty; | ||
707 | unsigned int iflag = tty->termios->c_iflag; | 706 | unsigned int iflag = tty->termios->c_iflag; |
708 | unsigned int old_iflag = old_termios->c_iflag; | 707 | unsigned int old_iflag = old_termios->c_iflag; |
709 | unsigned int cflag = tty->termios->c_cflag; | 708 | unsigned int cflag = tty->termios->c_cflag; |
@@ -711,65 +710,63 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
711 | struct klsi_105_port_settings cfg; | 710 | struct klsi_105_port_settings cfg; |
712 | unsigned long flags; | 711 | unsigned long flags; |
713 | speed_t baud; | 712 | speed_t baud; |
714 | 713 | ||
715 | /* lock while we are modifying the settings */ | 714 | /* lock while we are modifying the settings */ |
716 | spin_lock_irqsave (&priv->lock, flags); | 715 | spin_lock_irqsave(&priv->lock, flags); |
717 | 716 | ||
718 | /* | 717 | /* |
719 | * Update baud rate | 718 | * Update baud rate |
720 | */ | 719 | */ |
721 | baud = tty_get_baud_rate(tty); | 720 | baud = tty_get_baud_rate(tty); |
722 | 721 | ||
723 | if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { | 722 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
724 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 723 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
725 | if( (old_cflag & CBAUD) == B0 ) { | 724 | if ((old_cflag & CBAUD) == B0) { |
726 | dbg("%s: baud was B0", __func__); | 725 | dbg("%s: baud was B0", __func__); |
727 | #if 0 | 726 | #if 0 |
728 | priv->control_state |= TIOCM_DTR; | 727 | priv->control_state |= TIOCM_DTR; |
729 | /* don't set RTS if using hardware flow control */ | 728 | /* don't set RTS if using hardware flow control */ |
730 | if (!(old_cflag & CRTSCTS)) { | 729 | if (!(old_cflag & CRTSCTS)) |
731 | priv->control_state |= TIOCM_RTS; | 730 | priv->control_state |= TIOCM_RTS; |
732 | } | ||
733 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 731 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
734 | #endif | 732 | #endif |
735 | } | 733 | } |
736 | } | 734 | } |
737 | switch(baud) { | 735 | switch (baud) { |
738 | case 0: /* handled below */ | 736 | case 0: /* handled below */ |
739 | break; | 737 | break; |
740 | case 1200: | 738 | case 1200: |
741 | priv->cfg.baudrate = kl5kusb105a_sio_b1200; | 739 | priv->cfg.baudrate = kl5kusb105a_sio_b1200; |
742 | break; | 740 | break; |
743 | case 2400: | 741 | case 2400: |
744 | priv->cfg.baudrate = kl5kusb105a_sio_b2400; | 742 | priv->cfg.baudrate = kl5kusb105a_sio_b2400; |
745 | break; | 743 | break; |
746 | case 4800: | 744 | case 4800: |
747 | priv->cfg.baudrate = kl5kusb105a_sio_b4800; | 745 | priv->cfg.baudrate = kl5kusb105a_sio_b4800; |
748 | break; | 746 | break; |
749 | case 9600: | 747 | case 9600: |
750 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | 748 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
751 | break; | 749 | break; |
752 | case 19200: | 750 | case 19200: |
753 | priv->cfg.baudrate = kl5kusb105a_sio_b19200; | 751 | priv->cfg.baudrate = kl5kusb105a_sio_b19200; |
754 | break; | 752 | break; |
755 | case 38400: | 753 | case 38400: |
756 | priv->cfg.baudrate = kl5kusb105a_sio_b38400; | 754 | priv->cfg.baudrate = kl5kusb105a_sio_b38400; |
757 | break; | 755 | break; |
758 | case 57600: | 756 | case 57600: |
759 | priv->cfg.baudrate = kl5kusb105a_sio_b57600; | 757 | priv->cfg.baudrate = kl5kusb105a_sio_b57600; |
760 | break; | 758 | break; |
761 | case 115200: | 759 | case 115200: |
762 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | 760 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; |
763 | break; | 761 | break; |
764 | default: | 762 | default: |
765 | dbg("KLSI USB->Serial converter:" | 763 | dbg("KLSI USB->Serial converter:" |
766 | " unsupported baudrate request, using default" | 764 | " unsupported baudrate request, using default of 9600"); |
767 | " of 9600"); | ||
768 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | 765 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
769 | baud = 9600; | 766 | baud = 9600; |
770 | break; | 767 | break; |
771 | } | 768 | } |
772 | if ((cflag & CBAUD) == B0 ) { | 769 | if ((cflag & CBAUD) == B0) { |
773 | dbg("%s: baud is B0", __func__); | 770 | dbg("%s: baud is B0", __func__); |
774 | /* Drop RTS and DTR */ | 771 | /* Drop RTS and DTR */ |
775 | /* maybe this should be simulated by sending read | 772 | /* maybe this should be simulated by sending read |
@@ -778,7 +775,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
778 | ; | 775 | ; |
779 | #if 0 | 776 | #if 0 |
780 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 777 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
781 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 778 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
782 | #endif | 779 | #endif |
783 | } | 780 | } |
784 | tty_encode_baud_rate(tty, baud, baud); | 781 | tty_encode_baud_rate(tty, baud, baud); |
@@ -788,11 +785,11 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
788 | switch (cflag & CSIZE) { | 785 | switch (cflag & CSIZE) { |
789 | case CS5: | 786 | case CS5: |
790 | dbg("%s - 5 bits/byte not supported", __func__); | 787 | dbg("%s - 5 bits/byte not supported", __func__); |
791 | spin_unlock_irqrestore (&priv->lock, flags); | 788 | spin_unlock_irqrestore(&priv->lock, flags); |
792 | return ; | 789 | return ; |
793 | case CS6: | 790 | case CS6: |
794 | dbg("%s - 6 bits/byte not supported", __func__); | 791 | dbg("%s - 6 bits/byte not supported", __func__); |
795 | spin_unlock_irqrestore (&priv->lock, flags); | 792 | spin_unlock_irqrestore(&priv->lock, flags); |
796 | return ; | 793 | return ; |
797 | case CS7: | 794 | case CS7: |
798 | priv->cfg.databits = kl5kusb105a_dtb_7; | 795 | priv->cfg.databits = kl5kusb105a_dtb_7; |
@@ -811,8 +808,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
811 | * Update line control register (LCR) | 808 | * Update line control register (LCR) |
812 | */ | 809 | */ |
813 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) | 810 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) |
814 | || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { | 811 | || (cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
815 | |||
816 | /* Not currently supported */ | 812 | /* Not currently supported */ |
817 | tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); | 813 | tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); |
818 | #if 0 | 814 | #if 0 |
@@ -833,20 +829,18 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
833 | #endif | 829 | #endif |
834 | ; | 830 | ; |
835 | } | 831 | } |
836 | |||
837 | /* | 832 | /* |
838 | * Set flow control: well, I do not really now how to handle DTR/RTS. | 833 | * Set flow control: well, I do not really now how to handle DTR/RTS. |
839 | * Just do what we have seen with SniffUSB on Win98. | 834 | * Just do what we have seen with SniffUSB on Win98. |
840 | */ | 835 | */ |
841 | if( (iflag & IXOFF) != (old_iflag & IXOFF) | 836 | if ((iflag & IXOFF) != (old_iflag & IXOFF) |
842 | || (iflag & IXON) != (old_iflag & IXON) | 837 | || (iflag & IXON) != (old_iflag & IXON) |
843 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { | 838 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
844 | |||
845 | /* Not currently supported */ | 839 | /* Not currently supported */ |
846 | tty->termios->c_cflag &= ~CRTSCTS; | 840 | tty->termios->c_cflag &= ~CRTSCTS; |
847 | /* Drop DTR/RTS if no flow control otherwise assert */ | 841 | /* Drop DTR/RTS if no flow control otherwise assert */ |
848 | #if 0 | 842 | #if 0 |
849 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) | 843 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS)) |
850 | priv->control_state |= TIOCM_DTR | TIOCM_RTS; | 844 | priv->control_state |= TIOCM_DTR | TIOCM_RTS; |
851 | else | 845 | else |
852 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 846 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
@@ -854,19 +848,21 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
854 | #endif | 848 | #endif |
855 | ; | 849 | ; |
856 | } | 850 | } |
857 | memcpy (&cfg, &priv->cfg, sizeof(cfg)); | 851 | memcpy(&cfg, &priv->cfg, sizeof(cfg)); |
858 | spin_unlock_irqrestore (&priv->lock, flags); | 852 | spin_unlock_irqrestore(&priv->lock, flags); |
859 | 853 | ||
860 | /* now commit changes to device */ | 854 | /* now commit changes to device */ |
861 | klsi_105_chg_port_settings(port, &cfg); | 855 | klsi_105_chg_port_settings(port, &cfg); |
862 | } /* klsi_105_set_termios */ | 856 | } /* klsi_105_set_termios */ |
863 | 857 | ||
864 | 858 | ||
865 | #if 0 | 859 | #if 0 |
866 | static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) | 860 | static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) |
867 | { | 861 | { |
862 | struct usb_serial_port *port = tty->driver_data; | ||
868 | struct usb_serial *serial = port->serial; | 863 | struct usb_serial *serial = port->serial; |
869 | struct mct_u232_private *priv = (struct mct_u232_private *)port->private; | 864 | struct mct_u232_private *priv = |
865 | (struct mct_u232_private *)port->private; | ||
870 | unsigned char lcr = priv->last_lcr; | 866 | unsigned char lcr = priv->last_lcr; |
871 | 867 | ||
872 | dbg("%sstate=%d", __func__, break_state); | 868 | dbg("%sstate=%d", __func__, break_state); |
@@ -878,8 +874,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) | |||
878 | } /* mct_u232_break_ctl */ | 874 | } /* mct_u232_break_ctl */ |
879 | #endif | 875 | #endif |
880 | 876 | ||
881 | static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) | 877 | static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file) |
882 | { | 878 | { |
879 | struct usb_serial_port *port = tty->driver_data; | ||
883 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 880 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
884 | unsigned long flags; | 881 | unsigned long flags; |
885 | int rc; | 882 | int rc; |
@@ -893,18 +890,18 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) | |||
893 | return rc; | 890 | return rc; |
894 | } | 891 | } |
895 | 892 | ||
896 | spin_lock_irqsave (&priv->lock, flags); | 893 | spin_lock_irqsave(&priv->lock, flags); |
897 | priv->line_state = line_state; | 894 | priv->line_state = line_state; |
898 | spin_unlock_irqrestore (&priv->lock, flags); | 895 | spin_unlock_irqrestore(&priv->lock, flags); |
899 | dbg("%s - read line state 0x%lx", __func__, line_state); | 896 | dbg("%s - read line state 0x%lx", __func__, line_state); |
900 | return (int)line_state; | 897 | return (int)line_state; |
901 | } | 898 | } |
902 | 899 | ||
903 | static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, | 900 | static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file, |
904 | unsigned int set, unsigned int clear) | 901 | unsigned int set, unsigned int clear) |
905 | { | 902 | { |
906 | int retval = -EINVAL; | 903 | int retval = -EINVAL; |
907 | 904 | ||
908 | dbg("%s", __func__); | 905 | dbg("%s", __func__); |
909 | 906 | ||
910 | /* if this ever gets implemented, it should be done something like this: | 907 | /* if this ever gets implemented, it should be done something like this: |
@@ -929,14 +926,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, | |||
929 | return retval; | 926 | return retval; |
930 | } | 927 | } |
931 | 928 | ||
932 | static void klsi_105_throttle (struct usb_serial_port *port) | 929 | static void klsi_105_throttle(struct tty_struct *tty) |
933 | { | 930 | { |
931 | struct usb_serial_port *port = tty->driver_data; | ||
934 | dbg("%s - port %d", __func__, port->number); | 932 | dbg("%s - port %d", __func__, port->number); |
935 | usb_kill_urb(port->read_urb); | 933 | usb_kill_urb(port->read_urb); |
936 | } | 934 | } |
937 | 935 | ||
938 | static void klsi_105_unthrottle (struct usb_serial_port *port) | 936 | static void klsi_105_unthrottle(struct tty_struct *tty) |
939 | { | 937 | { |
938 | struct usb_serial_port *port = tty->driver_data; | ||
940 | int result; | 939 | int result; |
941 | 940 | ||
942 | dbg("%s - port %d", __func__, port->number); | 941 | dbg("%s - port %d", __func__, port->number); |
@@ -950,7 +949,7 @@ static void klsi_105_unthrottle (struct usb_serial_port *port) | |||
950 | 949 | ||
951 | 950 | ||
952 | 951 | ||
953 | static int __init klsi_105_init (void) | 952 | static int __init klsi_105_init(void) |
954 | { | 953 | { |
955 | int retval; | 954 | int retval; |
956 | retval = usb_serial_register(&kl5kusb105d_device); | 955 | retval = usb_serial_register(&kl5kusb105d_device); |
@@ -969,19 +968,19 @@ failed_usb_serial_register: | |||
969 | } | 968 | } |
970 | 969 | ||
971 | 970 | ||
972 | static void __exit klsi_105_exit (void) | 971 | static void __exit klsi_105_exit(void) |
973 | { | 972 | { |
974 | usb_deregister (&kl5kusb105d_driver); | 973 | usb_deregister(&kl5kusb105d_driver); |
975 | usb_serial_deregister (&kl5kusb105d_device); | 974 | usb_serial_deregister(&kl5kusb105d_device); |
976 | } | 975 | } |
977 | 976 | ||
978 | 977 | ||
979 | module_init (klsi_105_init); | 978 | module_init(klsi_105_init); |
980 | module_exit (klsi_105_exit); | 979 | module_exit(klsi_105_exit); |
981 | 980 | ||
982 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 981 | MODULE_AUTHOR(DRIVER_AUTHOR); |
983 | MODULE_DESCRIPTION( DRIVER_DESC ); | 982 | MODULE_DESCRIPTION(DRIVER_DESC); |
984 | MODULE_LICENSE("GPL"); | 983 | MODULE_LICENSE("GPL"); |
985 | 984 | ||
986 | 985 | ||
987 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 986 | module_param(debug, bool, S_IRUGO | S_IWUSR); |