aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/keyspan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/keyspan.c')
-rw-r--r--drivers/usb/serial/keyspan.c955
1 files changed, 470 insertions, 485 deletions
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 11e439b90eac..704716f6f6d3 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1,29 +1,29 @@
/*
Keyspan USB to Serial Converter driver
-
+
(C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org>
(C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com>
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See http://misc.nu/hugh/keyspan.html for more information.
-
+
Code in this driver inspired by and in a number of places taken
from Brian Warner's original Keyspan-PDA driver.
This driver has been put together with the support of Innosys, Inc.
and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
Thanks Guys :)
-
+
Thanks to Paulus for miscellaneous tidy ups, some largish chunks
of much nicer and/or completely new code and (perhaps most uniquely)
having the patience to sit down and explain why and where he'd changed
- stuff.
-
- Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
+ stuff.
+
+ Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
staff in their work on open source projects.
Change History
@@ -70,21 +70,21 @@
Thu May 31 11:56:42 PDT 2001 gkh
switched from using spinlock to a semaphore
-
+
(04/08/2001) gb
Identify version on module load.
-
+
(11/01/2000) Adam J. Richter
usb_device_id table support.
-
+
Tue Oct 10 23:15:33 EST 2000 Hugh
Merged Paul's changes with my USA-49W mods. Work in progress
still...
-
+
Wed Jul 19 14:00:42 EST 2000 gkh
Added module_init and module_exit functions to handle the fact that
this driver is a loadable module now.
-
+
Tue Jul 18 16:14:52 EST 2000 Hugh
Basic character input/output for USA-19 now mostly works,
fixed at 9600 baud for the moment.
@@ -107,7 +107,7 @@
#include <linux/spinlock.h>
#include <linux/firmware.h>
#include <linux/ihex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include "keyspan.h"
@@ -132,15 +132,15 @@ struct keyspan_serial_private {
struct urb *instat_urb;
char instat_buf[INSTAT_BUFLEN];
- /* added to support 49wg, where data from all 4 ports comes in on 1 EP */
- /* and high-speed supported */
+ /* added to support 49wg, where data from all 4 ports comes in
+ on 1 EP and high-speed supported */
struct urb *indat_urb;
char indat_buf[INDAT49W_BUFLEN];
/* XXX this one probably will need a lock */
struct urb *glocont_urb;
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 {
@@ -186,19 +186,19 @@ struct keyspan_port_private {
int resend_cont; /* need to resend control packet */
};
-
/* Include Keyspan message headers. All current Keyspan Adapters
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_usa28msg.h"
#include "keyspan_usa49msg.h"
#include "keyspan_usa90msg.h"
#include "keyspan_usa67msg.h"
-
+
/* Functions used by new usb-serial code. */
-static int __init keyspan_init (void)
+static int __init keyspan_init(void)
{
int retval;
retval = usb_serial_register(&keyspan_pre_device);
@@ -214,7 +214,7 @@ static int __init keyspan_init (void)
if (retval)
goto failed_4port_device_register;
retval = usb_register(&keyspan_driver);
- if (retval)
+ if (retval)
goto failed_usb_register;
info(DRIVER_VERSION ":" DRIVER_DESC);
@@ -232,35 +232,24 @@ failed_pre_device_register:
return retval;
}
-static void __exit keyspan_exit (void)
+static void __exit keyspan_exit(void)
{
- usb_deregister (&keyspan_driver);
- usb_serial_deregister (&keyspan_pre_device);
- usb_serial_deregister (&keyspan_1port_device);
- usb_serial_deregister (&keyspan_2port_device);
- usb_serial_deregister (&keyspan_4port_device);
+ usb_deregister(&keyspan_driver);
+ usb_serial_deregister(&keyspan_pre_device);
+ usb_serial_deregister(&keyspan_1port_device);
+ usb_serial_deregister(&keyspan_2port_device);
+ usb_serial_deregister(&keyspan_4port_device);
}
module_init(keyspan_init);
module_exit(keyspan_exit);
-static void keyspan_rx_throttle (struct usb_serial_port *port)
-{
- dbg("%s - port %d", __func__, port->number);
-}
-
-
-static void keyspan_rx_unthrottle (struct usb_serial_port *port)
-{
- dbg("%s - port %d", __func__, port->number);
-}
-
-
-static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
+static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
{
+ struct usb_serial_port *port = tty->driver_data;
struct keyspan_port_private *p_priv;
- dbg("%s", __func__);
+ dbg("%s", __func__);
p_priv = usb_get_serial_port_data(port);
@@ -273,14 +262,13 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
}
-static void keyspan_set_termios (struct usb_serial_port *port,
- struct ktermios *old_termios)
+static void keyspan_set_termios(struct tty_struct *tty,
+ struct usb_serial_port *port, struct ktermios *old_termios)
{
int baud_rate, device_port;
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
unsigned int cflag;
- struct tty_struct *tty = port->tty;
dbg("%s", __func__);
@@ -292,7 +280,7 @@ static void keyspan_set_termios (struct usb_serial_port *port,
/* Baud rate calculation takes baud rate as an integer
so other rates can be generated if desired. */
baud_rate = tty_get_baud_rate(tty);
- /* If no match or invalid, don't change */
+ /* If no match or invalid, don't change */
if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
/* FIXME - more to do here to ensure rate changes cleanly */
@@ -312,35 +300,32 @@ static void keyspan_set_termios (struct usb_serial_port *port,
keyspan_send_setup(port, 0);
}
-static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file)
+static int keyspan_tiocmget(struct tty_struct *tty, struct file *file)
{
+ struct usb_serial_port *port = tty->driver_data;
+ struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
unsigned int value;
- struct keyspan_port_private *p_priv;
- p_priv = usb_get_serial_port_data(port);
-
value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
((p_priv->dtr_state) ? TIOCM_DTR : 0) |
((p_priv->cts_state) ? TIOCM_CTS : 0) |
((p_priv->dsr_state) ? TIOCM_DSR : 0) |
((p_priv->dcd_state) ? TIOCM_CAR : 0) |
- ((p_priv->ri_state) ? TIOCM_RNG : 0);
+ ((p_priv->ri_state) ? TIOCM_RNG : 0);
return value;
}
-static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
+static int keyspan_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear)
{
- struct keyspan_port_private *p_priv;
+ struct usb_serial_port *port = tty->driver_data;
+ struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
- p_priv = usb_get_serial_port_data(port);
-
if (set & TIOCM_RTS)
p_priv->rts_state = 1;
if (set & TIOCM_DTR)
p_priv->dtr_state = 1;
-
if (clear & TIOCM_RTS)
p_priv->rts_state = 0;
if (clear & TIOCM_DTR)
@@ -349,35 +334,29 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
return 0;
}
-static int keyspan_ioctl(struct usb_serial_port *port, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return -ENOIOCTLCMD;
-}
-
- /* Write function is similar for the four protocols used
- with only a minor change for usa90 (usa19hs) required */
-static int keyspan_write(struct usb_serial_port *port,
- const unsigned char *buf, int count)
+/* Write function is similar for the four protocols used
+ with only a minor change for usa90 (usa19hs) required */
+static int keyspan_write(struct tty_struct *tty,
+ struct usb_serial_port *port, const unsigned char *buf, int count)
{
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
int flip;
int left, todo;
struct urb *this_urb;
- int err, maxDataLen, dataOffset;
+ int err, maxDataLen, dataOffset;
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
if (d_details->msg_format == msg_usa90) {
- maxDataLen = 64;
+ maxDataLen = 64;
dataOffset = 0;
} else {
maxDataLen = 63;
dataOffset = 1;
}
-
+
dbg("%s - for port %d (%d chars), flip=%d",
__func__, port->number, count, p_priv->out_flip);
@@ -387,37 +366,40 @@ static int keyspan_write(struct usb_serial_port *port,
todo = maxDataLen;
flip = p_priv->out_flip;
-
+
/* 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 */
dbg("%s - no output urb :(", __func__);
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 (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ))
+ if (time_before(jiffies,
+ p_priv->tx_start_time[flip] + 10 * HZ))
break;
usb_unlink_urb(this_urb);
break;
}
- /* First byte in buffer is "last flag" (except for usa19hx) - unused so
- for now so set to zero */
+ /* First byte in buffer is "last flag" (except for usa19hx)
+ - unused so for now so set to zero */
((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;
/* send the data out the bulk port */
this_urb->transfer_buffer_length = todo + dataOffset;
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);
- }
p_priv->tx_start_time[flip] = jiffies;
/* Flip for next time if usa26 or usa28 interface
@@ -437,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe);
@@ -448,17 +430,18 @@ static void usa26_indat_callback(struct urb *urb)
}
port = urb->context;
- tty = port->tty;
+ tty = port->port.tty;
if (tty && urb->actual_length) {
/* 0x80 bit is error flag */
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)
- err = TTY_OVERRUN;
- else err = 0;
- for (i = 1; i < urb->actual_length ; ++i) {
+ err = TTY_OVERRUN;
+ else
+ err = 0;
+ for (i = 1; i < urb->actual_length ; ++i)
tty_insert_flip_char(tty, data[i], err);
- }
} else {
/* some bytes had errors, every byte has status */
dbg("%s - RX error!!!!", __func__);
@@ -476,17 +459,19 @@ static void usa26_indat_callback(struct urb *urb)
}
tty_flip_buffer_push(tty);
}
-
- /* Resubmit urb so we continue receiving */
+
+ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev;
- if (port->open_count)
- if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
- dbg("%s - resubmit read urb failed. (%d)", __func__, err);
- }
+ if (port->port.count) {
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+ if (err != 0)
+ dbg("%s - resubmit read urb failed. (%d)",
+ __func__, err);
+ }
return;
}
- /* Outdat handling is common for all devices */
+/* Outdat handling is common for all devices */
static void usa2x_outdat_callback(struct urb *urb)
{
struct usb_serial_port *port;
@@ -494,16 +479,16 @@ static void usa2x_outdat_callback(struct urb *urb)
port = urb->context;
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->open_count)
+ if (port->port.count)
usb_serial_port_softint(port);
}
static void usa26_inack_callback(struct urb *urb)
{
- dbg ("%s", __func__);
-
+ dbg("%s", __func__);
+
}
static void usa26_outcont_callback(struct urb *urb)
@@ -515,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
- dbg ("%s - sending setup", __func__);
- keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1);
+ dbg("%s - sending setup", __func__);
+ keyspan_usa26_send_setup(port->serial, port,
+ p_priv->resend_cont - 1);
}
}
@@ -552,14 +538,14 @@ static void usa26_instat_callback(struct urb *urb)
/* Now do something useful with the 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) {
- dbg ("%s - Unexpected port number %d", __func__, msg->port);
+ dbg("%s - Unexpected port number %d", __func__, msg->port);
goto exit;
}
port = serial->port[msg->port];
p_priv = usb_get_serial_port_data(port);
-
+
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
@@ -567,39 +553,38 @@ static void usa26_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0);
- if (port->tty && !C_CLOCAL(port->tty)
+ if (port->port.tty && !C_CLOCAL(port->port.tty)
&& old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state)
- tty_hangup(port->tty);
+ tty_hangup(port->port.tty);
/* else */
/* wake_up_interruptible(&p_priv->open_wait); */
}
-
+
/* Resubmit urb so we continue receiving */
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);
- }
exit: ;
}
static void usa26_glocont_callback(struct urb *urb)
{
- dbg ("%s", __func__);
-
+ dbg("%s", __func__);
}
static void usa28_indat_callback(struct urb *urb)
{
- int i, err;
+ int err;
struct usb_serial_port *port;
struct tty_struct *tty;
unsigned char *data;
struct keyspan_port_private *p_priv;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
port = urb->context;
p_priv = usb_get_serial_port_data(port);
@@ -619,20 +604,20 @@ static void usa28_indat_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
data = urb->transfer_buffer;
- tty = port->tty;
+ tty = port->port.tty;
if (urb->actual_length) {
- for (i = 0; i < urb->actual_length ; ++i) {
- tty_insert_flip_char(tty, data[i], 0);
- }
+ tty_insert_flip_string(tty, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
/* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev;
- if (port->open_count)
- if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
- dbg("%s - resubmit read urb failed. (%d)", __func__, err);
- }
+ if (port->port.count) {
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+ if (err != 0)
+ dbg("%s - resubmit read urb failed. (%d)",
+ __func__, err);
+ }
p_priv->in_flip ^= 1;
urb = p_priv->in_urbs[p_priv->in_flip];
@@ -641,7 +626,7 @@ static void usa28_indat_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)
@@ -653,8 +638,9 @@ static void usa28_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
- dbg ("%s - sending setup", __func__);
- keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1);
+ dbg("%s - sending setup", __func__);
+ keyspan_usa28_send_setup(port->serial, port,
+ p_priv->resend_cont - 1);
}
}
@@ -684,19 +670,18 @@ static void usa28_instat_callback(struct urb *urb)
/*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__
data[0], data[1], data[2], data[3], data[4], data[5],
data[6], data[7], data[8], data[9], data[10], data[11]);*/
-
- /* Now do something useful with the data */
- msg = (struct keyspan_usa28_portStatusMessage *)data;
+ /* Now do something useful with the 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) {
- dbg ("%s - Unexpected port number %d", __func__, msg->port);
+ dbg("%s - Unexpected port number %d", __func__, msg->port);
goto exit;
}
port = serial->port[msg->port];
p_priv = usb_get_serial_port_data(port);
-
+
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -704,25 +689,25 @@ static void usa28_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0);
- if (port->tty && !C_CLOCAL(port->tty)
+ if (port->port.tty && !C_CLOCAL(port->port.tty)
&& old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state)
- tty_hangup(port->tty);
+ tty_hangup(port->port.tty);
/* else */
/* wake_up_interruptible(&p_priv->open_wait); */
}
/* Resubmit urb so we continue receiving */
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);
- }
exit: ;
}
static void usa28_glocont_callback(struct urb *urb)
{
- dbg ("%s", __func__);
+ dbg("%s", __func__);
}
@@ -733,7 +718,7 @@ static void usa49_glocont_callback(struct urb *urb)
struct keyspan_port_private *p_priv;
int i;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
serial = urb->context;
for (i = 0; i < serial->num_ports; ++i) {
@@ -741,8 +726,9 @@ static void usa49_glocont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
- dbg ("%s - sending setup", __func__);
- keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1);
+ dbg("%s - sending setup", __func__);
+ keyspan_usa49_send_setup(serial, port,
+ p_priv->resend_cont - 1);
break;
}
}
@@ -761,7 +747,7 @@ static void usa49_instat_callback(struct urb *urb)
int old_dcd_state;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
serial = urb->context;
@@ -770,7 +756,8 @@ static void usa49_instat_callback(struct urb *urb)
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);
goto exit;
}
@@ -778,18 +765,19 @@ static void usa49_instat_callback(struct urb *urb)
/*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__,
data[0], data[1], data[2], data[3], data[4], data[5],
data[6], data[7], data[8], data[9], data[10]);*/
-
- /* Now do something useful with the data */
+
+ /* Now do something useful with the data */
msg = (struct keyspan_usa49_portStatusMessage *)data;
- /* Check port number from message and retrieve private data */
+ /* Check port number from message and retrieve private data */
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;
}
port = serial->port[msg->portNumber];
p_priv = usb_get_serial_port_data(port);
-
+
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -797,26 +785,26 @@ static void usa49_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0);
- if (port->tty && !C_CLOCAL(port->tty)
+ if (port->port.tty && !C_CLOCAL(port->port.tty)
&& old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state)
- tty_hangup(port->tty);
+ tty_hangup(port->port.tty);
/* else */
/* wake_up_interruptible(&p_priv->open_wait); */
}
- /* Resubmit urb so we continue receiving */
+ /* Resubmit urb so we continue receiving */
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);
- }
exit: ;
}
static void usa49_inack_callback(struct urb *urb)
{
- dbg ("%s", __func__);
+ dbg("%s", __func__);
}
static void usa49_indat_callback(struct urb *urb)
@@ -828,7 +816,7 @@ static void usa49_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe);
@@ -839,14 +827,13 @@ static void usa49_indat_callback(struct urb *urb)
}
port = urb->context;
- tty = port->tty;
+ tty = port->port.tty;
if (tty && urb->actual_length) {
/* 0x80 bit is error flag */
if ((data[0] & 0x80) == 0) {
/* no error on any byte */
- for (i = 1; i < urb->actual_length ; ++i) {
- tty_insert_flip_char(tty, data[i], 0);
- }
+ tty_insert_flip_string(tty, data + 1,
+ urb->actual_length - 1);
} else {
/* some bytes had errors, every byte has status */
for (i = 0; i + 1 < urb->actual_length; i += 2) {
@@ -863,13 +850,15 @@ static void usa49_indat_callback(struct urb *urb)
}
tty_flip_buffer_push(tty);
}
-
- /* Resubmit urb so we continue receiving */
+
+ /* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev;
- if (port->open_count)
- if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
- dbg("%s - resubmit read urb failed. (%d)", __func__, err);
- }
+ if (port->port.count) {
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+ if (err != 0)
+ dbg("%s - resubmit read urb failed. (%d)",
+ __func__, err);
+ }
}
static void usa49wg_indat_callback(struct urb *urb)
@@ -881,7 +870,7 @@ static void usa49wg_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
serial = urb->context;
@@ -899,12 +888,12 @@ static void usa49wg_indat_callback(struct urb *urb)
/* Check port number from message*/
if (data[i] >= serial->num_ports) {
- dbg ("%s - Unexpected port number %d",
+ dbg("%s - Unexpected port number %d",
__func__, data[i]);
return;
}
port = serial->port[data[i++]];
- tty = port->tty;
+ tty = port->port.tty;
len = data[i++];
/* 0x80 bit is error flag */
@@ -912,7 +901,7 @@ static void usa49wg_indat_callback(struct urb *urb)
/* no error on any byte */
i++;
for (x = 1; x < len ; ++x)
- if (port->open_count)
+ if (port->port.count)
tty_insert_flip_char(tty,
data[i++], 0);
else
@@ -930,13 +919,13 @@ static void usa49wg_indat_callback(struct urb *urb)
if (stat & RXERROR_PARITY)
flag |= TTY_PARITY;
/* XXX should handle break (0x10) */
- if (port->open_count)
+ if (port->port.count)
tty_insert_flip_char(tty,
data[i+1], flag);
i += 2;
}
}
- if (port->open_count)
+ if (port->port.count)
tty_flip_buffer_push(tty);
}
}
@@ -952,7 +941,7 @@ static void usa49wg_indat_callback(struct urb *urb)
/* not used, usa-49 doesn't have per-port control endpoints */
static void usa49_outcont_callback(struct urb *urb)
{
- dbg ("%s", __func__);
+ dbg("%s", __func__);
}
static void usa90_indat_callback(struct urb *urb)
@@ -965,7 +954,7 @@ static void usa90_indat_callback(struct urb *urb)
unsigned char *data = urb->transfer_buffer;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
endpoint = usb_pipeendpoint(urb->pipe);
@@ -978,29 +967,26 @@ static void usa90_indat_callback(struct urb *urb)
port = urb->context;
p_priv = usb_get_serial_port_data(port);
- tty = port->tty;
+ tty = port->port.tty;
if (urb->actual_length) {
-
/* 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) {
- for (i = 0; i < urb->actual_length ; ++i)
- tty_insert_flip_char(tty, data[i], 0);
- }
+ if (p_priv->baud > 57600)
+ tty_insert_flip_string(tty, data, urb->actual_length);
else {
-
/* 0x80 bit is error flag */
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)
- err = TTY_OVERRUN;
- else err = 0;
- for (i = 1; i < urb->actual_length ; ++i)
- tty_insert_flip_char(tty, data[i], err);
-
- }
- else {
+ err = TTY_OVERRUN;
+ else
+ err = 0;
+ for (i = 1; i < urb->actual_length ; ++i)
+ tty_insert_flip_char(tty, data[i],
+ err);
+ } else {
/* some bytes had errors, every byte has status */
dbg("%s - RX error!!!!", __func__);
for (i = 0; i + 1 < urb->actual_length; i += 2) {
@@ -1012,19 +998,22 @@ static void usa90_indat_callback(struct urb *urb)
if (stat & RXERROR_PARITY)
flag |= TTY_PARITY;
/* XXX should handle break (0x10) */
- tty_insert_flip_char(tty, data[i+1], flag);
+ tty_insert_flip_char(tty, data[i+1],
+ flag);
}
}
}
tty_flip_buffer_push(tty);
}
-
+
/* Resubmit urb so we continue receiving */
urb->dev = port->serial->dev;
- if (port->open_count)
- if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
- dbg("%s - resubmit read urb failed. (%d)", __func__, err);
- }
+ if (port->port.count) {
+ err = usb_submit_urb(urb, GFP_ATOMIC);
+ if (err != 0)
+ dbg("%s - resubmit read urb failed. (%d)",
+ __func__, err);
+ }
return;
}
@@ -1056,7 +1045,7 @@ static void usa90_instat_callback(struct urb *urb)
port = serial->port[0];
p_priv = usb_get_serial_port_data(port);
-
+
/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -1064,19 +1053,19 @@ static void usa90_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0);
- if (port->tty && !C_CLOCAL(port->tty)
+ if (port->port.tty && !C_CLOCAL(port->port.tty)
&& old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state)
- tty_hangup(port->tty);
+ tty_hangup(port->port.tty);
/* else */
/* wake_up_interruptible(&p_priv->open_wait); */
}
-
+
/* Resubmit urb so we continue receiving */
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);
- }
exit:
;
}
@@ -1090,8 +1079,9 @@ static void usa90_outcont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
- dbg ("%s - sending setup", __func__);
- keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1);
+ dbg("%s - sending setup", __func__);
+ keyspan_usa90_send_setup(port->serial, port,
+ p_priv->resend_cont - 1);
}
}
@@ -1107,7 +1097,7 @@ static void usa67_instat_callback(struct urb *urb)
int old_dcd_state;
int status = urb->status;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
serial = urb->context;
@@ -1116,7 +1106,8 @@ static void usa67_instat_callback(struct urb *urb)
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);
return;
}
@@ -1127,7 +1118,7 @@ static void usa67_instat_callback(struct urb *urb)
/* Check port number from message and retrieve private data */
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;
}
@@ -1139,10 +1130,10 @@ static void usa67_instat_callback(struct urb *urb)
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
- if (port->tty && !C_CLOCAL(port->tty)
+ if (port->port.tty && !C_CLOCAL(port->port.tty)
&& old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state)
- tty_hangup(port->tty);
+ tty_hangup(port->port.tty);
/* else */
/* wake_up_interruptible(&p_priv->open_wait); */
}
@@ -1161,7 +1152,7 @@ static void usa67_glocont_callback(struct urb *urb)
struct keyspan_port_private *p_priv;
int i;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
serial = urb->context;
for (i = 0; i < serial->num_ports; ++i) {
@@ -1169,7 +1160,7 @@ static void usa67_glocont_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
if (p_priv->resend_cont) {
- dbg ("%s - sending setup", __func__);
+ dbg("%s - sending setup", __func__);
keyspan_usa67_send_setup(serial, port,
p_priv->resend_cont - 1);
break;
@@ -1177,8 +1168,9 @@ static void usa67_glocont_callback(struct urb *urb)
}
}
-static int keyspan_write_room (struct usb_serial_port *port)
+static int keyspan_write_room(struct tty_struct *tty)
{
+ struct usb_serial_port *port = tty->driver_data;
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
int flip;
@@ -1191,32 +1183,30 @@ static int keyspan_write_room (struct usb_serial_port *port)
/* FIXME: locking */
if (d_details->msg_format == msg_usa90)
- data_len = 64;
+ data_len = 64;
else
data_len = 63;
flip = p_priv->out_flip;
/* 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)
- return (data_len);
- flip = (flip + 1) & d_details->outdat_endp_flip;
- if ((this_urb = p_priv->out_urbs[flip]) != NULL)
+ return data_len;
+ flip = (flip + 1) & d_details->outdat_endp_flip;
+ this_urb = p_priv->out_urbs[flip];
+ if (this_urb != NULL) {
if (this_urb->status != -EINPROGRESS)
- return (data_len);
+ return data_len;
+ }
}
return 0;
}
-static int keyspan_chars_in_buffer (struct usb_serial_port *port)
-{
- return 0;
-}
-
-
-static int keyspan_open (struct usb_serial_port *port, struct file *filp)
+static int keyspan_open(struct tty_struct *tty,
+ struct usb_serial_port *port, struct file *filp)
{
struct keyspan_port_private *p_priv;
struct keyspan_serial_private *s_priv;
@@ -1225,7 +1215,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
int i, err;
int baud_rate, device_port;
struct urb *urb;
- unsigned int cflag;
+ unsigned int cflag = 0;
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
@@ -1247,50 +1237,53 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
/* Reset low level data toggle and start reading from endpoints */
for (i = 0; i < 2; i++) {
- if ((urb = p_priv->in_urbs[i]) == NULL)
+ urb = p_priv->in_urbs[i];
+ if (urb == NULL)
continue;
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);
-
- if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
- dbg("%s - submit urb %d failed (%d)", __func__, i, err);
- }
+ err = usb_submit_urb(urb, GFP_KERNEL);
+ if (err != 0)
+ dbg("%s - submit urb %d failed (%d)",
+ __func__, i, err);
}
/* Reset low level data toggle on out endpoints */
for (i = 0; i < 2; i++) {
- if ((urb = p_priv->out_urbs[i]) == NULL)
+ urb = p_priv->out_urbs[i];
+ if (urb == NULL)
continue;
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
* need to send 2 of them */
- cflag = port->tty->termios->c_cflag;
device_port = port->number - port->serial->minor;
-
- /* Baud rate calculation takes baud rate as an integer
- so other rates can be generated if desired. */
- baud_rate = tty_get_baud_rate(port->tty);
- /* If no match or invalid, leave as default */
- if (baud_rate >= 0
- && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
- NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
- p_priv->baud = baud_rate;
+ if (tty) {
+ cflag = tty->termios->c_cflag;
+ /* Baud rate calculation takes baud rate as an integer
+ so other rates can be generated if desired. */
+ baud_rate = tty_get_baud_rate(tty);
+ /* If no match or invalid, leave as default */
+ if (baud_rate >= 0
+ && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
+ NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
+ p_priv->baud = baud_rate;
+ }
}
-
/* set CTS/RTS handshake etc. */
p_priv->cflag = cflag;
p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
keyspan_send_setup(port, 1);
- //mdelay(100);
- //keyspan_set_termios(port, NULL);
+ /* mdelay(100); */
+ /* keyspan_set_termios(port, NULL); */
return 0;
}
@@ -1301,7 +1294,8 @@ static inline void stop_urb(struct urb *urb)
usb_kill_urb(urb);
}
-static void keyspan_close(struct usb_serial_port *port, struct file *filp)
+static void keyspan_close(struct tty_struct *tty,
+ struct usb_serial_port *port, struct file *filp)
{
int i;
struct usb_serial *serial = port->serial;
@@ -1311,15 +1305,15 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
-
+
p_priv->rts_state = 0;
p_priv->dtr_state = 0;
-
+
if (serial->dev) {
keyspan_send_setup(port, 2);
/* pilot-xfer seems to work best with this delay */
mdelay(100);
- // keyspan_set_termios(port, NULL);
+ /* keyspan_set_termios(port, NULL); */
}
/*while (p_priv->outcont_urb->status == -EINPROGRESS) {
@@ -1338,11 +1332,11 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
stop_urb(p_priv->out_urbs[i]);
}
}
- port->tty = NULL;
+ port->port.tty = NULL;
}
- /* download the firmware to a pre-renumeration device */
-static int keyspan_fake_startup (struct usb_serial *serial)
+/* download the firmware to a pre-renumeration device */
+static int keyspan_fake_startup(struct usb_serial *serial)
{
int response;
const struct ihex_binrec *record;
@@ -1352,10 +1346,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)
dbg("Keyspan startup version %04x product %04x",
le16_to_cpu(serial->dev->descriptor.bcdDevice),
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.");
- return(1);
+ return 1;
}
/* Select firmware image on the basis of idProduct */
@@ -1379,11 +1374,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)
case keyspan_usa19_pre_product_id:
fw_name = "keyspan/usa19.fw";
break;
-
+
case keyspan_usa19qi_pre_product_id:
fw_name = "keyspan/usa19qi.fw";
break;
-
+
case keyspan_mpr_pre_product_id:
fw_name = "keyspan/mpr.fw";
break;
@@ -1391,15 +1386,15 @@ static int keyspan_fake_startup (struct usb_serial *serial)
case keyspan_usa19qw_pre_product_id:
fw_name = "keyspan/usa19qw.fw";
break;
-
+
case keyspan_usa18x_pre_product_id:
fw_name = "keyspan/usa18x.fw";
break;
-
+
case keyspan_usa19w_pre_product_id:
fw_name = "keyspan/usa19w.fw";
break;
-
+
case keyspan_usa49w_pre_product_id:
fw_name = "keyspan/usa49w.fw";
break;
@@ -1431,8 +1426,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
(unsigned char *)record->data,
be16_to_cpu(record->len), 0xa0);
if (response < 0) {
- dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan"
- "firmware (%d %04X %p %d)\n",
+ dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n",
response, be32_to_cpu(record->addr),
record->data, be16_to_cpu(record->len));
break;
@@ -1445,7 +1439,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
response = ezusb_set_reset(serial, 0);
/* we don't want this device to have a driver assigned to it. */
- return (1);
+ return 1;
}
/* Helper functions used by keyspan_setup_urbs */
@@ -1467,7 +1461,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se
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,
void (*callback)(struct urb *))
{
@@ -1478,10 +1472,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
if (endpoint == -1)
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 */
if (urb == NULL) {
- dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint);
+ dbg("%s - alloc for endpoint %d failed.", __func__, endpoint);
return NULL;
}
@@ -1554,7 +1548,7 @@ static struct callbacks {
}, {
/* msg_usa90 callbacks */
.instat_callback = usa90_instat_callback,
- .glocont_callback = usa28_glocont_callback,
+ .glocont_callback = usa28_glocont_callback,
.indat_callback = usa90_indat_callback,
.outdat_callback = usa2x_outdat_callback,
.inack_callback = usa28_inack_callback,
@@ -1582,16 +1576,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
struct callbacks *cback;
int endp;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details;
- /* Setup values for the various callback routines */
+ /* Setup values for the various callback routines */
cback = &keyspan_callbacks[d_details->msg_format];
- /* Allocate and set up urbs for each one that is in use,
- starting with instat endpoints */
+ /* Allocate and set up urbs for each one that is in use,
+ starting with instat endpoints */
s_priv->instat_urb = keyspan_setup_urb
(serial, d_details->instat_endpoint, USB_DIR_IN,
serial, s_priv->instat_buf, INSTAT_BUFLEN,
@@ -1607,8 +1601,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
cback->glocont_callback);
- /* Setup endpoints for each port specific thing */
- for (i = 0; i < d_details->num_ports; i ++) {
+ /* Setup endpoints for each port specific thing */
+ for (i = 0; i < d_details->num_ports; i++) {
port = serial->port[i];
p_priv = usb_get_serial_port_data(port);
@@ -1644,8 +1638,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
(serial, d_details->outcont_endpoints[i], USB_DIR_OUT,
port, p_priv->outcont_buffer, 64,
cback->outcont_callback);
- }
-
+ }
}
/* usa19 function doesn't require prescaler */
@@ -1653,46 +1646,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
u8 *rate_low, u8 *prescaler, int portnum)
{
u32 b16, /* baud rate times 16 (actual rate used internally) */
- div, /* divisor */
+ div, /* divisor */
cnt; /* inverse of divisor (programmed into 8051) */
-
- dbg ("%s - %d.", __func__, baud_rate);
-
- /* prevent divide by zero... */
- if( (b16 = (baud_rate * 16L)) == 0) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
- /* Any "standard" rate over 57k6 is marginal on the USA-19
- as we run out of divisor resolution. */
- if (baud_rate > 57600) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
-
- /* calculate the divisor and the counter (its inverse) */
- if( (div = (baudclk / b16)) == 0) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
- else {
+ dbg("%s - %d.", __func__, baud_rate);
+
+ /* prevent divide by zero... */
+ b16 = baud_rate * 16L;
+ if (b16 == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
+ /* Any "standard" rate over 57k6 is marginal on the USA-19
+ as we run out of divisor resolution. */
+ if (baud_rate > 57600)
+ return KEYSPAN_INVALID_BAUD_RATE;
+
+ /* calculate the divisor and the counter (its inverse) */
+ div = baudclk / b16;
+ if (div == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
+ else
cnt = 0 - div;
- }
- if(div > 0xffff) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
+ if (div > 0xffff)
+ return KEYSPAN_INVALID_BAUD_RATE;
- /* return the counter values if non-null */
- if (rate_low) {
+ /* return the counter values if non-null */
+ if (rate_low)
*rate_low = (u8) (cnt & 0xff);
- }
- if (rate_hi) {
+ if (rate_hi)
*rate_hi = (u8) ((cnt >> 8) & 0xff);
- }
- if (rate_low && rate_hi) {
- dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
- }
-
- return (KEYSPAN_BAUD_RATE_OK);
+ if (rate_low && rate_hi)
+ dbg("%s - %d %02x %02x.",
+ __func__, baud_rate, *rate_hi, *rate_low);
+ return KEYSPAN_BAUD_RATE_OK;
}
/* usa19hs function doesn't require prescaler */
@@ -1700,34 +1686,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
u8 *rate_low, u8 *prescaler, int portnum)
{
u32 b16, /* baud rate times 16 (actual rate used internally) */
- div; /* divisor */
-
- dbg ("%s - %d.", __func__, baud_rate);
+ div; /* divisor */
- /* prevent divide by zero... */
- if( (b16 = (baud_rate * 16L)) == 0)
- return (KEYSPAN_INVALID_BAUD_RATE);
-
+ dbg("%s - %d.", __func__, baud_rate);
+ /* prevent divide by zero... */
+ b16 = baud_rate * 16L;
+ if (b16 == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
- /* calculate the divisor */
- if( (div = (baudclk / b16)) == 0)
- return (KEYSPAN_INVALID_BAUD_RATE);
+ /* calculate the divisor */
+ div = baudclk / b16;
+ if (div == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
- if(div > 0xffff)
- return (KEYSPAN_INVALID_BAUD_RATE);
+ if (div > 0xffff)
+ return KEYSPAN_INVALID_BAUD_RATE;
- /* return the counter values if non-null */
- if (rate_low)
+ /* return the counter values if non-null */
+ if (rate_low)
*rate_low = (u8) (div & 0xff);
-
- if (rate_hi)
+
+ if (rate_hi)
*rate_hi = (u8) ((div >> 8) & 0xff);
-
- if (rate_low && rate_hi)
- dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
-
- return (KEYSPAN_BAUD_RATE_OK);
+
+ if (rate_low && rate_hi)
+ dbg("%s - %d %02x %02x.",
+ __func__, baud_rate, *rate_hi, *rate_low);
+
+ return KEYSPAN_BAUD_RATE_OK;
}
static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
@@ -1735,64 +1722,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
{
u32 b16, /* baud rate times 16 (actual rate used internally) */
clk, /* clock with 13/8 prescaler */
- div, /* divisor using 13/8 prescaler */
+ div, /* divisor using 13/8 prescaler */
res, /* resulting baud rate using 13/8 prescaler */
diff, /* error using 13/8 prescaler */
smallest_diff;
u8 best_prescaler;
int i;
- dbg ("%s - %d.", __func__, baud_rate);
+ dbg("%s - %d.", __func__, baud_rate);
- /* prevent divide by zero */
- if( (b16 = baud_rate * 16L) == 0) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
+ /* prevent divide by zero */
+ b16 = baud_rate * 16L;
+ if (b16 == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
- /* Calculate prescaler by trying them all and looking
- for best fit */
-
- /* start with largest possible difference */
+ /* Calculate prescaler by trying them all and looking
+ for best fit */
+
+ /* start with largest possible difference */
smallest_diff = 0xffffffff;
/* 0 is an invalid prescaler, used as a flag */
best_prescaler = 0;
- for(i = 8; i <= 0xff; ++i) {
+ for (i = 8; i <= 0xff; ++i) {
clk = (baudclk * 8) / (u32) i;
-
- if( (div = clk / b16) == 0) {
+
+ div = clk / b16;
+ if (div == 0)
continue;
- }
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;
smallest_diff = diff;
}
}
- if(best_prescaler == 0) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
+ if (best_prescaler == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
clk = (baudclk * 8) / (u32) best_prescaler;
div = clk / b16;
- /* return the divisor and prescaler if non-null */
- if (rate_low) {
+ /* return the divisor and prescaler if non-null */
+ if (rate_low)
*rate_low = (u8) (div & 0xff);
- }
- if (rate_hi) {
+ if (rate_hi)
*rate_hi = (u8) ((div >> 8) & 0xff);
- }
if (prescaler) {
*prescaler = best_prescaler;
/* 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 */
@@ -1800,57 +1784,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
u8 *rate_low, u8 *prescaler, int portnum)
{
u32 b16, /* baud rate times 16 (actual rate used internally) */
- div, /* divisor */
+ div, /* divisor */
cnt; /* inverse of divisor (programmed into 8051) */
- dbg ("%s - %d.", __func__, baud_rate);
+ dbg("%s - %d.", __func__, baud_rate);
/* prevent divide by zero */
- if ((b16 = baud_rate * 16L) == 0)
- return (KEYSPAN_INVALID_BAUD_RATE);
-
- /* calculate the divisor and the counter (its inverse) */
- if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
- else {
+ b16 = baud_rate * 16L;
+ if (b16 == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
+
+ /* calculate the divisor and the counter (its inverse) */
+ div = KEYSPAN_USA28_BAUDCLK / b16;
+ if (div == 0)
+ return KEYSPAN_INVALID_BAUD_RATE;
+ else
cnt = 0 - div;
- }
- /* check for out of range, based on portnum,
- and return result */
- if(portnum == 0) {
- if(div > 0xffff)
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
- else {
- if(portnum == 1) {
- if(div > 0xff) {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
- }
- else {
- return (KEYSPAN_INVALID_BAUD_RATE);
- }
+ /* check for out of range, based on portnum,
+ and return result */
+ if (portnum == 0) {
+ if (div > 0xffff)
+ return KEYSPAN_INVALID_BAUD_RATE;
+ } else {
+ if (portnum == 1) {
+ if (div > 0xff)
+ return KEYSPAN_INVALID_BAUD_RATE;
+ } else
+ return KEYSPAN_INVALID_BAUD_RATE;
}
/* return the counter values if not NULL
(port 1 will ignore retHi) */
- if (rate_low) {
+ if (rate_low)
*rate_low = (u8) (cnt & 0xff);
- }
- if (rate_hi) {
+ if (rate_hi)
*rate_hi = (u8) ((cnt >> 8) & 0xff);
- }
- dbg ("%s - %d OK.", __func__, baud_rate);
- return (KEYSPAN_BAUD_RATE_OK);
+ dbg("%s - %d OK.", __func__, baud_rate);
+ return KEYSPAN_BAUD_RATE_OK;
}
static int keyspan_usa26_send_setup(struct usb_serial *serial,
struct usb_serial_port *port,
int reset_port)
{
- struct keyspan_usa26_portControlMessage msg;
+ struct keyspan_usa26_portControlMessage msg;
struct keyspan_serial_private *s_priv;
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
@@ -1858,7 +1836,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
struct urb *this_urb;
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);
p_priv = usb_get_serial_port_data(port);
@@ -1881,22 +1859,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) {
- /* dbg ("%s - already writing", __func__); */
+ /* dbg("%s - already writing", __func__); */
mdelay(5);
- return(-1);
+ return -1;
}
- memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage));
-
- /* Only set baud rate if it's changed */
+ memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
+
+ /* Only set baud rate if it's changed */
if (p_priv->old_baud != p_priv->baud) {
p_priv->old_baud = p_priv->baud;
msg.setClocking = 0xff;
if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi,
- &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
- dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
- p_priv->baud);
+ &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+ dbg("%s - Invalid baud rate %d requested, using 9600.",
+ __func__, p_priv->baud);
msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10;
@@ -1922,7 +1900,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)?
- USA_PARITY_ODD: USA_PARITY_EVEN;
+ USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
@@ -1963,7 +1941,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
/* Sending intermediate configs */
else {
- msg._txOn = (! p_priv->break_on);
+ msg._txOn = (!p_priv->break_on);
msg._txOff = 0;
msg.txFlush = 0;
msg.txBreak = (p_priv->break_on);
@@ -1975,23 +1953,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
msg.resetDataToggle = 0x0;
}
- /* Do handshaking outputs */
+ /* Do handshaking outputs */
msg.setTxTriState_setRts = 0xff;
msg.txTriState_rts = p_priv->rts_state;
msg.setHskoa_setDtr = 0xff;
msg.hskoa_dtr = p_priv->dtr_state;
-
+
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 */
this_urb->transfer_buffer_length = sizeof(msg);
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);
- }
#if 0
else {
dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
@@ -2007,14 +1985,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
struct usb_serial_port *port,
int reset_port)
{
- struct keyspan_usa28_portControlMessage msg;
+ struct keyspan_usa28_portControlMessage msg;
struct keyspan_serial_private *s_priv;
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
struct urb *this_urb;
int device_port, err;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
@@ -2022,7 +2000,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
device_port = port->number - port->serial->minor;
/* 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__);
return -1;
}
@@ -2032,17 +2011,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) {
- dbg ("%s already writing", __func__);
+ dbg("%s already writing", __func__);
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;
if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
- &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
- dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud);
+ &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+ dbg("%s - Invalid baud rate requested %d.",
+ __func__, p_priv->baud);
msg.baudLo = 0xff;
msg.baudHi = 0xb2; /* Values for 9600 baud */
}
@@ -2053,7 +2033,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
msg.xonFlowControl = 0;
- /* Do handshaking outputs, DTR is inverted relative to RTS */
+ /* Do handshaking outputs, DTR is inverted relative to RTS */
msg.rts = p_priv->rts_state;
msg.dtr = p_priv->dtr_state;
@@ -2095,7 +2075,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
}
/* Sending intermediate configs */
else {
- msg._txOn = (! p_priv->break_on);
+ msg._txOn = (!p_priv->break_on);
msg._txOff = 0;
msg.txFlush = 0;
msg.txForceXoff = 0;
@@ -2109,15 +2089,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
}
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 */
this_urb->transfer_buffer_length = sizeof(msg);
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__);
- }
#if 0
else {
dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__,
@@ -2140,7 +2120,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
struct urb *this_urb;
int err, device_port;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
@@ -2151,7 +2131,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
/* Work out which port within the device is being setup */
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 */
if (this_urb == NULL) {
@@ -2165,30 +2147,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) {
- /* dbg ("%s - already writing", __func__); */
+ /* dbg("%s - already writing", __func__); */
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 = device_port;
-
- /* Only set baud rate if it's changed */
+
+ /* Only set baud rate if it's changed */
if (p_priv->old_baud != p_priv->baud) {
p_priv->old_baud = p_priv->baud;
msg.setClocking = 0xff;
if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi,
- &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
- dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
- p_priv->baud);
+ &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+ dbg("%s - Invalid baud rate %d requested, using 9600.",
+ __func__, p_priv->baud);
msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10;
}
- //msg.setPrescaler = 0xff;
+ /* msg.setPrescaler = 0xff; */
}
msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
@@ -2209,19 +2191,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)?
- USA_PARITY_ODD: USA_PARITY_EVEN;
+ USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
msg.xonFlowControl = 0;
msg.setFlowControl = 0xff;
-
+
msg.forwardingLength = 16;
msg.xonChar = 17;
msg.xoffChar = 19;
- /* Opening port */
+ /* Opening port */
if (reset_port == 1) {
msg._txOn = 1;
msg._txOff = 0;
@@ -2253,7 +2235,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
}
/* Sending intermediate configs */
else {
- msg._txOn = (! p_priv->break_on);
+ msg._txOn = (!p_priv->break_on);
msg._txOff = 0;
msg.txFlush = 0;
msg.txBreak = (p_priv->break_on);
@@ -2267,16 +2249,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
msg.disablePort = 0;
}
- /* Do handshaking outputs */
+ /* Do handshaking outputs */
msg.setRts = 0xff;
msg.rts = p_priv->rts_state;
msg.setDtr = 0xff;
msg.dtr = p_priv->dtr_state;
-
+
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) {
dr = (void *)(s_priv->ctrl_buf);
@@ -2286,23 +2269,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
dr->wIndex = 0;
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),
- (unsigned char *)dr, s_priv->glocont_buf, sizeof(msg),
- usa49_glocont_callback, serial);
+ usb_fill_control_urb(this_urb, serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ (unsigned char *)dr, s_priv->glocont_buf,
+ sizeof(msg), usa49_glocont_callback, serial);
} else {
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
-
+
/* send the data out the device on control endpoint */
this_urb->transfer_buffer_length = sizeof(msg);
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);
- }
#if 0
else {
dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
@@ -2318,7 +2302,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
struct usb_serial_port *port,
int reset_port)
{
- struct keyspan_usa90_portControlMessage msg;
+ struct keyspan_usa90_portControlMessage msg;
struct keyspan_serial_private *s_priv;
struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
@@ -2326,14 +2310,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
int err;
u8 prescaler;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details;
/* 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__);
return -1;
}
@@ -2343,24 +2328,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) {
- dbg ("%s already writing", __func__);
+ dbg("%s already writing", __func__);
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) {
p_priv->old_baud = p_priv->baud;
msg.setClocking = 0x01;
if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi,
- &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) {
- dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
- p_priv->baud);
+ &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
+ dbg("%s - Invalid baud rate %d requested, using 9600.",
+ __func__, p_priv->baud);
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.setRxMode = 1;
@@ -2368,13 +2353,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
}
/* modes must always be correctly specified */
- if (p_priv->baud > 57600)
- {
+ if (p_priv->baud > 57600) {
msg.rxMode = RXMODE_DMA;
msg.txMode = TXMODE_DMA;
- }
- else
- {
+ } else {
msg.rxMode = RXMODE_BYHAND;
msg.txMode = TXMODE_BYHAND;
}
@@ -2397,7 +2379,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
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) {
p_priv->old_cflag = p_priv->cflag;
@@ -2408,47 +2390,46 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
msg.txFlowControl = TXFLOW_CTS;
msg.setTxFlowControl = 0x01;
msg.setRxFlowControl = 0x01;
-
+
msg.rxForwardingLength = 16;
- msg.rxForwardingTimeout = 16;
+ msg.rxForwardingTimeout = 16;
msg.txAckSetting = 0;
msg.xonChar = 17;
msg.xoffChar = 19;
- /* Opening port */
+ /* Opening port */
if (reset_port == 1) {
msg.portEnabled = 1;
msg.rxFlush = 1;
msg.txBreak = (p_priv->break_on);
}
/* Closing port */
- else if (reset_port == 2) {
+ else if (reset_port == 2)
msg.portEnabled = 0;
- }
/* Sending intermediate configs */
else {
- if (port->open_count)
+ if (port->port.count)
msg.portEnabled = 1;
msg.txBreak = (p_priv->break_on);
}
- /* Do handshaking outputs */
+ /* Do handshaking outputs */
msg.setRts = 0x01;
msg.rts = p_priv->rts_state;
msg.setDtr = 0x01;
msg.dtr = p_priv->dtr_state;
-
+
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 */
this_urb->transfer_buffer_length = sizeof(msg);
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);
- }
return 0;
}
@@ -2463,7 +2444,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
struct urb *this_urb;
int err, device_port;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port);
@@ -2486,9 +2467,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
if ((reset_port + 1) > p_priv->resend_cont)
p_priv->resend_cont = reset_port + 1;
if (this_urb->status == -EINPROGRESS) {
- /* dbg ("%s - already writing", __func__); */
+ /* dbg("%s - already writing", __func__); */
mdelay(5);
- return(-1);
+ return -1;
}
memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
@@ -2501,9 +2482,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
msg.setClocking = 0xff;
if (d_details->calculate_baud_rate
(p_priv->baud, d_details->baudclk, &msg.baudHi,
- &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
- dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
- p_priv->baud);
+ &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+ dbg("%s - Invalid baud rate %d requested, using 9600.",
+ __func__, p_priv->baud);
msg.baudLo = 0;
msg.baudHi = 125; /* Values for 9600 baud */
msg.prescaler = 10;
@@ -2529,7 +2510,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
msg.lcr |= (p_priv->cflag & PARODD)?
- USA_PARITY_ODD: USA_PARITY_EVEN;
+ USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
@@ -2566,7 +2547,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
msg.resetDataToggle = 0;
} else {
/* Sending intermediate configs */
- msg._txOn = (! p_priv->break_on);
+ msg._txOn = (!p_priv->break_on);
msg._txOff = 0;
msg.txFlush = 0;
msg.txBreak = (p_priv->break_on);
@@ -2606,7 +2587,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
struct keyspan_serial_private *s_priv;
const struct keyspan_device_details *d_details;
- dbg ("%s", __func__);
+ dbg("%s", __func__);
s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details;
@@ -2633,7 +2614,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
and renumeration has taken place. */
-static int keyspan_startup (struct usb_serial *serial)
+static int keyspan_startup(struct usb_serial *serial)
{
int i, err;
struct usb_serial_port *port;
@@ -2644,17 +2625,20 @@ static int keyspan_startup (struct usb_serial *serial)
dbg("%s", __func__);
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;
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;
}
/* Setup private data for serial driver */
s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
if (!s_priv) {
- dbg("%s - kmalloc for keyspan_serial_private failed.", __func__);
+ dbg("%s - kmalloc for keyspan_serial_private failed.",
+ __func__);
return -ENOMEM;
}
@@ -2664,10 +2648,11 @@ static int keyspan_startup (struct usb_serial *serial)
/* Now setup per port private data */
for (i = 0; i < serial->num_ports; 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) {
dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i);
- return (1);
+ return 1;
}
p_priv->device_details = d_details;
usb_set_serial_port_data(port, p_priv);
@@ -2689,11 +2674,11 @@ static int keyspan_startup (struct usb_serial *serial)
dbg("%s - submit indat urb failed %d", __func__,
err);
}
-
+
return 0;
}
-static void keyspan_shutdown (struct usb_serial *serial)
+static void keyspan_shutdown(struct usb_serial *serial)
{
int i, j;
struct usb_serial_port *port;
@@ -2745,8 +2730,8 @@ static void keyspan_shutdown (struct usb_serial *serial)
}
}
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_FIRMWARE("keyspan/usa28.fw");