summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/kl5kusb105.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/kl5kusb105.c')
-rw-r--r--drivers/usb/serial/kl5kusb105.c124
1 files changed, 65 insertions, 59 deletions
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 55736df7d2f..b395ac75988 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -126,9 +126,6 @@ static struct usb_serial_driver kl5kusb105d_device = {
.description = "KL5KUSB105D / PalmConnect",
.usb_driver = &kl5kusb105d_driver,
.id_table = id_table,
- .num_interrupt_in = 1,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
.num_ports = 1,
.open = klsi_105_open,
.close = klsi_105_close,
@@ -194,7 +191,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
if (rc < 0)
err("Change port settings failed (error = %d)", rc);
info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d",
- __FUNCTION__,
+ __func__,
settings->pktlen,
settings->baudrate, settings->databits,
settings->unknown1, settings->unknown2);
@@ -225,7 +222,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
__u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1};
__u16 status;
- info("%s - sending SIO Poll request", __FUNCTION__);
+ info("%s - sending SIO Poll request", __func__);
rc = usb_control_msg(port->serial->dev,
usb_rcvctrlpipe(port->serial->dev, 0),
KL5KUSB105A_SIO_POLL,
@@ -240,7 +237,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
else {
status = le16_to_cpu(*(u16 *)status_buf);
- info("%s - read status %x %x", __FUNCTION__,
+ info("%s - read status %x %x", __func__,
status_buf[0], status_buf[1]);
*line_state_p = klsi_105_status2linestate(status);
@@ -268,7 +265,7 @@ static int klsi_105_startup (struct usb_serial *serial)
priv = kmalloc(sizeof(struct klsi_105_private),
GFP_KERNEL);
if (!priv) {
- dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__);
+ dbg("%skmalloc for klsi_105_private failed.", __func__);
i--;
goto err_cleanup;
}
@@ -298,7 +295,7 @@ static int klsi_105_startup (struct usb_serial *serial)
urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE,
GFP_KERNEL);
if (!urb->transfer_buffer) {
- err("%s - out of memory for urb buffers.", __FUNCTION__);
+ err("%s - out of memory for urb buffers.", __func__);
goto err_cleanup;
}
}
@@ -328,7 +325,7 @@ static void klsi_105_shutdown (struct usb_serial *serial)
{
int i;
- dbg("%s", __FUNCTION__);
+ dbg("%s", __func__);
/* stop reads and writes on all ports */
for (i=0; i < serial->num_ports; ++i) {
@@ -373,7 +370,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
struct klsi_105_port_settings cfg;
unsigned long flags;
- dbg("%s port %d", __FUNCTION__, port->number);
+ dbg("%s port %d", __func__, port->number);
/* force low_latency on so that our tty_push actually forces
* the data through
@@ -419,7 +416,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
rc = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (rc) {
- err("%s - failed submitting read urb, error %d", __FUNCTION__, rc);
+ err("%s - failed submitting read urb, error %d", __func__, rc);
retval = rc;
goto exit;
}
@@ -437,14 +434,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
err("Enabling read failed (error = %d)", rc);
retval = rc;
} else
- dbg("%s - enabled reading", __FUNCTION__);
+ dbg("%s - enabled reading", __func__);
rc = klsi_105_get_line_state(port, &line_state);
if (rc >= 0) {
spin_lock_irqsave (&priv->lock, flags);
priv->line_state = line_state;
spin_unlock_irqrestore (&priv->lock, flags);
- dbg("%s - read line state 0x%lx", __FUNCTION__, line_state);
+ dbg("%s - read line state 0x%lx", __func__, line_state);
retval = 0;
} else
retval = rc;
@@ -459,7 +456,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
struct klsi_105_private *priv = usb_get_serial_port_data(port);
int rc;
- dbg("%s port %d", __FUNCTION__, port->number);
+ dbg("%s port %d", __func__, port->number);
mutex_lock(&port->serial->disc_mutex);
if (!port->serial->disconnected) {
@@ -502,7 +499,7 @@ static int klsi_105_write (struct usb_serial_port *port,
int result, size;
int bytes_sent=0;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("%s - port %d", __func__, port->number);
while (count > 0) {
/* try to find a free urb (write 0 bytes if none) */
@@ -514,21 +511,21 @@ static int klsi_105_write (struct usb_serial_port *port,
for (i=0; i<NUM_URBS; i++) {
if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
urb = priv->write_urb_pool[i];
- dbg("%s - using pool URB %d", __FUNCTION__, i);
+ dbg("%s - using pool URB %d", __func__, i);
break;
}
}
spin_unlock_irqrestore (&priv->lock, flags);
if (urb==NULL) {
- dbg("%s - no more free urbs", __FUNCTION__);
+ dbg("%s - no more free urbs", __func__);
goto exit;
}
if (urb->transfer_buffer == NULL) {
urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
if (urb->transfer_buffer == NULL) {
- err("%s - no more kernel memory...", __FUNCTION__);
+ err("%s - no more kernel memory...", __func__);
goto exit;
}
}
@@ -554,7 +551,7 @@ static int klsi_105_write (struct usb_serial_port *port,
/* send the data out the bulk port */
result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) {
- err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
+ err("%s - failed submitting write urb, error %d", __func__, result);
goto exit;
}
buf += size;
@@ -570,13 +567,13 @@ exit:
static void klsi_105_write_bulk_callback ( struct urb *urb)
{
- struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+ struct usb_serial_port *port = urb->context;
int status = urb->status;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("%s - port %d", __func__, port->number);
if (status) {
- dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
+ dbg("%s - nonzero write bulk status received: %d", __func__,
status);
return;
}
@@ -603,7 +600,7 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
spin_unlock_irqrestore (&priv->lock, flags);
- dbg("%s - returns %d", __FUNCTION__, chars);
+ dbg("%s - returns %d", __func__, chars);
return (chars);
}
@@ -623,7 +620,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
spin_unlock_irqrestore (&priv->lock, flags);
- dbg("%s - returns %d", __FUNCTION__, room);
+ dbg("%s - returns %d", __func__, room);
return (room);
}
@@ -631,18 +628,18 @@ static int klsi_105_write_room (struct usb_serial_port *port)
static void klsi_105_read_bulk_callback (struct urb *urb)
{
- struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+ struct usb_serial_port *port = urb->context;
struct klsi_105_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
int rc;
int status = urb->status;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("%s - port %d", __func__, port->number);
/* The urb might have been killed. */
if (status) {
- dbg("%s - nonzero read bulk status received: %d", __FUNCTION__,
+ dbg("%s - nonzero read bulk status received: %d", __func__,
status);
return;
}
@@ -652,12 +649,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
*/
if (urb->actual_length == 0) {
/* empty urbs seem to happen, we ignore them */
- /* dbg("%s - emtpy URB", __FUNCTION__); */
+ /* dbg("%s - emtpy URB", __func__); */
;
} else if (urb->actual_length <= 2) {
- dbg("%s - size %d URB not understood", __FUNCTION__,
+ dbg("%s - size %d URB not understood", __func__,
urb->actual_length);
- usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
+ usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length, data);
} else {
int bytes_sent = ((__u8 *) data)[0] +
@@ -669,12 +666,12 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
* intermixed tty_flip_buffer_push()s
* FIXME
*/
- usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
+ usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length, data);
if (bytes_sent + 2 > urb->actual_length) {
dbg("%s - trying to read more data than available"
- " (%d vs. %d)", __FUNCTION__,
+ " (%d vs. %d)", __func__,
bytes_sent+2, urb->actual_length);
/* cap at implied limit */
bytes_sent = urb->actual_length - 2;
@@ -697,7 +694,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
port);
rc = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (rc)
- err("%s - failed resubmitting read urb, error %d", __FUNCTION__, rc);
+ err("%s - failed resubmitting read urb, error %d", __func__, rc);
} /* klsi_105_read_bulk_callback */
@@ -705,12 +702,14 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
struct ktermios *old_termios)
{
struct klsi_105_private *priv = usb_get_serial_port_data(port);
- unsigned int iflag = port->tty->termios->c_iflag;
+ struct tty_struct *tty = port->tty;
+ unsigned int iflag = tty->termios->c_iflag;
unsigned int old_iflag = old_termios->c_iflag;
- unsigned int cflag = port->tty->termios->c_cflag;
+ unsigned int cflag = tty->termios->c_cflag;
unsigned int old_cflag = old_termios->c_cflag;
struct klsi_105_port_settings cfg;
unsigned long flags;
+ speed_t baud;
/* lock while we are modifying the settings */
spin_lock_irqsave (&priv->lock, flags);
@@ -718,10 +717,12 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
/*
* Update baud rate
*/
+ baud = tty_get_baud_rate(tty);
+
if( (cflag & CBAUD) != (old_cflag & CBAUD) ) {
/* reassert DTR and (maybe) RTS on transition from B0 */
if( (old_cflag & CBAUD) == B0 ) {
- dbg("%s: baud was B0", __FUNCTION__);
+ dbg("%s: baud was B0", __func__);
#if 0
priv->control_state |= TIOCM_DTR;
/* don't set RTS if using hardware flow control */
@@ -731,8 +732,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
mct_u232_set_modem_ctrl(serial, priv->control_state);
#endif
}
-
- switch(tty_get_baud_rate(port->tty)) {
+ }
+ switch(baud) {
case 0: /* handled below */
break;
case 1200:
@@ -760,35 +761,36 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
priv->cfg.baudrate = kl5kusb105a_sio_b115200;
break;
default:
- err("KLSI USB->Serial converter:"
+ dbg("KLSI USB->Serial converter:"
" unsupported baudrate request, using default"
" of 9600");
priv->cfg.baudrate = kl5kusb105a_sio_b9600;
+ baud = 9600;
break;
- }
- if ((cflag & CBAUD) == B0 ) {
- dbg("%s: baud is B0", __FUNCTION__);
- /* Drop RTS and DTR */
- /* maybe this should be simulated by sending read
- * disable and read enable messages?
- */
- ;
+ }
+ if ((cflag & CBAUD) == B0 ) {
+ dbg("%s: baud is B0", __func__);
+ /* Drop RTS and DTR */
+ /* maybe this should be simulated by sending read
+ * disable and read enable messages?
+ */
+ ;
#if 0
- priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
- mct_u232_set_modem_ctrl(serial, priv->control_state);
+ priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
+ mct_u232_set_modem_ctrl(serial, priv->control_state);
#endif
- }
}
+ tty_encode_baud_rate(tty, baud, baud);
if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
/* set the number of data bits */
switch (cflag & CSIZE) {
case CS5:
- dbg("%s - 5 bits/byte not supported", __FUNCTION__);
+ dbg("%s - 5 bits/byte not supported", __func__);
spin_unlock_irqrestore (&priv->lock, flags);
return ;
case CS6:
- dbg("%s - 6 bits/byte not supported", __FUNCTION__);
+ dbg("%s - 6 bits/byte not supported", __func__);
spin_unlock_irqrestore (&priv->lock, flags);
return ;
case CS7:
@@ -810,6 +812,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
|| (cflag & CSTOPB) != (old_cflag & CSTOPB) ) {
+ /* Not currently supported */
+ tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB);
#if 0
priv->last_lcr = 0;
@@ -837,6 +841,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
|| (iflag & IXON) != (old_iflag & IXON)
|| (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) {
+ /* Not currently supported */
+ tty->termios->c_cflag &= ~CRTSCTS;
/* Drop DTR/RTS if no flow control otherwise assert */
#if 0
if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) )
@@ -862,7 +868,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
struct mct_u232_private *priv = (struct mct_u232_private *)port->private;
unsigned char lcr = priv->last_lcr;
- dbg("%sstate=%d", __FUNCTION__, break_state);
+ dbg("%sstate=%d", __func__, break_state);
if (break_state)
lcr |= MCT_U232_SET_BREAK;
@@ -877,7 +883,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
unsigned long flags;
int rc;
unsigned long line_state;
- dbg("%s - request, just guessing", __FUNCTION__);
+ dbg("%s - request, just guessing", __func__);
rc = klsi_105_get_line_state(port, &line_state);
if (rc < 0) {
@@ -889,7 +895,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
spin_lock_irqsave (&priv->lock, flags);
priv->line_state = line_state;
spin_unlock_irqrestore (&priv->lock, flags);
- dbg("%s - read line state 0x%lx", __FUNCTION__, line_state);
+ dbg("%s - read line state 0x%lx", __func__, line_state);
return (int)line_state;
}
@@ -898,7 +904,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
{
int retval = -EINVAL;
- dbg("%s", __FUNCTION__);
+ dbg("%s", __func__);
/* if this ever gets implemented, it should be done something like this:
struct usb_serial *serial = port->serial;
@@ -924,7 +930,7 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
static void klsi_105_throttle (struct usb_serial_port *port)
{
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("%s - port %d", __func__, port->number);
usb_kill_urb(port->read_urb);
}
@@ -932,12 +938,12 @@ static void klsi_105_unthrottle (struct usb_serial_port *port)
{
int result;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("%s - port %d", __func__, port->number);
port->read_urb->dev = port->serial->dev;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result)
- err("%s - failed submitting read urb, error %d", __FUNCTION__,
+ err("%s - failed submitting read urb, error %d", __func__,
result);
}