Commit deb91685 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

tty-usb-keyspan: Coding style

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9e8e2d2a
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/ihex.h> #include <linux/ihex.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
#include "keyspan.h" #include "keyspan.h"
...@@ -132,15 +132,15 @@ struct keyspan_serial_private { ...@@ -132,15 +132,15 @@ struct keyspan_serial_private {
struct urb *instat_urb; struct urb *instat_urb;
char instat_buf[INSTAT_BUFLEN]; char instat_buf[INSTAT_BUFLEN];
/* added to support 49wg, where data from all 4 ports comes in on 1 EP */ /* added to support 49wg, where data from all 4 ports comes in
/* and high-speed supported */ on 1 EP and high-speed supported */
struct urb *indat_urb; struct urb *indat_urb;
char indat_buf[INDAT49W_BUFLEN]; char indat_buf[INDAT49W_BUFLEN];
/* XXX this one probably will need a lock */ /* XXX this one probably will need a lock */
struct urb *glocont_urb; struct urb *glocont_urb;
char glocont_buf[GLOCONT_BUFLEN]; char glocont_buf[GLOCONT_BUFLEN];
char ctrl_buf[8]; // for EP0 control message char ctrl_buf[8]; /* for EP0 control message */
}; };
struct keyspan_port_private { struct keyspan_port_private {
...@@ -186,10 +186,10 @@ struct keyspan_port_private { ...@@ -186,10 +186,10 @@ struct keyspan_port_private {
int resend_cont; /* need to resend control packet */ int resend_cont; /* need to resend control packet */
}; };
/* Include Keyspan message headers. All current Keyspan Adapters /* Include Keyspan message headers. All current Keyspan Adapters
make use of one of five message formats which are referred make use of one of five message formats which are referred
to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */ to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
within this driver. */
#include "keyspan_usa26msg.h" #include "keyspan_usa26msg.h"
#include "keyspan_usa28msg.h" #include "keyspan_usa28msg.h"
#include "keyspan_usa49msg.h" #include "keyspan_usa49msg.h"
...@@ -198,7 +198,7 @@ struct keyspan_port_private { ...@@ -198,7 +198,7 @@ struct keyspan_port_private {
/* Functions used by new usb-serial code. */ /* Functions used by new usb-serial code. */
static int __init keyspan_init (void) static int __init keyspan_init(void)
{ {
int retval; int retval;
retval = usb_serial_register(&keyspan_pre_device); retval = usb_serial_register(&keyspan_pre_device);
...@@ -232,13 +232,13 @@ static int __init keyspan_init (void) ...@@ -232,13 +232,13 @@ static int __init keyspan_init (void)
return retval; return retval;
} }
static void __exit keyspan_exit (void) static void __exit keyspan_exit(void)
{ {
usb_deregister (&keyspan_driver); usb_deregister(&keyspan_driver);
usb_serial_deregister (&keyspan_pre_device); usb_serial_deregister(&keyspan_pre_device);
usb_serial_deregister (&keyspan_1port_device); usb_serial_deregister(&keyspan_1port_device);
usb_serial_deregister (&keyspan_2port_device); usb_serial_deregister(&keyspan_2port_device);
usb_serial_deregister (&keyspan_4port_device); usb_serial_deregister(&keyspan_4port_device);
} }
module_init(keyspan_init); module_init(keyspan_init);
...@@ -262,7 +262,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state) ...@@ -262,7 +262,7 @@ static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
} }
static void keyspan_set_termios (struct tty_struct *tty, static void keyspan_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
int baud_rate, device_port; int baud_rate, device_port;
...@@ -368,35 +368,38 @@ static int keyspan_write(struct tty_struct *tty, ...@@ -368,35 +368,38 @@ static int keyspan_write(struct tty_struct *tty,
flip = p_priv->out_flip; flip = p_priv->out_flip;
/* Check we have a valid urb/endpoint before we use it... */ /* Check we have a valid urb/endpoint before we use it... */
if ((this_urb = p_priv->out_urbs[flip]) == NULL) { this_urb = p_priv->out_urbs[flip];
if (this_urb == NULL) {
/* no bulk out, so return 0 bytes written */ /* no bulk out, so return 0 bytes written */
dbg("%s - no output urb :(", __func__); dbg("%s - no output urb :(", __func__);
return count; return count;
} }
dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip); dbg("%s - endpoint %d flip %d",
__func__, usb_pipeendpoint(this_urb->pipe), flip);
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ)) if (time_before(jiffies,
p_priv->tx_start_time[flip] + 10 * HZ))
break; break;
usb_unlink_urb(this_urb); usb_unlink_urb(this_urb);
break; break;
} }
/* First byte in buffer is "last flag" (except for usa19hx) - unused so /* First byte in buffer is "last flag" (except for usa19hx)
for now so set to zero */ - unused so for now so set to zero */
((char *)this_urb->transfer_buffer)[0] = 0; ((char *)this_urb->transfer_buffer)[0] = 0;
memcpy (this_urb->transfer_buffer + dataOffset, buf, todo); memcpy(this_urb->transfer_buffer + dataOffset, buf, todo);
buf += todo; buf += todo;
/* send the data out the bulk port */ /* send the data out the bulk port */
this_urb->transfer_buffer_length = todo + dataOffset; this_urb->transfer_buffer_length = todo + dataOffset;
this_urb->dev = port->serial->dev; this_urb->dev = port->serial->dev;
if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err != 0)
dbg("usb_submit_urb(write bulk) failed (%d)", err); dbg("usb_submit_urb(write bulk) failed (%d)", err);
}
p_priv->tx_start_time[flip] = jiffies; p_priv->tx_start_time[flip] = jiffies;
/* Flip for next time if usa26 or usa28 interface /* Flip for next time if usa26 or usa28 interface
...@@ -416,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb) ...@@ -416,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe); endpoint = usb_pipeendpoint(urb->pipe);
...@@ -431,13 +434,14 @@ static void usa26_indat_callback(struct urb *urb) ...@@ -431,13 +434,14 @@ static void usa26_indat_callback(struct urb *urb)
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
/* 0x80 bit is error flag */ /* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) { if ((data[0] & 0x80) == 0) {
/* no errors on individual bytes, only possible overrun err*/ /* no errors on individual bytes, only
possible overrun err */
if (data[0] & RXERROR_OVERRUN) if (data[0] & RXERROR_OVERRUN)
err = TTY_OVERRUN; err = TTY_OVERRUN;
else err = 0; else
for (i = 1; i < urb->actual_length ; ++i) { err = 0;
for (i = 1; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], err); tty_insert_flip_char(tty, data[i], err);
}
} else { } else {
/* some bytes had errors, every byte has status */ /* some bytes had errors, every byte has status */
dbg("%s - RX error!!!!", __func__); dbg("%s - RX error!!!!", __func__);
...@@ -458,14 +462,16 @@ static void usa26_indat_callback(struct urb *urb) ...@@ -458,14 +462,16 @@ static void usa26_indat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev; urb->dev = port->serial->dev;
if (port->port.count) if (port->port.count) {
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
dbg("%s - resubmit read urb failed. (%d)", __func__, err); if (err != 0)
dbg("%s - resubmit read urb failed. (%d)",
__func__, err);
} }
return; return;
} }
/* Outdat handling is common for all devices */ /* Outdat handling is common for all devices */
static void usa2x_outdat_callback(struct urb *urb) static void usa2x_outdat_callback(struct urb *urb)
{ {
struct usb_serial_port *port; struct usb_serial_port *port;
...@@ -473,7 +479,7 @@ static void usa2x_outdat_callback(struct urb *urb) ...@@ -473,7 +479,7 @@ static void usa2x_outdat_callback(struct urb *urb)
port = urb->context; port = urb->context;
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
if (port->port.count) if (port->port.count)
usb_serial_port_softint(port); usb_serial_port_softint(port);
...@@ -481,7 +487,7 @@ static void usa2x_outdat_callback(struct urb *urb) ...@@ -481,7 +487,7 @@ static void usa2x_outdat_callback(struct urb *urb)
static void usa26_inack_callback(struct urb *urb) static void usa26_inack_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
...@@ -494,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb) ...@@ -494,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) { if (p_priv->resend_cont) {
dbg ("%s - sending setup", __func__); dbg("%s - sending setup", __func__);
keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1); keyspan_usa26_send_setup(port->serial, port,
p_priv->resend_cont - 1);
} }
} }
...@@ -533,7 +540,7 @@ static void usa26_instat_callback(struct urb *urb) ...@@ -533,7 +540,7 @@ static void usa26_instat_callback(struct urb *urb)
/* Check port number from message and retrieve private data */ /* Check port number from message and retrieve private data */
if (msg->port >= serial->num_ports) { if (msg->port >= serial->num_ports) {
dbg ("%s - Unexpected port number %d", __func__, msg->port); dbg("%s - Unexpected port number %d", __func__, msg->port);
goto exit; goto exit;
} }
port = serial->port[msg->port]; port = serial->port[msg->port];
...@@ -556,16 +563,15 @@ static void usa26_instat_callback(struct urb *urb) ...@@ -556,16 +563,15 @@ static void usa26_instat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = serial->dev; urb->dev = serial->dev;
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
}
exit: ; exit: ;
} }
static void usa26_glocont_callback(struct urb *urb) static void usa26_glocont_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
...@@ -578,7 +584,7 @@ static void usa28_indat_callback(struct urb *urb) ...@@ -578,7 +584,7 @@ static void usa28_indat_callback(struct urb *urb)
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
port = urb->context; port = urb->context;
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -600,17 +606,18 @@ static void usa28_indat_callback(struct urb *urb) ...@@ -600,17 +606,18 @@ static void usa28_indat_callback(struct urb *urb)
tty = port->port.tty; tty = port->port.tty;
if (urb->actual_length) { if (urb->actual_length) {
for (i = 0; i < urb->actual_length ; ++i) { for (i = 0; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], 0); tty_insert_flip_char(tty, data[i], 0);
}
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev; urb->dev = port->serial->dev;
if (port->port.count) if (port->port.count) {
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
dbg("%s - resubmit read urb failed. (%d)", __func__, err); if (err != 0)
dbg("%s - resubmit read urb failed. (%d)",
__func__, err);
} }
p_priv->in_flip ^= 1; p_priv->in_flip ^= 1;
...@@ -620,7 +627,7 @@ static void usa28_indat_callback(struct urb *urb) ...@@ -620,7 +627,7 @@ static void usa28_indat_callback(struct urb *urb)
static void usa28_inack_callback(struct urb *urb) static void usa28_inack_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
static void usa28_outcont_callback(struct urb *urb) static void usa28_outcont_callback(struct urb *urb)
...@@ -632,8 +639,9 @@ static void usa28_outcont_callback(struct urb *urb) ...@@ -632,8 +639,9 @@ static void usa28_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) { if (p_priv->resend_cont) {
dbg ("%s - sending setup", __func__); dbg("%s - sending setup", __func__);
keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1); keyspan_usa28_send_setup(port->serial, port,
p_priv->resend_cont - 1);
} }
} }
...@@ -667,10 +675,9 @@ static void usa28_instat_callback(struct urb *urb) ...@@ -667,10 +675,9 @@ static void usa28_instat_callback(struct urb *urb)
/* Now do something useful with the data */ /* Now do something useful with the data */
msg = (struct keyspan_usa28_portStatusMessage *)data; msg = (struct keyspan_usa28_portStatusMessage *)data;
/* Check port number from message and retrieve private data */ /* Check port number from message and retrieve private data */
if (msg->port >= serial->num_ports) { if (msg->port >= serial->num_ports) {
dbg ("%s - Unexpected port number %d", __func__, msg->port); dbg("%s - Unexpected port number %d", __func__, msg->port);
goto exit; goto exit;
} }
port = serial->port[msg->port]; port = serial->port[msg->port];
...@@ -693,15 +700,15 @@ static void usa28_instat_callback(struct urb *urb) ...@@ -693,15 +700,15 @@ static void usa28_instat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = serial->dev; urb->dev = serial->dev;
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
}
exit: ; exit: ;
} }
static void usa28_glocont_callback(struct urb *urb) static void usa28_glocont_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
...@@ -712,7 +719,7 @@ static void usa49_glocont_callback(struct urb *urb) ...@@ -712,7 +719,7 @@ static void usa49_glocont_callback(struct urb *urb)
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
int i; int i;
dbg ("%s", __func__); dbg("%s", __func__);
serial = urb->context; serial = urb->context;
for (i = 0; i < serial->num_ports; ++i) { for (i = 0; i < serial->num_ports; ++i) {
...@@ -720,8 +727,9 @@ static void usa49_glocont_callback(struct urb *urb) ...@@ -720,8 +727,9 @@ static void usa49_glocont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) { if (p_priv->resend_cont) {
dbg ("%s - sending setup", __func__); dbg("%s - sending setup", __func__);
keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1); keyspan_usa49_send_setup(serial, port,
p_priv->resend_cont - 1);
break; break;
} }
} }
...@@ -740,7 +748,7 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -740,7 +748,7 @@ static void usa49_instat_callback(struct urb *urb)
int old_dcd_state; int old_dcd_state;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
serial = urb->context; serial = urb->context;
...@@ -749,7 +757,8 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -749,7 +757,8 @@ static void usa49_instat_callback(struct urb *urb)
return; return;
} }
if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) { if (urb->actual_length !=
sizeof(struct keyspan_usa49_portStatusMessage)) {
dbg("%s - bad length %d", __func__, urb->actual_length); dbg("%s - bad length %d", __func__, urb->actual_length);
goto exit; goto exit;
} }
...@@ -763,7 +772,8 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -763,7 +772,8 @@ static void usa49_instat_callback(struct urb *urb)
/* Check port number from message and retrieve private data */ /* Check port number from message and retrieve private data */
if (msg->portNumber >= serial->num_ports) { if (msg->portNumber >= serial->num_ports) {
dbg ("%s - Unexpected port number %d", __func__, msg->portNumber); dbg("%s - Unexpected port number %d",
__func__, msg->portNumber);
goto exit; goto exit;
} }
port = serial->port[msg->portNumber]; port = serial->port[msg->portNumber];
...@@ -787,15 +797,15 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -787,15 +797,15 @@ static void usa49_instat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = serial->dev; urb->dev = serial->dev;
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
}
exit: ; exit: ;
} }
static void usa49_inack_callback(struct urb *urb) static void usa49_inack_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
static void usa49_indat_callback(struct urb *urb) static void usa49_indat_callback(struct urb *urb)
...@@ -807,7 +817,7 @@ static void usa49_indat_callback(struct urb *urb) ...@@ -807,7 +817,7 @@ static void usa49_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe); endpoint = usb_pipeendpoint(urb->pipe);
...@@ -823,9 +833,8 @@ static void usa49_indat_callback(struct urb *urb) ...@@ -823,9 +833,8 @@ static void usa49_indat_callback(struct urb *urb)
/* 0x80 bit is error flag */ /* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) { if ((data[0] & 0x80) == 0) {
/* no error on any byte */ /* no error on any byte */
for (i = 1; i < urb->actual_length ; ++i) { for (i = 1; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], 0); tty_insert_flip_char(tty, data[i], 0);
}
} else { } else {
/* some bytes had errors, every byte has status */ /* some bytes had errors, every byte has status */
for (i = 0; i + 1 < urb->actual_length; i += 2) { for (i = 0; i + 1 < urb->actual_length; i += 2) {
...@@ -845,9 +854,11 @@ static void usa49_indat_callback(struct urb *urb) ...@@ -845,9 +854,11 @@ static void usa49_indat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev; urb->dev = port->serial->dev;
if (port->port.count) if (port->port.count) {
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
dbg("%s - resubmit read urb failed. (%d)", __func__, err); if (err != 0)
dbg("%s - resubmit read urb failed. (%d)",
__func__, err);
} }
} }
...@@ -860,7 +871,7 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -860,7 +871,7 @@ static void usa49wg_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
serial = urb->context; serial = urb->context;
...@@ -878,7 +889,7 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -878,7 +889,7 @@ static void usa49wg_indat_callback(struct urb *urb)
/* Check port number from message*/ /* Check port number from message*/
if (data[i] >= serial->num_ports) { if (data[i] >= serial->num_ports) {
dbg ("%s - Unexpected port number %d", dbg("%s - Unexpected port number %d",
__func__, data[i]); __func__, data[i]);
return; return;
} }
...@@ -931,7 +942,7 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -931,7 +942,7 @@ static void usa49wg_indat_callback(struct urb *urb)
/* not used, usa-49 doesn't have per-port control endpoints */ /* not used, usa-49 doesn't have per-port control endpoints */
static void usa49_outcont_callback(struct urb *urb) static void usa49_outcont_callback(struct urb *urb)
{ {
dbg ("%s", __func__); dbg("%s", __func__);
} }
static void usa90_indat_callback(struct urb *urb) static void usa90_indat_callback(struct urb *urb)
...@@ -944,7 +955,7 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -944,7 +955,7 @@ static void usa90_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe); endpoint = usb_pipeendpoint(urb->pipe);
...@@ -959,27 +970,25 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -959,27 +970,25 @@ static void usa90_indat_callback(struct urb *urb)
tty = port->port.tty; tty = port->port.tty;
if (urb->actual_length) { if (urb->actual_length) {
/* if current mode is DMA, looks like usa28 format /* if current mode is DMA, looks like usa28 format
otherwise looks like usa26 data format */ otherwise looks like usa26 data format */
if (p_priv->baud > 57600) { if (p_priv->baud > 57600) {
for (i = 0; i < urb->actual_length ; ++i) for (i = 0; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], 0); tty_insert_flip_char(tty, data[i], 0);
} } else {
else {
/* 0x80 bit is error flag */ /* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) { if ((data[0] & 0x80) == 0) {
/* no errors on individual bytes, only possible overrun err*/ /* no errors on individual bytes, only
possible overrun err*/
if (data[0] & RXERROR_OVERRUN) if (data[0] & RXERROR_OVERRUN)
err = TTY_OVERRUN; err = TTY_OVERRUN;
else err = 0; else
err = 0;
for (i = 1; i < urb->actual_length ; ++i) for (i = 1; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], err); tty_insert_flip_char(tty, data[i],
err);
} } else {
else {
/* some bytes had errors, every byte has status */ /* some bytes had errors, every byte has status */
dbg("%s - RX error!!!!", __func__); dbg("%s - RX error!!!!", __func__);
for (i = 0; i + 1 < urb->actual_length; i += 2) { for (i = 0; i + 1 < urb->actual_length; i += 2) {
...@@ -991,7 +1000,8 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -991,7 +1000,8 @@ static void usa90_indat_callback(struct urb *urb)
if (stat & RXERROR_PARITY) if (stat & RXERROR_PARITY)
flag |= TTY_PARITY; flag |= TTY_PARITY;
/* XXX should handle break (0x10) */ /* XXX should handle break (0x10) */
tty_insert_flip_char(tty, data[i+1], flag); tty_insert_flip_char(tty, data[i+1],
flag);
} }
} }
} }
...@@ -1000,9 +1010,11 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -1000,9 +1010,11 @@ static void usa90_indat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev; urb->dev = port->serial->dev;
if (port->port.count) if (port->port.count) {
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
dbg("%s - resubmit read urb failed. (%d)", __func__, err); if (err != 0)
dbg("%s - resubmit read urb failed. (%d)",
__func__, err);
} }
return; return;
} }
...@@ -1053,9 +1065,9 @@ static void usa90_instat_callback(struct urb *urb) ...@@ -1053,9 +1065,9 @@ static void usa90_instat_callback(struct urb *urb)
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
urb->dev = serial->dev; urb->dev = serial->dev;
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
}
exit: exit:
; ;
} }
...@@ -1069,8 +1081,9 @@ static void usa90_outcont_callback(struct urb *urb) ...@@ -1069,8 +1081,9 @@ static void usa90_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) { if (p_priv->resend_cont) {
dbg ("%s - sending setup", __func__); dbg("%s - sending setup", __func__);
keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1); keyspan_usa90_send_setup(port->serial, port,
p_priv->resend_cont - 1);
} }
} }
...@@ -1086,7 +1099,7 @@ static void usa67_instat_callback(struct urb *urb) ...@@ -1086,7 +1099,7 @@ static void usa67_instat_callback(struct urb *urb)
int old_dcd_state; int old_dcd_state;
int status = urb->status; int status = urb->status;
dbg ("%s", __func__); dbg("%s", __func__);
serial = urb->context; serial = urb->context;
...@@ -1095,7 +1108,8 @@ static void usa67_instat_callback(struct urb *urb) ...@@ -1095,7 +1108,8 @@ static void usa67_instat_callback(struct urb *urb)
return; return;
} }
if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) { if (urb->actual_length !=
sizeof(struct keyspan_usa67_portStatusMessage)) {
dbg("%s - bad length %d", __func__, urb->actual_length); dbg("%s - bad length %d", __func__, urb->actual_length);
return; return;
} }
...@@ -1106,7 +1120,7 @@ static void usa67_instat_callback(struct urb *urb) ...@@ -1106,7 +1120,7 @@ static void usa67_instat_callback(struct urb *urb)
/* Check port number from message and retrieve private data */ /* Check port number from message and retrieve private data */
if (msg->port >= serial->num_ports) { if (msg->port >= serial->num_ports) {
dbg ("%s - Unexpected port number %d", __func__, msg->port); dbg("%s - Unexpected port number %d", __func__, msg->port);
return; return;
} }
...@@ -1140,7 +1154,7 @@ static void usa67_glocont_callback(struct urb *urb) ...@@ -1140,7 +1154,7 @@ static void usa67_glocont_callback(struct urb *urb)
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
int i; int i;
dbg ("%s", __func__); dbg("%s", __func__);
serial = urb->context; serial = urb->context;
for (i = 0; i < serial->num_ports; ++i) { for (i = 0; i < serial->num_ports; ++i) {
...@@ -1148,7 +1162,7 @@ static void usa67_glocont_callback(struct urb *urb) ...@@ -1148,7 +1162,7 @@ static void usa67_glocont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) { if (p_priv->resend_cont) {
dbg ("%s - sending setup", __func__); dbg("%s - sending setup", __func__);
keyspan_usa67_send_setup(serial, port, keyspan_usa67_send_setup(serial, port,
p_priv->resend_cont - 1); p_priv->resend_cont - 1);
break; break;
...@@ -1178,13 +1192,16 @@ static int keyspan_write_room(struct tty_struct *tty) ...@@ -1178,13 +1192,16 @@ static int keyspan_write_room(struct tty_struct *tty)
flip = p_priv->out_flip; flip = p_priv->out_flip;
/* Check both endpoints to see if any are available. */ /* Check both endpoints to see if any are available. */
if ((this_urb = p_priv->out_urbs[flip]) != NULL) { this_urb = p_priv->out_urbs[flip];
if (this_urb != NULL) {
if (this_urb->status != -EINPROGRESS) if (this_urb->status != -EINPROGRESS)
return (data_len); return data_len;
flip = (flip + 1) & d_details->outdat_endp_flip; flip = (flip + 1) & d_details->outdat_endp_flip;
if ((this_urb = p_priv->out_urbs[flip]) != NULL) this_urb = p_priv->out_urbs[flip];
if (this_urb != NULL) {
if (this_urb->status != -EINPROGRESS) if (this_urb->status != -EINPROGRESS)
return (data_len); return data_len;
}
} }
return 0; return 0;
} }
...@@ -1222,25 +1239,28 @@ static int keyspan_open(struct tty_struct *tty, ...@@ -1222,25 +1239,28 @@ static int keyspan_open(struct tty_struct *tty,
/* Reset low level data toggle and start reading from endpoints */ /* Reset low level data toggle and start reading from endpoints */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if ((urb = p_priv->in_urbs[i]) == NULL) urb = p_priv->in_urbs[i];
if (urb == NULL)
continue; continue;
urb->dev = serial->dev; urb->dev = serial->dev;
/* make sure endpoint data toggle is synchronized with the device */ /* make sure endpoint data toggle is synchronized
with the device */
usb_clear_halt(urb->dev, urb->pipe); usb_clear_halt(urb->dev, urb->pipe);
err = usb_submit_urb(urb, GFP_KERNEL);
if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { if (err != 0)
dbg("%s - submit urb %d failed (%d)", __func__, i, err); dbg("%s - submit urb %d failed (%d)",
} __func__, i, err);
} }
/* Reset low level data toggle on out endpoints */ /* Reset low level data toggle on out endpoints */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if ((urb = p_priv->out_urbs[i]) == NULL) urb = p_priv->out_urbs[i];
if (urb == NULL)
continue; continue;
urb->dev = serial->dev; urb->dev = serial->dev;
/* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
usb_pipeout(urb->pipe), 0); */
} }
/* get the terminal config for the setup message now so we don't /* 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,8 +1284,8 @@ static int keyspan_open(struct tty_struct *tty,
p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
keyspan_send_setup(port, 1); keyspan_send_setup(port, 1);
//mdelay(100); /* mdelay(100); */
//keyspan_set_termios(port, NULL); /* keyspan_set_termios(port, NULL); */
return 0; return 0;
} }
...@@ -1295,7 +1315,7 @@ static void keyspan_close(struct tty_struct *tty, ...@@ -1295,7 +1315,7 @@ static void keyspan_close(struct tty_struct *tty,
keyspan_send_setup(port, 2); keyspan_send_setup(port, 2);
/* pilot-xfer seems to work best with this delay */ /* pilot-xfer seems to work best with this delay */
mdelay(100); mdelay(100);
// keyspan_set_termios(port, NULL); /* keyspan_set_termios(port, NULL); */
} }
/*while (p_priv->outcont_urb->status == -EINPROGRESS) { /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
...@@ -1317,8 +1337,8 @@ static void keyspan_close(struct tty_struct *tty, ...@@ -1317,8 +1337,8 @@ static void keyspan_close(struct tty_struct *tty,
port->port.tty = NULL; port->port.tty = NULL;
} }
/* download the firmware to a pre-renumeration device */ /* download the firmware to a pre-renumeration device */
static int keyspan_fake_startup (struct usb_serial *serial) static int keyspan_fake_startup(struct usb_serial *serial)
{ {
int response; int response;
const struct ihex_binrec *record; const struct ihex_binrec *record;
...@@ -1329,9 +1349,10 @@ static int keyspan_fake_startup (struct usb_serial *serial) ...@@ -1329,9 +1349,10 @@ static int keyspan_fake_startup (struct usb_serial *serial)
le16_to_cpu(serial->dev->descriptor.bcdDevice), le16_to_cpu(serial->dev->descriptor.bcdDevice),
le16_to_cpu(serial->dev->descriptor.idProduct)); le16_to_cpu(serial->dev->descriptor.idProduct));
if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) { if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
!= 0x8000) {
dbg("Firmware already loaded. Quitting."); dbg("Firmware already loaded. Quitting.");
return(1); return 1;
} }
/* Select firmware image on the basis of idProduct */ /* Select firmware image on the basis of idProduct */
...@@ -1407,8 +1428,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) ...@@ -1407,8 +1428,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
(unsigned char *)record->data, (unsigned char *)record->data,
be16_to_cpu(record->len), 0xa0); be16_to_cpu(record->len), 0xa0);
if (response < 0) { if (response < 0) {
dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan" dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n",
"firmware (%d %04X %p %d)\n",
response, be32_to_cpu(record->addr), response, be32_to_cpu(record->addr),
record->data, be16_to_cpu(record->len)); record->data, be16_to_cpu(record->len));
break; break;
...@@ -1421,7 +1441,7 @@ static int keyspan_fake_startup (struct usb_serial *serial) ...@@ -1421,7 +1441,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
response = ezusb_set_reset(serial, 0); response = ezusb_set_reset(serial, 0);
/* we don't want this device to have a driver assigned to it. */ /* we don't want this device to have a driver assigned to it. */
return (1); return 1;
} }
/* Helper functions used by keyspan_setup_urbs */ /* 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,7 +1463,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se
return NULL; return NULL;
} }
static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len, int dir, void *ctx, char *buf, int len,
void (*callback)(struct urb *)) void (*callback)(struct urb *))
{ {
...@@ -1454,10 +1474,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, ...@@ -1454,10 +1474,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
if (endpoint == -1) if (endpoint == -1)
return NULL; /* endpoint not needed */ return NULL; /* endpoint not needed */
dbg ("%s - alloc for endpoint %d.", __func__, endpoint); dbg("%s - alloc for endpoint %d.", __func__, endpoint);
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
if (urb == NULL) { if (urb == NULL) {
dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint); dbg("%s - alloc for endpoint %d failed.", __func__, endpoint);
return NULL; return NULL;
} }
...@@ -1558,7 +1578,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) ...@@ -1558,7 +1578,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
struct callbacks *cback; struct callbacks *cback;
int endp; int endp;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details; d_details = s_priv->device_details;
...@@ -1584,7 +1604,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) ...@@ -1584,7 +1604,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
cback->glocont_callback); cback->glocont_callback);
/* Setup endpoints for each port specific thing */ /* Setup endpoints for each port specific thing */
for (i = 0; i < d_details->num_ports; i ++) { for (i = 0; i < d_details->num_ports; i++) {
port = serial->port[i]; port = serial->port[i];
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -1621,7 +1641,6 @@ static void keyspan_setup_urbs(struct usb_serial *serial) ...@@ -1621,7 +1641,6 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
port, p_priv->outcont_buffer, 64, port, p_priv->outcont_buffer, 64,
cback->outcont_callback); cback->outcont_callback);
} }
} }
/* usa19 function doesn't require prescaler */ /* usa19 function doesn't require prescaler */
...@@ -1632,43 +1651,36 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1632,43 +1651,36 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
div, /* divisor */ div, /* divisor */
cnt; /* inverse of divisor (programmed into 8051) */ cnt; /* inverse of divisor (programmed into 8051) */
dbg ("%s - %d.", __func__, baud_rate); dbg("%s - %d.", __func__, baud_rate);
/* prevent divide by zero... */ /* prevent divide by zero... */
if( (b16 = (baud_rate * 16L)) == 0) { b16 = baud_rate * 16L;
return (KEYSPAN_INVALID_BAUD_RATE); if (b16 == 0)
} return KEYSPAN_INVALID_BAUD_RATE;
/* Any "standard" rate over 57k6 is marginal on the USA-19 /* Any "standard" rate over 57k6 is marginal on the USA-19
as we run out of divisor resolution. */ as we run out of divisor resolution. */
if (baud_rate > 57600) { if (baud_rate > 57600)
return (KEYSPAN_INVALID_BAUD_RATE); return KEYSPAN_INVALID_BAUD_RATE;
}
/* calculate the divisor and the counter (its inverse) */ /* calculate the divisor and the counter (its inverse) */
if( (div = (baudclk / b16)) == 0) { div = baudclk / b16;
return (KEYSPAN_INVALID_BAUD_RATE); if (div == 0)
} return KEYSPAN_INVALID_BAUD_RATE;
else { else
cnt = 0 - div; cnt = 0 - div;
}
if(div > 0xffff) { if (div > 0xffff)
return (KEYSPAN_INVALID_BAUD_RATE); return KEYSPAN_INVALID_BAUD_RATE;
}
/* return the counter values if non-null */ /* return the counter values if non-null */
if (rate_low) { if (rate_low)
*rate_low = (u8) (cnt & 0xff); *rate_low = (u8) (cnt & 0xff);
} if (rate_hi)
if (rate_hi) {
*rate_hi = (u8) ((cnt >> 8) & 0xff); *rate_hi = (u8) ((cnt >> 8) & 0xff);
} if (rate_low && rate_hi)
if (rate_low && rate_hi) { dbg("%s - %d %02x %02x.",
dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); __func__, baud_rate, *rate_hi, *rate_low);
} return KEYSPAN_BAUD_RATE_OK;
return (KEYSPAN_BAUD_RATE_OK);
} }
/* usa19hs function doesn't require prescaler */ /* usa19hs function doesn't require prescaler */
...@@ -1678,20 +1690,20 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1678,20 +1690,20 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
u32 b16, /* baud rate times 16 (actual rate used internally) */ u32 b16, /* baud rate times 16 (actual rate used internally) */
div; /* divisor */ div; /* divisor */
dbg ("%s - %d.", __func__, baud_rate); dbg("%s - %d.", __func__, baud_rate);
/* prevent divide by zero... */ /* prevent divide by zero... */
if( (b16 = (baud_rate * 16L)) == 0) b16 = baud_rate * 16L;
return (KEYSPAN_INVALID_BAUD_RATE); if (b16 == 0)
return KEYSPAN_INVALID_BAUD_RATE;
/* calculate the divisor */ /* calculate the divisor */
if( (div = (baudclk / b16)) == 0) div = baudclk / b16;
return (KEYSPAN_INVALID_BAUD_RATE); if (div == 0)
return KEYSPAN_INVALID_BAUD_RATE;
if(div > 0xffff) if (div > 0xffff)
return (KEYSPAN_INVALID_BAUD_RATE); return KEYSPAN_INVALID_BAUD_RATE;
/* return the counter values if non-null */ /* return the counter values if non-null */
if (rate_low) if (rate_low)
...@@ -1701,9 +1713,10 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1701,9 +1713,10 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
*rate_hi = (u8) ((div >> 8) & 0xff); *rate_hi = (u8) ((div >> 8) & 0xff);
if (rate_low && rate_hi) if (rate_low && rate_hi)
dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low); dbg("%s - %d %02x %02x.",
__func__, baud_rate, *rate_hi, *rate_low);
return (KEYSPAN_BAUD_RATE_OK); return KEYSPAN_BAUD_RATE_OK;
} }
static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
...@@ -1718,12 +1731,12 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1718,12 +1731,12 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
u8 best_prescaler; u8 best_prescaler;
int i; int i;
dbg ("%s - %d.", __func__, baud_rate); dbg("%s - %d.", __func__, baud_rate);
/* prevent divide by zero */ /* prevent divide by zero */
if( (b16 = baud_rate * 16L) == 0) { b16 = baud_rate * 16L;
return (KEYSPAN_INVALID_BAUD_RATE); if (b16 == 0)
} return KEYSPAN_INVALID_BAUD_RATE;
/* Calculate prescaler by trying them all and looking /* Calculate prescaler by trying them all and looking
for best fit */ for best fit */
...@@ -1734,41 +1747,38 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1734,41 +1747,38 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
/* 0 is an invalid prescaler, used as a flag */ /* 0 is an invalid prescaler, used as a flag */
best_prescaler = 0; best_prescaler = 0;
for(i = 8; i <= 0xff; ++i) { for (i = 8; i <= 0xff; ++i) {
clk = (baudclk * 8) / (u32) i; clk = (baudclk * 8) / (u32) i;
if( (div = clk / b16) == 0) { div = clk / b16;
if (div == 0)
continue; continue;
}
res = clk / div; res = clk / div;
diff= (res > b16) ? (res-b16) : (b16-res); diff = (res > b16) ? (res-b16) : (b16-res);
if(diff < smallest_diff) { if (diff < smallest_diff) {
best_prescaler = i; best_prescaler = i;
smallest_diff = diff; smallest_diff = diff;
} }
} }
if(best_prescaler == 0) { if (best_prescaler == 0)
return (KEYSPAN_INVALID_BAUD_RATE); return KEYSPAN_INVALID_BAUD_RATE;
}
clk = (baudclk * 8) / (u32) best_prescaler; clk = (baudclk * 8) / (u32) best_prescaler;
div = clk / b16; div = clk / b16;
/* return the divisor and prescaler if non-null */ /* return the divisor and prescaler if non-null */
if (rate_low) { if (rate_low)
*rate_low = (u8) (div & 0xff); *rate_low = (u8) (div & 0xff);
} if (rate_hi)
if (rate_hi) {
*rate_hi = (u8) ((div >> 8) & 0xff); *rate_hi = (u8) ((div >> 8) & 0xff);
}
if (prescaler) { if (prescaler) {
*prescaler = best_prescaler; *prescaler = best_prescaler;
/* dbg("%s - %d %d", __func__, *prescaler, div); */ /* dbg("%s - %d %d", __func__, *prescaler, div); */
} }
return (KEYSPAN_BAUD_RATE_OK); return KEYSPAN_BAUD_RATE_OK;
} }
/* USA-28 supports different maximum baud rates on each port */ /* USA-28 supports different maximum baud rates on each port */
...@@ -1779,47 +1789,41 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, ...@@ -1779,47 +1789,41 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
div, /* divisor */ div, /* divisor */
cnt; /* inverse of divisor (programmed into 8051) */ cnt; /* inverse of divisor (programmed into 8051) */
dbg ("%s - %d.", __func__, baud_rate); dbg("%s - %d.", __func__, baud_rate);
/* prevent divide by zero */ /* prevent divide by zero */
if ((b16 = baud_rate * 16L) == 0) b16 = baud_rate * 16L;
return (KEYSPAN_INVALID_BAUD_RATE); if (b16 == 0)
return KEYSPAN_INVALID_BAUD_RATE;
/* calculate the divisor and the counter (its inverse) */ /* calculate the divisor and the counter (its inverse) */
if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) { div = KEYSPAN_USA28_BAUDCLK / b16;
return (KEYSPAN_INVALID_BAUD_RATE); if (div == 0)
} return KEYSPAN_INVALID_BAUD_RATE;
else { else
cnt = 0 - div; cnt = 0 - div;
}
/* check for out of range, based on portnum, /* check for out of range, based on portnum,
and return result */ and return result */
if(portnum == 0) { if (portnum == 0) {
if(div > 0xffff) if (div > 0xffff)
return (KEYSPAN_INVALID_BAUD_RATE); return KEYSPAN_INVALID_BAUD_RATE;
} } else {
else { if (portnum == 1) {
if(portnum == 1) { if (div > 0xff)
if(div > 0xff) { return KEYSPAN_INVALID_BAUD_RATE;
return (KEYSPAN_INVALID_BAUD_RATE); } else
} return KEYSPAN_INVALID_BAUD_RATE;
}
else {
return (KEYSPAN_INVALID_BAUD_RATE);
}
} }
/* return the counter values if not NULL /* return the counter values if not NULL
(port 1 will ignore retHi) */ (port 1 will ignore retHi) */
if (rate_low) { if (rate_low)
*rate_low = (u8) (cnt & 0xff); *rate_low = (u8) (cnt & 0xff);
} if (rate_hi)
if (rate_hi) {
*rate_hi = (u8) ((cnt >> 8) & 0xff); *rate_hi = (u8) ((cnt >> 8) & 0xff);
} dbg("%s - %d OK.", __func__, baud_rate);
dbg ("%s - %d OK.", __func__, baud_rate); return KEYSPAN_BAUD_RATE_OK;
return (KEYSPAN_BAUD_RATE_OK);
} }
static int keyspan_usa26_send_setup(struct usb_serial *serial, static int keyspan_usa26_send_setup(struct usb_serial *serial,
...@@ -1834,7 +1838,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1834,7 +1838,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
struct urb *this_urb; struct urb *this_urb;
int device_port, err; int device_port, err;
dbg ("%s reset=%d", __func__, reset_port); dbg("%s reset=%d", __func__, reset_port);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -1857,12 +1861,12 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1857,12 +1861,12 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont) if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1; p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
/* dbg ("%s - already writing", __func__); */ /* dbg("%s - already writing", __func__); */
mdelay(5); mdelay(5);
return(-1); return -1;
} }
memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage)); memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
/* Only set baud rate if it's changed */ /* Only set baud rate if it's changed */
if (p_priv->old_baud != p_priv->baud) { if (p_priv->old_baud != p_priv->baud) {
...@@ -1870,9 +1874,9 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1870,9 +1874,9 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
msg.setClocking = 0xff; msg.setClocking = 0xff;
if (d_details->calculate_baud_rate if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi, (p_priv->baud, d_details->baudclk, &msg.baudHi,
&msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, dbg("%s - Invalid baud rate %d requested, using 9600.",
p_priv->baud); __func__, p_priv->baud);
msg.baudLo = 0; msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */ msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10; msg.prescaler = 10;
...@@ -1898,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1898,7 +1902,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) { if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */ /* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)? msg.lcr |= (p_priv->cflag & PARODD)?
USA_PARITY_ODD: USA_PARITY_EVEN; USA_PARITY_ODD : USA_PARITY_EVEN;
} }
msg.setLcr = 0xff; msg.setLcr = 0xff;
...@@ -1939,7 +1943,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1939,7 +1943,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
/* Sending intermediate configs */ /* Sending intermediate configs */
else { else {
msg._txOn = (! p_priv->break_on); msg._txOn = (!p_priv->break_on);
msg._txOff = 0; msg._txOff = 0;
msg.txFlush = 0; msg.txFlush = 0;
msg.txBreak = (p_priv->break_on); msg.txBreak = (p_priv->break_on);
...@@ -1959,15 +1963,15 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1959,15 +1963,15 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
msg.hskoa_dtr = p_priv->dtr_state; msg.hskoa_dtr = p_priv->dtr_state;
p_priv->resend_cont = 0; p_priv->resend_cont = 0;
memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
/* send the data out the device on control endpoint */ /* send the data out the device on control endpoint */
this_urb->transfer_buffer_length = sizeof(msg); this_urb->transfer_buffer_length = sizeof(msg);
this_urb->dev = serial->dev; this_urb->dev = serial->dev;
if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
}
#if 0 #if 0
else { else {
dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
...@@ -1990,7 +1994,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -1990,7 +1994,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
struct urb *this_urb; struct urb *this_urb;
int device_port, err; int device_port, err;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -1998,7 +2002,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -1998,7 +2002,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
device_port = port->number - port->serial->minor; device_port = port->number - port->serial->minor;
/* only do something if we have a bulk out endpoint */ /* only do something if we have a bulk out endpoint */
if ((this_urb = p_priv->outcont_urb) == NULL) { this_urb = p_priv->outcont_urb;
if (this_urb == NULL) {
dbg("%s - oops no urb.", __func__); dbg("%s - oops no urb.", __func__);
return -1; return -1;
} }
...@@ -2008,17 +2013,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -2008,17 +2013,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont) if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1; p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
dbg ("%s already writing", __func__); dbg("%s already writing", __func__);
mdelay(5); mdelay(5);
return(-1); return -1;
} }
memset(&msg, 0, sizeof (struct keyspan_usa28_portControlMessage)); memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
msg.setBaudRate = 1; msg.setBaudRate = 1;
if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
&msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud); dbg("%s - Invalid baud rate requested %d.",
__func__, p_priv->baud);
msg.baudLo = 0xff; msg.baudLo = 0xff;
msg.baudHi = 0xb2; /* Values for 9600 baud */ msg.baudHi = 0xb2; /* Values for 9600 baud */
} }
...@@ -2071,7 +2077,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -2071,7 +2077,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
} }
/* Sending intermediate configs */ /* Sending intermediate configs */
else { else {
msg._txOn = (! p_priv->break_on); msg._txOn = (!p_priv->break_on);
msg._txOff = 0; msg._txOff = 0;
msg.txFlush = 0; msg.txFlush = 0;
msg.txForceXoff = 0; msg.txForceXoff = 0;
...@@ -2085,15 +2091,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -2085,15 +2091,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
} }
p_priv->resend_cont = 0; p_priv->resend_cont = 0;
memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
/* send the data out the device on control endpoint */ /* send the data out the device on control endpoint */
this_urb->transfer_buffer_length = sizeof(msg); this_urb->transfer_buffer_length = sizeof(msg);
this_urb->dev = serial->dev; this_urb->dev = serial->dev;
if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - usb_submit_urb(setup) failed", __func__); dbg("%s - usb_submit_urb(setup) failed", __func__);
}
#if 0 #if 0
else { else {
dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, 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,7 +2122,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
struct urb *this_urb; struct urb *this_urb;
int err, device_port; int err, device_port;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -2127,7 +2133,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2127,7 +2133,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
/* Work out which port within the device is being setup */ /* Work out which port within the device is being setup */
device_port = port->number - port->serial->minor; device_port = port->number - port->serial->minor;
dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port); dbg("%s - endpoint %d port %d (%d)",
__func__, usb_pipeendpoint(this_urb->pipe),
port->number, device_port);
/* Make sure we have an urb then send the message */ /* Make sure we have an urb then send the message */
if (this_urb == NULL) { if (this_urb == NULL) {
...@@ -2141,12 +2149,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2141,12 +2149,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
p_priv->resend_cont = reset_port + 1; p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
/* dbg ("%s - already writing", __func__); */ /* dbg("%s - already writing", __func__); */
mdelay(5); mdelay(5);
return(-1); return -1;
} }
memset(&msg, 0, sizeof (struct keyspan_usa49_portControlMessage)); memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
/*msg.portNumber = port->number;*/ /*msg.portNumber = port->number;*/
msg.portNumber = device_port; msg.portNumber = device_port;
...@@ -2157,14 +2165,14 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2157,14 +2165,14 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
msg.setClocking = 0xff; msg.setClocking = 0xff;
if (d_details->calculate_baud_rate if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi, (p_priv->baud, d_details->baudclk, &msg.baudHi,
&msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, dbg("%s - Invalid baud rate %d requested, using 9600.",
p_priv->baud); __func__, p_priv->baud);
msg.baudLo = 0; msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */ msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10; msg.prescaler = 10;
} }
//msg.setPrescaler = 0xff; /* msg.setPrescaler = 0xff; */
} }
msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1; msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
...@@ -2185,7 +2193,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2185,7 +2193,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) { if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */ /* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)? msg.lcr |= (p_priv->cflag & PARODD)?
USA_PARITY_ODD: USA_PARITY_EVEN; USA_PARITY_ODD : USA_PARITY_EVEN;
} }
msg.setLcr = 0xff; msg.setLcr = 0xff;
...@@ -2229,7 +2237,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2229,7 +2237,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
} }
/* Sending intermediate configs */ /* Sending intermediate configs */
else { else {
msg._txOn = (! p_priv->break_on); msg._txOn = (!p_priv->break_on);
msg._txOff = 0; msg._txOff = 0;
msg.txFlush = 0; msg.txFlush = 0;
msg.txBreak = (p_priv->break_on); msg.txBreak = (p_priv->break_on);
...@@ -2252,7 +2260,8 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2252,7 +2260,8 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
p_priv->resend_cont = 0; p_priv->resend_cont = 0;
/* if the device is a 49wg, we send control message on usb control EP 0 */ /* if the device is a 49wg, we send control message on usb
control EP 0 */
if (d_details->product_id == keyspan_usa49wg_product_id) { if (d_details->product_id == keyspan_usa49wg_product_id) {
dr = (void *)(s_priv->ctrl_buf); dr = (void *)(s_priv->ctrl_buf);
...@@ -2262,11 +2271,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2262,11 +2271,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
dr->wIndex = 0; dr->wIndex = 0;
dr->wLength = cpu_to_le16(sizeof(msg)); dr->wLength = cpu_to_le16(sizeof(msg));
memcpy (s_priv->glocont_buf, &msg, sizeof(msg)); memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
usb_fill_control_urb(this_urb, serial->dev, usb_sndctrlpipe(serial->dev, 0), usb_fill_control_urb(this_urb, serial->dev,
(unsigned char *)dr, s_priv->glocont_buf, sizeof(msg), usb_sndctrlpipe(serial->dev, 0),
usa49_glocont_callback, serial); (unsigned char *)dr, s_priv->glocont_buf,
sizeof(msg), usa49_glocont_callback, serial);
} else { } else {
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg)); memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
...@@ -2276,9 +2286,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -2276,9 +2286,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
this_urb->dev = serial->dev; this_urb->dev = serial->dev;
} }
if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
}
#if 0 #if 0
else { else {
dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
...@@ -2302,14 +2312,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2302,14 +2312,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
int err; int err;
u8 prescaler; u8 prescaler;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details; d_details = s_priv->device_details;
/* only do something if we have a bulk out endpoint */ /* only do something if we have a bulk out endpoint */
if ((this_urb = p_priv->outcont_urb) == NULL) { this_urb = p_priv->outcont_urb;
if (this_urb == NULL) {
dbg("%s - oops no urb.", __func__); dbg("%s - oops no urb.", __func__);
return -1; return -1;
} }
...@@ -2319,12 +2330,12 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2319,12 +2330,12 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont) if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1; p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
dbg ("%s already writing", __func__); dbg("%s already writing", __func__);
mdelay(5); mdelay(5);
return(-1); return -1;
} }
memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage)); memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
/* Only set baud rate if it's changed */ /* Only set baud rate if it's changed */
if (p_priv->old_baud != p_priv->baud) { if (p_priv->old_baud != p_priv->baud) {
...@@ -2332,11 +2343,11 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2332,11 +2343,11 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
msg.setClocking = 0x01; msg.setClocking = 0x01;
if (d_details->calculate_baud_rate if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi, (p_priv->baud, d_details->baudclk, &msg.baudHi,
&msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) { &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, dbg("%s - Invalid baud rate %d requested, using 9600.",
p_priv->baud); __func__, p_priv->baud);
p_priv->baud = 9600; p_priv->baud = 9600;
d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
&msg.baudHi, &msg.baudLo, &prescaler, 0); &msg.baudHi, &msg.baudLo, &prescaler, 0);
} }
msg.setRxMode = 1; msg.setRxMode = 1;
...@@ -2344,13 +2355,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2344,13 +2355,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
} }
/* modes must always be correctly specified */ /* modes must always be correctly specified */
if (p_priv->baud > 57600) if (p_priv->baud > 57600) {
{
msg.rxMode = RXMODE_DMA; msg.rxMode = RXMODE_DMA;
msg.txMode = TXMODE_DMA; msg.txMode = TXMODE_DMA;
} } else {
else
{
msg.rxMode = RXMODE_BYHAND; msg.rxMode = RXMODE_BYHAND;
msg.txMode = TXMODE_BYHAND; msg.txMode = TXMODE_BYHAND;
} }
...@@ -2373,7 +2381,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2373,7 +2381,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) { if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */ /* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)? msg.lcr |= (p_priv->cflag & PARODD)?
USA_PARITY_ODD: USA_PARITY_EVEN; USA_PARITY_ODD : USA_PARITY_EVEN;
} }
if (p_priv->old_cflag != p_priv->cflag) { if (p_priv->old_cflag != p_priv->cflag) {
p_priv->old_cflag = p_priv->cflag; p_priv->old_cflag = p_priv->cflag;
...@@ -2398,9 +2406,8 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2398,9 +2406,8 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
msg.txBreak = (p_priv->break_on); msg.txBreak = (p_priv->break_on);
} }
/* Closing port */ /* Closing port */
else if (reset_port == 2) { else if (reset_port == 2)
msg.portEnabled = 0; msg.portEnabled = 0;
}
/* Sending intermediate configs */ /* Sending intermediate configs */
else { else {
if (port->port.count) if (port->port.count)
...@@ -2416,15 +2423,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2416,15 +2423,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
msg.dtr = p_priv->dtr_state; msg.dtr = p_priv->dtr_state;
p_priv->resend_cont = 0; p_priv->resend_cont = 0;
memcpy (this_urb->transfer_buffer, &msg, sizeof(msg)); memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
/* send the data out the device on control endpoint */ /* send the data out the device on control endpoint */
this_urb->transfer_buffer_length = sizeof(msg); this_urb->transfer_buffer_length = sizeof(msg);
this_urb->dev = serial->dev; this_urb->dev = serial->dev;
if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) { err = usb_submit_urb(this_urb, GFP_ATOMIC);
if (err != 0)
dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
}
return 0; return 0;
} }
...@@ -2439,7 +2446,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, ...@@ -2439,7 +2446,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
struct urb *this_urb; struct urb *this_urb;
int err, device_port; int err, device_port;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
...@@ -2462,9 +2469,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, ...@@ -2462,9 +2469,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont) if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1; p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) { if (this_urb->status == -EINPROGRESS) {
/* dbg ("%s - already writing", __func__); */ /* dbg("%s - already writing", __func__); */
mdelay(5); mdelay(5);
return(-1); return -1;
} }
memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage)); memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
...@@ -2477,9 +2484,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, ...@@ -2477,9 +2484,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
msg.setClocking = 0xff; msg.setClocking = 0xff;
if (d_details->calculate_baud_rate if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi, (p_priv->baud, d_details->baudclk, &msg.baudHi,
&msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) { &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
dbg("%s - Invalid baud rate %d requested, using 9600.", __func__, dbg("%s - Invalid baud rate %d requested, using 9600.",
p_priv->baud); __func__, p_priv->baud);
msg.baudLo = 0; msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */ msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10; msg.prescaler = 10;
...@@ -2505,7 +2512,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, ...@@ -2505,7 +2512,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) { if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */ /* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)? msg.lcr |= (p_priv->cflag & PARODD)?
USA_PARITY_ODD: USA_PARITY_EVEN; USA_PARITY_ODD : USA_PARITY_EVEN;
} }
msg.setLcr = 0xff; msg.setLcr = 0xff;
...@@ -2542,7 +2549,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial, ...@@ -2542,7 +2549,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
msg.resetDataToggle = 0; msg.resetDataToggle = 0;
} else { } else {
/* Sending intermediate configs */ /* Sending intermediate configs */
msg._txOn = (! p_priv->break_on); msg._txOn = (!p_priv->break_on);
msg._txOff = 0; msg._txOff = 0;
msg.txFlush = 0; msg.txFlush = 0;
msg.txBreak = (p_priv->break_on); msg.txBreak = (p_priv->break_on);
...@@ -2582,7 +2589,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) ...@@ -2582,7 +2589,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
struct keyspan_serial_private *s_priv; struct keyspan_serial_private *s_priv;
const struct keyspan_device_details *d_details; const struct keyspan_device_details *d_details;
dbg ("%s", __func__); dbg("%s", __func__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details; d_details = s_priv->device_details;
...@@ -2609,7 +2616,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) ...@@ -2609,7 +2616,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
/* Gets called by the "real" driver (ie once firmware is loaded /* Gets called by the "real" driver (ie once firmware is loaded
and renumeration has taken place. */ and renumeration has taken place. */
static int keyspan_startup (struct usb_serial *serial) static int keyspan_startup(struct usb_serial *serial)
{ {
int i, err; int i, err;
struct usb_serial_port *port; struct usb_serial_port *port;
...@@ -2620,17 +2627,20 @@ static int keyspan_startup (struct usb_serial *serial) ...@@ -2620,17 +2627,20 @@ static int keyspan_startup (struct usb_serial *serial)
dbg("%s", __func__); dbg("%s", __func__);
for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) if (d_details->product_id ==
le16_to_cpu(serial->dev->descriptor.idProduct))
break; break;
if (d_details == NULL) { if (d_details == NULL) {
dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
__func__, le16_to_cpu(serial->dev->descriptor.idProduct));
return 1; return 1;
} }
/* Setup private data for serial driver */ /* Setup private data for serial driver */
s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
if (!s_priv) { if (!s_priv) {
dbg("%s - kmalloc for keyspan_serial_private failed.", __func__); dbg("%s - kmalloc for keyspan_serial_private failed.",
__func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -2640,10 +2650,11 @@ static int keyspan_startup (struct usb_serial *serial) ...@@ -2640,10 +2650,11 @@ static int keyspan_startup (struct usb_serial *serial)
/* Now setup per port private data */ /* Now setup per port private data */
for (i = 0; i < serial->num_ports; i++) { for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i]; port = serial->port[i];
p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); p_priv = kzalloc(sizeof(struct keyspan_port_private),
GFP_KERNEL);
if (!p_priv) { if (!p_priv) {
dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i);
return (1); return 1;
} }
p_priv->device_details = d_details; p_priv->device_details = d_details;
usb_set_serial_port_data(port, p_priv); usb_set_serial_port_data(port, p_priv);
...@@ -2669,7 +2680,7 @@ static int keyspan_startup (struct usb_serial *serial) ...@@ -2669,7 +2680,7 @@ static int keyspan_startup (struct usb_serial *serial)
return 0; return 0;
} }
static void keyspan_shutdown (struct usb_serial *serial) static void keyspan_shutdown(struct usb_serial *serial)
{ {
int i, j; int i, j;
struct usb_serial_port *port; struct usb_serial_port *port;
...@@ -2721,8 +2732,8 @@ static void keyspan_shutdown (struct usb_serial *serial) ...@@ -2721,8 +2732,8 @@ static void keyspan_shutdown (struct usb_serial *serial)
} }
} }
MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE("keyspan/usa28.fw"); MODULE_FIRMWARE("keyspan/usa28.fw");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment