diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:13:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:24 -0400 |
commit | deb91685784fc0bc845c582f8b2bc229cb7bc9da (patch) | |
tree | 8fc54e950055159dec24162d2432a93508d09958 /drivers | |
parent | 9e8e2d2ab58ee942b700a9453541d7539b704994 (diff) |
tty-usb-keyspan: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/serial/keyspan.c | 825 |
1 files changed, 418 insertions, 407 deletions
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index a371c41bb3ab..2b1cfcbf8f9b 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -1,29 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | Keyspan USB to Serial Converter driver | 2 | Keyspan USB to Serial Converter driver |
3 | 3 | ||
4 | (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org> | 4 | (C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org> |
5 | (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com> | 5 | (C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | See http://misc.nu/hugh/keyspan.html for more information. | 12 | See http://misc.nu/hugh/keyspan.html for more information. |
13 | 13 | ||
14 | Code in this driver inspired by and in a number of places taken | 14 | Code in this driver inspired by and in a number of places taken |
15 | from Brian Warner's original Keyspan-PDA driver. | 15 | from Brian Warner's original Keyspan-PDA driver. |
16 | 16 | ||
17 | This driver has been put together with the support of Innosys, Inc. | 17 | This driver has been put together with the support of Innosys, Inc. |
18 | and Keyspan, Inc the manufacturers of the Keyspan USB-serial products. | 18 | and Keyspan, Inc the manufacturers of the Keyspan USB-serial products. |
19 | Thanks Guys :) | 19 | Thanks Guys :) |
20 | 20 | ||
21 | Thanks to Paulus for miscellaneous tidy ups, some largish chunks | 21 | Thanks to Paulus for miscellaneous tidy ups, some largish chunks |
22 | of much nicer and/or completely new code and (perhaps most uniquely) | 22 | of much nicer and/or completely new code and (perhaps most uniquely) |
23 | having the patience to sit down and explain why and where he'd changed | 23 | having the patience to sit down and explain why and where he'd changed |
24 | stuff. | 24 | stuff. |
25 | 25 | ||
26 | Tip 'o the hat to IBM (and previously Linuxcare :) for supporting | 26 | Tip 'o the hat to IBM (and previously Linuxcare :) for supporting |
27 | staff in their work on open source projects. | 27 | staff in their work on open source projects. |
28 | 28 | ||
29 | Change History | 29 | Change History |
@@ -70,21 +70,21 @@ | |||
70 | 70 | ||
71 | Thu May 31 11:56:42 PDT 2001 gkh | 71 | Thu May 31 11:56:42 PDT 2001 gkh |
72 | switched from using spinlock to a semaphore | 72 | switched from using spinlock to a semaphore |
73 | 73 | ||
74 | (04/08/2001) gb | 74 | (04/08/2001) gb |
75 | Identify version on module load. | 75 | Identify version on module load. |
76 | 76 | ||
77 | (11/01/2000) Adam J. Richter | 77 | (11/01/2000) Adam J. Richter |
78 | usb_device_id table support. | 78 | usb_device_id table support. |
79 | 79 | ||
80 | Tue Oct 10 23:15:33 EST 2000 Hugh | 80 | Tue Oct 10 23:15:33 EST 2000 Hugh |
81 | Merged Paul's changes with my USA-49W mods. Work in progress | 81 | Merged Paul's changes with my USA-49W mods. Work in progress |
82 | still... | 82 | still... |
83 | 83 | ||
84 | Wed Jul 19 14:00:42 EST 2000 gkh | 84 | Wed Jul 19 14:00:42 EST 2000 gkh |
85 | Added module_init and module_exit functions to handle the fact that | 85 | Added module_init and module_exit functions to handle the fact that |
86 | this driver is a loadable module now. | 86 | this driver is a loadable module now. |
87 | 87 | ||
88 | Tue Jul 18 16:14:52 EST 2000 Hugh | 88 | Tue Jul 18 16:14:52 EST 2000 Hugh |
89 | Basic character input/output for USA-19 now mostly works, | 89 | Basic character input/output for USA-19 now mostly works, |
90 | fixed at 9600 baud for the moment. | 90 | fixed at 9600 baud for the moment. |
@@ -107,7 +107,7 @@ | |||
107 | #include <linux/spinlock.h> | 107 | #include <linux/spinlock.h> |
108 | #include <linux/firmware.h> | 108 | #include <linux/firmware.h> |
109 | #include <linux/ihex.h> | 109 | #include <linux/ihex.h> |
110 | #include <asm/uaccess.h> | 110 | #include <linux/uaccess.h> |
111 | #include <linux/usb.h> | 111 | #include <linux/usb.h> |
112 | #include <linux/usb/serial.h> | 112 | #include <linux/usb/serial.h> |
113 | #include "keyspan.h" | 113 | #include "keyspan.h" |
@@ -132,15 +132,15 @@ struct keyspan_serial_private { | |||
132 | struct urb *instat_urb; | 132 | struct urb *instat_urb; |
133 | char instat_buf[INSTAT_BUFLEN]; | 133 | char instat_buf[INSTAT_BUFLEN]; |
134 | 134 | ||
135 | /* added to support 49wg, where data from all 4 ports comes in on 1 EP */ | 135 | /* added to support 49wg, where data from all 4 ports comes in |
136 | /* and high-speed supported */ | 136 | on 1 EP and high-speed supported */ |
137 | struct urb *indat_urb; | 137 | struct urb *indat_urb; |
138 | char indat_buf[INDAT49W_BUFLEN]; | 138 | char indat_buf[INDAT49W_BUFLEN]; |
139 | 139 | ||
140 | /* XXX this one probably will need a lock */ | 140 | /* XXX this one probably will need a lock */ |
141 | struct urb *glocont_urb; | 141 | struct urb *glocont_urb; |
142 | char glocont_buf[GLOCONT_BUFLEN]; | 142 | char glocont_buf[GLOCONT_BUFLEN]; |
143 | char ctrl_buf[8]; // for EP0 control message | 143 | char ctrl_buf[8]; /* for EP0 control message */ |
144 | }; | 144 | }; |
145 | 145 | ||
146 | struct keyspan_port_private { | 146 | struct keyspan_port_private { |
@@ -186,19 +186,19 @@ struct keyspan_port_private { | |||
186 | int resend_cont; /* need to resend control packet */ | 186 | int resend_cont; /* need to resend control packet */ |
187 | }; | 187 | }; |
188 | 188 | ||
189 | |||
190 | /* Include Keyspan message headers. All current Keyspan Adapters | 189 | /* Include Keyspan message headers. All current Keyspan Adapters |
191 | make use of one of five message formats which are referred | 190 | make use of one of five message formats which are referred |
192 | to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */ | 191 | to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and |
192 | within this driver. */ | ||
193 | #include "keyspan_usa26msg.h" | 193 | #include "keyspan_usa26msg.h" |
194 | #include "keyspan_usa28msg.h" | 194 | #include "keyspan_usa28msg.h" |
195 | #include "keyspan_usa49msg.h" | 195 | #include "keyspan_usa49msg.h" |
196 | #include "keyspan_usa90msg.h" | 196 | #include "keyspan_usa90msg.h" |
197 | #include "keyspan_usa67msg.h" | 197 | #include "keyspan_usa67msg.h" |
198 | 198 | ||
199 | 199 | ||
200 | /* Functions used by new usb-serial code. */ | 200 | /* Functions used by new usb-serial code. */ |
201 | static int __init keyspan_init (void) | 201 | static int __init keyspan_init(void) |
202 | { | 202 | { |
203 | int retval; | 203 | int retval; |
204 | retval = usb_serial_register(&keyspan_pre_device); | 204 | retval = usb_serial_register(&keyspan_pre_device); |
@@ -214,7 +214,7 @@ static int __init keyspan_init (void) | |||
214 | if (retval) | 214 | if (retval) |
215 | goto failed_4port_device_register; | 215 | goto failed_4port_device_register; |
216 | retval = usb_register(&keyspan_driver); | 216 | retval = usb_register(&keyspan_driver); |
217 | if (retval) | 217 | if (retval) |
218 | goto failed_usb_register; | 218 | goto failed_usb_register; |
219 | 219 | ||
220 | info(DRIVER_VERSION ":" DRIVER_DESC); | 220 | info(DRIVER_VERSION ":" DRIVER_DESC); |
@@ -232,13 +232,13 @@ failed_pre_device_register: | |||
232 | return retval; | 232 | return retval; |
233 | } | 233 | } |
234 | 234 | ||
235 | static void __exit keyspan_exit (void) | 235 | static void __exit keyspan_exit(void) |
236 | { | 236 | { |
237 | usb_deregister (&keyspan_driver); | 237 | usb_deregister(&keyspan_driver); |
238 | usb_serial_deregister (&keyspan_pre_device); | 238 | usb_serial_deregister(&keyspan_pre_device); |
239 | usb_serial_deregister (&keyspan_1port_device); | 239 | usb_serial_deregister(&keyspan_1port_device); |
240 | usb_serial_deregister (&keyspan_2port_device); | 240 | usb_serial_deregister(&keyspan_2port_device); |
241 | usb_serial_deregister (&keyspan_4port_device); | 241 | usb_serial_deregister(&keyspan_4port_device); |
242 | } | 242 | } |
243 | 243 | ||
244 | module_init(keyspan_init); | 244 | module_init(keyspan_init); |
@@ -249,7 +249,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) | |||
249 | struct usb_serial_port *port = tty->driver_data; | 249 | struct usb_serial_port *port = tty->driver_data; |
250 | struct keyspan_port_private *p_priv; | 250 | struct keyspan_port_private *p_priv; |
251 | 251 | ||
252 | dbg("%s", __func__); | 252 | dbg("%s", __func__); |
253 | 253 | ||
254 | p_priv = usb_get_serial_port_data(port); | 254 | p_priv = usb_get_serial_port_data(port); |
255 | 255 | ||
@@ -262,7 +262,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) | |||
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | static void keyspan_set_termios (struct tty_struct *tty, | 265 | static void keyspan_set_termios(struct tty_struct *tty, |
266 | struct usb_serial_port *port, struct ktermios *old_termios) | 266 | struct usb_serial_port *port, struct ktermios *old_termios) |
267 | { | 267 | { |
268 | int baud_rate, device_port; | 268 | int baud_rate, device_port; |
@@ -280,7 +280,7 @@ static void keyspan_set_termios (struct tty_struct *tty, | |||
280 | /* Baud rate calculation takes baud rate as an integer | 280 | /* Baud rate calculation takes baud rate as an integer |
281 | so other rates can be generated if desired. */ | 281 | so other rates can be generated if desired. */ |
282 | baud_rate = tty_get_baud_rate(tty); | 282 | baud_rate = tty_get_baud_rate(tty); |
283 | /* If no match or invalid, don't change */ | 283 | /* If no match or invalid, don't change */ |
284 | if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, | 284 | if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, |
285 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { | 285 | NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { |
286 | /* FIXME - more to do here to ensure rate changes cleanly */ | 286 | /* FIXME - more to do here to ensure rate changes cleanly */ |
@@ -305,13 +305,13 @@ static int keyspan_tiocmget(struct tty_struct *tty, struct file *file) | |||
305 | struct usb_serial_port *port = tty->driver_data; | 305 | struct usb_serial_port *port = tty->driver_data; |
306 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); | 306 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); |
307 | unsigned int value; | 307 | unsigned int value; |
308 | 308 | ||
309 | value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | | 309 | value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | |
310 | ((p_priv->dtr_state) ? TIOCM_DTR : 0) | | 310 | ((p_priv->dtr_state) ? TIOCM_DTR : 0) | |
311 | ((p_priv->cts_state) ? TIOCM_CTS : 0) | | 311 | ((p_priv->cts_state) ? TIOCM_CTS : 0) | |
312 | ((p_priv->dsr_state) ? TIOCM_DSR : 0) | | 312 | ((p_priv->dsr_state) ? TIOCM_DSR : 0) | |
313 | ((p_priv->dcd_state) ? TIOCM_CAR : 0) | | 313 | ((p_priv->dcd_state) ? TIOCM_CAR : 0) | |
314 | ((p_priv->ri_state) ? TIOCM_RNG : 0); | 314 | ((p_priv->ri_state) ? TIOCM_RNG : 0); |
315 | 315 | ||
316 | return value; | 316 | return value; |
317 | } | 317 | } |
@@ -321,7 +321,7 @@ static int keyspan_tiocmset(struct tty_struct *tty, struct file *file, | |||
321 | { | 321 | { |
322 | struct usb_serial_port *port = tty->driver_data; | 322 | struct usb_serial_port *port = tty->driver_data; |
323 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); | 323 | struct keyspan_port_private *p_priv = usb_get_serial_port_data(port); |
324 | 324 | ||
325 | if (set & TIOCM_RTS) | 325 | if (set & TIOCM_RTS) |
326 | p_priv->rts_state = 1; | 326 | p_priv->rts_state = 1; |
327 | if (set & TIOCM_DTR) | 327 | if (set & TIOCM_DTR) |
@@ -344,19 +344,19 @@ static int keyspan_write(struct tty_struct *tty, | |||
344 | int flip; | 344 | int flip; |
345 | int left, todo; | 345 | int left, todo; |
346 | struct urb *this_urb; | 346 | struct urb *this_urb; |
347 | int err, maxDataLen, dataOffset; | 347 | int err, maxDataLen, dataOffset; |
348 | 348 | ||
349 | p_priv = usb_get_serial_port_data(port); | 349 | p_priv = usb_get_serial_port_data(port); |
350 | d_details = p_priv->device_details; | 350 | d_details = p_priv->device_details; |
351 | 351 | ||
352 | if (d_details->msg_format == msg_usa90) { | 352 | if (d_details->msg_format == msg_usa90) { |
353 | maxDataLen = 64; | 353 | maxDataLen = 64; |
354 | dataOffset = 0; | 354 | dataOffset = 0; |
355 | } else { | 355 | } else { |
356 | maxDataLen = 63; | 356 | maxDataLen = 63; |
357 | dataOffset = 1; | 357 | dataOffset = 1; |
358 | } | 358 | } |
359 | 359 | ||
360 | dbg("%s - for port %d (%d chars), flip=%d", | 360 | dbg("%s - for port %d (%d chars), flip=%d", |
361 | __func__, port->number, count, p_priv->out_flip); | 361 | __func__, port->number, count, p_priv->out_flip); |
362 | 362 | ||
@@ -366,37 +366,40 @@ static int keyspan_write(struct tty_struct *tty, | |||
366 | todo = maxDataLen; | 366 | todo = maxDataLen; |
367 | 367 | ||
368 | flip = p_priv->out_flip; | 368 | flip = p_priv->out_flip; |
369 | 369 | ||
370 | /* Check we have a valid urb/endpoint before we use it... */ | 370 | /* Check we have a valid urb/endpoint before we use it... */ |
371 | if ((this_urb = p_priv->out_urbs[flip]) == NULL) { | 371 | this_urb = p_priv->out_urbs[flip]; |
372 | if (this_urb == NULL) { | ||
372 | /* no bulk out, so return 0 bytes written */ | 373 | /* no bulk out, so return 0 bytes written */ |
373 | dbg("%s - no output urb :(", __func__); | 374 | dbg("%s - no output urb :(", __func__); |
374 | return count; | 375 | return count; |
375 | } | 376 | } |
376 | 377 | ||
377 | dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip); | 378 | dbg("%s - endpoint %d flip %d", |
379 | __func__, usb_pipeendpoint(this_urb->pipe), flip); | ||
378 | 380 | ||
379 | if (this_urb->status == -EINPROGRESS) { | 381 | if (this_urb->status == -EINPROGRESS) { |
380 | if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) | 382 | if (time_before(jiffies, |
383 | p_priv->tx_start_time[flip] + 10 * HZ)) | ||
381 | break; | 384 | break; |
382 | usb_unlink_urb(this_urb); | 385 | usb_unlink_urb(this_urb); |
383 | break; | 386 | break; |
384 | } | 387 | } |
385 | 388 | ||
386 | /* First byte in buffer is "last flag" (except for usa19hx) - unused so | 389 | /* First byte in buffer is "last flag" (except for usa19hx) |
387 | for now so set to zero */ | 390 | - unused so for now so set to zero */ |
388 | ((char *)this_urb->transfer_buffer)[0] = 0; | 391 | ((char *)this_urb->transfer_buffer)[0] = 0; |
389 | 392 | ||
390 | memcpy (this_urb->transfer_buffer + dataOffset, buf, todo); | 393 | memcpy(this_urb->transfer_buffer + dataOffset, buf, todo); |
391 | buf += todo; | 394 | buf += todo; |
392 | 395 | ||
393 | /* send the data out the bulk port */ | 396 | /* send the data out the bulk port */ |
394 | this_urb->transfer_buffer_length = todo + dataOffset; | 397 | this_urb->transfer_buffer_length = todo + dataOffset; |
395 | 398 | ||
396 | this_urb->dev = port->serial->dev; | 399 | this_urb->dev = port->serial->dev; |
397 | if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { | 400 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
401 | if (err != 0) | ||
398 | dbg("usb_submit_urb(write bulk) failed (%d)", err); | 402 | dbg("usb_submit_urb(write bulk) failed (%d)", err); |
399 | } | ||
400 | p_priv->tx_start_time[flip] = jiffies; | 403 | p_priv->tx_start_time[flip] = jiffies; |
401 | 404 | ||
402 | /* Flip for next time if usa26 or usa28 interface | 405 | /* Flip for next time if usa26 or usa28 interface |
@@ -416,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb) | |||
416 | unsigned char *data = urb->transfer_buffer; | 419 | unsigned char *data = urb->transfer_buffer; |
417 | int status = urb->status; | 420 | int status = urb->status; |
418 | 421 | ||
419 | dbg ("%s", __func__); | 422 | dbg("%s", __func__); |
420 | 423 | ||
421 | endpoint = usb_pipeendpoint(urb->pipe); | 424 | endpoint = usb_pipeendpoint(urb->pipe); |
422 | 425 | ||
@@ -431,13 +434,14 @@ static void usa26_indat_callback(struct urb *urb) | |||
431 | if (tty && urb->actual_length) { | 434 | if (tty && urb->actual_length) { |
432 | /* 0x80 bit is error flag */ | 435 | /* 0x80 bit is error flag */ |
433 | if ((data[0] & 0x80) == 0) { | 436 | if ((data[0] & 0x80) == 0) { |
434 | /* no errors on individual bytes, only possible overrun err*/ | 437 | /* no errors on individual bytes, only |
438 | possible overrun err */ | ||
435 | if (data[0] & RXERROR_OVERRUN) | 439 | if (data[0] & RXERROR_OVERRUN) |
436 | err = TTY_OVERRUN; | 440 | err = TTY_OVERRUN; |
437 | else err = 0; | 441 | else |
438 | for (i = 1; i < urb->actual_length ; ++i) { | 442 | err = 0; |
443 | for (i = 1; i < urb->actual_length ; ++i) | ||
439 | tty_insert_flip_char(tty, data[i], err); | 444 | tty_insert_flip_char(tty, data[i], err); |
440 | } | ||
441 | } else { | 445 | } else { |
442 | /* some bytes had errors, every byte has status */ | 446 | /* some bytes had errors, every byte has status */ |
443 | dbg("%s - RX error!!!!", __func__); | 447 | dbg("%s - RX error!!!!", __func__); |
@@ -455,17 +459,19 @@ static void usa26_indat_callback(struct urb *urb) | |||
455 | } | 459 | } |
456 | tty_flip_buffer_push(tty); | 460 | tty_flip_buffer_push(tty); |
457 | } | 461 | } |
458 | 462 | ||
459 | /* Resubmit urb so we continue receiving */ | 463 | /* Resubmit urb so we continue receiving */ |
460 | urb->dev = port->serial->dev; | 464 | urb->dev = port->serial->dev; |
461 | if (port->port.count) | 465 | if (port->port.count) { |
462 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 466 | err = usb_submit_urb(urb, GFP_ATOMIC); |
463 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 467 | if (err != 0) |
464 | } | 468 | dbg("%s - resubmit read urb failed. (%d)", |
469 | __func__, err); | ||
470 | } | ||
465 | return; | 471 | return; |
466 | } | 472 | } |
467 | 473 | ||
468 | /* Outdat handling is common for all devices */ | 474 | /* Outdat handling is common for all devices */ |
469 | static void usa2x_outdat_callback(struct urb *urb) | 475 | static void usa2x_outdat_callback(struct urb *urb) |
470 | { | 476 | { |
471 | struct usb_serial_port *port; | 477 | struct usb_serial_port *port; |
@@ -473,7 +479,7 @@ static void usa2x_outdat_callback(struct urb *urb) | |||
473 | 479 | ||
474 | port = urb->context; | 480 | port = urb->context; |
475 | p_priv = usb_get_serial_port_data(port); | 481 | p_priv = usb_get_serial_port_data(port); |
476 | dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); | 482 | dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); |
477 | 483 | ||
478 | if (port->port.count) | 484 | if (port->port.count) |
479 | usb_serial_port_softint(port); | 485 | usb_serial_port_softint(port); |
@@ -481,8 +487,8 @@ static void usa2x_outdat_callback(struct urb *urb) | |||
481 | 487 | ||
482 | static void usa26_inack_callback(struct urb *urb) | 488 | static void usa26_inack_callback(struct urb *urb) |
483 | { | 489 | { |
484 | dbg ("%s", __func__); | 490 | dbg("%s", __func__); |
485 | 491 | ||
486 | } | 492 | } |
487 | 493 | ||
488 | static void usa26_outcont_callback(struct urb *urb) | 494 | static void usa26_outcont_callback(struct urb *urb) |
@@ -494,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb) | |||
494 | p_priv = usb_get_serial_port_data(port); | 500 | p_priv = usb_get_serial_port_data(port); |
495 | 501 | ||
496 | if (p_priv->resend_cont) { | 502 | if (p_priv->resend_cont) { |
497 | dbg ("%s - sending setup", __func__); | 503 | dbg("%s - sending setup", __func__); |
498 | keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1); | 504 | keyspan_usa26_send_setup(port->serial, port, |
505 | p_priv->resend_cont - 1); | ||
499 | } | 506 | } |
500 | } | 507 | } |
501 | 508 | ||
@@ -531,14 +538,14 @@ static void usa26_instat_callback(struct urb *urb) | |||
531 | /* Now do something useful with the data */ | 538 | /* Now do something useful with the data */ |
532 | 539 | ||
533 | 540 | ||
534 | /* Check port number from message and retrieve private data */ | 541 | /* Check port number from message and retrieve private data */ |
535 | if (msg->port >= serial->num_ports) { | 542 | if (msg->port >= serial->num_ports) { |
536 | dbg ("%s - Unexpected port number %d", __func__, msg->port); | 543 | dbg("%s - Unexpected port number %d", __func__, msg->port); |
537 | goto exit; | 544 | goto exit; |
538 | } | 545 | } |
539 | port = serial->port[msg->port]; | 546 | port = serial->port[msg->port]; |
540 | p_priv = usb_get_serial_port_data(port); | 547 | p_priv = usb_get_serial_port_data(port); |
541 | 548 | ||
542 | /* Update handshaking pin state information */ | 549 | /* Update handshaking pin state information */ |
543 | old_dcd_state = p_priv->dcd_state; | 550 | old_dcd_state = p_priv->dcd_state; |
544 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); | 551 | p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); |
@@ -553,19 +560,18 @@ static void usa26_instat_callback(struct urb *urb) | |||
553 | /* else */ | 560 | /* else */ |
554 | /* wake_up_interruptible(&p_priv->open_wait); */ | 561 | /* wake_up_interruptible(&p_priv->open_wait); */ |
555 | } | 562 | } |
556 | 563 | ||
557 | /* Resubmit urb so we continue receiving */ | 564 | /* Resubmit urb so we continue receiving */ |
558 | urb->dev = serial->dev; | 565 | urb->dev = serial->dev; |
559 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 566 | err = usb_submit_urb(urb, GFP_ATOMIC); |
567 | if (err != 0) | ||
560 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 568 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
561 | } | ||
562 | exit: ; | 569 | exit: ; |
563 | } | 570 | } |
564 | 571 | ||
565 | static void usa26_glocont_callback(struct urb *urb) | 572 | static void usa26_glocont_callback(struct urb *urb) |
566 | { | 573 | { |
567 | dbg ("%s", __func__); | 574 | dbg("%s", __func__); |
568 | |||
569 | } | 575 | } |
570 | 576 | ||
571 | 577 | ||
@@ -578,7 +584,7 @@ static void usa28_indat_callback(struct urb *urb) | |||
578 | struct keyspan_port_private *p_priv; | 584 | struct keyspan_port_private *p_priv; |
579 | int status = urb->status; | 585 | int status = urb->status; |
580 | 586 | ||
581 | dbg ("%s", __func__); | 587 | dbg("%s", __func__); |
582 | 588 | ||
583 | port = urb->context; | 589 | port = urb->context; |
584 | p_priv = usb_get_serial_port_data(port); | 590 | p_priv = usb_get_serial_port_data(port); |
@@ -600,18 +606,19 @@ static void usa28_indat_callback(struct urb *urb) | |||
600 | 606 | ||
601 | tty = port->port.tty; | 607 | tty = port->port.tty; |
602 | if (urb->actual_length) { | 608 | if (urb->actual_length) { |
603 | for (i = 0; i < urb->actual_length ; ++i) { | 609 | for (i = 0; i < urb->actual_length ; ++i) |
604 | tty_insert_flip_char(tty, data[i], 0); | 610 | tty_insert_flip_char(tty, data[i], 0); |
605 | } | ||
606 | tty_flip_buffer_push(tty); | 611 | tty_flip_buffer_push(tty); |
607 | } | 612 | } |
608 | 613 | ||
609 | /* Resubmit urb so we continue receiving */ | 614 | /* Resubmit urb so we continue receiving */ |
610 | urb->dev = port->serial->dev; | 615 | urb->dev = port->serial->dev; |
611 | if (port->port.count) | 616 | if (port->port.count) { |
612 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 617 | err = usb_submit_urb(urb, GFP_ATOMIC); |
613 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 618 | if (err != 0) |
614 | } | 619 | dbg("%s - resubmit read urb failed. (%d)", |
620 | __func__, err); | ||
621 | } | ||
615 | p_priv->in_flip ^= 1; | 622 | p_priv->in_flip ^= 1; |
616 | 623 | ||
617 | urb = p_priv->in_urbs[p_priv->in_flip]; | 624 | urb = p_priv->in_urbs[p_priv->in_flip]; |
@@ -620,7 +627,7 @@ static void usa28_indat_callback(struct urb *urb) | |||
620 | 627 | ||
621 | static void usa28_inack_callback(struct urb *urb) | 628 | static void usa28_inack_callback(struct urb *urb) |
622 | { | 629 | { |
623 | dbg ("%s", __func__); | 630 | dbg("%s", __func__); |
624 | } | 631 | } |
625 | 632 | ||
626 | static void usa28_outcont_callback(struct urb *urb) | 633 | static void usa28_outcont_callback(struct urb *urb) |
@@ -632,8 +639,9 @@ static void usa28_outcont_callback(struct urb *urb) | |||
632 | p_priv = usb_get_serial_port_data(port); | 639 | p_priv = usb_get_serial_port_data(port); |
633 | 640 | ||
634 | if (p_priv->resend_cont) { | 641 | if (p_priv->resend_cont) { |
635 | dbg ("%s - sending setup", __func__); | 642 | dbg("%s - sending setup", __func__); |
636 | keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1); | 643 | keyspan_usa28_send_setup(port->serial, port, |
644 | p_priv->resend_cont - 1); | ||
637 | } | 645 | } |
638 | } | 646 | } |
639 | 647 | ||
@@ -663,19 +671,18 @@ static void usa28_instat_callback(struct urb *urb) | |||
663 | /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ | 671 | /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ |
664 | data[0], data[1], data[2], data[3], data[4], data[5], | 672 | data[0], data[1], data[2], data[3], data[4], data[5], |
665 | data[6], data[7], data[8], data[9], data[10], data[11]);*/ | 673 | data[6], data[7], data[8], data[9], data[10], data[11]);*/ |
666 | |||
667 | /* Now do something useful with the data */ | ||
668 | msg = (struct keyspan_usa28_portStatusMessage *)data; | ||
669 | 674 | ||
675 | /* Now do something useful with the data */ | ||
676 | msg = (struct keyspan_usa28_portStatusMessage *)data; | ||
670 | 677 | ||
671 | /* Check port number from message and retrieve private data */ | 678 | /* Check port number from message and retrieve private data */ |
672 | if (msg->port >= serial->num_ports) { | 679 | if (msg->port >= serial->num_ports) { |
673 | dbg ("%s - Unexpected port number %d", __func__, msg->port); | 680 | dbg("%s - Unexpected port number %d", __func__, msg->port); |
674 | goto exit; | 681 | goto exit; |
675 | } | 682 | } |
676 | port = serial->port[msg->port]; | 683 | port = serial->port[msg->port]; |
677 | p_priv = usb_get_serial_port_data(port); | 684 | p_priv = usb_get_serial_port_data(port); |
678 | 685 | ||
679 | /* Update handshaking pin state information */ | 686 | /* Update handshaking pin state information */ |
680 | old_dcd_state = p_priv->dcd_state; | 687 | old_dcd_state = p_priv->dcd_state; |
681 | p_priv->cts_state = ((msg->cts) ? 1 : 0); | 688 | p_priv->cts_state = ((msg->cts) ? 1 : 0); |
@@ -693,15 +700,15 @@ static void usa28_instat_callback(struct urb *urb) | |||
693 | 700 | ||
694 | /* Resubmit urb so we continue receiving */ | 701 | /* Resubmit urb so we continue receiving */ |
695 | urb->dev = serial->dev; | 702 | urb->dev = serial->dev; |
696 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 703 | err = usb_submit_urb(urb, GFP_ATOMIC); |
704 | if (err != 0) | ||
697 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 705 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
698 | } | ||
699 | exit: ; | 706 | exit: ; |
700 | } | 707 | } |
701 | 708 | ||
702 | static void usa28_glocont_callback(struct urb *urb) | 709 | static void usa28_glocont_callback(struct urb *urb) |
703 | { | 710 | { |
704 | dbg ("%s", __func__); | 711 | dbg("%s", __func__); |
705 | } | 712 | } |
706 | 713 | ||
707 | 714 | ||
@@ -712,7 +719,7 @@ static void usa49_glocont_callback(struct urb *urb) | |||
712 | struct keyspan_port_private *p_priv; | 719 | struct keyspan_port_private *p_priv; |
713 | int i; | 720 | int i; |
714 | 721 | ||
715 | dbg ("%s", __func__); | 722 | dbg("%s", __func__); |
716 | 723 | ||
717 | serial = urb->context; | 724 | serial = urb->context; |
718 | for (i = 0; i < serial->num_ports; ++i) { | 725 | for (i = 0; i < serial->num_ports; ++i) { |
@@ -720,8 +727,9 @@ static void usa49_glocont_callback(struct urb *urb) | |||
720 | p_priv = usb_get_serial_port_data(port); | 727 | p_priv = usb_get_serial_port_data(port); |
721 | 728 | ||
722 | if (p_priv->resend_cont) { | 729 | if (p_priv->resend_cont) { |
723 | dbg ("%s - sending setup", __func__); | 730 | dbg("%s - sending setup", __func__); |
724 | keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1); | 731 | keyspan_usa49_send_setup(serial, port, |
732 | p_priv->resend_cont - 1); | ||
725 | break; | 733 | break; |
726 | } | 734 | } |
727 | } | 735 | } |
@@ -740,7 +748,7 @@ static void usa49_instat_callback(struct urb *urb) | |||
740 | int old_dcd_state; | 748 | int old_dcd_state; |
741 | int status = urb->status; | 749 | int status = urb->status; |
742 | 750 | ||
743 | dbg ("%s", __func__); | 751 | dbg("%s", __func__); |
744 | 752 | ||
745 | serial = urb->context; | 753 | serial = urb->context; |
746 | 754 | ||
@@ -749,7 +757,8 @@ static void usa49_instat_callback(struct urb *urb) | |||
749 | return; | 757 | return; |
750 | } | 758 | } |
751 | 759 | ||
752 | if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) { | 760 | if (urb->actual_length != |
761 | sizeof(struct keyspan_usa49_portStatusMessage)) { | ||
753 | dbg("%s - bad length %d", __func__, urb->actual_length); | 762 | dbg("%s - bad length %d", __func__, urb->actual_length); |
754 | goto exit; | 763 | goto exit; |
755 | } | 764 | } |
@@ -757,18 +766,19 @@ static void usa49_instat_callback(struct urb *urb) | |||
757 | /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, | 766 | /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, |
758 | data[0], data[1], data[2], data[3], data[4], data[5], | 767 | data[0], data[1], data[2], data[3], data[4], data[5], |
759 | data[6], data[7], data[8], data[9], data[10]);*/ | 768 | data[6], data[7], data[8], data[9], data[10]);*/ |
760 | 769 | ||
761 | /* Now do something useful with the data */ | 770 | /* Now do something useful with the data */ |
762 | msg = (struct keyspan_usa49_portStatusMessage *)data; | 771 | msg = (struct keyspan_usa49_portStatusMessage *)data; |
763 | 772 | ||
764 | /* Check port number from message and retrieve private data */ | 773 | /* Check port number from message and retrieve private data */ |
765 | if (msg->portNumber >= serial->num_ports) { | 774 | if (msg->portNumber >= serial->num_ports) { |
766 | dbg ("%s - Unexpected port number %d", __func__, msg->portNumber); | 775 | dbg("%s - Unexpected port number %d", |
776 | __func__, msg->portNumber); | ||
767 | goto exit; | 777 | goto exit; |
768 | } | 778 | } |
769 | port = serial->port[msg->portNumber]; | 779 | port = serial->port[msg->portNumber]; |
770 | p_priv = usb_get_serial_port_data(port); | 780 | p_priv = usb_get_serial_port_data(port); |
771 | 781 | ||
772 | /* Update handshaking pin state information */ | 782 | /* Update handshaking pin state information */ |
773 | old_dcd_state = p_priv->dcd_state; | 783 | old_dcd_state = p_priv->dcd_state; |
774 | p_priv->cts_state = ((msg->cts) ? 1 : 0); | 784 | p_priv->cts_state = ((msg->cts) ? 1 : 0); |
@@ -784,18 +794,18 @@ static void usa49_instat_callback(struct urb *urb) | |||
784 | /* wake_up_interruptible(&p_priv->open_wait); */ | 794 | /* wake_up_interruptible(&p_priv->open_wait); */ |
785 | } | 795 | } |
786 | 796 | ||
787 | /* Resubmit urb so we continue receiving */ | 797 | /* Resubmit urb so we continue receiving */ |
788 | urb->dev = serial->dev; | 798 | urb->dev = serial->dev; |
789 | 799 | ||
790 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 800 | err = usb_submit_urb(urb, GFP_ATOMIC); |
801 | if (err != 0) | ||
791 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 802 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
792 | } | ||
793 | exit: ; | 803 | exit: ; |
794 | } | 804 | } |
795 | 805 | ||
796 | static void usa49_inack_callback(struct urb *urb) | 806 | static void usa49_inack_callback(struct urb *urb) |
797 | { | 807 | { |
798 | dbg ("%s", __func__); | 808 | dbg("%s", __func__); |
799 | } | 809 | } |
800 | 810 | ||
801 | static void usa49_indat_callback(struct urb *urb) | 811 | static void usa49_indat_callback(struct urb *urb) |
@@ -807,7 +817,7 @@ static void usa49_indat_callback(struct urb *urb) | |||
807 | unsigned char *data = urb->transfer_buffer; | 817 | unsigned char *data = urb->transfer_buffer; |
808 | int status = urb->status; | 818 | int status = urb->status; |
809 | 819 | ||
810 | dbg ("%s", __func__); | 820 | dbg("%s", __func__); |
811 | 821 | ||
812 | endpoint = usb_pipeendpoint(urb->pipe); | 822 | endpoint = usb_pipeendpoint(urb->pipe); |
813 | 823 | ||
@@ -823,9 +833,8 @@ static void usa49_indat_callback(struct urb *urb) | |||
823 | /* 0x80 bit is error flag */ | 833 | /* 0x80 bit is error flag */ |
824 | if ((data[0] & 0x80) == 0) { | 834 | if ((data[0] & 0x80) == 0) { |
825 | /* no error on any byte */ | 835 | /* no error on any byte */ |
826 | for (i = 1; i < urb->actual_length ; ++i) { | 836 | for (i = 1; i < urb->actual_length ; ++i) |
827 | tty_insert_flip_char(tty, data[i], 0); | 837 | tty_insert_flip_char(tty, data[i], 0); |
828 | } | ||
829 | } else { | 838 | } else { |
830 | /* some bytes had errors, every byte has status */ | 839 | /* some bytes had errors, every byte has status */ |
831 | for (i = 0; i + 1 < urb->actual_length; i += 2) { | 840 | for (i = 0; i + 1 < urb->actual_length; i += 2) { |
@@ -842,13 +851,15 @@ static void usa49_indat_callback(struct urb *urb) | |||
842 | } | 851 | } |
843 | tty_flip_buffer_push(tty); | 852 | tty_flip_buffer_push(tty); |
844 | } | 853 | } |
845 | 854 | ||
846 | /* Resubmit urb so we continue receiving */ | 855 | /* Resubmit urb so we continue receiving */ |
847 | urb->dev = port->serial->dev; | 856 | urb->dev = port->serial->dev; |
848 | if (port->port.count) | 857 | if (port->port.count) { |
849 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 858 | err = usb_submit_urb(urb, GFP_ATOMIC); |
850 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 859 | if (err != 0) |
851 | } | 860 | dbg("%s - resubmit read urb failed. (%d)", |
861 | __func__, err); | ||
862 | } | ||
852 | } | 863 | } |
853 | 864 | ||
854 | static void usa49wg_indat_callback(struct urb *urb) | 865 | static void usa49wg_indat_callback(struct urb *urb) |
@@ -860,7 +871,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
860 | unsigned char *data = urb->transfer_buffer; | 871 | unsigned char *data = urb->transfer_buffer; |
861 | int status = urb->status; | 872 | int status = urb->status; |
862 | 873 | ||
863 | dbg ("%s", __func__); | 874 | dbg("%s", __func__); |
864 | 875 | ||
865 | serial = urb->context; | 876 | serial = urb->context; |
866 | 877 | ||
@@ -878,7 +889,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
878 | 889 | ||
879 | /* Check port number from message*/ | 890 | /* Check port number from message*/ |
880 | if (data[i] >= serial->num_ports) { | 891 | if (data[i] >= serial->num_ports) { |
881 | dbg ("%s - Unexpected port number %d", | 892 | dbg("%s - Unexpected port number %d", |
882 | __func__, data[i]); | 893 | __func__, data[i]); |
883 | return; | 894 | return; |
884 | } | 895 | } |
@@ -931,7 +942,7 @@ static void usa49wg_indat_callback(struct urb *urb) | |||
931 | /* not used, usa-49 doesn't have per-port control endpoints */ | 942 | /* not used, usa-49 doesn't have per-port control endpoints */ |
932 | static void usa49_outcont_callback(struct urb *urb) | 943 | static void usa49_outcont_callback(struct urb *urb) |
933 | { | 944 | { |
934 | dbg ("%s", __func__); | 945 | dbg("%s", __func__); |
935 | } | 946 | } |
936 | 947 | ||
937 | static void usa90_indat_callback(struct urb *urb) | 948 | static void usa90_indat_callback(struct urb *urb) |
@@ -944,7 +955,7 @@ static void usa90_indat_callback(struct urb *urb) | |||
944 | unsigned char *data = urb->transfer_buffer; | 955 | unsigned char *data = urb->transfer_buffer; |
945 | int status = urb->status; | 956 | int status = urb->status; |
946 | 957 | ||
947 | dbg ("%s", __func__); | 958 | dbg("%s", __func__); |
948 | 959 | ||
949 | endpoint = usb_pipeendpoint(urb->pipe); | 960 | endpoint = usb_pipeendpoint(urb->pipe); |
950 | 961 | ||
@@ -959,27 +970,25 @@ static void usa90_indat_callback(struct urb *urb) | |||
959 | 970 | ||
960 | tty = port->port.tty; | 971 | tty = port->port.tty; |
961 | if (urb->actual_length) { | 972 | if (urb->actual_length) { |
962 | |||
963 | /* if current mode is DMA, looks like usa28 format | 973 | /* if current mode is DMA, looks like usa28 format |
964 | otherwise looks like usa26 data format */ | 974 | otherwise looks like usa26 data format */ |
965 | 975 | ||
966 | if (p_priv->baud > 57600) { | 976 | if (p_priv->baud > 57600) { |
967 | for (i = 0; i < urb->actual_length ; ++i) | 977 | for (i = 0; i < urb->actual_length ; ++i) |
968 | tty_insert_flip_char(tty, data[i], 0); | 978 | tty_insert_flip_char(tty, data[i], 0); |
969 | } | 979 | } else { |
970 | else { | ||
971 | |||
972 | /* 0x80 bit is error flag */ | 980 | /* 0x80 bit is error flag */ |
973 | if ((data[0] & 0x80) == 0) { | 981 | if ((data[0] & 0x80) == 0) { |
974 | /* no errors on individual bytes, only possible overrun err*/ | 982 | /* no errors on individual bytes, only |
983 | possible overrun err*/ | ||
975 | if (data[0] & RXERROR_OVERRUN) | 984 | if (data[0] & RXERROR_OVERRUN) |
976 | err = TTY_OVERRUN; | 985 | err = TTY_OVERRUN; |
977 | else err = 0; | 986 | else |
978 | for (i = 1; i < urb->actual_length ; ++i) | 987 | err = 0; |
979 | tty_insert_flip_char(tty, data[i], err); | 988 | for (i = 1; i < urb->actual_length ; ++i) |
980 | 989 | tty_insert_flip_char(tty, data[i], | |
981 | } | 990 | err); |
982 | else { | 991 | } else { |
983 | /* some bytes had errors, every byte has status */ | 992 | /* some bytes had errors, every byte has status */ |
984 | dbg("%s - RX error!!!!", __func__); | 993 | dbg("%s - RX error!!!!", __func__); |
985 | for (i = 0; i + 1 < urb->actual_length; i += 2) { | 994 | for (i = 0; i + 1 < urb->actual_length; i += 2) { |
@@ -991,19 +1000,22 @@ static void usa90_indat_callback(struct urb *urb) | |||
991 | if (stat & RXERROR_PARITY) | 1000 | if (stat & RXERROR_PARITY) |
992 | flag |= TTY_PARITY; | 1001 | flag |= TTY_PARITY; |
993 | /* XXX should handle break (0x10) */ | 1002 | /* XXX should handle break (0x10) */ |
994 | tty_insert_flip_char(tty, data[i+1], flag); | 1003 | tty_insert_flip_char(tty, data[i+1], |
1004 | flag); | ||
995 | } | 1005 | } |
996 | } | 1006 | } |
997 | } | 1007 | } |
998 | tty_flip_buffer_push(tty); | 1008 | tty_flip_buffer_push(tty); |
999 | } | 1009 | } |
1000 | 1010 | ||
1001 | /* Resubmit urb so we continue receiving */ | 1011 | /* Resubmit urb so we continue receiving */ |
1002 | urb->dev = port->serial->dev; | 1012 | urb->dev = port->serial->dev; |
1003 | if (port->port.count) | 1013 | if (port->port.count) { |
1004 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 1014 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1005 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 1015 | if (err != 0) |
1006 | } | 1016 | dbg("%s - resubmit read urb failed. (%d)", |
1017 | __func__, err); | ||
1018 | } | ||
1007 | return; | 1019 | return; |
1008 | } | 1020 | } |
1009 | 1021 | ||
@@ -1035,7 +1047,7 @@ static void usa90_instat_callback(struct urb *urb) | |||
1035 | 1047 | ||
1036 | port = serial->port[0]; | 1048 | port = serial->port[0]; |
1037 | p_priv = usb_get_serial_port_data(port); | 1049 | p_priv = usb_get_serial_port_data(port); |
1038 | 1050 | ||
1039 | /* Update handshaking pin state information */ | 1051 | /* Update handshaking pin state information */ |
1040 | old_dcd_state = p_priv->dcd_state; | 1052 | old_dcd_state = p_priv->dcd_state; |
1041 | p_priv->cts_state = ((msg->cts) ? 1 : 0); | 1053 | p_priv->cts_state = ((msg->cts) ? 1 : 0); |
@@ -1050,12 +1062,12 @@ static void usa90_instat_callback(struct urb *urb) | |||
1050 | /* else */ | 1062 | /* else */ |
1051 | /* wake_up_interruptible(&p_priv->open_wait); */ | 1063 | /* wake_up_interruptible(&p_priv->open_wait); */ |
1052 | } | 1064 | } |
1053 | 1065 | ||
1054 | /* Resubmit urb so we continue receiving */ | 1066 | /* Resubmit urb so we continue receiving */ |
1055 | urb->dev = serial->dev; | 1067 | urb->dev = serial->dev; |
1056 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { | 1068 | err = usb_submit_urb(urb, GFP_ATOMIC); |
1069 | if (err != 0) | ||
1057 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); | 1070 | dbg("%s - resubmit read urb failed. (%d)", __func__, err); |
1058 | } | ||
1059 | exit: | 1071 | exit: |
1060 | ; | 1072 | ; |
1061 | } | 1073 | } |
@@ -1069,8 +1081,9 @@ static void usa90_outcont_callback(struct urb *urb) | |||
1069 | p_priv = usb_get_serial_port_data(port); | 1081 | p_priv = usb_get_serial_port_data(port); |
1070 | 1082 | ||
1071 | if (p_priv->resend_cont) { | 1083 | if (p_priv->resend_cont) { |
1072 | dbg ("%s - sending setup", __func__); | 1084 | dbg("%s - sending setup", __func__); |
1073 | keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1); | 1085 | keyspan_usa90_send_setup(port->serial, port, |
1086 | p_priv->resend_cont - 1); | ||
1074 | } | 1087 | } |
1075 | } | 1088 | } |
1076 | 1089 | ||
@@ -1086,7 +1099,7 @@ static void usa67_instat_callback(struct urb *urb) | |||
1086 | int old_dcd_state; | 1099 | int old_dcd_state; |
1087 | int status = urb->status; | 1100 | int status = urb->status; |
1088 | 1101 | ||
1089 | dbg ("%s", __func__); | 1102 | dbg("%s", __func__); |
1090 | 1103 | ||
1091 | serial = urb->context; | 1104 | serial = urb->context; |
1092 | 1105 | ||
@@ -1095,7 +1108,8 @@ static void usa67_instat_callback(struct urb *urb) | |||
1095 | return; | 1108 | return; |
1096 | } | 1109 | } |
1097 | 1110 | ||
1098 | if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) { | 1111 | if (urb->actual_length != |
1112 | sizeof(struct keyspan_usa67_portStatusMessage)) { | ||
1099 | dbg("%s - bad length %d", __func__, urb->actual_length); | 1113 | dbg("%s - bad length %d", __func__, urb->actual_length); |
1100 | return; | 1114 | return; |
1101 | } | 1115 | } |
@@ -1106,7 +1120,7 @@ static void usa67_instat_callback(struct urb *urb) | |||
1106 | 1120 | ||
1107 | /* Check port number from message and retrieve private data */ | 1121 | /* Check port number from message and retrieve private data */ |
1108 | if (msg->port >= serial->num_ports) { | 1122 | if (msg->port >= serial->num_ports) { |
1109 | dbg ("%s - Unexpected port number %d", __func__, msg->port); | 1123 | dbg("%s - Unexpected port number %d", __func__, msg->port); |
1110 | return; | 1124 | return; |
1111 | } | 1125 | } |
1112 | 1126 | ||
@@ -1140,7 +1154,7 @@ static void usa67_glocont_callback(struct urb *urb) | |||
1140 | struct keyspan_port_private *p_priv; | 1154 | struct keyspan_port_private *p_priv; |
1141 | int i; | 1155 | int i; |
1142 | 1156 | ||
1143 | dbg ("%s", __func__); | 1157 | dbg("%s", __func__); |
1144 | 1158 | ||
1145 | serial = urb->context; | 1159 | serial = urb->context; |
1146 | for (i = 0; i < serial->num_ports; ++i) { | 1160 | for (i = 0; i < serial->num_ports; ++i) { |
@@ -1148,7 +1162,7 @@ static void usa67_glocont_callback(struct urb *urb) | |||
1148 | p_priv = usb_get_serial_port_data(port); | 1162 | p_priv = usb_get_serial_port_data(port); |
1149 | 1163 | ||
1150 | if (p_priv->resend_cont) { | 1164 | if (p_priv->resend_cont) { |
1151 | dbg ("%s - sending setup", __func__); | 1165 | dbg("%s - sending setup", __func__); |
1152 | keyspan_usa67_send_setup(serial, port, | 1166 | keyspan_usa67_send_setup(serial, port, |
1153 | p_priv->resend_cont - 1); | 1167 | p_priv->resend_cont - 1); |
1154 | break; | 1168 | break; |
@@ -1171,20 +1185,23 @@ static int keyspan_write_room(struct tty_struct *tty) | |||
1171 | 1185 | ||
1172 | /* FIXME: locking */ | 1186 | /* FIXME: locking */ |
1173 | if (d_details->msg_format == msg_usa90) | 1187 | if (d_details->msg_format == msg_usa90) |
1174 | data_len = 64; | 1188 | data_len = 64; |
1175 | else | 1189 | else |
1176 | data_len = 63; | 1190 | data_len = 63; |
1177 | 1191 | ||
1178 | flip = p_priv->out_flip; | 1192 | flip = p_priv->out_flip; |
1179 | 1193 | ||
1180 | /* Check both endpoints to see if any are available. */ | 1194 | /* Check both endpoints to see if any are available. */ |
1181 | if ((this_urb = p_priv->out_urbs[flip]) != NULL) { | 1195 | this_urb = p_priv->out_urbs[flip]; |
1196 | if (this_urb != NULL) { | ||
1182 | if (this_urb->status != -EINPROGRESS) | 1197 | if (this_urb->status != -EINPROGRESS) |
1183 | return (data_len); | 1198 | return data_len; |
1184 | flip = (flip + 1) & d_details->outdat_endp_flip; | 1199 | flip = (flip + 1) & d_details->outdat_endp_flip; |
1185 | if ((this_urb = p_priv->out_urbs[flip]) != NULL) | 1200 | this_urb = p_priv->out_urbs[flip]; |
1201 | if (this_urb != NULL) { | ||
1186 | if (this_urb->status != -EINPROGRESS) | 1202 | if (this_urb->status != -EINPROGRESS) |
1187 | return (data_len); | 1203 | return data_len; |
1204 | } | ||
1188 | } | 1205 | } |
1189 | return 0; | 1206 | return 0; |
1190 | } | 1207 | } |
@@ -1222,25 +1239,28 @@ static int keyspan_open(struct tty_struct *tty, | |||
1222 | 1239 | ||
1223 | /* Reset low level data toggle and start reading from endpoints */ | 1240 | /* Reset low level data toggle and start reading from endpoints */ |
1224 | for (i = 0; i < 2; i++) { | 1241 | for (i = 0; i < 2; i++) { |
1225 | if ((urb = p_priv->in_urbs[i]) == NULL) | 1242 | urb = p_priv->in_urbs[i]; |
1243 | if (urb == NULL) | ||
1226 | continue; | 1244 | continue; |
1227 | urb->dev = serial->dev; | 1245 | urb->dev = serial->dev; |
1228 | 1246 | ||
1229 | /* make sure endpoint data toggle is synchronized with the device */ | 1247 | /* make sure endpoint data toggle is synchronized |
1230 | 1248 | with the device */ | |
1231 | usb_clear_halt(urb->dev, urb->pipe); | 1249 | usb_clear_halt(urb->dev, urb->pipe); |
1232 | 1250 | err = usb_submit_urb(urb, GFP_KERNEL); | |
1233 | if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { | 1251 | if (err != 0) |
1234 | dbg("%s - submit urb %d failed (%d)", __func__, i, err); | 1252 | dbg("%s - submit urb %d failed (%d)", |
1235 | } | 1253 | __func__, i, err); |
1236 | } | 1254 | } |
1237 | 1255 | ||
1238 | /* Reset low level data toggle on out endpoints */ | 1256 | /* Reset low level data toggle on out endpoints */ |
1239 | for (i = 0; i < 2; i++) { | 1257 | for (i = 0; i < 2; i++) { |
1240 | if ((urb = p_priv->out_urbs[i]) == NULL) | 1258 | urb = p_priv->out_urbs[i]; |
1259 | if (urb == NULL) | ||
1241 | continue; | 1260 | continue; |
1242 | urb->dev = serial->dev; | 1261 | urb->dev = serial->dev; |
1243 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ | 1262 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), |
1263 | usb_pipeout(urb->pipe), 0); */ | ||
1244 | } | 1264 | } |
1245 | 1265 | ||
1246 | /* get the terminal config for the setup message now so we don't | 1266 | /* get the terminal config for the setup message now so we don't |
@@ -1264,8 +1284,8 @@ static int keyspan_open(struct tty_struct *tty, | |||
1264 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; | 1284 | p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; |
1265 | 1285 | ||
1266 | keyspan_send_setup(port, 1); | 1286 | keyspan_send_setup(port, 1); |
1267 | //mdelay(100); | 1287 | /* mdelay(100); */ |
1268 | //keyspan_set_termios(port, NULL); | 1288 | /* keyspan_set_termios(port, NULL); */ |
1269 | 1289 | ||
1270 | return 0; | 1290 | return 0; |
1271 | } | 1291 | } |
@@ -1287,15 +1307,15 @@ static void keyspan_close(struct tty_struct *tty, | |||
1287 | dbg("%s", __func__); | 1307 | dbg("%s", __func__); |
1288 | s_priv = usb_get_serial_data(serial); | 1308 | s_priv = usb_get_serial_data(serial); |
1289 | p_priv = usb_get_serial_port_data(port); | 1309 | p_priv = usb_get_serial_port_data(port); |
1290 | 1310 | ||
1291 | p_priv->rts_state = 0; | 1311 | p_priv->rts_state = 0; |
1292 | p_priv->dtr_state = 0; | 1312 | p_priv->dtr_state = 0; |
1293 | 1313 | ||
1294 | if (serial->dev) { | 1314 | if (serial->dev) { |
1295 | keyspan_send_setup(port, 2); | 1315 | keyspan_send_setup(port, 2); |
1296 | /* pilot-xfer seems to work best with this delay */ | 1316 | /* pilot-xfer seems to work best with this delay */ |
1297 | mdelay(100); | 1317 | mdelay(100); |
1298 | // keyspan_set_termios(port, NULL); | 1318 | /* keyspan_set_termios(port, NULL); */ |
1299 | } | 1319 | } |
1300 | 1320 | ||
1301 | /*while (p_priv->outcont_urb->status == -EINPROGRESS) { | 1321 | /*while (p_priv->outcont_urb->status == -EINPROGRESS) { |
@@ -1317,8 +1337,8 @@ static void keyspan_close(struct tty_struct *tty, | |||
1317 | port->port.tty = NULL; | 1337 | port->port.tty = NULL; |
1318 | } | 1338 | } |
1319 | 1339 | ||
1320 | /* download the firmware to a pre-renumeration device */ | 1340 | /* download the firmware to a pre-renumeration device */ |
1321 | static int keyspan_fake_startup (struct usb_serial *serial) | 1341 | static int keyspan_fake_startup(struct usb_serial *serial) |
1322 | { | 1342 | { |
1323 | int response; | 1343 | int response; |
1324 | const struct ihex_binrec *record; | 1344 | const struct ihex_binrec *record; |
@@ -1328,10 +1348,11 @@ static int keyspan_fake_startup (struct usb_serial *serial) | |||
1328 | dbg("Keyspan startup version %04x product %04x", | 1348 | dbg("Keyspan startup version %04x product %04x", |
1329 | le16_to_cpu(serial->dev->descriptor.bcdDevice), | 1349 | le16_to_cpu(serial->dev->descriptor.bcdDevice), |
1330 | le16_to_cpu(serial->dev->descriptor.idProduct)); | 1350 | le16_to_cpu(serial->dev->descriptor.idProduct)); |
1331 | 1351 | ||
1332 | if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) { | 1352 | if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) |
1353 | != 0x8000) { | ||
1333 | dbg("Firmware already loaded. Quitting."); | 1354 | dbg("Firmware already loaded. Quitting."); |
1334 | return(1); | 1355 | return 1; |
1335 | } | 1356 | } |
1336 | 1357 | ||
1337 | /* Select firmware image on the basis of idProduct */ | 1358 | /* Select firmware image on the basis of idProduct */ |
@@ -1355,11 +1376,11 @@ static int keyspan_fake_startup (struct usb_serial *serial) | |||
1355 | case keyspan_usa19_pre_product_id: | 1376 | case keyspan_usa19_pre_product_id: |
1356 | fw_name = "keyspan/usa19.fw"; | 1377 | fw_name = "keyspan/usa19.fw"; |
1357 | break; | 1378 | break; |
1358 | 1379 | ||
1359 | case keyspan_usa19qi_pre_product_id: | 1380 | case keyspan_usa19qi_pre_product_id: |
1360 | fw_name = "keyspan/usa19qi.fw"; | 1381 | fw_name = "keyspan/usa19qi.fw"; |
1361 | break; | 1382 | break; |
1362 | 1383 | ||
1363 | case keyspan_mpr_pre_product_id: | 1384 | case keyspan_mpr_pre_product_id: |
1364 | fw_name = "keyspan/mpr.fw"; | 1385 | fw_name = "keyspan/mpr.fw"; |
1365 | break; | 1386 | break; |
@@ -1367,15 +1388,15 @@ static int keyspan_fake_startup (struct usb_serial *serial) | |||
1367 | case keyspan_usa19qw_pre_product_id: | 1388 | case keyspan_usa19qw_pre_product_id: |
1368 | fw_name = "keyspan/usa19qw.fw"; | 1389 | fw_name = "keyspan/usa19qw.fw"; |
1369 | break; | 1390 | break; |
1370 | 1391 | ||
1371 | case keyspan_usa18x_pre_product_id: | 1392 | case keyspan_usa18x_pre_product_id: |
1372 | fw_name = "keyspan/usa18x.fw"; | 1393 | fw_name = "keyspan/usa18x.fw"; |
1373 | break; | 1394 | break; |
1374 | 1395 | ||
1375 | case keyspan_usa19w_pre_product_id: | 1396 | case keyspan_usa19w_pre_product_id: |
1376 | fw_name = "keyspan/usa19w.fw"; | 1397 | fw_name = "keyspan/usa19w.fw"; |
1377 | break; | 1398 | break; |
1378 | 1399 | ||
1379 | case keyspan_usa49w_pre_product_id: | 1400 | case keyspan_usa49w_pre_product_id: |
1380 | fw_name = "keyspan/usa49w.fw"; | 1401 | fw_name = "keyspan/usa49w.fw"; |
1381 | break; | 1402 | break; |
@@ -1407,8 +1428,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) | |||
1407 | (unsigned char *)record->data, | 1428 | (unsigned char *)record->data, |
1408 | be16_to_cpu(record->len), 0xa0); | 1429 | be16_to_cpu(record->len), 0xa0); |
1409 | if (response < 0) { | 1430 | if (response < 0) { |
1410 | dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan" | 1431 | dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n", |
1411 | "firmware (%d %04X %p %d)\n", | ||
1412 | response, be32_to_cpu(record->addr), | 1432 | response, be32_to_cpu(record->addr), |
1413 | record->data, be16_to_cpu(record->len)); | 1433 | record->data, be16_to_cpu(record->len)); |
1414 | break; | 1434 | break; |
@@ -1421,7 +1441,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) | |||
1421 | response = ezusb_set_reset(serial, 0); | 1441 | response = ezusb_set_reset(serial, 0); |
1422 | 1442 | ||
1423 | /* we don't want this device to have a driver assigned to it. */ | 1443 | /* we don't want this device to have a driver assigned to it. */ |
1424 | return (1); | 1444 | return 1; |
1425 | } | 1445 | } |
1426 | 1446 | ||
1427 | /* Helper functions used by keyspan_setup_urbs */ | 1447 | /* Helper functions used by keyspan_setup_urbs */ |
@@ -1443,7 +1463,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se | |||
1443 | return NULL; | 1463 | return NULL; |
1444 | } | 1464 | } |
1445 | 1465 | ||
1446 | static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, | 1466 | static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, |
1447 | int dir, void *ctx, char *buf, int len, | 1467 | int dir, void *ctx, char *buf, int len, |
1448 | void (*callback)(struct urb *)) | 1468 | void (*callback)(struct urb *)) |
1449 | { | 1469 | { |
@@ -1454,10 +1474,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, | |||
1454 | if (endpoint == -1) | 1474 | if (endpoint == -1) |
1455 | return NULL; /* endpoint not needed */ | 1475 | return NULL; /* endpoint not needed */ |
1456 | 1476 | ||
1457 | dbg ("%s - alloc for endpoint %d.", __func__, endpoint); | 1477 | dbg("%s - alloc for endpoint %d.", __func__, endpoint); |
1458 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | 1478 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ |
1459 | if (urb == NULL) { | 1479 | if (urb == NULL) { |
1460 | dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint); | 1480 | dbg("%s - alloc for endpoint %d failed.", __func__, endpoint); |
1461 | return NULL; | 1481 | return NULL; |
1462 | } | 1482 | } |
1463 | 1483 | ||
@@ -1530,7 +1550,7 @@ static struct callbacks { | |||
1530 | }, { | 1550 | }, { |
1531 | /* msg_usa90 callbacks */ | 1551 | /* msg_usa90 callbacks */ |
1532 | .instat_callback = usa90_instat_callback, | 1552 | .instat_callback = usa90_instat_callback, |
1533 | .glocont_callback = usa28_glocont_callback, | 1553 | .glocont_callback = usa28_glocont_callback, |
1534 | .indat_callback = usa90_indat_callback, | 1554 | .indat_callback = usa90_indat_callback, |
1535 | .outdat_callback = usa2x_outdat_callback, | 1555 | .outdat_callback = usa2x_outdat_callback, |
1536 | .inack_callback = usa28_inack_callback, | 1556 | .inack_callback = usa28_inack_callback, |
@@ -1558,16 +1578,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial) | |||
1558 | struct callbacks *cback; | 1578 | struct callbacks *cback; |
1559 | int endp; | 1579 | int endp; |
1560 | 1580 | ||
1561 | dbg ("%s", __func__); | 1581 | dbg("%s", __func__); |
1562 | 1582 | ||
1563 | s_priv = usb_get_serial_data(serial); | 1583 | s_priv = usb_get_serial_data(serial); |
1564 | d_details = s_priv->device_details; | 1584 | d_details = s_priv->device_details; |
1565 | 1585 | ||
1566 | /* Setup values for the various callback routines */ | 1586 | /* Setup values for the various callback routines */ |
1567 | cback = &keyspan_callbacks[d_details->msg_format]; | 1587 | cback = &keyspan_callbacks[d_details->msg_format]; |
1568 | 1588 | ||
1569 | /* Allocate and set up urbs for each one that is in use, | 1589 | /* Allocate and set up urbs for each one that is in use, |
1570 | starting with instat endpoints */ | 1590 | starting with instat endpoints */ |
1571 | s_priv->instat_urb = keyspan_setup_urb | 1591 | s_priv->instat_urb = keyspan_setup_urb |
1572 | (serial, d_details->instat_endpoint, USB_DIR_IN, | 1592 | (serial, d_details->instat_endpoint, USB_DIR_IN, |
1573 | serial, s_priv->instat_buf, INSTAT_BUFLEN, | 1593 | serial, s_priv->instat_buf, INSTAT_BUFLEN, |
@@ -1583,8 +1603,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial) | |||
1583 | serial, s_priv->glocont_buf, GLOCONT_BUFLEN, | 1603 | serial, s_priv->glocont_buf, GLOCONT_BUFLEN, |
1584 | cback->glocont_callback); | 1604 | cback->glocont_callback); |
1585 | 1605 | ||
1586 | /* Setup endpoints for each port specific thing */ | 1606 | /* Setup endpoints for each port specific thing */ |
1587 | for (i = 0; i < d_details->num_ports; i ++) { | 1607 | for (i = 0; i < d_details->num_ports; i++) { |
1588 | port = serial->port[i]; | 1608 | port = serial->port[i]; |
1589 | p_priv = usb_get_serial_port_data(port); | 1609 | p_priv = usb_get_serial_port_data(port); |
1590 | 1610 | ||
@@ -1620,8 +1640,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) | |||
1620 | (serial, d_details->outcont_endpoints[i], USB_DIR_OUT, | 1640 | (serial, d_details->outcont_endpoints[i], USB_DIR_OUT, |
1621 | port, p_priv->outcont_buffer, 64, | 1641 | port, p_priv->outcont_buffer, 64, |
1622 | cback->outcont_callback); | 1642 | cback->outcont_callback); |
1623 | } | 1643 | } |
1624 | |||
1625 | } | 1644 | } |
1626 | 1645 | ||
1627 | /* usa19 function doesn't require prescaler */ | 1646 | /* usa19 function doesn't require prescaler */ |
@@ -1629,46 +1648,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1629 | u8 *rate_low, u8 *prescaler, int portnum) | 1648 | u8 *rate_low, u8 *prescaler, int portnum) |
1630 | { | 1649 | { |
1631 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1650 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1632 | div, /* divisor */ | 1651 | div, /* divisor */ |
1633 | cnt; /* inverse of divisor (programmed into 8051) */ | 1652 | cnt; /* inverse of divisor (programmed into 8051) */ |
1634 | |||
1635 | dbg ("%s - %d.", __func__, baud_rate); | ||
1636 | 1653 | ||
1637 | /* prevent divide by zero... */ | 1654 | dbg("%s - %d.", __func__, baud_rate); |
1638 | if( (b16 = (baud_rate * 16L)) == 0) { | 1655 | |
1639 | return (KEYSPAN_INVALID_BAUD_RATE); | 1656 | /* prevent divide by zero... */ |
1640 | } | 1657 | b16 = baud_rate * 16L; |
1641 | 1658 | if (b16 == 0) | |
1642 | /* Any "standard" rate over 57k6 is marginal on the USA-19 | 1659 | return KEYSPAN_INVALID_BAUD_RATE; |
1643 | as we run out of divisor resolution. */ | 1660 | /* Any "standard" rate over 57k6 is marginal on the USA-19 |
1644 | if (baud_rate > 57600) { | 1661 | as we run out of divisor resolution. */ |
1645 | return (KEYSPAN_INVALID_BAUD_RATE); | 1662 | if (baud_rate > 57600) |
1646 | } | 1663 | return KEYSPAN_INVALID_BAUD_RATE; |
1647 | 1664 | ||
1648 | /* calculate the divisor and the counter (its inverse) */ | 1665 | /* calculate the divisor and the counter (its inverse) */ |
1649 | if( (div = (baudclk / b16)) == 0) { | 1666 | div = baudclk / b16; |
1650 | return (KEYSPAN_INVALID_BAUD_RATE); | 1667 | if (div == 0) |
1651 | } | 1668 | return KEYSPAN_INVALID_BAUD_RATE; |
1652 | else { | 1669 | else |
1653 | cnt = 0 - div; | 1670 | cnt = 0 - div; |
1654 | } | ||
1655 | 1671 | ||
1656 | if(div > 0xffff) { | 1672 | if (div > 0xffff) |
1657 | return (KEYSPAN_INVALID_BAUD_RATE); | 1673 | return KEYSPAN_INVALID_BAUD_RATE; |
1658 | } | ||
1659 | 1674 | ||
1660 | /* return the counter values if non-null */ | 1675 | /* return the counter values if non-null */ |
1661 | if (rate_low) { | 1676 | if (rate_low) |
1662 | *rate_low = (u8) (cnt & 0xff); | 1677 | *rate_low = (u8) (cnt & 0xff); |
1663 | } | 1678 | if (rate_hi) |
1664 | if (rate_hi) { | ||
1665 | *rate_hi = (u8) ((cnt >> 8) & 0xff); | 1679 | *rate_hi = (u8) ((cnt >> 8) & 0xff); |
1666 | } | 1680 | if (rate_low && rate_hi) |
1667 | if (rate_low && rate_hi) { | 1681 | dbg("%s - %d %02x %02x.", |
1668 | dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); | 1682 | __func__, baud_rate, *rate_hi, *rate_low); |
1669 | } | 1683 | return KEYSPAN_BAUD_RATE_OK; |
1670 | |||
1671 | return (KEYSPAN_BAUD_RATE_OK); | ||
1672 | } | 1684 | } |
1673 | 1685 | ||
1674 | /* usa19hs function doesn't require prescaler */ | 1686 | /* usa19hs function doesn't require prescaler */ |
@@ -1676,34 +1688,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1676 | u8 *rate_low, u8 *prescaler, int portnum) | 1688 | u8 *rate_low, u8 *prescaler, int portnum) |
1677 | { | 1689 | { |
1678 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1690 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1679 | div; /* divisor */ | 1691 | div; /* divisor */ |
1680 | |||
1681 | dbg ("%s - %d.", __func__, baud_rate); | ||
1682 | 1692 | ||
1683 | /* prevent divide by zero... */ | 1693 | dbg("%s - %d.", __func__, baud_rate); |
1684 | if( (b16 = (baud_rate * 16L)) == 0) | ||
1685 | return (KEYSPAN_INVALID_BAUD_RATE); | ||
1686 | |||
1687 | 1694 | ||
1695 | /* prevent divide by zero... */ | ||
1696 | b16 = baud_rate * 16L; | ||
1697 | if (b16 == 0) | ||
1698 | return KEYSPAN_INVALID_BAUD_RATE; | ||
1688 | 1699 | ||
1689 | /* calculate the divisor */ | 1700 | /* calculate the divisor */ |
1690 | if( (div = (baudclk / b16)) == 0) | 1701 | div = baudclk / b16; |
1691 | return (KEYSPAN_INVALID_BAUD_RATE); | 1702 | if (div == 0) |
1703 | return KEYSPAN_INVALID_BAUD_RATE; | ||
1692 | 1704 | ||
1693 | if(div > 0xffff) | 1705 | if (div > 0xffff) |
1694 | return (KEYSPAN_INVALID_BAUD_RATE); | 1706 | return KEYSPAN_INVALID_BAUD_RATE; |
1695 | 1707 | ||
1696 | /* return the counter values if non-null */ | 1708 | /* return the counter values if non-null */ |
1697 | if (rate_low) | 1709 | if (rate_low) |
1698 | *rate_low = (u8) (div & 0xff); | 1710 | *rate_low = (u8) (div & 0xff); |
1699 | 1711 | ||
1700 | if (rate_hi) | 1712 | if (rate_hi) |
1701 | *rate_hi = (u8) ((div >> 8) & 0xff); | 1713 | *rate_hi = (u8) ((div >> 8) & 0xff); |
1702 | 1714 | ||
1703 | if (rate_low && rate_hi) | 1715 | if (rate_low && rate_hi) |
1704 | dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); | 1716 | dbg("%s - %d %02x %02x.", |
1705 | 1717 | __func__, baud_rate, *rate_hi, *rate_low); | |
1706 | return (KEYSPAN_BAUD_RATE_OK); | 1718 | |
1719 | return KEYSPAN_BAUD_RATE_OK; | ||
1707 | } | 1720 | } |
1708 | 1721 | ||
1709 | static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | 1722 | static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, |
@@ -1711,64 +1724,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1711 | { | 1724 | { |
1712 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1725 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1713 | clk, /* clock with 13/8 prescaler */ | 1726 | clk, /* clock with 13/8 prescaler */ |
1714 | div, /* divisor using 13/8 prescaler */ | 1727 | div, /* divisor using 13/8 prescaler */ |
1715 | res, /* resulting baud rate using 13/8 prescaler */ | 1728 | res, /* resulting baud rate using 13/8 prescaler */ |
1716 | diff, /* error using 13/8 prescaler */ | 1729 | diff, /* error using 13/8 prescaler */ |
1717 | smallest_diff; | 1730 | smallest_diff; |
1718 | u8 best_prescaler; | 1731 | u8 best_prescaler; |
1719 | int i; | 1732 | int i; |
1720 | 1733 | ||
1721 | dbg ("%s - %d.", __func__, baud_rate); | 1734 | dbg("%s - %d.", __func__, baud_rate); |
1722 | 1735 | ||
1723 | /* prevent divide by zero */ | 1736 | /* prevent divide by zero */ |
1724 | if( (b16 = baud_rate * 16L) == 0) { | 1737 | b16 = baud_rate * 16L; |
1725 | return (KEYSPAN_INVALID_BAUD_RATE); | 1738 | if (b16 == 0) |
1726 | } | 1739 | return KEYSPAN_INVALID_BAUD_RATE; |
1727 | 1740 | ||
1728 | /* Calculate prescaler by trying them all and looking | 1741 | /* Calculate prescaler by trying them all and looking |
1729 | for best fit */ | 1742 | for best fit */ |
1730 | 1743 | ||
1731 | /* start with largest possible difference */ | 1744 | /* start with largest possible difference */ |
1732 | smallest_diff = 0xffffffff; | 1745 | smallest_diff = 0xffffffff; |
1733 | 1746 | ||
1734 | /* 0 is an invalid prescaler, used as a flag */ | 1747 | /* 0 is an invalid prescaler, used as a flag */ |
1735 | best_prescaler = 0; | 1748 | best_prescaler = 0; |
1736 | 1749 | ||
1737 | for(i = 8; i <= 0xff; ++i) { | 1750 | for (i = 8; i <= 0xff; ++i) { |
1738 | clk = (baudclk * 8) / (u32) i; | 1751 | clk = (baudclk * 8) / (u32) i; |
1739 | 1752 | ||
1740 | if( (div = clk / b16) == 0) { | 1753 | div = clk / b16; |
1754 | if (div == 0) | ||
1741 | continue; | 1755 | continue; |
1742 | } | ||
1743 | 1756 | ||
1744 | res = clk / div; | 1757 | res = clk / div; |
1745 | diff= (res > b16) ? (res-b16) : (b16-res); | 1758 | diff = (res > b16) ? (res-b16) : (b16-res); |
1746 | 1759 | ||
1747 | if(diff < smallest_diff) { | 1760 | if (diff < smallest_diff) { |
1748 | best_prescaler = i; | 1761 | best_prescaler = i; |
1749 | smallest_diff = diff; | 1762 | smallest_diff = diff; |
1750 | } | 1763 | } |
1751 | } | 1764 | } |
1752 | 1765 | ||
1753 | if(best_prescaler == 0) { | 1766 | if (best_prescaler == 0) |
1754 | return (KEYSPAN_INVALID_BAUD_RATE); | 1767 | return KEYSPAN_INVALID_BAUD_RATE; |
1755 | } | ||
1756 | 1768 | ||
1757 | clk = (baudclk * 8) / (u32) best_prescaler; | 1769 | clk = (baudclk * 8) / (u32) best_prescaler; |
1758 | div = clk / b16; | 1770 | div = clk / b16; |
1759 | 1771 | ||
1760 | /* return the divisor and prescaler if non-null */ | 1772 | /* return the divisor and prescaler if non-null */ |
1761 | if (rate_low) { | 1773 | if (rate_low) |
1762 | *rate_low = (u8) (div & 0xff); | 1774 | *rate_low = (u8) (div & 0xff); |
1763 | } | 1775 | if (rate_hi) |
1764 | if (rate_hi) { | ||
1765 | *rate_hi = (u8) ((div >> 8) & 0xff); | 1776 | *rate_hi = (u8) ((div >> 8) & 0xff); |
1766 | } | ||
1767 | if (prescaler) { | 1777 | if (prescaler) { |
1768 | *prescaler = best_prescaler; | 1778 | *prescaler = best_prescaler; |
1769 | /* dbg("%s - %d %d", __func__, *prescaler, div); */ | 1779 | /* dbg("%s - %d %d", __func__, *prescaler, div); */ |
1770 | } | 1780 | } |
1771 | return (KEYSPAN_BAUD_RATE_OK); | 1781 | return KEYSPAN_BAUD_RATE_OK; |
1772 | } | 1782 | } |
1773 | 1783 | ||
1774 | /* USA-28 supports different maximum baud rates on each port */ | 1784 | /* USA-28 supports different maximum baud rates on each port */ |
@@ -1776,57 +1786,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, | |||
1776 | u8 *rate_low, u8 *prescaler, int portnum) | 1786 | u8 *rate_low, u8 *prescaler, int portnum) |
1777 | { | 1787 | { |
1778 | u32 b16, /* baud rate times 16 (actual rate used internally) */ | 1788 | u32 b16, /* baud rate times 16 (actual rate used internally) */ |
1779 | div, /* divisor */ | 1789 | div, /* divisor */ |
1780 | cnt; /* inverse of divisor (programmed into 8051) */ | 1790 | cnt; /* inverse of divisor (programmed into 8051) */ |
1781 | 1791 | ||
1782 | dbg ("%s - %d.", __func__, baud_rate); | 1792 | dbg("%s - %d.", __func__, baud_rate); |
1783 | 1793 | ||
1784 | /* prevent divide by zero */ | 1794 | /* prevent divide by zero */ |
1785 | if ((b16 = baud_rate * 16L) == 0) | 1795 | b16 = baud_rate * 16L; |
1786 | return (KEYSPAN_INVALID_BAUD_RATE); | 1796 | if (b16 == 0) |
1787 | 1797 | return KEYSPAN_INVALID_BAUD_RATE; | |
1788 | /* calculate the divisor and the counter (its inverse) */ | 1798 | |
1789 | if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) { | 1799 | /* calculate the divisor and the counter (its inverse) */ |
1790 | return (KEYSPAN_INVALID_BAUD_RATE); | 1800 | div = KEYSPAN_USA28_BAUDCLK / b16; |
1791 | } | 1801 | if (div == 0) |
1792 | else { | 1802 | return KEYSPAN_INVALID_BAUD_RATE; |
1803 | else | ||
1793 | cnt = 0 - div; | 1804 | cnt = 0 - div; |
1794 | } | ||
1795 | 1805 | ||
1796 | /* check for out of range, based on portnum, | 1806 | /* check for out of range, based on portnum, |
1797 | and return result */ | 1807 | and return result */ |
1798 | if(portnum == 0) { | 1808 | if (portnum == 0) { |
1799 | if(div > 0xffff) | 1809 | if (div > 0xffff) |
1800 | return (KEYSPAN_INVALID_BAUD_RATE); | 1810 | return KEYSPAN_INVALID_BAUD_RATE; |
1801 | } | 1811 | } else { |
1802 | else { | 1812 | if (portnum == 1) { |
1803 | if(portnum == 1) { | 1813 | if (div > 0xff) |
1804 | if(div > 0xff) { | 1814 | return KEYSPAN_INVALID_BAUD_RATE; |
1805 | return (KEYSPAN_INVALID_BAUD_RATE); | 1815 | } else |
1806 | } | 1816 | return KEYSPAN_INVALID_BAUD_RATE; |
1807 | } | ||
1808 | else { | ||
1809 | return (KEYSPAN_INVALID_BAUD_RATE); | ||
1810 | } | ||
1811 | } | 1817 | } |
1812 | 1818 | ||
1813 | /* return the counter values if not NULL | 1819 | /* return the counter values if not NULL |
1814 | (port 1 will ignore retHi) */ | 1820 | (port 1 will ignore retHi) */ |
1815 | if (rate_low) { | 1821 | if (rate_low) |
1816 | *rate_low = (u8) (cnt & 0xff); | 1822 | *rate_low = (u8) (cnt & 0xff); |
1817 | } | 1823 | if (rate_hi) |
1818 | if (rate_hi) { | ||
1819 | *rate_hi = (u8) ((cnt >> 8) & 0xff); | 1824 | *rate_hi = (u8) ((cnt >> 8) & 0xff); |
1820 | } | 1825 | dbg("%s - %d OK.", __func__, baud_rate); |
1821 | dbg ("%s - %d OK.", __func__, baud_rate); | 1826 | return KEYSPAN_BAUD_RATE_OK; |
1822 | return (KEYSPAN_BAUD_RATE_OK); | ||
1823 | } | 1827 | } |
1824 | 1828 | ||
1825 | static int keyspan_usa26_send_setup(struct usb_serial *serial, | 1829 | static int keyspan_usa26_send_setup(struct usb_serial *serial, |
1826 | struct usb_serial_port *port, | 1830 | struct usb_serial_port *port, |
1827 | int reset_port) | 1831 | int reset_port) |
1828 | { | 1832 | { |
1829 | struct keyspan_usa26_portControlMessage msg; | 1833 | struct keyspan_usa26_portControlMessage msg; |
1830 | struct keyspan_serial_private *s_priv; | 1834 | struct keyspan_serial_private *s_priv; |
1831 | struct keyspan_port_private *p_priv; | 1835 | struct keyspan_port_private *p_priv; |
1832 | const struct keyspan_device_details *d_details; | 1836 | const struct keyspan_device_details *d_details; |
@@ -1834,7 +1838,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1834 | struct urb *this_urb; | 1838 | struct urb *this_urb; |
1835 | int device_port, err; | 1839 | int device_port, err; |
1836 | 1840 | ||
1837 | dbg ("%s reset=%d", __func__, reset_port); | 1841 | dbg("%s reset=%d", __func__, reset_port); |
1838 | 1842 | ||
1839 | s_priv = usb_get_serial_data(serial); | 1843 | s_priv = usb_get_serial_data(serial); |
1840 | p_priv = usb_get_serial_port_data(port); | 1844 | p_priv = usb_get_serial_port_data(port); |
@@ -1857,22 +1861,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1857 | if ((reset_port + 1) > p_priv->resend_cont) | 1861 | if ((reset_port + 1) > p_priv->resend_cont) |
1858 | p_priv->resend_cont = reset_port + 1; | 1862 | p_priv->resend_cont = reset_port + 1; |
1859 | if (this_urb->status == -EINPROGRESS) { | 1863 | if (this_urb->status == -EINPROGRESS) { |
1860 | /* dbg ("%s - already writing", __func__); */ | 1864 | /* dbg("%s - already writing", __func__); */ |
1861 | mdelay(5); | 1865 | mdelay(5); |
1862 | return(-1); | 1866 | return -1; |
1863 | } | 1867 | } |
1864 | 1868 | ||
1865 | memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage)); | 1869 | memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage)); |
1866 | 1870 | ||
1867 | /* Only set baud rate if it's changed */ | 1871 | /* Only set baud rate if it's changed */ |
1868 | if (p_priv->old_baud != p_priv->baud) { | 1872 | if (p_priv->old_baud != p_priv->baud) { |
1869 | p_priv->old_baud = p_priv->baud; | 1873 | p_priv->old_baud = p_priv->baud; |
1870 | msg.setClocking = 0xff; | 1874 | msg.setClocking = 0xff; |
1871 | if (d_details->calculate_baud_rate | 1875 | if (d_details->calculate_baud_rate |
1872 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 1876 | (p_priv->baud, d_details->baudclk, &msg.baudHi, |
1873 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { | 1877 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
1874 | dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, | 1878 | dbg("%s - Invalid baud rate %d requested, using 9600.", |
1875 | p_priv->baud); | 1879 | __func__, p_priv->baud); |
1876 | msg.baudLo = 0; | 1880 | msg.baudLo = 0; |
1877 | msg.baudHi = 125; /* Values for 9600 baud */ | 1881 | msg.baudHi = 125; /* Values for 9600 baud */ |
1878 | msg.prescaler = 10; | 1882 | msg.prescaler = 10; |
@@ -1898,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1898 | if (p_priv->cflag & PARENB) { | 1902 | if (p_priv->cflag & PARENB) { |
1899 | /* note USA_PARITY_NONE == 0 */ | 1903 | /* note USA_PARITY_NONE == 0 */ |
1900 | msg.lcr |= (p_priv->cflag & PARODD)? | 1904 | msg.lcr |= (p_priv->cflag & PARODD)? |
1901 | USA_PARITY_ODD: USA_PARITY_EVEN; | 1905 | USA_PARITY_ODD : USA_PARITY_EVEN; |
1902 | } | 1906 | } |
1903 | msg.setLcr = 0xff; | 1907 | msg.setLcr = 0xff; |
1904 | 1908 | ||
@@ -1939,7 +1943,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1939 | 1943 | ||
1940 | /* Sending intermediate configs */ | 1944 | /* Sending intermediate configs */ |
1941 | else { | 1945 | else { |
1942 | msg._txOn = (! p_priv->break_on); | 1946 | msg._txOn = (!p_priv->break_on); |
1943 | msg._txOff = 0; | 1947 | msg._txOff = 0; |
1944 | msg.txFlush = 0; | 1948 | msg.txFlush = 0; |
1945 | msg.txBreak = (p_priv->break_on); | 1949 | msg.txBreak = (p_priv->break_on); |
@@ -1951,23 +1955,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, | |||
1951 | msg.resetDataToggle = 0x0; | 1955 | msg.resetDataToggle = 0x0; |
1952 | } | 1956 | } |
1953 | 1957 | ||
1954 | /* Do handshaking outputs */ | 1958 | /* Do handshaking outputs */ |
1955 | msg.setTxTriState_setRts = 0xff; | 1959 | msg.setTxTriState_setRts = 0xff; |
1956 | msg.txTriState_rts = p_priv->rts_state; | 1960 | msg.txTriState_rts = p_priv->rts_state; |
1957 | 1961 | ||
1958 | msg.setHskoa_setDtr = 0xff; | 1962 | msg.setHskoa_setDtr = 0xff; |
1959 | msg.hskoa_dtr = p_priv->dtr_state; | 1963 | msg.hskoa_dtr = p_priv->dtr_state; |
1960 | 1964 | ||
1961 | p_priv->resend_cont = 0; | 1965 | p_priv->resend_cont = 0; |
1962 | memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); | 1966 | memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); |
1963 | 1967 | ||
1964 | /* send the data out the device on control endpoint */ | 1968 | /* send the data out the device on control endpoint */ |
1965 | this_urb->transfer_buffer_length = sizeof(msg); | 1969 | this_urb->transfer_buffer_length = sizeof(msg); |
1966 | 1970 | ||
1967 | this_urb->dev = serial->dev; | 1971 | this_urb->dev = serial->dev; |
1968 | if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { | 1972 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
1973 | if (err != 0) | ||
1969 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 1974 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); |
1970 | } | ||
1971 | #if 0 | 1975 | #if 0 |
1972 | else { | 1976 | else { |
1973 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ | 1977 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ |
@@ -1983,14 +1987,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1983 | struct usb_serial_port *port, | 1987 | struct usb_serial_port *port, |
1984 | int reset_port) | 1988 | int reset_port) |
1985 | { | 1989 | { |
1986 | struct keyspan_usa28_portControlMessage msg; | 1990 | struct keyspan_usa28_portControlMessage msg; |
1987 | struct keyspan_serial_private *s_priv; | 1991 | struct keyspan_serial_private *s_priv; |
1988 | struct keyspan_port_private *p_priv; | 1992 | struct keyspan_port_private *p_priv; |
1989 | const struct keyspan_device_details *d_details; | 1993 | const struct keyspan_device_details *d_details; |
1990 | struct urb *this_urb; | 1994 | struct urb *this_urb; |
1991 | int device_port, err; | 1995 | int device_port, err; |
1992 | 1996 | ||
1993 | dbg ("%s", __func__); | 1997 | dbg("%s", __func__); |
1994 | 1998 | ||
1995 | s_priv = usb_get_serial_data(serial); | 1999 | s_priv = usb_get_serial_data(serial); |
1996 | p_priv = usb_get_serial_port_data(port); | 2000 | p_priv = usb_get_serial_port_data(port); |
@@ -1998,7 +2002,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
1998 | device_port = port->number - port->serial->minor; | 2002 | device_port = port->number - port->serial->minor; |
1999 | 2003 | ||
2000 | /* only do something if we have a bulk out endpoint */ | 2004 | /* only do something if we have a bulk out endpoint */ |
2001 | if ((this_urb = p_priv->outcont_urb) == NULL) { | 2005 | this_urb = p_priv->outcont_urb; |
2006 | if (this_urb == NULL) { | ||
2002 | dbg("%s - oops no urb.", __func__); | 2007 | dbg("%s - oops no urb.", __func__); |
2003 | return -1; | 2008 | return -1; |
2004 | } | 2009 | } |
@@ -2008,17 +2013,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
2008 | if ((reset_port + 1) > p_priv->resend_cont) | 2013 | if ((reset_port + 1) > p_priv->resend_cont) |
2009 | p_priv->resend_cont = reset_port + 1; | 2014 | p_priv->resend_cont = reset_port + 1; |
2010 | if (this_urb->status == -EINPROGRESS) { | 2015 | if (this_urb->status == -EINPROGRESS) { |
2011 | dbg ("%s already writing", __func__); | 2016 | dbg("%s already writing", __func__); |
2012 | mdelay(5); | 2017 | mdelay(5); |
2013 | return(-1); | 2018 | return -1; |
2014 | } | 2019 | } |
2015 | 2020 | ||
2016 | memset(&msg, 0, sizeof (struct keyspan_usa28_portControlMessage)); | 2021 | memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage)); |
2017 | 2022 | ||
2018 | msg.setBaudRate = 1; | 2023 | msg.setBaudRate = 1; |
2019 | if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, | 2024 | if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, |
2020 | &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { | 2025 | &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
2021 | dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud); | 2026 | dbg("%s - Invalid baud rate requested %d.", |
2027 | __func__, p_priv->baud); | ||
2022 | msg.baudLo = 0xff; | 2028 | msg.baudLo = 0xff; |
2023 | msg.baudHi = 0xb2; /* Values for 9600 baud */ | 2029 | msg.baudHi = 0xb2; /* Values for 9600 baud */ |
2024 | } | 2030 | } |
@@ -2029,7 +2035,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
2029 | msg.ctsFlowControl = (p_priv->flow_control == flow_cts); | 2035 | msg.ctsFlowControl = (p_priv->flow_control == flow_cts); |
2030 | msg.xonFlowControl = 0; | 2036 | msg.xonFlowControl = 0; |
2031 | 2037 | ||
2032 | /* Do handshaking outputs, DTR is inverted relative to RTS */ | 2038 | /* Do handshaking outputs, DTR is inverted relative to RTS */ |
2033 | msg.rts = p_priv->rts_state; | 2039 | msg.rts = p_priv->rts_state; |
2034 | msg.dtr = p_priv->dtr_state; | 2040 | msg.dtr = p_priv->dtr_state; |
2035 | 2041 | ||
@@ -2071,7 +2077,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
2071 | } | 2077 | } |
2072 | /* Sending intermediate configs */ | 2078 | /* Sending intermediate configs */ |
2073 | else { | 2079 | else { |
2074 | msg._txOn = (! p_priv->break_on); | 2080 | msg._txOn = (!p_priv->break_on); |
2075 | msg._txOff = 0; | 2081 | msg._txOff = 0; |
2076 | msg.txFlush = 0; | 2082 | msg.txFlush = 0; |
2077 | msg.txForceXoff = 0; | 2083 | msg.txForceXoff = 0; |
@@ -2085,15 +2091,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, | |||
2085 | } | 2091 | } |
2086 | 2092 | ||
2087 | p_priv->resend_cont = 0; | 2093 | p_priv->resend_cont = 0; |
2088 | memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); | 2094 | memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); |
2089 | 2095 | ||
2090 | /* send the data out the device on control endpoint */ | 2096 | /* send the data out the device on control endpoint */ |
2091 | this_urb->transfer_buffer_length = sizeof(msg); | 2097 | this_urb->transfer_buffer_length = sizeof(msg); |
2092 | 2098 | ||
2093 | this_urb->dev = serial->dev; | 2099 | this_urb->dev = serial->dev; |
2094 | if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { | 2100 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2101 | if (err != 0) | ||
2095 | dbg("%s - usb_submit_urb(setup) failed", __func__); | 2102 | dbg("%s - usb_submit_urb(setup) failed", __func__); |
2096 | } | ||
2097 | #if 0 | 2103 | #if 0 |
2098 | else { | 2104 | else { |
2099 | dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, | 2105 | dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, |
@@ -2116,7 +2122,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2116 | struct urb *this_urb; | 2122 | struct urb *this_urb; |
2117 | int err, device_port; | 2123 | int err, device_port; |
2118 | 2124 | ||
2119 | dbg ("%s", __func__); | 2125 | dbg("%s", __func__); |
2120 | 2126 | ||
2121 | s_priv = usb_get_serial_data(serial); | 2127 | s_priv = usb_get_serial_data(serial); |
2122 | p_priv = usb_get_serial_port_data(port); | 2128 | p_priv = usb_get_serial_port_data(port); |
@@ -2127,7 +2133,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2127 | /* Work out which port within the device is being setup */ | 2133 | /* Work out which port within the device is being setup */ |
2128 | device_port = port->number - port->serial->minor; | 2134 | device_port = port->number - port->serial->minor; |
2129 | 2135 | ||
2130 | dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); | 2136 | dbg("%s - endpoint %d port %d (%d)", |
2137 | __func__, usb_pipeendpoint(this_urb->pipe), | ||
2138 | port->number, device_port); | ||
2131 | 2139 | ||
2132 | /* Make sure we have an urb then send the message */ | 2140 | /* Make sure we have an urb then send the message */ |
2133 | if (this_urb == NULL) { | 2141 | if (this_urb == NULL) { |
@@ -2141,30 +2149,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2141 | p_priv->resend_cont = reset_port + 1; | 2149 | p_priv->resend_cont = reset_port + 1; |
2142 | 2150 | ||
2143 | if (this_urb->status == -EINPROGRESS) { | 2151 | if (this_urb->status == -EINPROGRESS) { |
2144 | /* dbg ("%s - already writing", __func__); */ | 2152 | /* dbg("%s - already writing", __func__); */ |
2145 | mdelay(5); | 2153 | mdelay(5); |
2146 | return(-1); | 2154 | return -1; |
2147 | } | 2155 | } |
2148 | 2156 | ||
2149 | memset(&msg, 0, sizeof (struct keyspan_usa49_portControlMessage)); | 2157 | memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage)); |
2150 | 2158 | ||
2151 | /*msg.portNumber = port->number;*/ | 2159 | /*msg.portNumber = port->number;*/ |
2152 | msg.portNumber = device_port; | 2160 | msg.portNumber = device_port; |
2153 | 2161 | ||
2154 | /* Only set baud rate if it's changed */ | 2162 | /* Only set baud rate if it's changed */ |
2155 | if (p_priv->old_baud != p_priv->baud) { | 2163 | if (p_priv->old_baud != p_priv->baud) { |
2156 | p_priv->old_baud = p_priv->baud; | 2164 | p_priv->old_baud = p_priv->baud; |
2157 | msg.setClocking = 0xff; | 2165 | msg.setClocking = 0xff; |
2158 | if (d_details->calculate_baud_rate | 2166 | if (d_details->calculate_baud_rate |
2159 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 2167 | (p_priv->baud, d_details->baudclk, &msg.baudHi, |
2160 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { | 2168 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
2161 | dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, | 2169 | dbg("%s - Invalid baud rate %d requested, using 9600.", |
2162 | p_priv->baud); | 2170 | __func__, p_priv->baud); |
2163 | msg.baudLo = 0; | 2171 | msg.baudLo = 0; |
2164 | msg.baudHi = 125; /* Values for 9600 baud */ | 2172 | msg.baudHi = 125; /* Values for 9600 baud */ |
2165 | msg.prescaler = 10; | 2173 | msg.prescaler = 10; |
2166 | } | 2174 | } |
2167 | //msg.setPrescaler = 0xff; | 2175 | /* msg.setPrescaler = 0xff; */ |
2168 | } | 2176 | } |
2169 | 2177 | ||
2170 | msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1; | 2178 | msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1; |
@@ -2185,19 +2193,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2185 | if (p_priv->cflag & PARENB) { | 2193 | if (p_priv->cflag & PARENB) { |
2186 | /* note USA_PARITY_NONE == 0 */ | 2194 | /* note USA_PARITY_NONE == 0 */ |
2187 | msg.lcr |= (p_priv->cflag & PARODD)? | 2195 | msg.lcr |= (p_priv->cflag & PARODD)? |
2188 | USA_PARITY_ODD: USA_PARITY_EVEN; | 2196 | USA_PARITY_ODD : USA_PARITY_EVEN; |
2189 | } | 2197 | } |
2190 | msg.setLcr = 0xff; | 2198 | msg.setLcr = 0xff; |
2191 | 2199 | ||
2192 | msg.ctsFlowControl = (p_priv->flow_control == flow_cts); | 2200 | msg.ctsFlowControl = (p_priv->flow_control == flow_cts); |
2193 | msg.xonFlowControl = 0; | 2201 | msg.xonFlowControl = 0; |
2194 | msg.setFlowControl = 0xff; | 2202 | msg.setFlowControl = 0xff; |
2195 | 2203 | ||
2196 | msg.forwardingLength = 16; | 2204 | msg.forwardingLength = 16; |
2197 | msg.xonChar = 17; | 2205 | msg.xonChar = 17; |
2198 | msg.xoffChar = 19; | 2206 | msg.xoffChar = 19; |
2199 | 2207 | ||
2200 | /* Opening port */ | 2208 | /* Opening port */ |
2201 | if (reset_port == 1) { | 2209 | if (reset_port == 1) { |
2202 | msg._txOn = 1; | 2210 | msg._txOn = 1; |
2203 | msg._txOff = 0; | 2211 | msg._txOff = 0; |
@@ -2229,7 +2237,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2229 | } | 2237 | } |
2230 | /* Sending intermediate configs */ | 2238 | /* Sending intermediate configs */ |
2231 | else { | 2239 | else { |
2232 | msg._txOn = (! p_priv->break_on); | 2240 | msg._txOn = (!p_priv->break_on); |
2233 | msg._txOff = 0; | 2241 | msg._txOff = 0; |
2234 | msg.txFlush = 0; | 2242 | msg.txFlush = 0; |
2235 | msg.txBreak = (p_priv->break_on); | 2243 | msg.txBreak = (p_priv->break_on); |
@@ -2243,16 +2251,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2243 | msg.disablePort = 0; | 2251 | msg.disablePort = 0; |
2244 | } | 2252 | } |
2245 | 2253 | ||
2246 | /* Do handshaking outputs */ | 2254 | /* Do handshaking outputs */ |
2247 | msg.setRts = 0xff; | 2255 | msg.setRts = 0xff; |
2248 | msg.rts = p_priv->rts_state; | 2256 | msg.rts = p_priv->rts_state; |
2249 | 2257 | ||
2250 | msg.setDtr = 0xff; | 2258 | msg.setDtr = 0xff; |
2251 | msg.dtr = p_priv->dtr_state; | 2259 | msg.dtr = p_priv->dtr_state; |
2252 | 2260 | ||
2253 | p_priv->resend_cont = 0; | 2261 | p_priv->resend_cont = 0; |
2254 | 2262 | ||
2255 | /* if the device is a 49wg, we send control message on usb control EP 0 */ | 2263 | /* if the device is a 49wg, we send control message on usb |
2264 | control EP 0 */ | ||
2256 | 2265 | ||
2257 | if (d_details->product_id == keyspan_usa49wg_product_id) { | 2266 | if (d_details->product_id == keyspan_usa49wg_product_id) { |
2258 | dr = (void *)(s_priv->ctrl_buf); | 2267 | dr = (void *)(s_priv->ctrl_buf); |
@@ -2262,23 +2271,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, | |||
2262 | dr->wIndex = 0; | 2271 | dr->wIndex = 0; |
2263 | dr->wLength = cpu_to_le16(sizeof(msg)); | 2272 | dr->wLength = cpu_to_le16(sizeof(msg)); |
2264 | 2273 | ||
2265 | memcpy (s_priv->glocont_buf, &msg, sizeof(msg)); | 2274 | memcpy(s_priv->glocont_buf, &msg, sizeof(msg)); |
2266 | 2275 | ||
2267 | usb_fill_control_urb(this_urb, serial->dev, usb_sndctrlpipe(serial->dev, 0), | 2276 | usb_fill_control_urb(this_urb, serial->dev, |
2268 | (unsigned char *)dr, s_priv->glocont_buf, sizeof(msg), | 2277 | usb_sndctrlpipe(serial->dev, 0), |
2269 | usa49_glocont_callback, serial); | 2278 | (unsigned char *)dr, s_priv->glocont_buf, |
2279 | sizeof(msg), usa49_glocont_callback, serial); | ||
2270 | 2280 | ||
2271 | } else { | 2281 | } else { |
2272 | memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); | 2282 | memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); |
2273 | 2283 | ||
2274 | /* send the data out the device on control endpoint */ | 2284 | /* send the data out the device on control endpoint */ |
2275 | this_urb->transfer_buffer_length = sizeof(msg); | 2285 | this_urb->transfer_buffer_length = sizeof(msg); |
2276 | 2286 | ||
2277 | this_urb->dev = serial->dev; | 2287 | this_urb->dev = serial->dev; |
2278 | } | 2288 | } |
2279 | if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { | 2289 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2290 | if (err != 0) | ||
2280 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 2291 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); |
2281 | } | ||
2282 | #if 0 | 2292 | #if 0 |
2283 | else { | 2293 | else { |
2284 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, | 2294 | dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, |
@@ -2294,7 +2304,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2294 | struct usb_serial_port *port, | 2304 | struct usb_serial_port *port, |
2295 | int reset_port) | 2305 | int reset_port) |
2296 | { | 2306 | { |
2297 | struct keyspan_usa90_portControlMessage msg; | 2307 | struct keyspan_usa90_portControlMessage msg; |
2298 | struct keyspan_serial_private *s_priv; | 2308 | struct keyspan_serial_private *s_priv; |
2299 | struct keyspan_port_private *p_priv; | 2309 | struct keyspan_port_private *p_priv; |
2300 | const struct keyspan_device_details *d_details; | 2310 | const struct keyspan_device_details *d_details; |
@@ -2302,14 +2312,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2302 | int err; | 2312 | int err; |
2303 | u8 prescaler; | 2313 | u8 prescaler; |
2304 | 2314 | ||
2305 | dbg ("%s", __func__); | 2315 | dbg("%s", __func__); |
2306 | 2316 | ||
2307 | s_priv = usb_get_serial_data(serial); | 2317 | s_priv = usb_get_serial_data(serial); |
2308 | p_priv = usb_get_serial_port_data(port); | 2318 | p_priv = usb_get_serial_port_data(port); |
2309 | d_details = s_priv->device_details; | 2319 | d_details = s_priv->device_details; |
2310 | 2320 | ||
2311 | /* only do something if we have a bulk out endpoint */ | 2321 | /* only do something if we have a bulk out endpoint */ |
2312 | if ((this_urb = p_priv->outcont_urb) == NULL) { | 2322 | this_urb = p_priv->outcont_urb; |
2323 | if (this_urb == NULL) { | ||
2313 | dbg("%s - oops no urb.", __func__); | 2324 | dbg("%s - oops no urb.", __func__); |
2314 | return -1; | 2325 | return -1; |
2315 | } | 2326 | } |
@@ -2319,24 +2330,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2319 | if ((reset_port + 1) > p_priv->resend_cont) | 2330 | if ((reset_port + 1) > p_priv->resend_cont) |
2320 | p_priv->resend_cont = reset_port + 1; | 2331 | p_priv->resend_cont = reset_port + 1; |
2321 | if (this_urb->status == -EINPROGRESS) { | 2332 | if (this_urb->status == -EINPROGRESS) { |
2322 | dbg ("%s already writing", __func__); | 2333 | dbg("%s already writing", __func__); |
2323 | mdelay(5); | 2334 | mdelay(5); |
2324 | return(-1); | 2335 | return -1; |
2325 | } | 2336 | } |
2326 | 2337 | ||
2327 | memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage)); | 2338 | memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage)); |
2328 | 2339 | ||
2329 | /* Only set baud rate if it's changed */ | 2340 | /* Only set baud rate if it's changed */ |
2330 | if (p_priv->old_baud != p_priv->baud) { | 2341 | if (p_priv->old_baud != p_priv->baud) { |
2331 | p_priv->old_baud = p_priv->baud; | 2342 | p_priv->old_baud = p_priv->baud; |
2332 | msg.setClocking = 0x01; | 2343 | msg.setClocking = 0x01; |
2333 | if (d_details->calculate_baud_rate | 2344 | if (d_details->calculate_baud_rate |
2334 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 2345 | (p_priv->baud, d_details->baudclk, &msg.baudHi, |
2335 | &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) { | 2346 | &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) { |
2336 | dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, | 2347 | dbg("%s - Invalid baud rate %d requested, using 9600.", |
2337 | p_priv->baud); | 2348 | __func__, p_priv->baud); |
2338 | p_priv->baud = 9600; | 2349 | p_priv->baud = 9600; |
2339 | d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, | 2350 | d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, |
2340 | &msg.baudHi, &msg.baudLo, &prescaler, 0); | 2351 | &msg.baudHi, &msg.baudLo, &prescaler, 0); |
2341 | } | 2352 | } |
2342 | msg.setRxMode = 1; | 2353 | msg.setRxMode = 1; |
@@ -2344,13 +2355,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2344 | } | 2355 | } |
2345 | 2356 | ||
2346 | /* modes must always be correctly specified */ | 2357 | /* modes must always be correctly specified */ |
2347 | if (p_priv->baud > 57600) | 2358 | if (p_priv->baud > 57600) { |
2348 | { | ||
2349 | msg.rxMode = RXMODE_DMA; | 2359 | msg.rxMode = RXMODE_DMA; |
2350 | msg.txMode = TXMODE_DMA; | 2360 | msg.txMode = TXMODE_DMA; |
2351 | } | 2361 | } else { |
2352 | else | ||
2353 | { | ||
2354 | msg.rxMode = RXMODE_BYHAND; | 2362 | msg.rxMode = RXMODE_BYHAND; |
2355 | msg.txMode = TXMODE_BYHAND; | 2363 | msg.txMode = TXMODE_BYHAND; |
2356 | } | 2364 | } |
@@ -2373,7 +2381,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2373 | if (p_priv->cflag & PARENB) { | 2381 | if (p_priv->cflag & PARENB) { |
2374 | /* note USA_PARITY_NONE == 0 */ | 2382 | /* note USA_PARITY_NONE == 0 */ |
2375 | msg.lcr |= (p_priv->cflag & PARODD)? | 2383 | msg.lcr |= (p_priv->cflag & PARODD)? |
2376 | USA_PARITY_ODD: USA_PARITY_EVEN; | 2384 | USA_PARITY_ODD : USA_PARITY_EVEN; |
2377 | } | 2385 | } |
2378 | if (p_priv->old_cflag != p_priv->cflag) { | 2386 | if (p_priv->old_cflag != p_priv->cflag) { |
2379 | p_priv->old_cflag = p_priv->cflag; | 2387 | p_priv->old_cflag = p_priv->cflag; |
@@ -2384,23 +2392,22 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2384 | msg.txFlowControl = TXFLOW_CTS; | 2392 | msg.txFlowControl = TXFLOW_CTS; |
2385 | msg.setTxFlowControl = 0x01; | 2393 | msg.setTxFlowControl = 0x01; |
2386 | msg.setRxFlowControl = 0x01; | 2394 | msg.setRxFlowControl = 0x01; |
2387 | 2395 | ||
2388 | msg.rxForwardingLength = 16; | 2396 | msg.rxForwardingLength = 16; |
2389 | msg.rxForwardingTimeout = 16; | 2397 | msg.rxForwardingTimeout = 16; |
2390 | msg.txAckSetting = 0; | 2398 | msg.txAckSetting = 0; |
2391 | msg.xonChar = 17; | 2399 | msg.xonChar = 17; |
2392 | msg.xoffChar = 19; | 2400 | msg.xoffChar = 19; |
2393 | 2401 | ||
2394 | /* Opening port */ | 2402 | /* Opening port */ |
2395 | if (reset_port == 1) { | 2403 | if (reset_port == 1) { |
2396 | msg.portEnabled = 1; | 2404 | msg.portEnabled = 1; |
2397 | msg.rxFlush = 1; | 2405 | msg.rxFlush = 1; |
2398 | msg.txBreak = (p_priv->break_on); | 2406 | msg.txBreak = (p_priv->break_on); |
2399 | } | 2407 | } |
2400 | /* Closing port */ | 2408 | /* Closing port */ |
2401 | else if (reset_port == 2) { | 2409 | else if (reset_port == 2) |
2402 | msg.portEnabled = 0; | 2410 | msg.portEnabled = 0; |
2403 | } | ||
2404 | /* Sending intermediate configs */ | 2411 | /* Sending intermediate configs */ |
2405 | else { | 2412 | else { |
2406 | if (port->port.count) | 2413 | if (port->port.count) |
@@ -2408,23 +2415,23 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, | |||
2408 | msg.txBreak = (p_priv->break_on); | 2415 | msg.txBreak = (p_priv->break_on); |
2409 | } | 2416 | } |
2410 | 2417 | ||
2411 | /* Do handshaking outputs */ | 2418 | /* Do handshaking outputs */ |
2412 | msg.setRts = 0x01; | 2419 | msg.setRts = 0x01; |
2413 | msg.rts = p_priv->rts_state; | 2420 | msg.rts = p_priv->rts_state; |
2414 | 2421 | ||
2415 | msg.setDtr = 0x01; | 2422 | msg.setDtr = 0x01; |
2416 | msg.dtr = p_priv->dtr_state; | 2423 | msg.dtr = p_priv->dtr_state; |
2417 | 2424 | ||
2418 | p_priv->resend_cont = 0; | 2425 | p_priv->resend_cont = 0; |
2419 | memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); | 2426 | memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); |
2420 | 2427 | ||
2421 | /* send the data out the device on control endpoint */ | 2428 | /* send the data out the device on control endpoint */ |
2422 | this_urb->transfer_buffer_length = sizeof(msg); | 2429 | this_urb->transfer_buffer_length = sizeof(msg); |
2423 | 2430 | ||
2424 | this_urb->dev = serial->dev; | 2431 | this_urb->dev = serial->dev; |
2425 | if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { | 2432 | err = usb_submit_urb(this_urb, GFP_ATOMIC); |
2433 | if (err != 0) | ||
2426 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); | 2434 | dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); |
2427 | } | ||
2428 | return 0; | 2435 | return 0; |
2429 | } | 2436 | } |
2430 | 2437 | ||
@@ -2439,7 +2446,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2439 | struct urb *this_urb; | 2446 | struct urb *this_urb; |
2440 | int err, device_port; | 2447 | int err, device_port; |
2441 | 2448 | ||
2442 | dbg ("%s", __func__); | 2449 | dbg("%s", __func__); |
2443 | 2450 | ||
2444 | s_priv = usb_get_serial_data(serial); | 2451 | s_priv = usb_get_serial_data(serial); |
2445 | p_priv = usb_get_serial_port_data(port); | 2452 | p_priv = usb_get_serial_port_data(port); |
@@ -2462,9 +2469,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2462 | if ((reset_port + 1) > p_priv->resend_cont) | 2469 | if ((reset_port + 1) > p_priv->resend_cont) |
2463 | p_priv->resend_cont = reset_port + 1; | 2470 | p_priv->resend_cont = reset_port + 1; |
2464 | if (this_urb->status == -EINPROGRESS) { | 2471 | if (this_urb->status == -EINPROGRESS) { |
2465 | /* dbg ("%s - already writing", __func__); */ | 2472 | /* dbg("%s - already writing", __func__); */ |
2466 | mdelay(5); | 2473 | mdelay(5); |
2467 | return(-1); | 2474 | return -1; |
2468 | } | 2475 | } |
2469 | 2476 | ||
2470 | memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage)); | 2477 | memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage)); |
@@ -2477,9 +2484,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2477 | msg.setClocking = 0xff; | 2484 | msg.setClocking = 0xff; |
2478 | if (d_details->calculate_baud_rate | 2485 | if (d_details->calculate_baud_rate |
2479 | (p_priv->baud, d_details->baudclk, &msg.baudHi, | 2486 | (p_priv->baud, d_details->baudclk, &msg.baudHi, |
2480 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { | 2487 | &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { |
2481 | dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, | 2488 | dbg("%s - Invalid baud rate %d requested, using 9600.", |
2482 | p_priv->baud); | 2489 | __func__, p_priv->baud); |
2483 | msg.baudLo = 0; | 2490 | msg.baudLo = 0; |
2484 | msg.baudHi = 125; /* Values for 9600 baud */ | 2491 | msg.baudHi = 125; /* Values for 9600 baud */ |
2485 | msg.prescaler = 10; | 2492 | msg.prescaler = 10; |
@@ -2505,7 +2512,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2505 | if (p_priv->cflag & PARENB) { | 2512 | if (p_priv->cflag & PARENB) { |
2506 | /* note USA_PARITY_NONE == 0 */ | 2513 | /* note USA_PARITY_NONE == 0 */ |
2507 | msg.lcr |= (p_priv->cflag & PARODD)? | 2514 | msg.lcr |= (p_priv->cflag & PARODD)? |
2508 | USA_PARITY_ODD: USA_PARITY_EVEN; | 2515 | USA_PARITY_ODD : USA_PARITY_EVEN; |
2509 | } | 2516 | } |
2510 | msg.setLcr = 0xff; | 2517 | msg.setLcr = 0xff; |
2511 | 2518 | ||
@@ -2542,7 +2549,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, | |||
2542 | msg.resetDataToggle = 0; | 2549 | msg.resetDataToggle = 0; |
2543 | } else { | 2550 | } else { |
2544 | /* Sending intermediate configs */ | 2551 | /* Sending intermediate configs */ |
2545 | msg._txOn = (! p_priv->break_on); | 2552 | msg._txOn = (!p_priv->break_on); |
2546 | msg._txOff = 0; | 2553 | msg._txOff = 0; |
2547 | msg.txFlush = 0; | 2554 | msg.txFlush = 0; |
2548 | msg.txBreak = (p_priv->break_on); | 2555 | msg.txBreak = (p_priv->break_on); |
@@ -2582,7 +2589,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) | |||
2582 | struct keyspan_serial_private *s_priv; | 2589 | struct keyspan_serial_private *s_priv; |
2583 | const struct keyspan_device_details *d_details; | 2590 | const struct keyspan_device_details *d_details; |
2584 | 2591 | ||
2585 | dbg ("%s", __func__); | 2592 | dbg("%s", __func__); |
2586 | 2593 | ||
2587 | s_priv = usb_get_serial_data(serial); | 2594 | s_priv = usb_get_serial_data(serial); |
2588 | d_details = s_priv->device_details; | 2595 | d_details = s_priv->device_details; |
@@ -2609,7 +2616,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) | |||
2609 | 2616 | ||
2610 | /* Gets called by the "real" driver (ie once firmware is loaded | 2617 | /* Gets called by the "real" driver (ie once firmware is loaded |
2611 | and renumeration has taken place. */ | 2618 | and renumeration has taken place. */ |
2612 | static int keyspan_startup (struct usb_serial *serial) | 2619 | static int keyspan_startup(struct usb_serial *serial) |
2613 | { | 2620 | { |
2614 | int i, err; | 2621 | int i, err; |
2615 | struct usb_serial_port *port; | 2622 | struct usb_serial_port *port; |
@@ -2620,17 +2627,20 @@ static int keyspan_startup (struct usb_serial *serial) | |||
2620 | dbg("%s", __func__); | 2627 | dbg("%s", __func__); |
2621 | 2628 | ||
2622 | for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) | 2629 | for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) |
2623 | if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) | 2630 | if (d_details->product_id == |
2631 | le16_to_cpu(serial->dev->descriptor.idProduct)) | ||
2624 | break; | 2632 | break; |
2625 | if (d_details == NULL) { | 2633 | if (d_details == NULL) { |
2626 | dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); | 2634 | dev_err(&serial->dev->dev, "%s - unknown product id %x\n", |
2635 | __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); | ||
2627 | return 1; | 2636 | return 1; |
2628 | } | 2637 | } |
2629 | 2638 | ||
2630 | /* Setup private data for serial driver */ | 2639 | /* Setup private data for serial driver */ |
2631 | s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); | 2640 | s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); |
2632 | if (!s_priv) { | 2641 | if (!s_priv) { |
2633 | dbg("%s - kmalloc for keyspan_serial_private failed.", __func__); | 2642 | dbg("%s - kmalloc for keyspan_serial_private failed.", |
2643 | __func__); | ||
2634 | return -ENOMEM; | 2644 | return -ENOMEM; |
2635 | } | 2645 | } |
2636 | 2646 | ||
@@ -2640,10 +2650,11 @@ static int keyspan_startup (struct usb_serial *serial) | |||
2640 | /* Now setup per port private data */ | 2650 | /* Now setup per port private data */ |
2641 | for (i = 0; i < serial->num_ports; i++) { | 2651 | for (i = 0; i < serial->num_ports; i++) { |
2642 | port = serial->port[i]; | 2652 | port = serial->port[i]; |
2643 | p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); | 2653 | p_priv = kzalloc(sizeof(struct keyspan_port_private), |
2654 | GFP_KERNEL); | ||
2644 | if (!p_priv) { | 2655 | if (!p_priv) { |
2645 | dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); | 2656 | dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); |
2646 | return (1); | 2657 | return 1; |
2647 | } | 2658 | } |
2648 | p_priv->device_details = d_details; | 2659 | p_priv->device_details = d_details; |
2649 | usb_set_serial_port_data(port, p_priv); | 2660 | usb_set_serial_port_data(port, p_priv); |
@@ -2665,11 +2676,11 @@ static int keyspan_startup (struct usb_serial *serial) | |||
2665 | dbg("%s - submit indat urb failed %d", __func__, | 2676 | dbg("%s - submit indat urb failed %d", __func__, |
2666 | err); | 2677 | err); |
2667 | } | 2678 | } |
2668 | 2679 | ||
2669 | return 0; | 2680 | return 0; |
2670 | } | 2681 | } |
2671 | 2682 | ||
2672 | static void keyspan_shutdown (struct usb_serial *serial) | 2683 | static void keyspan_shutdown(struct usb_serial *serial) |
2673 | { | 2684 | { |
2674 | int i, j; | 2685 | int i, j; |
2675 | struct usb_serial_port *port; | 2686 | struct usb_serial_port *port; |
@@ -2721,8 +2732,8 @@ static void keyspan_shutdown (struct usb_serial *serial) | |||
2721 | } | 2732 | } |
2722 | } | 2733 | } |
2723 | 2734 | ||
2724 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 2735 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2725 | MODULE_DESCRIPTION( DRIVER_DESC ); | 2736 | MODULE_DESCRIPTION(DRIVER_DESC); |
2726 | MODULE_LICENSE("GPL"); | 2737 | MODULE_LICENSE("GPL"); |
2727 | 2738 | ||
2728 | MODULE_FIRMWARE("keyspan/usa28.fw"); | 2739 | MODULE_FIRMWARE("keyspan/usa28.fw"); |