提交 95da310e 编写于 作者: A Alan Cox 提交者: Linus Torvalds

usb_serial: API all change

USB serial likes to use port->tty back pointers for the real work it does and
to do so without any actual locking. Unfortunately when you consider hangup
events, hangup/parallel reopen or even worse hangup followed by parallel close
events the tty->port and port->tty pointers are not guaranteed to be the same
as port->tty is the active tty while tty->port is the port the tty may or
may not still be attached to.

So rework the entire API to pass the tty struct. For console cases we need
to pass both for now. This shows up multiple drivers that immediately crash
with USB console some of which have been fixed in the process.

Longer term we need a proper tty as console abstraction
Signed-off-by: NAlan Cox <alan@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 1aa3692d
...@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work) ...@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work)
* 64 bytes, to ensure I do not get throttled. * 64 bytes, to ensure I do not get throttled.
* Ask USB mailing list for better aproach. * Ask USB mailing list for better aproach.
*/ */
tty = port->tty; tty = port->port.tty;
if (!tty) { if (!tty) {
schedule_work(&priv->rx_work); schedule_work(&priv->rx_work);
...@@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial) ...@@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial)
} }
} }
static int aircable_write_room(struct usb_serial_port *port) static int aircable_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct aircable_private *priv = usb_get_serial_port_data(port); struct aircable_private *priv = usb_get_serial_port_data(port);
return serial_buf_data_avail(priv->tx_buf); return serial_buf_data_avail(priv->tx_buf);
} }
static int aircable_write(struct usb_serial_port *port, static int aircable_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *source, int count) const unsigned char *source, int count)
{ {
struct aircable_private *priv = usb_get_serial_port_data(port); struct aircable_private *priv = usb_get_serial_port_data(port);
...@@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
if (status) { if (status) {
dbg("%s - urb status = %d", __func__, status); dbg("%s - urb status = %d", __func__, status);
if (!port->open_count) { if (!port->port.count) {
dbg("%s - port is closed, exiting.", __func__); dbg("%s - port is closed, exiting.", __func__);
return; return;
} }
...@@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
usb_serial_debug_data(debug, &port->dev, __func__, usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length, urb->transfer_buffer); urb->actual_length, urb->transfer_buffer);
tty = port->tty; tty = port->port.tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
if (urb->actual_length <= 2) { if (urb->actual_length <= 2) {
/* This is an incomplete package */ /* This is an incomplete package */
...@@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
} }
/* Schedule the next read _if_ we are still open */ /* Schedule the next read _if_ we are still open */
if (port->open_count) { if (port->port.count) {
usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(port->serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
...@@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb) ...@@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb)
} }
/* Based on ftdi_sio.c throttle */ /* Based on ftdi_sio.c throttle */
static void aircable_throttle(struct usb_serial_port *port) static void aircable_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct aircable_private *priv = usb_get_serial_port_data(port); struct aircable_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port) ...@@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port)
} }
/* Based on ftdi_sio.c unthrottle */ /* Based on ftdi_sio.c unthrottle */
static void aircable_unthrottle(struct usb_serial_port *port) static void aircable_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct aircable_private *priv = usb_get_serial_port_data(port); struct aircable_private *priv = usb_get_serial_port_data(port);
int actually_throttled; int actually_throttled;
unsigned long flags; unsigned long flags;
......
/*
* AirPrime CDMA Wireless Serial USB driver
*
* Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
static struct usb_device_id id_table [] = {
{ USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
{ },
};
MODULE_DEVICE_TABLE(usb, id_table);
#define URB_TRANSFER_BUFFER_SIZE 4096
#define NUM_READ_URBS 4
#define NUM_WRITE_URBS 4
#define NUM_BULK_EPS 3
#define MAX_BULK_EPS 6
/* if overridden by the user, then use their value for the size of the
* read and write urbs, and the number of endpoints */
static int buffer_size = URB_TRANSFER_BUFFER_SIZE;
static int endpoints = NUM_BULK_EPS;
static int debug;
struct airprime_private {
spinlock_t lock;
int outstanding_urbs;
int throttled;
struct urb *read_urbp[NUM_READ_URBS];
/* Settings for the port */
int rts_state; /* Handshaking pins (outputs) */
int dtr_state;
int cts_state; /* Handshaking pins (inputs) */
int dsr_state;
int dcd_state;
int ri_state;
};
static int airprime_send_setup(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct airprime_private *priv;
dbg("%s", __func__);
if (port->number != 0)
return 0;
priv = usb_get_serial_port_data(port);
if (port->port.tty) {
int val = 0;
if (priv->dtr_state)
val |= 0x01;
if (priv->rts_state)
val |= 0x02;
return usb_control_msg(serial->dev,
usb_rcvctrlpipe(serial->dev, 0),
0x22, 0x21, val, 0, NULL, 0,
USB_CTRL_SET_TIMEOUT);
}
return 0;
}
static void airprime_read_bulk_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
unsigned char *data = urb->transfer_buffer;
struct tty_struct *tty;
int result;
int status = urb->status;
dbg("%s - port %d", __func__, port->number);
if (status) {
dbg("%s - nonzero read bulk status received: %d",
__func__, status);
return;
}
usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length, data);
tty = port->port.tty;
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_flip_buffer_push(tty);
}
result = usb_submit_urb(urb, GFP_ATOMIC);
if (result)
dev_err(&port->dev,
"%s - failed resubmitting read urb, error %d\n",
__func__, result);
return;
}
static void airprime_write_bulk_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
struct airprime_private *priv = usb_get_serial_port_data(port);
int status = urb->status;
unsigned long flags;
dbg("%s - port %d", __func__, port->number);
/* free up the transfer buffer, as usb_free_urb() does not do this */
kfree(urb->transfer_buffer);
if (status)
dbg("%s - nonzero write bulk status received: %d",
__func__, status);
spin_lock_irqsave(&priv->lock, flags);
--priv->outstanding_urbs;
spin_unlock_irqrestore(&priv->lock, flags);
usb_serial_port_softint(port);
}
static int airprime_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{
struct airprime_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial;
struct urb *urb;
char *buffer = NULL;
int i;
int result = 0;
dbg("%s - port %d", __func__, port->number);
/* initialize our private data structure if it isn't already created */
if (!priv) {
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
result = -ENOMEM;
goto out;
}
spin_lock_init(&priv->lock);
usb_set_serial_port_data(port, priv);
}
/* Set some sane defaults */
priv->rts_state = 1;
priv->dtr_state = 1;
for (i = 0; i < NUM_READ_URBS; ++i) {
buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!buffer) {
dev_err(&port->dev, "%s - out of memory.\n",
__func__);
result = -ENOMEM;
goto errout;
}
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
kfree(buffer);
dev_err(&port->dev, "%s - no more urbs?\n",
__func__);
result = -ENOMEM;
goto errout;
}
usb_fill_bulk_urb(urb, serial->dev,
usb_rcvbulkpipe(serial->dev,
port->bulk_out_endpointAddress),
buffer, buffer_size,
airprime_read_bulk_callback, port);
result = usb_submit_urb(urb, GFP_KERNEL);
if (result) {
usb_free_urb(urb);
kfree(buffer);
dev_err(&port->dev,
"%s - failed submitting read urb %d for port %d, error %d\n",
__func__, i, port->number, result);
goto errout;
}
/* remember this urb so we can kill it when the
port is closed */
priv->read_urbp[i] = urb;
}
airprime_send_setup(port);
goto out;
errout:
/* some error happened, cancel any submitted urbs and clean up
anything that got allocated successfully */
while (i-- != 0) {
urb = priv->read_urbp[i];
buffer = urb->transfer_buffer;
usb_kill_urb(urb);
usb_free_urb(urb);
kfree(buffer);
}
out:
return result;
}
static void airprime_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{
struct airprime_private *priv = usb_get_serial_port_data(port);
int i;
dbg("%s - port %d", __func__, port->number);
priv->rts_state = 0;
priv->dtr_state = 0;
mutex_lock(&port->serial->disc_mutex);
if (!port->serial->disconnected)
airprime_send_setup(port);
mutex_unlock(&port->serial->disc_mutex);
for (i = 0; i < NUM_READ_URBS; ++i) {
usb_kill_urb(priv->read_urbp[i]);
kfree(priv->read_urbp[i]->transfer_buffer);
usb_free_urb(priv->read_urbp[i]);
}
/* free up private structure */
kfree(priv);
usb_set_serial_port_data(port, NULL);
}
static int airprime_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count)
{
struct airprime_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial;
struct urb *urb;
unsigned char *buffer;
unsigned long flags;
int status;
dbg("%s - port %d", __func__, port->number);
spin_lock_irqsave(&priv->lock, flags);
if (priv->outstanding_urbs > NUM_WRITE_URBS) {
spin_unlock_irqrestore(&priv->lock, flags);
dbg("%s - write limit hit\n", __func__);
return 0;
}
spin_unlock_irqrestore(&priv->lock, flags);
buffer = kmalloc(count, GFP_ATOMIC);
if (!buffer) {
dev_err(&port->dev, "out of memory\n");
return -ENOMEM;
}
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
dev_err(&port->dev, "no more free urbs\n");
kfree(buffer);
return -ENOMEM;
}
memcpy(buffer, buf, count);
usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev,
port->bulk_out_endpointAddress),
buffer, count,
airprime_write_bulk_callback, port);
/* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) {
dev_err(&port->dev,
"%s - usb_submit_urb(write bulk) failed with status = %d\n",
__func__, status);
count = status;
kfree(buffer);
} else {
spin_lock_irqsave(&priv->lock, flags);
++priv->outstanding_urbs;
spin_unlock_irqrestore(&priv->lock, flags);
}
/* we are done with this urb, so let the host driver
* really free it when it is finished with it */
usb_free_urb(urb);
return count;
}
static struct usb_driver airprime_driver = {
.name = "airprime",
.probe = usb_serial_probe,
.disconnect = usb_serial_disconnect,
.id_table = id_table,
.no_dynamic_id = 1,
};
static struct usb_serial_driver airprime_device = {
.driver = {
.owner = THIS_MODULE,
.name = "airprime",
},
.usb_driver = &airprime_driver,
.id_table = id_table,
.open = airprime_open,
.close = airprime_close,
.write = airprime_write,
};
static int __init airprime_init(void)
{
int retval;
airprime_device.num_ports = endpoints;
if (endpoints < 0 || endpoints >= MAX_BULK_EPS)
airprime_device.num_ports = NUM_BULK_EPS;
retval = usb_serial_register(&airprime_device);
if (retval)
return retval;
retval = usb_register(&airprime_driver);
if (retval)
usb_serial_deregister(&airprime_device);
return retval;
}
static void __exit airprime_exit(void)
{
dbg("%s", __func__);
usb_deregister(&airprime_driver);
usb_serial_deregister(&airprime_device);
}
module_init(airprime_init);
module_exit(airprime_exit);
MODULE_LICENSE("GPL");
module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled");
module_param(buffer_size, int, 0);
MODULE_PARM_DESC(buffer_size,
"Size of the transfer buffers in bytes (default 4096)");
module_param(endpoints, int, 0);
MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");
...@@ -158,12 +158,13 @@ static int ark3116_attach(struct usb_serial *serial) ...@@ -158,12 +158,13 @@ static int ark3116_attach(struct usb_serial *serial)
return -ENOMEM; return -ENOMEM;
} }
static void ark3116_set_termios(struct usb_serial_port *port, static void ark3116_set_termios(struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ark3116_private *priv = usb_get_serial_port_data(port); struct ark3116_private *priv = usb_get_serial_port_data(port);
struct ktermios *termios = port->tty->termios; struct ktermios *termios = tty->termios;
unsigned int cflag = termios->c_cflag; unsigned int cflag = termios->c_cflag;
unsigned long flags; unsigned long flags;
int baud; int baud;
...@@ -177,8 +178,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -177,8 +178,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (!priv->termios_initialized) { if (!priv->termios_initialized) {
*(port->tty->termios) = tty_std_termios; *termios = tty_std_termios;
port->tty->termios->c_cflag = B9600 | CS8 termios->c_cflag = B9600 | CS8
| CREAD | HUPCL | CLOCAL; | CREAD | HUPCL | CLOCAL;
termios->c_ispeed = 9600; termios->c_ispeed = 9600;
termios->c_ospeed = 9600; termios->c_ospeed = 9600;
...@@ -192,7 +193,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -192,7 +193,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
buf = kmalloc(1, GFP_KERNEL); buf = kmalloc(1, GFP_KERNEL);
if (!buf) { if (!buf) {
dbg("error kmalloc"); dbg("error kmalloc");
*port->tty->termios = *old_termios; *termios = *old_termios;
return; return;
} }
...@@ -243,7 +244,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -243,7 +244,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
} }
/* set baudrate */ /* set baudrate */
baud = tty_get_baud_rate(port->tty); baud = tty_get_baud_rate(tty);
switch (baud) { switch (baud) {
case 75: case 75:
...@@ -262,11 +263,11 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -262,11 +263,11 @@ static void ark3116_set_termios(struct usb_serial_port *port,
case 230400: case 230400:
case 460800: case 460800:
/* Report the resulting rate back to the caller */ /* Report the resulting rate back to the caller */
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
break; break;
/* set 9600 as default (if given baudrate is invalid for example) */ /* set 9600 as default (if given baudrate is invalid for example) */
default: default:
tty_encode_baud_rate(port->tty, 9600, 9600); tty_encode_baud_rate(tty, 9600, 9600);
case 0: case 0:
baud = 9600; baud = 9600;
} }
...@@ -317,7 +318,8 @@ static void ark3116_set_termios(struct usb_serial_port *port, ...@@ -317,7 +318,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
return; return;
} }
static int ark3116_open(struct usb_serial_port *port, struct file *filp) static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
struct ktermios tmp_termios; struct ktermios tmp_termios;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -332,7 +334,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) ...@@ -332,7 +334,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
return -ENOMEM; return -ENOMEM;
} }
result = usb_serial_generic_open(port, filp); result = usb_serial_generic_open(tty, port, filp);
if (result) if (result)
goto err_out; goto err_out;
...@@ -362,8 +364,8 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) ...@@ -362,8 +364,8 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf); ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
/* initialise termios */ /* initialise termios */
if (port->tty) if (tty)
ark3116_set_termios(port, &tmp_termios); ark3116_set_termios(tty, port, &tmp_termios);
err_out: err_out:
kfree(buf); kfree(buf);
...@@ -371,9 +373,10 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp) ...@@ -371,9 +373,10 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
return result; return result;
} }
static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
struct serial_struct serstruct; struct serial_struct serstruct;
void __user *user_arg = (void __user *)arg; void __user *user_arg = (void __user *)arg;
...@@ -403,8 +406,9 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, ...@@ -403,8 +406,9 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file) static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
char *buf; char *buf;
char temp; char temp;
......
...@@ -89,14 +89,13 @@ static int debug; ...@@ -89,14 +89,13 @@ static int debug;
/* function prototypes for a Belkin USB Serial Adapter F5U103 */ /* function prototypes for a Belkin USB Serial Adapter F5U103 */
static int belkin_sa_startup (struct usb_serial *serial); static int belkin_sa_startup (struct usb_serial *serial);
static void belkin_sa_shutdown (struct usb_serial *serial); static void belkin_sa_shutdown (struct usb_serial *serial);
static int belkin_sa_open (struct usb_serial_port *port, struct file *filp); static int belkin_sa_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void belkin_sa_close (struct usb_serial_port *port, struct file *filp); static void belkin_sa_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void belkin_sa_read_int_callback (struct urb *urb); static void belkin_sa_read_int_callback (struct urb *urb);
static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios * old); static void belkin_sa_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); static void belkin_sa_break_ctl (struct tty_struct *tty, int break_state );
static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state ); static int belkin_sa_tiocmget (struct tty_struct *tty, struct file *file);
static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file); static int belkin_sa_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
static struct usb_device_id id_table_combined [] = { static struct usb_device_id id_table_combined [] = {
...@@ -132,7 +131,6 @@ static struct usb_serial_driver belkin_device = { ...@@ -132,7 +131,6 @@ static struct usb_serial_driver belkin_device = {
.open = belkin_sa_open, .open = belkin_sa_open,
.close = belkin_sa_close, .close = belkin_sa_close,
.read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */
.ioctl = belkin_sa_ioctl,
.set_termios = belkin_sa_set_termios, .set_termios = belkin_sa_set_termios,
.break_ctl = belkin_sa_break_ctl, .break_ctl = belkin_sa_break_ctl,
.tiocmget = belkin_sa_tiocmget, .tiocmget = belkin_sa_tiocmget,
...@@ -190,7 +188,7 @@ static int belkin_sa_startup (struct usb_serial *serial) ...@@ -190,7 +188,7 @@ static int belkin_sa_startup (struct usb_serial *serial)
} }
static void belkin_sa_shutdown (struct usb_serial *serial) static void belkin_sa_shutdown(struct usb_serial *serial)
{ {
struct belkin_sa_private *priv; struct belkin_sa_private *priv;
int i; int i;
...@@ -206,7 +204,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial) ...@@ -206,7 +204,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
} }
static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) static int belkin_sa_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
{ {
int retval = 0; int retval = 0;
...@@ -235,7 +233,8 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) ...@@ -235,7 +233,8 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
} /* belkin_sa_open */ } /* belkin_sa_open */
static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) static void belkin_sa_close (struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
dbg("%s port %d", __func__, port->number); dbg("%s port %d", __func__, port->number);
...@@ -246,7 +245,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) ...@@ -246,7 +245,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
} /* belkin_sa_close */ } /* belkin_sa_close */
static void belkin_sa_read_int_callback (struct urb *urb) static void belkin_sa_read_int_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct belkin_sa_private *priv; struct belkin_sa_private *priv;
...@@ -311,7 +310,7 @@ static void belkin_sa_read_int_callback (struct urb *urb) ...@@ -311,7 +310,7 @@ static void belkin_sa_read_int_callback (struct urb *urb)
* to look in to this before committing any code. * to look in to this before committing any code.
*/ */
if (priv->last_lsr & BELKIN_SA_LSR_ERR) { if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
tty = port->tty; tty = port->port.tty;
/* Overrun Error */ /* Overrun Error */
if (priv->last_lsr & BELKIN_SA_LSR_OE) { if (priv->last_lsr & BELKIN_SA_LSR_OE) {
} }
...@@ -334,7 +333,8 @@ static void belkin_sa_read_int_callback (struct urb *urb) ...@@ -334,7 +333,8 @@ static void belkin_sa_read_int_callback (struct urb *urb)
__func__, retval); __func__, retval);
} }
static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) static void belkin_sa_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct belkin_sa_private *priv = usb_get_serial_port_data(port); struct belkin_sa_private *priv = usb_get_serial_port_data(port);
...@@ -347,7 +347,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -347,7 +347,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
unsigned long control_state; unsigned long control_state;
int bad_flow_control; int bad_flow_control;
speed_t baud; speed_t baud;
struct ktermios *termios = port->tty->termios; struct ktermios *termios = tty->termios;
iflag = termios->c_iflag; iflag = termios->c_iflag;
cflag = termios->c_cflag; cflag = termios->c_cflag;
...@@ -377,7 +377,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -377,7 +377,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
} }
} }
baud = tty_get_baud_rate(port->tty); baud = tty_get_baud_rate(tty);
if (baud) { if (baud) {
urb_value = BELKIN_SA_BAUD(baud); urb_value = BELKIN_SA_BAUD(baud);
/* Clip to maximum speed */ /* Clip to maximum speed */
...@@ -387,7 +387,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -387,7 +387,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
baud = BELKIN_SA_BAUD(urb_value); baud = BELKIN_SA_BAUD(urb_value);
/* Report the actual baud rate back to the caller */ /* Report the actual baud rate back to the caller */
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
err("Set baudrate error"); err("Set baudrate error");
} else { } else {
...@@ -463,8 +463,9 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios ...@@ -463,8 +463,9 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
} /* belkin_sa_set_termios */ } /* belkin_sa_set_termios */
static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state ) static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
...@@ -472,8 +473,9 @@ static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -472,8 +473,9 @@ static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
} }
static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct belkin_sa_private *priv = usb_get_serial_port_data(port); struct belkin_sa_private *priv = usb_get_serial_port_data(port);
unsigned long control_state; unsigned long control_state;
unsigned long flags; unsigned long flags;
...@@ -488,9 +490,10 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -488,9 +490,10 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
} }
static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct belkin_sa_private *priv = usb_get_serial_port_data(port); struct belkin_sa_private *priv = usb_get_serial_port_data(port);
unsigned long control_state; unsigned long control_state;
...@@ -540,29 +543,7 @@ static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, ...@@ -540,29 +543,7 @@ static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
} }
static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int __init belkin_sa_init(void)
{
switch (cmd) {
case TIOCMIWAIT:
/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
/* TODO */
return( 0 );
case TIOCGICOUNT:
/* return count of modemline transitions */
/* TODO */
return 0;
default:
dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
return(-ENOIOCTLCMD);
break;
}
return 0;
} /* belkin_sa_ioctl */
static int __init belkin_sa_init (void)
{ {
int retval; int retval;
retval = usb_serial_register(&belkin_device); retval = usb_serial_register(&belkin_device);
...@@ -583,7 +564,7 @@ static int __init belkin_sa_init (void) ...@@ -583,7 +564,7 @@ static int __init belkin_sa_init (void)
static void __exit belkin_sa_exit (void) static void __exit belkin_sa_exit (void)
{ {
usb_deregister (&belkin_driver); usb_deregister (&belkin_driver);
usb_serial_deregister (&belkin_device); usb_serial_deregister(&belkin_device);
} }
......
...@@ -232,7 +232,8 @@ error: kfree(priv); ...@@ -232,7 +232,8 @@ error: kfree(priv);
} }
/* open this device, set default parameters */ /* open this device, set default parameters */
static int ch341_open(struct usb_serial_port *port, struct file *filp) static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]);
...@@ -256,7 +257,7 @@ static int ch341_open(struct usb_serial_port *port, struct file *filp) ...@@ -256,7 +257,7 @@ static int ch341_open(struct usb_serial_port *port, struct file *filp)
if (r) if (r)
goto out; goto out;
r = usb_serial_generic_open(port, filp); r = usb_serial_generic_open(tty, port, filp);
out: return r; out: return r;
} }
...@@ -264,11 +265,10 @@ out: return r; ...@@ -264,11 +265,10 @@ out: return r;
/* Old_termios contains the original termios settings and /* Old_termios contains the original termios settings and
* tty->termios contains the new setting to be used. * tty->termios contains the new setting to be used.
*/ */
static void ch341_set_termios(struct usb_serial_port *port, static void ch341_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct ch341_private *priv = usb_get_serial_port_data(port); struct ch341_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned baud_rate; unsigned baud_rate;
dbg("ch341_set_termios()"); dbg("ch341_set_termios()");
......
...@@ -145,12 +145,12 @@ static int usb_console_setup(struct console *co, char *options) ...@@ -145,12 +145,12 @@ static int usb_console_setup(struct console *co, char *options)
} }
port = serial->port[0]; port = serial->port[0];
port->tty = NULL; port->port.tty = NULL;
info->port = port; info->port = port;
++port->open_count; ++port->port.count;
if (port->open_count == 1) { if (port->port.count == 1) {
if (serial->type->set_termios) { if (serial->type->set_termios) {
/* /*
* allocate a fake tty so the driver can initialize * allocate a fake tty so the driver can initialize
...@@ -171,15 +171,15 @@ static int usb_console_setup(struct console *co, char *options) ...@@ -171,15 +171,15 @@ static int usb_console_setup(struct console *co, char *options)
} }
memset(&dummy, 0, sizeof(struct ktermios)); memset(&dummy, 0, sizeof(struct ktermios));
tty->termios = termios; tty->termios = termios;
port->tty = tty; port->port.tty = tty;
} }
/* only call the device specific open if this /* only call the device specific open if this
* is the first time the port is opened */ * is the first time the port is opened */
if (serial->type->open) if (serial->type->open)
retval = serial->type->open(port, NULL); retval = serial->type->open(NULL, port, NULL);
else else
retval = usb_serial_generic_open(port, NULL); retval = usb_serial_generic_open(NULL, port, NULL);
if (retval) { if (retval) {
err("could not open USB console port"); err("could not open USB console port");
...@@ -188,9 +188,9 @@ static int usb_console_setup(struct console *co, char *options) ...@@ -188,9 +188,9 @@ static int usb_console_setup(struct console *co, char *options)
if (serial->type->set_termios) { if (serial->type->set_termios) {
termios->c_cflag = cflag; termios->c_cflag = cflag;
serial->type->set_termios(port, &dummy); serial->type->set_termios(NULL, port, &dummy);
port->tty = NULL; port->port.tty = NULL;
kfree(termios); kfree(termios);
kfree(tty); kfree(tty);
} }
...@@ -203,11 +203,11 @@ static int usb_console_setup(struct console *co, char *options) ...@@ -203,11 +203,11 @@ static int usb_console_setup(struct console *co, char *options)
return retval; return retval;
free_termios: free_termios:
kfree(termios); kfree(termios);
port->tty = NULL; port->port.tty = NULL;
free_tty: free_tty:
kfree(tty); kfree(tty);
reset_open_count: reset_open_count:
port->open_count = 0; port->port.count = 0;
goto out; goto out;
} }
...@@ -227,7 +227,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun ...@@ -227,7 +227,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
dbg("%s - port %d, %d byte(s)", __func__, port->number, count); dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
if (!port->open_count) { if (!port->port.count) {
dbg ("%s - port not opened", __func__); dbg ("%s - port not opened", __func__);
return; return;
} }
...@@ -245,17 +245,17 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun ...@@ -245,17 +245,17 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
} }
/* pass on to the driver specific version of this function if it is available */ /* pass on to the driver specific version of this function if it is available */
if (serial->type->write) if (serial->type->write)
retval = serial->type->write(port, buf, i); retval = serial->type->write(NULL, port, buf, i);
else else
retval = usb_serial_generic_write(port, buf, i); retval = usb_serial_generic_write(NULL, port, buf, i);
dbg("%s - return value : %d", __func__, retval); dbg("%s - return value : %d", __func__, retval);
if (lf) { if (lf) {
/* append CR after LF */ /* append CR after LF */
unsigned char cr = 13; unsigned char cr = 13;
if (serial->type->write) if (serial->type->write)
retval = serial->type->write(port, &cr, 1); retval = serial->type->write(NULL, port, &cr, 1);
else else
retval = usb_serial_generic_write(port, &cr, 1); retval = usb_serial_generic_write(NULL, port, &cr, 1);
dbg("%s - return value : %d", __func__, retval); dbg("%s - return value : %d", __func__, retval);
} }
buf += i; buf += i;
...@@ -306,8 +306,8 @@ void usb_serial_console_exit (void) ...@@ -306,8 +306,8 @@ void usb_serial_console_exit (void)
{ {
if (usbcons_info.port) { if (usbcons_info.port) {
unregister_console(&usbcons); unregister_console(&usbcons);
if (usbcons_info.port->open_count) if (usbcons_info.port->port.count)
usbcons_info.port->open_count--; usbcons_info.port->port.count--;
usbcons_info.port = NULL; usbcons_info.port = NULL;
} }
} }
......
...@@ -37,15 +37,18 @@ ...@@ -37,15 +37,18 @@
/* /*
* Function Prototypes * Function Prototypes
*/ */
static int cp2101_open(struct usb_serial_port*, struct file*); static int cp2101_open(struct tty_struct *, struct usb_serial_port *,
static void cp2101_cleanup(struct usb_serial_port*); struct file *);
static void cp2101_close(struct usb_serial_port*, struct file*); static void cp2101_cleanup(struct usb_serial_port *);
static void cp2101_get_termios(struct usb_serial_port*); static void cp2101_close(struct tty_struct *, struct usb_serial_port *,
static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*); struct file*);
static int cp2101_tiocmget (struct usb_serial_port *, struct file *); static void cp2101_get_termios(struct tty_struct *);
static int cp2101_tiocmset (struct usb_serial_port *, struct file *, static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *,
struct ktermios*);
static int cp2101_tiocmget (struct tty_struct *, struct file *);
static int cp2101_tiocmset (struct tty_struct *, struct file *,
unsigned int, unsigned int); unsigned int, unsigned int);
static void cp2101_break_ctl(struct usb_serial_port*, int); static void cp2101_break_ctl(struct tty_struct *, int);
static int cp2101_startup (struct usb_serial *); static int cp2101_startup (struct usb_serial *);
static void cp2101_shutdown(struct usb_serial*); static void cp2101_shutdown(struct usb_serial*);
...@@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = { ...@@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = {
* 'data' is a pointer to a pre-allocated array of integers large * 'data' is a pointer to a pre-allocated array of integers large
* enough to hold 'size' bytes (with 4 bytes to each integer) * enough to hold 'size' bytes (with 4 bytes to each integer)
*/ */
static int cp2101_get_config(struct usb_serial_port* port, u8 request, static int cp2101_get_config(struct usb_serial_port *port, u8 request,
unsigned int *data, int size) unsigned int *data, int size)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, ...@@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
* Values less than 16 bits wide are sent directly * Values less than 16 bits wide are sent directly
* 'size' is specified in bytes. * 'size' is specified in bytes.
*/ */
static int cp2101_set_config(struct usb_serial_port* port, u8 request, static int cp2101_set_config(struct usb_serial_port *port, u8 request,
unsigned int *data, int size) unsigned int *data, int size)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, ...@@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
* Convenience function for calling cp2101_set_config on single data values * Convenience function for calling cp2101_set_config on single data values
* without requiring an integer pointer * without requiring an integer pointer
*/ */
static inline int cp2101_set_config_single(struct usb_serial_port* port, static inline int cp2101_set_config_single(struct usb_serial_port *port,
u8 request, unsigned int data) u8 request, unsigned int data)
{ {
return cp2101_set_config(port, request, &data, 2); return cp2101_set_config(port, request, &data, 2);
} }
static int cp2101_open (struct usb_serial_port *port, struct file *filp) static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int result; int result;
...@@ -318,10 +322,10 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) ...@@ -318,10 +322,10 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
} }
/* Configure the termios structure */ /* Configure the termios structure */
cp2101_get_termios(port); cp2101_get_termios(tty);
/* Set the DTR and RTS pins low */ /* Set the DTR and RTS pins low */
cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0);
return 0; return 0;
} }
...@@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port) ...@@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port)
} }
} }
static void cp2101_close (struct usb_serial_port *port, struct file * filp) static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file * filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) ...@@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp)
* from the device, corrects any unsupported values, and configures the * from the device, corrects any unsupported values, and configures the
* termios structure to reflect the state of the device * termios structure to reflect the state of the device
*/ */
static void cp2101_get_termios (struct usb_serial_port *port) static void cp2101_get_termios (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned int cflag, modem_ctl[4]; unsigned int cflag, modem_ctl[4];
unsigned int baud; unsigned int baud;
unsigned int bits; unsigned int bits;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (!port->tty || !port->tty->termios) {
dbg("%s - no tty structures", __func__);
return;
}
cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2);
/* Convert to baudrate */ /* Convert to baudrate */
if (baud) if (baud)
...@@ -382,8 +383,8 @@ static void cp2101_get_termios (struct usb_serial_port *port) ...@@ -382,8 +383,8 @@ static void cp2101_get_termios (struct usb_serial_port *port)
dbg("%s - baud rate = %d", __func__, baud); dbg("%s - baud rate = %d", __func__, baud);
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
cflag = port->tty->termios->c_cflag; cflag = tty->termios->c_cflag;
cp2101_get_config(port, CP2101_BITS, &bits, 2); cp2101_get_config(port, CP2101_BITS, &bits, 2);
cflag &= ~CSIZE; cflag &= ~CSIZE;
...@@ -491,11 +492,11 @@ static void cp2101_get_termios (struct usb_serial_port *port) ...@@ -491,11 +492,11 @@ static void cp2101_get_termios (struct usb_serial_port *port)
cflag &= ~CRTSCTS; cflag &= ~CRTSCTS;
} }
port->tty->termios->c_cflag = cflag; tty->termios->c_cflag = cflag;
} }
static void cp2101_set_termios (struct usb_serial_port *port, static void cp2101_set_termios (struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
unsigned int cflag, old_cflag; unsigned int cflag, old_cflag;
unsigned int baud = 0, bits; unsigned int baud = 0, bits;
...@@ -503,15 +504,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, ...@@ -503,15 +504,13 @@ static void cp2101_set_termios (struct usb_serial_port *port,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (!port->tty || !port->tty->termios) { if (!tty)
dbg("%s - no tty structures", __func__);
return; return;
}
port->tty->termios->c_cflag &= ~CMSPAR;
cflag = port->tty->termios->c_cflag; tty->termios->c_cflag &= ~CMSPAR;
cflag = tty->termios->c_cflag;
old_cflag = old_termios->c_cflag; old_cflag = old_termios->c_cflag;
baud = tty_get_baud_rate(port->tty); baud = tty_get_baud_rate(tty);
/* If the baud rate is to be updated*/ /* If the baud rate is to be updated*/
if (baud != tty_termios_baud_rate(old_termios)) { if (baud != tty_termios_baud_rate(old_termios)) {
...@@ -554,7 +553,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, ...@@ -554,7 +553,7 @@ static void cp2101_set_termios (struct usb_serial_port *port,
} }
} }
/* Report back the resulting baud rate */ /* Report back the resulting baud rate */
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
/* If the number of data bits is to be updated */ /* If the number of data bits is to be updated */
if ((cflag & CSIZE) != (old_cflag & CSIZE)) { if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
...@@ -651,9 +650,10 @@ static void cp2101_set_termios (struct usb_serial_port *port, ...@@ -651,9 +650,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
} }
static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, static int cp2101_tiocmset (struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned int control = 0; unsigned int control = 0;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -681,8 +681,9 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, ...@@ -681,8 +681,9 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
} }
static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) static int cp2101_tiocmget (struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned int control; unsigned int control;
int result; int result;
...@@ -702,8 +703,9 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -702,8 +703,9 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
return result; return result;
} }
static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) static void cp2101_break_ctl (struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned int state; unsigned int state;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
......
...@@ -57,15 +57,18 @@ static int debug; ...@@ -57,15 +57,18 @@ static int debug;
#define CYBERJACK_PRODUCT_ID 0x0100 #define CYBERJACK_PRODUCT_ID 0x0100
/* Function prototypes */ /* Function prototypes */
static int cyberjack_startup (struct usb_serial *serial); static int cyberjack_startup(struct usb_serial *serial);
static void cyberjack_shutdown (struct usb_serial *serial); static void cyberjack_shutdown(struct usb_serial *serial);
static int cyberjack_open (struct usb_serial_port *port, struct file *filp); static int cyberjack_open(struct tty_struct *tty,
static void cyberjack_close (struct usb_serial_port *port, struct file *filp); struct usb_serial_port *port, struct file *filp);
static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count); static void cyberjack_close(struct tty_struct *tty,
static int cyberjack_write_room( struct usb_serial_port *port ); struct usb_serial_port *port, struct file *filp);
static void cyberjack_read_int_callback (struct urb *urb); static int cyberjack_write(struct tty_struct *tty,
static void cyberjack_read_bulk_callback (struct urb *urb); struct usb_serial_port *port, const unsigned char *buf, int count);
static void cyberjack_write_bulk_callback (struct urb *urb); static int cyberjack_write_room( struct tty_struct *tty);
static void cyberjack_read_int_callback(struct urb *urb);
static void cyberjack_read_bulk_callback(struct urb *urb);
static void cyberjack_write_bulk_callback(struct urb *urb);
static struct usb_device_id id_table [] = { static struct usb_device_id id_table [] = {
{ USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
...@@ -111,7 +114,7 @@ struct cyberjack_private { ...@@ -111,7 +114,7 @@ struct cyberjack_private {
}; };
/* do some startup allocations not currently performed by usb_serial_probe() */ /* do some startup allocations not currently performed by usb_serial_probe() */
static int cyberjack_startup (struct usb_serial *serial) static int cyberjack_startup(struct usb_serial *serial)
{ {
struct cyberjack_private *priv; struct cyberjack_private *priv;
int i; int i;
...@@ -145,7 +148,7 @@ static int cyberjack_startup (struct usb_serial *serial) ...@@ -145,7 +148,7 @@ static int cyberjack_startup (struct usb_serial *serial)
return( 0 ); return( 0 );
} }
static void cyberjack_shutdown (struct usb_serial *serial) static void cyberjack_shutdown(struct usb_serial *serial)
{ {
int i; int i;
...@@ -159,7 +162,8 @@ static void cyberjack_shutdown (struct usb_serial *serial) ...@@ -159,7 +162,8 @@ static void cyberjack_shutdown (struct usb_serial *serial)
} }
} }
static int cyberjack_open (struct usb_serial_port *port, struct file *filp) static int cyberjack_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct cyberjack_private *priv; struct cyberjack_private *priv;
unsigned long flags; unsigned long flags;
...@@ -174,7 +178,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) ...@@ -174,7 +178,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
* the data through, otherwise it is scheduled, and with high * the data through, otherwise it is scheduled, and with high
* data rates (like with OHCI) data can get lost. * data rates (like with OHCI) data can get lost.
*/ */
port->tty->low_latency = 1; if (tty)
tty->low_latency = 1;
priv = usb_get_serial_port_data(port); priv = usb_get_serial_port_data(port);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -186,7 +191,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp) ...@@ -186,7 +191,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
return result; return result;
} }
static void cyberjack_close (struct usb_serial_port *port, struct file *filp) static void cyberjack_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp) ...@@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
} }
} }
static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count) static int cyberjack_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
...@@ -292,13 +299,13 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b ...@@ -292,13 +299,13 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
return (count); return (count);
} }
static int cyberjack_write_room( struct usb_serial_port *port ) static int cyberjack_write_room(struct tty_struct *tty)
{ {
/* FIXME: .... */ /* FIXME: .... */
return CYBERJACK_LOCAL_BUF_SIZE; return CYBERJACK_LOCAL_BUF_SIZE;
} }
static void cyberjack_read_int_callback( struct urb *urb ) static void cyberjack_read_int_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
...@@ -355,7 +362,7 @@ static void cyberjack_read_int_callback( struct urb *urb ) ...@@ -355,7 +362,7 @@ static void cyberjack_read_int_callback( struct urb *urb )
dbg("%s - usb_submit_urb(int urb)", __func__); dbg("%s - usb_submit_urb(int urb)", __func__);
} }
static void cyberjack_read_bulk_callback (struct urb *urb) static void cyberjack_read_bulk_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
...@@ -374,7 +381,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb) ...@@ -374,7 +381,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
return; return;
} }
tty = port->tty; tty = port->port.tty;
if (!tty) { if (!tty) {
dbg("%s - ignoring since device not open\n", __func__); dbg("%s - ignoring since device not open\n", __func__);
return; return;
...@@ -407,7 +414,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb) ...@@ -407,7 +414,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
} }
} }
static void cyberjack_write_bulk_callback (struct urb *urb) static void cyberjack_write_bulk_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
......
...@@ -167,18 +167,18 @@ static int cypress_earthmate_startup (struct usb_serial *serial); ...@@ -167,18 +167,18 @@ static int cypress_earthmate_startup (struct usb_serial *serial);
static int cypress_hidcom_startup (struct usb_serial *serial); static int cypress_hidcom_startup (struct usb_serial *serial);
static int cypress_ca42v2_startup (struct usb_serial *serial); static int cypress_ca42v2_startup (struct usb_serial *serial);
static void cypress_shutdown (struct usb_serial *serial); static void cypress_shutdown (struct usb_serial *serial);
static int cypress_open (struct usb_serial_port *port, struct file *filp); static int cypress_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void cypress_close (struct usb_serial_port *port, struct file *filp); static void cypress_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count); static int cypress_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
static void cypress_send (struct usb_serial_port *port); static void cypress_send (struct usb_serial_port *port);
static int cypress_write_room (struct usb_serial_port *port); static int cypress_write_room (struct tty_struct *tty);
static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); static int cypress_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
static void cypress_set_termios (struct usb_serial_port *port, struct ktermios * old); static void cypress_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
static int cypress_tiocmget (struct usb_serial_port *port, struct file *file); static int cypress_tiocmget (struct tty_struct *tty, struct file *file);
static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); static int cypress_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
static int cypress_chars_in_buffer (struct usb_serial_port *port); static int cypress_chars_in_buffer (struct tty_struct *tty);
static void cypress_throttle (struct usb_serial_port *port); static void cypress_throttle (struct tty_struct *tty);
static void cypress_unthrottle (struct usb_serial_port *port); static void cypress_unthrottle (struct tty_struct *tty);
static void cypress_set_dead (struct usb_serial_port *port); static void cypress_set_dead (struct usb_serial_port *port);
static void cypress_read_int_callback (struct urb *urb); static void cypress_read_int_callback (struct urb *urb);
static void cypress_write_int_callback (struct urb *urb); static void cypress_write_int_callback (struct urb *urb);
...@@ -322,8 +322,10 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate) ...@@ -322,8 +322,10 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
/* This function can either set or retrieve the current serial line settings */ /* This function can either set or retrieve the current serial line settings */
static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits, static int cypress_serial_control (struct tty_struct *tty,
int parity_enable, int parity_type, int reset, int cypress_request_type) struct usb_serial_port *port, speed_t baud_rate, int data_bits,
int stop_bits, int parity_enable, int parity_type, int reset,
int cypress_request_type)
{ {
int new_baudrate = 0, retval = 0, tries = 0; int new_baudrate = 0, retval = 0, tries = 0;
struct cypress_private *priv; struct cypress_private *priv;
...@@ -395,7 +397,7 @@ static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_ra ...@@ -395,7 +397,7 @@ static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_ra
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* If we asked for a speed change encode it */ /* If we asked for a speed change encode it */
if (baud_rate) if (baud_rate)
tty_encode_baud_rate(port->tty, tty_encode_baud_rate(tty,
new_baudrate, new_baudrate); new_baudrate, new_baudrate);
} }
break; break;
...@@ -611,7 +613,8 @@ static void cypress_shutdown (struct usb_serial *serial) ...@@ -611,7 +613,8 @@ static void cypress_shutdown (struct usb_serial *serial)
} }
static int cypress_open (struct usb_serial_port *port, struct file *filp) static int cypress_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -636,14 +639,15 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) ...@@ -636,14 +639,15 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* setting to zero could cause data loss */ /* setting to zero could cause data loss */
port->tty->low_latency = 1; if (tty)
tty->low_latency = 1;
/* raise both lines and set termios */ /* raise both lines and set termios */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
priv->line_control = CONTROL_DTR | CONTROL_RTS; priv->line_control = CONTROL_DTR | CONTROL_RTS;
priv->cmd_ctrl = 1; priv->cmd_ctrl = 1;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
result = cypress_write(port, NULL, 0); result = cypress_write(tty, port, NULL, 0);
if (result) { if (result) {
dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result); dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result);
...@@ -651,7 +655,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) ...@@ -651,7 +655,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
} else } else
dbg("%s - success setting the control lines", __func__); dbg("%s - success setting the control lines", __func__);
cypress_set_termios(port, &priv->tmp_termios); if (tty)
cypress_set_termios(tty, port, &priv->tmp_termios);
/* setup the port and start reading from the device */ /* setup the port and start reading from the device */
if(!port->interrupt_in_urb){ if(!port->interrupt_in_urb){
...@@ -674,7 +679,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp) ...@@ -674,7 +679,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
} /* cypress_open */ } /* cypress_open */
static void cypress_close(struct usb_serial_port *port, struct file * filp) static void cypress_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
unsigned int c_cflag; unsigned int c_cflag;
...@@ -688,7 +694,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) ...@@ -688,7 +694,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
spin_lock_irq(&priv->lock); spin_lock_irq(&priv->lock);
timeout = CYPRESS_CLOSING_WAIT; timeout = CYPRESS_CLOSING_WAIT;
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&port->tty->write_wait, &wait); add_wait_queue(&tty->write_wait, &wait);
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (cypress_buf_data_avail(priv->buf) == 0 if (cypress_buf_data_avail(priv->buf) == 0
...@@ -701,7 +707,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) ...@@ -701,7 +707,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
spin_lock_irq(&priv->lock); spin_lock_irq(&priv->lock);
} }
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&port->tty->write_wait, &wait); remove_wait_queue(&tty->write_wait, &wait);
/* clear out any remaining data in the buffer */ /* clear out any remaining data in the buffer */
cypress_buf_clear(priv->buf); cypress_buf_clear(priv->buf);
spin_unlock_irq(&priv->lock); spin_unlock_irq(&priv->lock);
...@@ -713,19 +719,21 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) ...@@ -713,19 +719,21 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
return; return;
} }
/* wait for characters to drain from device */ /* wait for characters to drain from device */
bps = tty_get_baud_rate(port->tty); if (tty) {
bps = tty_get_baud_rate(tty);
if (bps > 1200) if (bps > 1200)
timeout = max((HZ*2560)/bps,HZ/10); timeout = max((HZ*2560)/bps,HZ/10);
else else
timeout = 2*HZ; timeout = 2*HZ;
schedule_timeout_interruptible(timeout); schedule_timeout_interruptible(timeout);
}
dbg("%s - stopping urbs", __func__); dbg("%s - stopping urbs", __func__);
usb_kill_urb (port->interrupt_in_urb); usb_kill_urb (port->interrupt_in_urb);
usb_kill_urb (port->interrupt_out_urb); usb_kill_urb (port->interrupt_out_urb);
if (port->tty) { if (tty) {
c_cflag = port->tty->termios->c_cflag; c_cflag = tty->termios->c_cflag;
if (c_cflag & HUPCL) { if (c_cflag & HUPCL) {
/* drop dtr and rts */ /* drop dtr and rts */
priv = usb_get_serial_port_data(port); priv = usb_get_serial_port_data(port);
...@@ -733,7 +741,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) ...@@ -733,7 +741,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
priv->line_control = 0; priv->line_control = 0;
priv->cmd_ctrl = 1; priv->cmd_ctrl = 1;
spin_unlock_irq(&priv->lock); spin_unlock_irq(&priv->lock);
cypress_write(port, NULL, 0); cypress_write(tty, port, NULL, 0);
} }
} }
...@@ -744,7 +752,8 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp) ...@@ -744,7 +752,8 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
} /* cypress_close */ } /* cypress_close */
static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count) static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count)
{ {
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -878,8 +887,9 @@ static void cypress_send(struct usb_serial_port *port) ...@@ -878,8 +887,9 @@ static void cypress_send(struct usb_serial_port *port)
/* returns how much space is available in the soft buffer */ /* returns how much space is available in the soft buffer */
static int cypress_write_room(struct usb_serial_port *port) static int cypress_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
int room = 0; int room = 0;
unsigned long flags; unsigned long flags;
...@@ -895,8 +905,9 @@ static int cypress_write_room(struct usb_serial_port *port) ...@@ -895,8 +905,9 @@ static int cypress_write_room(struct usb_serial_port *port)
} }
static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) static int cypress_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
__u8 status, control; __u8 status, control;
unsigned int result = 0; unsigned int result = 0;
...@@ -922,9 +933,10 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -922,9 +933,10 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
} }
static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -942,12 +954,14 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, ...@@ -942,12 +954,14 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
priv->cmd_ctrl = 1; priv->cmd_ctrl = 1;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
return cypress_write(port, NULL, 0); return cypress_write(tty, port, NULL, 0);
} }
static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int cypress_ioctl(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
...@@ -983,22 +997,18 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi ...@@ -983,22 +997,18 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
} }
} }
return 0; return 0;
break;
default: default:
break; break;
} }
dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd);
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} /* cypress_ioctl */ } /* cypress_ioctl */
static void cypress_set_termios (struct usb_serial_port *port, static void cypress_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty;
int data_bits, stop_bits, parity_type, parity_enable; int data_bits, stop_bits, parity_type, parity_enable;
unsigned cflag, iflag; unsigned cflag, iflag;
unsigned long flags; unsigned long flags;
...@@ -1007,8 +1017,6 @@ static void cypress_set_termios (struct usb_serial_port *port, ...@@ -1007,8 +1017,6 @@ static void cypress_set_termios (struct usb_serial_port *port,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
tty = port->tty;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (!priv->termios_initialized) { if (!priv->termios_initialized) {
if (priv->chiptype == CT_EARTHMATE) { if (priv->chiptype == CT_EARTHMATE) {
...@@ -1096,13 +1104,13 @@ static void cypress_set_termios (struct usb_serial_port *port, ...@@ -1096,13 +1104,13 @@ static void cypress_set_termios (struct usb_serial_port *port,
"%d data_bits (+5)", __func__, stop_bits, "%d data_bits (+5)", __func__, stop_bits,
parity_enable, parity_type, data_bits); parity_enable, parity_type, data_bits);
cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits, cypress_serial_control(tty, port, tty_get_baud_rate(tty), data_bits, stop_bits,
parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
/* we perform a CYPRESS_GET_CONFIG so that the current settings are /* we perform a CYPRESS_GET_CONFIG so that the current settings are
* filled into the private structure this should confirm that all is * filled into the private structure this should confirm that all is
* working if it returns what we just set */ * working if it returns what we just set */
cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
/* Here we can define custom tty settings for devices; the main tty /* Here we can define custom tty settings for devices; the main tty
* termios flag base comes from empeg.c */ * termios flag base comes from empeg.c */
...@@ -1142,14 +1150,15 @@ static void cypress_set_termios (struct usb_serial_port *port, ...@@ -1142,14 +1150,15 @@ static void cypress_set_termios (struct usb_serial_port *port,
/* if necessary, set lines */ /* if necessary, set lines */
if (linechange) { if (linechange) {
priv->cmd_ctrl = 1; priv->cmd_ctrl = 1;
cypress_write(port, NULL, 0); cypress_write(tty, port, NULL, 0);
} }
} /* cypress_set_termios */ } /* cypress_set_termios */
/* returns amount of data still left in soft buffer */ /* returns amount of data still left in soft buffer */
static int cypress_chars_in_buffer(struct usb_serial_port *port) static int cypress_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
int chars = 0; int chars = 0;
unsigned long flags; unsigned long flags;
...@@ -1165,8 +1174,9 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port) ...@@ -1165,8 +1174,9 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port)
} }
static void cypress_throttle (struct usb_serial_port *port) static void cypress_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -1178,8 +1188,9 @@ static void cypress_throttle (struct usb_serial_port *port) ...@@ -1178,8 +1188,9 @@ static void cypress_throttle (struct usb_serial_port *port)
} }
static void cypress_unthrottle (struct usb_serial_port *port) static void cypress_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct cypress_private *priv = usb_get_serial_port_data(port); struct cypress_private *priv = usb_get_serial_port_data(port);
int actually_throttled, result; int actually_throttled, result;
unsigned long flags; unsigned long flags;
...@@ -1251,7 +1262,7 @@ static void cypress_read_int_callback(struct urb *urb) ...@@ -1251,7 +1262,7 @@ static void cypress_read_int_callback(struct urb *urb)
} }
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
tty = port->tty; tty = port->port.tty;
if (!tty) { if (!tty) {
dbg("%s - bad tty pointer - exiting", __func__); dbg("%s - bad tty pointer - exiting", __func__);
return; return;
...@@ -1327,7 +1338,7 @@ static void cypress_read_int_callback(struct urb *urb) ...@@ -1327,7 +1338,7 @@ static void cypress_read_int_callback(struct urb *urb)
data[i]); data[i]);
tty_insert_flip_char(tty, data[i], tty_flag); tty_insert_flip_char(tty, data[i], tty_flag);
} }
tty_flip_buffer_push(port->tty); tty_flip_buffer_push(port->port.tty);
} }
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -1339,7 +1350,7 @@ static void cypress_read_int_callback(struct urb *urb) ...@@ -1339,7 +1350,7 @@ static void cypress_read_int_callback(struct urb *urb)
/* Continue trying to always read... unless the port has closed. */ /* Continue trying to always read... unless the port has closed. */
if (port->open_count > 0 && priv->comm_is_ok) { if (port->port.count > 0 && priv->comm_is_ok) {
usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
usb_rcvintpipe(port->serial->dev, usb_rcvintpipe(port->serial->dev,
port->interrupt_in_endpointAddress), port->interrupt_in_endpointAddress),
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Al Borchers (borchers@steinerpoint.com) * Al Borchers (borchers@steinerpoint.com)
* *
* (12/03/2001) gkh * (12/03/2001) gkh
* switched to using port->open_count instead of private version. * switched to using port->port.count instead of private version.
* Removed port->active * Removed port->active
* *
* (04/08/2001) gb * (04/08/2001) gb
...@@ -441,22 +441,23 @@ static int digi_set_modem_signals(struct usb_serial_port *port, ...@@ -441,22 +441,23 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
unsigned int modem_signals, int interruptible); unsigned int modem_signals, int interruptible);
static int digi_transmit_idle(struct usb_serial_port *port, static int digi_transmit_idle(struct usb_serial_port *port,
unsigned long timeout); unsigned long timeout);
static void digi_rx_throttle (struct usb_serial_port *port); static void digi_rx_throttle (struct tty_struct *tty);
static void digi_rx_unthrottle (struct usb_serial_port *port); static void digi_rx_unthrottle (struct tty_struct *tty);
static void digi_set_termios(struct usb_serial_port *port, static void digi_set_termios(struct tty_struct *tty,
struct ktermios *old_termios); struct usb_serial_port *port, struct ktermios *old_termios);
static void digi_break_ctl(struct usb_serial_port *port, int break_state); static void digi_break_ctl(struct tty_struct *tty, int break_state);
static int digi_ioctl(struct usb_serial_port *port, struct file *file, static int digi_tiocmget(struct tty_struct *tty, struct file *file);
unsigned int cmd, unsigned long arg); static int digi_tiocmset(struct tty_struct *tty, struct file *file,
static int digi_tiocmget(struct usb_serial_port *port, struct file *file);
static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
unsigned int set, unsigned int clear); unsigned int set, unsigned int clear);
static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count); static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static void digi_write_bulk_callback(struct urb *urb); static void digi_write_bulk_callback(struct urb *urb);
static int digi_write_room(struct usb_serial_port *port); static int digi_write_room(struct tty_struct *tty);
static int digi_chars_in_buffer(struct usb_serial_port *port); static int digi_chars_in_buffer(struct tty_struct *tty);
static int digi_open(struct usb_serial_port *port, struct file *filp); static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
static void digi_close(struct usb_serial_port *port, struct file *filp); struct file *filp);
static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
static int digi_startup_device(struct usb_serial *serial); static int digi_startup_device(struct usb_serial *serial);
static int digi_startup(struct usb_serial *serial); static int digi_startup(struct usb_serial *serial);
static void digi_shutdown(struct usb_serial *serial); static void digi_shutdown(struct usb_serial *serial);
...@@ -516,7 +517,6 @@ static struct usb_serial_driver digi_acceleport_2_device = { ...@@ -516,7 +517,6 @@ static struct usb_serial_driver digi_acceleport_2_device = {
.chars_in_buffer = digi_chars_in_buffer, .chars_in_buffer = digi_chars_in_buffer,
.throttle = digi_rx_throttle, .throttle = digi_rx_throttle,
.unthrottle = digi_rx_unthrottle, .unthrottle = digi_rx_unthrottle,
.ioctl = digi_ioctl,
.set_termios = digi_set_termios, .set_termios = digi_set_termios,
.break_ctl = digi_break_ctl, .break_ctl = digi_break_ctl,
.tiocmget = digi_tiocmget, .tiocmget = digi_tiocmget,
...@@ -543,7 +543,6 @@ static struct usb_serial_driver digi_acceleport_4_device = { ...@@ -543,7 +543,6 @@ static struct usb_serial_driver digi_acceleport_4_device = {
.chars_in_buffer = digi_chars_in_buffer, .chars_in_buffer = digi_chars_in_buffer,
.throttle = digi_rx_throttle, .throttle = digi_rx_throttle,
.unthrottle = digi_rx_unthrottle, .unthrottle = digi_rx_unthrottle,
.ioctl = digi_ioctl,
.set_termios = digi_set_termios, .set_termios = digi_set_termios,
.break_ctl = digi_break_ctl, .break_ctl = digi_break_ctl,
.tiocmget = digi_tiocmget, .tiocmget = digi_tiocmget,
...@@ -604,7 +603,7 @@ static void digi_wakeup_write_lock(struct work_struct *work) ...@@ -604,7 +603,7 @@ static void digi_wakeup_write_lock(struct work_struct *work)
static void digi_wakeup_write(struct usb_serial_port *port) static void digi_wakeup_write(struct usb_serial_port *port)
{ {
tty_wakeup(port->tty); tty_wakeup(port->port.tty);
} }
...@@ -856,9 +855,10 @@ static int digi_transmit_idle(struct usb_serial_port *port, ...@@ -856,9 +855,10 @@ static int digi_transmit_idle(struct usb_serial_port *port,
} }
static void digi_rx_throttle(struct usb_serial_port *port) static void digi_rx_throttle(struct tty_struct *tty)
{ {
unsigned long flags; unsigned long flags;
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
...@@ -872,10 +872,11 @@ static void digi_rx_throttle(struct usb_serial_port *port) ...@@ -872,10 +872,11 @@ static void digi_rx_throttle(struct usb_serial_port *port)
} }
static void digi_rx_unthrottle(struct usb_serial_port *port) static void digi_rx_unthrottle(struct tty_struct *tty)
{ {
int ret = 0; int ret = 0;
unsigned long flags; unsigned long flags;
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num); dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num);
...@@ -900,12 +901,10 @@ static void digi_rx_unthrottle(struct usb_serial_port *port) ...@@ -900,12 +901,10 @@ static void digi_rx_unthrottle(struct usb_serial_port *port)
} }
static void digi_set_termios(struct usb_serial_port *port, static void digi_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned int iflag = tty->termios->c_iflag; unsigned int iflag = tty->termios->c_iflag;
unsigned int cflag = tty->termios->c_cflag; unsigned int cflag = tty->termios->c_cflag;
unsigned int old_iflag = old_termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag;
...@@ -1088,8 +1087,9 @@ static void digi_set_termios(struct usb_serial_port *port, ...@@ -1088,8 +1087,9 @@ static void digi_set_termios(struct usb_serial_port *port,
} }
static void digi_break_ctl(struct usb_serial_port *port, int break_state) static void digi_break_ctl(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned char buf[4]; unsigned char buf[4];
buf[0] = DIGI_CMD_BREAK_CONTROL; buf[0] = DIGI_CMD_BREAK_CONTROL;
...@@ -1100,8 +1100,9 @@ static void digi_break_ctl(struct usb_serial_port *port, int break_state) ...@@ -1100,8 +1100,9 @@ static void digi_break_ctl(struct usb_serial_port *port, int break_state)
} }
static int digi_tiocmget(struct usb_serial_port *port, struct file *file) static int digi_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
unsigned int val; unsigned int val;
unsigned long flags; unsigned long flags;
...@@ -1115,9 +1116,10 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file) ...@@ -1115,9 +1116,10 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
} }
static int digi_tiocmset(struct usb_serial_port *port, struct file *file, static int digi_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
unsigned int val; unsigned int val;
unsigned long flags; unsigned long flags;
...@@ -1131,27 +1133,8 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -1131,27 +1133,8 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
} }
static int digi_ioctl(struct usb_serial_port *port, struct file *file, static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
unsigned int cmd, unsigned long arg) const unsigned char *buf, int count)
{
struct digi_port *priv = usb_get_serial_port_data(port);
dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd);
switch (cmd) {
case TIOCMIWAIT:
/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
/* TODO */
return 0;
case TIOCGICOUNT:
/* return count of modemline transitions */
/* TODO */
return 0;
}
return -ENOIOCTLCMD;
}
static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
int ret,data_len,new_len; int ret,data_len,new_len;
...@@ -1261,7 +1244,7 @@ static void digi_write_bulk_callback(struct urb *urb) ...@@ -1261,7 +1244,7 @@ static void digi_write_bulk_callback(struct urb *urb)
/* try to send any buffered data on this port, if it is open */ /* try to send any buffered data on this port, if it is open */
spin_lock(&priv->dp_port_lock); spin_lock(&priv->dp_port_lock);
priv->dp_write_urb_in_use = 0; priv->dp_write_urb_in_use = 0;
if (port->open_count && port->write_urb->status != -EINPROGRESS if (port->port.count && port->write_urb->status != -EINPROGRESS
&& priv->dp_out_buf_len > 0) { && priv->dp_out_buf_len > 0) {
*((unsigned char *)(port->write_urb->transfer_buffer)) *((unsigned char *)(port->write_urb->transfer_buffer))
= (unsigned char)DIGI_CMD_SEND_DATA; = (unsigned char)DIGI_CMD_SEND_DATA;
...@@ -1288,11 +1271,11 @@ static void digi_write_bulk_callback(struct urb *urb) ...@@ -1288,11 +1271,11 @@ static void digi_write_bulk_callback(struct urb *urb)
__func__, ret, priv->dp_port_num); __func__, ret, priv->dp_port_num);
} }
static int digi_write_room(struct usb_serial_port *port) static int digi_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int room;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
int room;
unsigned long flags = 0; unsigned long flags = 0;
spin_lock_irqsave(&priv->dp_port_lock, flags); spin_lock_irqsave(&priv->dp_port_lock, flags);
...@@ -1308,12 +1291,11 @@ static int digi_write_room(struct usb_serial_port *port) ...@@ -1308,12 +1291,11 @@ static int digi_write_room(struct usb_serial_port *port)
} }
static int digi_chars_in_buffer(struct usb_serial_port *port) static int digi_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
if (port->write_urb->status == -EINPROGRESS if (port->write_urb->status == -EINPROGRESS
|| priv->dp_write_urb_in_use) { || priv->dp_write_urb_in_use) {
dbg("digi_chars_in_buffer: port=%d, chars=%d", dbg("digi_chars_in_buffer: port=%d, chars=%d",
...@@ -1329,7 +1311,8 @@ static int digi_chars_in_buffer(struct usb_serial_port *port) ...@@ -1329,7 +1311,8 @@ static int digi_chars_in_buffer(struct usb_serial_port *port)
} }
static int digi_open(struct usb_serial_port *port, struct file *filp) static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
int ret; int ret;
unsigned char buf[32]; unsigned char buf[32];
...@@ -1338,7 +1321,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) ...@@ -1338,7 +1321,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
unsigned long flags = 0; unsigned long flags = 0;
dbg("digi_open: TOP: port=%d, open_count=%d", dbg("digi_open: TOP: port=%d, open_count=%d",
priv->dp_port_num, port->open_count); priv->dp_port_num, port->port.count);
/* be sure the device is started up */ /* be sure the device is started up */
if (digi_startup_device(port->serial) != 0) if (digi_startup_device(port->serial) != 0)
...@@ -1380,9 +1363,11 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) ...@@ -1380,9 +1363,11 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
dbg("digi_open: write oob failed, ret=%d", ret); dbg("digi_open: write oob failed, ret=%d", ret);
/* set termios settings */ /* set termios settings */
not_termios.c_cflag = ~port->tty->termios->c_cflag; if (tty) {
not_termios.c_iflag = ~port->tty->termios->c_iflag; not_termios.c_cflag = ~tty->termios->c_cflag;
digi_set_termios(port, &not_termios); not_termios.c_iflag = ~tty->termios->c_iflag;
digi_set_termios(tty, port, &not_termios);
}
/* set DTR and RTS */ /* set DTR and RTS */
digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1); digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1);
...@@ -1391,16 +1376,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp) ...@@ -1391,16 +1376,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
} }
static void digi_close(struct usb_serial_port *port, struct file *filp) static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
int ret; int ret;
unsigned char buf[32]; unsigned char buf[32];
struct tty_struct *tty = port->tty;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
dbg("digi_close: TOP: port=%d, open_count=%d", dbg("digi_close: TOP: port=%d, open_count=%d",
priv->dp_port_num, port->open_count); priv->dp_port_num, port->port.count);
mutex_lock(&port->serial->disc_mutex); mutex_lock(&port->serial->disc_mutex);
/* if disconnected, just clear flags */ /* if disconnected, just clear flags */
...@@ -1663,7 +1648,7 @@ static int digi_read_inb_callback(struct urb *urb) ...@@ -1663,7 +1648,7 @@ static int digi_read_inb_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->port.tty;
struct digi_port *priv = usb_get_serial_port_data(port); struct digi_port *priv = usb_get_serial_port_data(port);
int opcode = ((unsigned char *)urb->transfer_buffer)[0]; int opcode = ((unsigned char *)urb->transfer_buffer)[0];
int len = ((unsigned char *)urb->transfer_buffer)[1]; int len = ((unsigned char *)urb->transfer_buffer)[1];
...@@ -1675,7 +1660,7 @@ static int digi_read_inb_callback(struct urb *urb) ...@@ -1675,7 +1660,7 @@ static int digi_read_inb_callback(struct urb *urb)
/* do not process callbacks on closed ports */ /* do not process callbacks on closed ports */
/* but do continue the read chain */ /* but do continue the read chain */
if (port->open_count == 0) if (port->port.count == 0)
return 0; return 0;
/* short/multiple packet check */ /* short/multiple packet check */
...@@ -1785,17 +1770,17 @@ static int digi_read_oob_callback(struct urb *urb) ...@@ -1785,17 +1770,17 @@ static int digi_read_oob_callback(struct urb *urb)
if (val & DIGI_READ_INPUT_SIGNALS_CTS) { if (val & DIGI_READ_INPUT_SIGNALS_CTS) {
priv->dp_modem_signals |= TIOCM_CTS; priv->dp_modem_signals |= TIOCM_CTS;
/* port must be open to use tty struct */ /* port must be open to use tty struct */
if (port->open_count if (port->port.count
&& port->tty->termios->c_cflag & CRTSCTS) { && port->port.tty->termios->c_cflag & CRTSCTS) {
port->tty->hw_stopped = 0; port->port.tty->hw_stopped = 0;
digi_wakeup_write(port); digi_wakeup_write(port);
} }
} else { } else {
priv->dp_modem_signals &= ~TIOCM_CTS; priv->dp_modem_signals &= ~TIOCM_CTS;
/* port must be open to use tty struct */ /* port must be open to use tty struct */
if (port->open_count if (port->port.count
&& port->tty->termios->c_cflag & CRTSCTS) { && port->port.tty->termios->c_cflag & CRTSCTS) {
port->tty->hw_stopped = 1; port->port.tty->hw_stopped = 1;
} }
} }
if (val & DIGI_READ_INPUT_SIGNALS_DSR) if (val & DIGI_READ_INPUT_SIGNALS_DSR)
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* Moved MOD_DEC_USE_COUNT to end of empeg_close(). * Moved MOD_DEC_USE_COUNT to end of empeg_close().
* *
* (12/03/2000) gb * (12/03/2000) gb
* Added port->tty->ldisc.set_termios(port->tty, NULL) to empeg_open() * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open()
* This notifies the tty driver that the termios have changed. * This notifies the tty driver that the termios have changed.
* *
* (11/13/2000) gb * (11/13/2000) gb
...@@ -77,22 +77,18 @@ static int debug; ...@@ -77,22 +77,18 @@ static int debug;
#define EMPEG_PRODUCT_ID 0x0001 #define EMPEG_PRODUCT_ID 0x0001
/* function prototypes for an empeg-car player */ /* function prototypes for an empeg-car player */
static int empeg_open (struct usb_serial_port *port, struct file *filp); static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void empeg_close (struct usb_serial_port *port, struct file *filp); static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static int empeg_write (struct usb_serial_port *port, static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, const unsigned char *buf,
int count); int count);
static int empeg_write_room (struct usb_serial_port *port); static int empeg_write_room (struct tty_struct *tty);
static int empeg_chars_in_buffer (struct usb_serial_port *port); static int empeg_chars_in_buffer (struct tty_struct *tty);
static void empeg_throttle (struct usb_serial_port *port); static void empeg_throttle (struct tty_struct *tty);
static void empeg_unthrottle (struct usb_serial_port *port); static void empeg_unthrottle (struct tty_struct *tty);
static int empeg_startup (struct usb_serial *serial); static int empeg_startup (struct usb_serial *serial);
static void empeg_shutdown (struct usb_serial *serial); static void empeg_shutdown (struct usb_serial *serial);
static int empeg_ioctl (struct usb_serial_port *port, static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
struct file * file,
unsigned int cmd,
unsigned long arg);
static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios);
static void empeg_write_bulk_callback (struct urb *urb); static void empeg_write_bulk_callback (struct urb *urb);
static void empeg_read_bulk_callback (struct urb *urb); static void empeg_read_bulk_callback (struct urb *urb);
...@@ -125,7 +121,6 @@ static struct usb_serial_driver empeg_device = { ...@@ -125,7 +121,6 @@ static struct usb_serial_driver empeg_device = {
.unthrottle = empeg_unthrottle, .unthrottle = empeg_unthrottle,
.attach = empeg_startup, .attach = empeg_startup,
.shutdown = empeg_shutdown, .shutdown = empeg_shutdown,
.ioctl = empeg_ioctl,
.set_termios = empeg_set_termios, .set_termios = empeg_set_termios,
.write = empeg_write, .write = empeg_write,
.write_room = empeg_write_room, .write_room = empeg_write_room,
...@@ -145,7 +140,8 @@ static int bytes_out; ...@@ -145,7 +140,8 @@ static int bytes_out;
/****************************************************************************** /******************************************************************************
* Empeg specific driver functions * Empeg specific driver functions
******************************************************************************/ ******************************************************************************/
static int empeg_open (struct usb_serial_port *port, struct file *filp) static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int result = 0; int result = 0;
...@@ -153,7 +149,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -153,7 +149,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
/* Force default termio settings */ /* Force default termio settings */
empeg_set_termios (port, NULL) ; empeg_set_termios (tty, port, NULL) ;
bytes_in = 0; bytes_in = 0;
bytes_out = 0; bytes_out = 0;
...@@ -178,7 +174,8 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -178,7 +174,8 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
} }
static void empeg_close (struct usb_serial_port *port, struct file * filp) static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file * filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -189,7 +186,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) ...@@ -189,7 +186,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
} }
static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count) static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct urb *urb; struct urb *urb;
...@@ -203,7 +200,6 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, ...@@ -203,7 +200,6 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
while (count > 0) { while (count > 0) {
/* try to find a free urb in our list of them */ /* try to find a free urb in our list of them */
urb = NULL; urb = NULL;
...@@ -262,15 +258,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, ...@@ -262,15 +258,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
bytes_out += transfer_size; bytes_out += transfer_size;
} }
exit: exit:
return bytes_sent; return bytes_sent;
} }
static int empeg_write_room (struct usb_serial_port *port) static int empeg_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned long flags; unsigned long flags;
int i; int i;
int room = 0; int room = 0;
...@@ -278,25 +273,22 @@ static int empeg_write_room (struct usb_serial_port *port) ...@@ -278,25 +273,22 @@ static int empeg_write_room (struct usb_serial_port *port)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
spin_lock_irqsave (&write_urb_pool_lock, flags); spin_lock_irqsave (&write_urb_pool_lock, flags);
/* tally up the number of bytes available */ /* tally up the number of bytes available */
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
if (write_urb_pool[i]->status != -EINPROGRESS) { if (write_urb_pool[i]->status != -EINPROGRESS) {
room += URB_TRANSFER_BUFFER_SIZE; room += URB_TRANSFER_BUFFER_SIZE;
} }
} }
spin_unlock_irqrestore (&write_urb_pool_lock, flags); spin_unlock_irqrestore (&write_urb_pool_lock, flags);
dbg("%s - returns %d", __func__, room); dbg("%s - returns %d", __func__, room);
return room;
return (room);
} }
static int empeg_chars_in_buffer (struct usb_serial_port *port) static int empeg_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned long flags; unsigned long flags;
int i; int i;
int chars = 0; int chars = 0;
...@@ -356,7 +348,7 @@ static void empeg_read_bulk_callback (struct urb *urb) ...@@ -356,7 +348,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
tty = port->tty; tty = port->port.tty;
if (urb->actual_length) { if (urb->actual_length) {
tty_buffer_request_room(tty, urb->actual_length); tty_buffer_request_room(tty, urb->actual_length);
...@@ -386,27 +378,24 @@ static void empeg_read_bulk_callback (struct urb *urb) ...@@ -386,27 +378,24 @@ static void empeg_read_bulk_callback (struct urb *urb)
} }
static void empeg_throttle (struct usb_serial_port *port) static void empeg_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
usb_kill_urb(port->read_urb); usb_kill_urb(port->read_urb);
} }
static void empeg_unthrottle (struct usb_serial_port *port) static void empeg_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int result; int result;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
port->read_urb->dev = port->serial->dev; port->read_urb->dev = port->serial->dev;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
return;
} }
...@@ -436,17 +425,10 @@ static void empeg_shutdown (struct usb_serial *serial) ...@@ -436,17 +425,10 @@ static void empeg_shutdown (struct usb_serial *serial)
} }
static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static void empeg_set_termios(struct tty_struct *tty,
{ struct usb_serial_port *port, struct ktermios *old_termios)
dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
return -ENOIOCTLCMD;
}
static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct ktermios *termios = port->tty->termios; struct ktermios *termios = tty->termios;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
/* /*
...@@ -491,8 +473,8 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol ...@@ -491,8 +473,8 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol
* this is bad as it opens up the possibility of dropping bytes * this is bad as it opens up the possibility of dropping bytes
* on the floor. We don't want to drop bytes on the floor. :) * on the floor. We don't want to drop bytes on the floor. :)
*/ */
port->tty->low_latency = 1; tty->low_latency = 1;
tty_encode_baud_rate(port->tty, 115200, 115200); tty_encode_baud_rate(tty, 115200, 115200);
} }
......
...@@ -682,21 +682,21 @@ static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_i ...@@ -682,21 +682,21 @@ static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_i
static void ftdi_shutdown (struct usb_serial *serial); static void ftdi_shutdown (struct usb_serial *serial);
static int ftdi_sio_port_probe (struct usb_serial_port *port); static int ftdi_sio_port_probe (struct usb_serial_port *port);
static int ftdi_sio_port_remove (struct usb_serial_port *port); static int ftdi_sio_port_remove (struct usb_serial_port *port);
static int ftdi_open (struct usb_serial_port *port, struct file *filp); static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void ftdi_close (struct usb_serial_port *port, struct file *filp); static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count); static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
static int ftdi_write_room (struct usb_serial_port *port); static int ftdi_write_room (struct tty_struct *tty);
static int ftdi_chars_in_buffer (struct usb_serial_port *port); static int ftdi_chars_in_buffer (struct tty_struct *tty);
static void ftdi_write_bulk_callback (struct urb *urb); static void ftdi_write_bulk_callback (struct urb *urb);
static void ftdi_read_bulk_callback (struct urb *urb); static void ftdi_read_bulk_callback (struct urb *urb);
static void ftdi_process_read (struct work_struct *work); static void ftdi_process_read (struct work_struct *work);
static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios * old); static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); static int ftdi_tiocmget (struct tty_struct *tty, struct file *file);
static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear);
static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
static void ftdi_break_ctl (struct usb_serial_port *port, int break_state ); static void ftdi_break_ctl (struct tty_struct *tty, int break_state );
static void ftdi_throttle (struct usb_serial_port *port); static void ftdi_throttle (struct tty_struct *tty);
static void ftdi_unthrottle (struct usb_serial_port *port); static void ftdi_unthrottle (struct tty_struct *tty);
static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base);
static unsigned short int ftdi_232am_baud_to_divisor (int baud); static unsigned short int ftdi_232am_baud_to_divisor (int baud);
...@@ -843,42 +843,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned ...@@ -843,42 +843,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
} }
static __u32 get_ftdi_divisor(struct usb_serial_port * port); static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port)
static int change_speed(struct usb_serial_port *port)
{
struct ftdi_private *priv = usb_get_serial_port_data(port);
char *buf;
__u16 urb_value;
__u16 urb_index;
__u32 urb_index_value;
int rv;
buf = kmalloc(1, GFP_NOIO);
if (!buf)
return -ENOMEM;
urb_index_value = get_ftdi_divisor(port);
urb_value = (__u16)urb_index_value;
urb_index = (__u16)(urb_index_value >> 16);
if (priv->interface) { /* FT2232C */
urb_index = (__u16)((urb_index << 8) | priv->interface);
}
rv = usb_control_msg(port->serial->dev,
usb_sndctrlpipe(port->serial->dev, 0),
FTDI_SIO_SET_BAUDRATE_REQUEST,
FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
urb_value, urb_index,
buf, 0, WDR_SHORT_TIMEOUT);
kfree(buf);
return rv;
}
static __u32 get_ftdi_divisor(struct usb_serial_port * port)
{ /* get_ftdi_divisor */ { /* get_ftdi_divisor */
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
__u32 div_value = 0; __u32 div_value = 0;
...@@ -910,7 +875,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) ...@@ -910,7 +875,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
/* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */
baud = tty_get_baud_rate(port->tty); baud = tty_get_baud_rate(tty);
dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
/* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */
...@@ -976,10 +941,42 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) ...@@ -976,10 +941,42 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
ftdi_chip_name[priv->chip_type]); ftdi_chip_name[priv->chip_type]);
} }
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
return(div_value); return(div_value);
} }
static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
{
struct ftdi_private *priv = usb_get_serial_port_data(port);
char *buf;
__u16 urb_value;
__u16 urb_index;
__u32 urb_index_value;
int rv;
buf = kmalloc(1, GFP_NOIO);
if (!buf)
return -ENOMEM;
urb_index_value = get_ftdi_divisor(tty, port);
urb_value = (__u16)urb_index_value;
urb_index = (__u16)(urb_index_value >> 16);
if (priv->interface) { /* FT2232C */
urb_index = (__u16)((urb_index << 8) | priv->interface);
}
rv = usb_control_msg(port->serial->dev,
usb_sndctrlpipe(port->serial->dev, 0),
FTDI_SIO_SET_BAUDRATE_REQUEST,
FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
urb_value, urb_index,
buf, 0, WDR_SHORT_TIMEOUT);
kfree(buf);
return rv;
}
static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo)
{ {
...@@ -998,7 +995,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _ ...@@ -998,7 +995,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _
} /* get_serial_info */ } /* get_serial_info */
static int set_serial_info(struct usb_serial_port * port, struct serial_struct __user * newinfo) static int set_serial_info(struct tty_struct *tty,
struct usb_serial_port * port, struct serial_struct __user * newinfo)
{ /* set_serial_info */ { /* set_serial_info */
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
struct serial_struct new_serial; struct serial_struct new_serial;
...@@ -1030,30 +1028,29 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _ ...@@ -1030,30 +1028,29 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
(new_serial.flags & ASYNC_FLAGS)); (new_serial.flags & ASYNC_FLAGS));
priv->custom_divisor = new_serial.custom_divisor; priv->custom_divisor = new_serial.custom_divisor;
port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit: check_and_exit:
if ((old_priv.flags & ASYNC_SPD_MASK) != if ((old_priv.flags & ASYNC_SPD_MASK) !=
(priv->flags & ASYNC_SPD_MASK)) { (priv->flags & ASYNC_SPD_MASK)) {
if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
port->tty->alt_speed = 57600; tty->alt_speed = 57600;
else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
port->tty->alt_speed = 115200; tty->alt_speed = 115200;
else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
port->tty->alt_speed = 230400; tty->alt_speed = 230400;
else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
port->tty->alt_speed = 460800; tty->alt_speed = 460800;
else else
port->tty->alt_speed = 0; tty->alt_speed = 0;
} }
if (((old_priv.flags & ASYNC_SPD_MASK) != if (((old_priv.flags & ASYNC_SPD_MASK) !=
(priv->flags & ASYNC_SPD_MASK)) || (priv->flags & ASYNC_SPD_MASK)) ||
(((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
(old_priv.custom_divisor != priv->custom_divisor))) { (old_priv.custom_divisor != priv->custom_divisor))) {
change_speed(port); change_speed(tty, port);
} }
return 0;
return (0);
} /* set_serial_info */ } /* set_serial_info */
...@@ -1415,7 +1412,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) ...@@ -1415,7 +1412,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
return 0; return 0;
} }
static int ftdi_open (struct usb_serial_port *port, struct file *filp) static int ftdi_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ /* ftdi_open */ { /* ftdi_open */
struct usb_device *dev = port->serial->dev; struct usb_device *dev = port->serial->dev;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
...@@ -1433,8 +1431,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) ...@@ -1433,8 +1431,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
priv->rx_bytes = 0; priv->rx_bytes = 0;
spin_unlock_irqrestore(&priv->rx_lock, flags); spin_unlock_irqrestore(&priv->rx_lock, flags);
if (port->tty) if (tty)
port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/* No error checking for this (will get errors later anyway) */ /* No error checking for this (will get errors later anyway) */
/* See ftdi_sio.h for description of what is reset */ /* See ftdi_sio.h for description of what is reset */
...@@ -1448,8 +1446,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) ...@@ -1448,8 +1446,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
This is same behaviour as serial.c/rs_open() - Kuba */ This is same behaviour as serial.c/rs_open() - Kuba */
/* ftdi_set_termios will send usb control messages */ /* ftdi_set_termios will send usb control messages */
if (port->tty) if (tty)
ftdi_set_termios(port, port->tty->termios); ftdi_set_termios(tty, port, tty->termios);
/* FIXME: Flow control might be enabled, so it should be checked - /* FIXME: Flow control might be enabled, so it should be checked -
we have no control of defaults! */ we have no control of defaults! */
...@@ -1485,9 +1483,10 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) ...@@ -1485,9 +1483,10 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
* *
*/ */
static void ftdi_close (struct usb_serial_port *port, struct file *filp) static void ftdi_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ /* ftdi_close */ { /* ftdi_close */
unsigned int c_cflag = port->tty->termios->c_cflag; unsigned int c_cflag = tty->termios->c_cflag;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
char buf[1]; char buf[1];
...@@ -1527,7 +1526,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) ...@@ -1527,7 +1526,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
* *
* The new devices do not require this byte * The new devices do not require this byte
*/ */
static int ftdi_write (struct usb_serial_port *port, static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ /* ftdi_write */ { /* ftdi_write */
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
...@@ -1686,8 +1685,9 @@ static void ftdi_write_bulk_callback (struct urb *urb) ...@@ -1686,8 +1685,9 @@ static void ftdi_write_bulk_callback (struct urb *urb)
} /* ftdi_write_bulk_callback */ } /* ftdi_write_bulk_callback */
static int ftdi_write_room( struct usb_serial_port *port ) static int ftdi_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
int room; int room;
unsigned long flags; unsigned long flags;
...@@ -1707,11 +1707,11 @@ static int ftdi_write_room( struct usb_serial_port *port ) ...@@ -1707,11 +1707,11 @@ static int ftdi_write_room( struct usb_serial_port *port )
} }
spin_unlock_irqrestore(&priv->tx_lock, flags); spin_unlock_irqrestore(&priv->tx_lock, flags);
return room; return room;
} /* ftdi_write_room */ }
static int ftdi_chars_in_buffer (struct usb_serial_port *port) static int ftdi_chars_in_buffer(struct tty_struct *tty)
{ /* ftdi_chars_in_buffer */ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
int buffered; int buffered;
unsigned long flags; unsigned long flags;
...@@ -1726,12 +1726,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port) ...@@ -1726,12 +1726,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
buffered = 0; buffered = 0;
} }
return buffered; return buffered;
} /* ftdi_chars_in_buffer */ }
static void ftdi_read_bulk_callback (struct urb *urb) static void ftdi_read_bulk_callback(struct urb *urb)
{ /* ftdi_read_bulk_callback */ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct tty_struct *tty; struct tty_struct *tty;
struct ftdi_private *priv; struct ftdi_private *priv;
...@@ -1747,10 +1745,10 @@ static void ftdi_read_bulk_callback (struct urb *urb) ...@@ -1747,10 +1745,10 @@ static void ftdi_read_bulk_callback (struct urb *urb)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (port->open_count <= 0) if (port->port.count <= 0)
return; return;
tty = port->tty; tty = port->port.tty;
if (!tty) { if (!tty) {
dbg("%s - bad tty pointer - exiting",__func__); dbg("%s - bad tty pointer - exiting",__func__);
return; return;
...@@ -1803,10 +1801,10 @@ static void ftdi_process_read (struct work_struct *work) ...@@ -1803,10 +1801,10 @@ static void ftdi_process_read (struct work_struct *work)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (port->open_count <= 0) if (port->port.count <= 0)
return; return;
tty = port->tty; tty = port->port.tty;
if (!tty) { if (!tty) {
dbg("%s - bad tty pointer - exiting",__func__); dbg("%s - bad tty pointer - exiting",__func__);
return; return;
...@@ -1954,7 +1952,7 @@ static void ftdi_process_read (struct work_struct *work) ...@@ -1954,7 +1952,7 @@ static void ftdi_process_read (struct work_struct *work)
} }
spin_unlock_irqrestore(&priv->rx_lock, flags); spin_unlock_irqrestore(&priv->rx_lock, flags);
/* if the port is closed stop trying to read */ /* if the port is closed stop trying to read */
if (port->open_count > 0){ if (port->port.count > 0){
/* delay processing of remainder */ /* delay processing of remainder */
schedule_delayed_work(&priv->rx_work, 1); schedule_delayed_work(&priv->rx_work, 1);
} else { } else {
...@@ -1967,7 +1965,7 @@ static void ftdi_process_read (struct work_struct *work) ...@@ -1967,7 +1965,7 @@ static void ftdi_process_read (struct work_struct *work)
priv->rx_processed = 0; priv->rx_processed = 0;
/* if the port is closed stop trying to read */ /* if the port is closed stop trying to read */
if (port->open_count > 0){ if (port->port.count > 0){
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb(port->read_urb, port->serial->dev, usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
...@@ -1983,8 +1981,9 @@ static void ftdi_process_read (struct work_struct *work) ...@@ -1983,8 +1981,9 @@ static void ftdi_process_read (struct work_struct *work)
} /* ftdi_process_read */ } /* ftdi_process_read */
static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
__u16 urb_value = 0; __u16 urb_value = 0;
char buf[1]; char buf[1];
...@@ -2018,11 +2017,12 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -2018,11 +2017,12 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
* WARNING: set_termios calls this with old_termios in kernel space * WARNING: set_termios calls this with old_termios in kernel space
*/ */
static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) static void ftdi_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{ /* ftdi_termios */ { /* ftdi_termios */
struct usb_device *dev = port->serial->dev; struct usb_device *dev = port->serial->dev;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
struct ktermios *termios = port->tty->termios; struct ktermios *termios = tty->termios;
unsigned int cflag = termios->c_cflag; unsigned int cflag = termios->c_cflag;
__u16 urb_value; /* will hold the new flags */ __u16 urb_value; /* will hold the new flags */
char buf[1]; /* Perhaps I should dynamically alloc this? */ char buf[1]; /* Perhaps I should dynamically alloc this? */
...@@ -2037,7 +2037,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old ...@@ -2037,7 +2037,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
/* Force baud rate if this device requires it, unless it is set to B0. */ /* Force baud rate if this device requires it, unless it is set to B0. */
if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
dbg("%s: forcing baud rate for this device", __func__); dbg("%s: forcing baud rate for this device", __func__);
tty_encode_baud_rate(port->tty, priv->force_baud, tty_encode_baud_rate(tty, priv->force_baud,
priv->force_baud); priv->force_baud);
} }
...@@ -2104,7 +2104,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old ...@@ -2104,7 +2104,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
} else { } else {
/* set the baudrate determined before */ /* set the baudrate determined before */
if (change_speed(port)) { if (change_speed(tty, port)) {
err("%s urb failed to set baudrate", __func__); err("%s urb failed to set baudrate", __func__);
} }
/* Ensure RTS and DTR are raised when baudrate changed from 0 */ /* Ensure RTS and DTR are raised when baudrate changed from 0 */
...@@ -2168,11 +2168,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old ...@@ -2168,11 +2168,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
} }
return; return;
} /* ftdi_termios */ }
static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
unsigned char buf[2]; unsigned char buf[2];
int ret; int ret;
...@@ -2221,15 +2221,18 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -2221,15 +2221,18 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
priv->last_dtr_rts; priv->last_dtr_rts;
} }
static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) static int ftdi_tiocmset(struct tty_struct *tty, struct file * file,
unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
dbg("%s TIOCMSET", __func__); dbg("%s TIOCMSET", __func__);
return update_mctrl(port, set, clear); return update_mctrl(port, set, clear);
} }
static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
dbg("%s cmd 0x%04x", __func__, cmd); dbg("%s cmd 0x%04x", __func__, cmd);
...@@ -2241,7 +2244,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne ...@@ -2241,7 +2244,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
return get_serial_info(port, (struct serial_struct __user *) arg); return get_serial_info(port, (struct serial_struct __user *) arg);
case TIOCSSERIAL: /* sets serial port data */ case TIOCSSERIAL: /* sets serial port data */
return set_serial_info(port, (struct serial_struct __user *) arg); return set_serial_info(tty, port, (struct serial_struct __user *) arg);
/* /*
* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
...@@ -2280,25 +2283,20 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne ...@@ -2280,25 +2283,20 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
*/ */
} }
} }
return(0); return 0;
break;
default: default:
break; break;
} }
/* This is not necessarily an error - turns out the higher layers will do /* This is not necessarily an error - turns out the higher layers will do
* some ioctls itself (see comment above) * some ioctls itself (see comment above)
*/ */
dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
return -ENOIOCTLCMD;
}
return(-ENOIOCTLCMD); static void ftdi_throttle(struct tty_struct *tty)
} /* ftdi_ioctl */
static void ftdi_throttle (struct usb_serial_port *port)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -2310,8 +2308,9 @@ static void ftdi_throttle (struct usb_serial_port *port) ...@@ -2310,8 +2308,9 @@ static void ftdi_throttle (struct usb_serial_port *port)
} }
static void ftdi_unthrottle (struct usb_serial_port *port) static void ftdi_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
int actually_throttled; int actually_throttled;
unsigned long flags; unsigned long flags;
......
...@@ -275,7 +275,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf) ...@@ -275,7 +275,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
static void send_to_tty(struct usb_serial_port *port, static void send_to_tty(struct usb_serial_port *port,
char *data, unsigned int actual_length) char *data, unsigned int actual_length)
{ {
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->port.tty;
if (tty && actual_length) { if (tty && actual_length) {
...@@ -970,7 +970,8 @@ static int garmin_init_session(struct usb_serial_port *port) ...@@ -970,7 +970,8 @@ static int garmin_init_session(struct usb_serial_port *port)
static int garmin_open (struct usb_serial_port *port, struct file *filp) static int garmin_open (struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
unsigned long flags; unsigned long flags;
int status = 0; int status = 0;
...@@ -983,8 +984,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) ...@@ -983,8 +984,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
* through, otherwise it is scheduled, and with high data rates (like * through, otherwise it is scheduled, and with high data rates (like
* with OHCI) data can get lost. * with OHCI) data can get lost.
*/ */
if (port->tty) if (tty)
port->tty->low_latency = 1; tty->low_latency = 1;
spin_lock_irqsave(&garmin_data_p->lock, flags); spin_lock_irqsave(&garmin_data_p->lock, flags);
garmin_data_p->mode = initial_mode; garmin_data_p->mode = initial_mode;
...@@ -998,17 +999,16 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) ...@@ -998,17 +999,16 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
usb_kill_urb (port->write_urb); usb_kill_urb (port->write_urb);
usb_kill_urb (port->read_urb); usb_kill_urb (port->read_urb);
if (garmin_data_p->state == STATE_RESET) { if (garmin_data_p->state == STATE_RESET)
status = garmin_init_session(port); status = garmin_init_session(port);
}
garmin_data_p->state = STATE_ACTIVE; garmin_data_p->state = STATE_ACTIVE;
return status; return status;
} }
static void garmin_close (struct usb_serial_port *port, struct file * filp) static void garmin_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
...@@ -1042,7 +1042,6 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp) ...@@ -1042,7 +1042,6 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
mutex_unlock(&port->serial->disc_mutex); mutex_unlock(&port->serial->disc_mutex);
} }
static void garmin_write_bulk_callback (struct urb *urb) static void garmin_write_bulk_callback (struct urb *urb)
{ {
unsigned long flags; unsigned long flags;
...@@ -1145,9 +1144,7 @@ static int garmin_write_bulk (struct usb_serial_port *port, ...@@ -1145,9 +1144,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
return count; return count;
} }
static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port,
static int garmin_write (struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
int pktid, pktsiz, len; int pktid, pktsiz, len;
...@@ -1158,7 +1155,6 @@ static int garmin_write (struct usb_serial_port *port, ...@@ -1158,7 +1155,6 @@ static int garmin_write (struct usb_serial_port *port,
/* check for our private packets */ /* check for our private packets */
if (count >= GARMIN_PKTHDR_LENGTH) { if (count >= GARMIN_PKTHDR_LENGTH) {
len = PRIVPKTSIZ; len = PRIVPKTSIZ;
if (count < len) if (count < len)
len = count; len = count;
...@@ -1226,8 +1222,9 @@ static int garmin_write (struct usb_serial_port *port, ...@@ -1226,8 +1222,9 @@ static int garmin_write (struct usb_serial_port *port,
} }
static int garmin_write_room (struct usb_serial_port *port) static int garmin_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
/* /*
* Report back the bytes currently available in the output buffer. * Report back the bytes currently available in the output buffer.
*/ */
...@@ -1236,20 +1233,6 @@ static int garmin_write_room (struct usb_serial_port *port) ...@@ -1236,20 +1233,6 @@ static int garmin_write_room (struct usb_serial_port *port)
} }
static int garmin_chars_in_buffer (struct usb_serial_port *port)
{
/*
* Report back the number of bytes currently in our input buffer.
* Will this lock up the driver - the buffer contains an incomplete
* package which will not be written to the device until it
* has been completed ?
*/
//struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
//return garmin_data_p->insize;
return 0;
}
static void garmin_read_process(struct garmin_data * garmin_data_p, static void garmin_read_process(struct garmin_data * garmin_data_p,
unsigned char *data, unsigned data_length) unsigned char *data, unsigned data_length)
{ {
...@@ -1468,10 +1451,11 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p) ...@@ -1468,10 +1451,11 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
} }
static void garmin_throttle (struct usb_serial_port *port) static void garmin_throttle(struct tty_struct *tty)
{ {
unsigned long flags; struct usb_serial_port *port = tty->driver_data;
struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
unsigned long flags;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
/* set flag, data received will be put into a queue /* set flag, data received will be put into a queue
...@@ -1482,10 +1466,11 @@ static void garmin_throttle (struct usb_serial_port *port) ...@@ -1482,10 +1466,11 @@ static void garmin_throttle (struct usb_serial_port *port)
} }
static void garmin_unthrottle (struct usb_serial_port *port) static void garmin_unthrottle (struct tty_struct *tty)
{ {
unsigned long flags; struct usb_serial_port *port = tty->driver_data;
struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
unsigned long flags;
int status; int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -1507,8 +1492,6 @@ static void garmin_unthrottle (struct usb_serial_port *port) ...@@ -1507,8 +1492,6 @@ static void garmin_unthrottle (struct usb_serial_port *port)
} }
} }
/* /*
* The timer is currently only used to send queued packets to * The timer is currently only used to send queued packets to
* the tty in cases where the protocol provides no own handshaking * the tty in cases where the protocol provides no own handshaking
...@@ -1526,7 +1509,7 @@ static void timeout_handler(unsigned long data) ...@@ -1526,7 +1509,7 @@ static void timeout_handler(unsigned long data)
static int garmin_attach (struct usb_serial *serial) static int garmin_attach(struct usb_serial *serial)
{ {
int status = 0; int status = 0;
struct usb_serial_port *port = serial->port[0]; struct usb_serial_port *port = serial->port[0];
...@@ -1556,7 +1539,7 @@ static int garmin_attach (struct usb_serial *serial) ...@@ -1556,7 +1539,7 @@ static int garmin_attach (struct usb_serial *serial)
} }
static void garmin_shutdown (struct usb_serial *serial) static void garmin_shutdown(struct usb_serial *serial)
{ {
struct usb_serial_port *port = serial->port[0]; struct usb_serial_port *port = serial->port[0];
struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
...@@ -1588,7 +1571,6 @@ static struct usb_serial_driver garmin_device = { ...@@ -1588,7 +1571,6 @@ static struct usb_serial_driver garmin_device = {
.shutdown = garmin_shutdown, .shutdown = garmin_shutdown,
.write = garmin_write, .write = garmin_write,
.write_room = garmin_write_room, .write_room = garmin_write_room,
.chars_in_buffer = garmin_chars_in_buffer,
.write_bulk_callback = garmin_write_bulk_callback, .write_bulk_callback = garmin_write_bulk_callback,
.read_bulk_callback = garmin_read_bulk_callback, .read_bulk_callback = garmin_read_bulk_callback,
.read_int_callback = garmin_read_int_callback, .read_int_callback = garmin_read_int_callback,
......
...@@ -112,7 +112,8 @@ void usb_serial_generic_deregister (void) ...@@ -112,7 +112,8 @@ void usb_serial_generic_deregister (void)
#endif #endif
} }
int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) int usb_serial_generic_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int result = 0; int result = 0;
...@@ -123,8 +124,8 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) ...@@ -123,8 +124,8 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
/* force low_latency on so that our tty_push actually forces the data through, /* force low_latency on so that our tty_push actually forces the data through,
otherwise it is scheduled, and with high data rates (like with OHCI) data otherwise it is scheduled, and with high data rates (like with OHCI) data
can get lost. */ can get lost. */
if (port->tty) if (tty)
port->tty->low_latency = 1; tty->low_latency = 1;
/* clear the throttle flags */ /* clear the throttle flags */
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
...@@ -152,7 +153,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) ...@@ -152,7 +153,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
} }
EXPORT_SYMBOL_GPL(usb_serial_generic_open); EXPORT_SYMBOL_GPL(usb_serial_generic_open);
static void generic_cleanup (struct usb_serial_port *port) static void generic_cleanup(struct usb_serial_port *port)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -182,7 +183,7 @@ int usb_serial_generic_resume(struct usb_serial *serial) ...@@ -182,7 +183,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
#endif #endif
for (i = 0; i < serial->num_ports; i++) { for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i]; port = serial->port[i];
if (port->open_count && port->read_urb) { if (port->port.count && port->read_urb) {
r = usb_submit_urb(port->read_urb, GFP_NOIO); r = usb_submit_urb(port->read_urb, GFP_NOIO);
if (r < 0) if (r < 0)
c++; c++;
...@@ -192,13 +193,15 @@ int usb_serial_generic_resume(struct usb_serial *serial) ...@@ -192,13 +193,15 @@ int usb_serial_generic_resume(struct usb_serial *serial)
return c ? -EIO : 0; return c ? -EIO : 0;
} }
void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) void usb_serial_generic_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
generic_cleanup (port); generic_cleanup (port);
} }
int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count) int usb_serial_generic_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int result; int result;
...@@ -255,8 +258,9 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * ...@@ -255,8 +258,9 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
return 0; return 0;
} }
int usb_serial_generic_write_room (struct usb_serial_port *port) int usb_serial_generic_write_room (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int room = 0; int room = 0;
...@@ -272,8 +276,9 @@ int usb_serial_generic_write_room (struct usb_serial_port *port) ...@@ -272,8 +276,9 @@ int usb_serial_generic_write_room (struct usb_serial_port *port)
return room; return room;
} }
int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int chars = 0; int chars = 0;
...@@ -286,7 +291,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) ...@@ -286,7 +291,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
} }
dbg("%s - returns %d", __func__, chars); dbg("%s - returns %d", __func__, chars);
return (chars); return chars;
} }
...@@ -311,10 +316,10 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) ...@@ -311,10 +316,10 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
} }
/* Push data to tty layer and resubmit the bulk read URB */ /* Push data to tty layer and resubmit the bulk read URB */
static void flush_and_resubmit_read_urb (struct usb_serial_port *port) static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
{ {
struct urb *urb = port->read_urb; struct urb *urb = port->read_urb;
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->port.tty;
int room; int room;
/* Push data to tty */ /* Push data to tty */
...@@ -329,7 +334,7 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port) ...@@ -329,7 +334,7 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port)
resubmit_read_urb(port, GFP_ATOMIC); resubmit_read_urb(port, GFP_ATOMIC);
} }
void usb_serial_generic_read_bulk_callback (struct urb *urb) void usb_serial_generic_read_bulk_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -357,7 +362,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb) ...@@ -357,7 +362,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
} }
EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
void usb_serial_generic_write_bulk_callback (struct urb *urb) void usb_serial_generic_write_bulk_callback(struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
int status = urb->status; int status = urb->status;
...@@ -374,8 +379,9 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb) ...@@ -374,8 +379,9 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb)
} }
EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
void usb_serial_generic_throttle (struct usb_serial_port *port) void usb_serial_generic_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned long flags; unsigned long flags;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -387,8 +393,9 @@ void usb_serial_generic_throttle (struct usb_serial_port *port) ...@@ -387,8 +393,9 @@ void usb_serial_generic_throttle (struct usb_serial_port *port)
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
} }
void usb_serial_generic_unthrottle (struct usb_serial_port *port) void usb_serial_generic_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int was_throttled; int was_throttled;
unsigned long flags; unsigned long flags;
......
...@@ -206,18 +206,18 @@ static void edge_bulk_out_data_callback (struct urb *urb); ...@@ -206,18 +206,18 @@ static void edge_bulk_out_data_callback (struct urb *urb);
static void edge_bulk_out_cmd_callback (struct urb *urb); static void edge_bulk_out_cmd_callback (struct urb *urb);
/* function prototypes for the usbserial callbacks */ /* function prototypes for the usbserial callbacks */
static int edge_open (struct usb_serial_port *port, struct file *filp); static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static void edge_close (struct usb_serial_port *port, struct file *filp); static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
static int edge_write (struct usb_serial_port *port, const unsigned char *buf, int count); static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
static int edge_write_room (struct usb_serial_port *port); static int edge_write_room (struct tty_struct *tty);
static int edge_chars_in_buffer (struct usb_serial_port *port); static int edge_chars_in_buffer (struct tty_struct *tty);
static void edge_throttle (struct usb_serial_port *port); static void edge_throttle (struct tty_struct *tty);
static void edge_unthrottle (struct usb_serial_port *port); static void edge_unthrottle (struct tty_struct *tty);
static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
static void edge_break (struct usb_serial_port *port, int break_state); static void edge_break (struct tty_struct *tty, int break_state);
static int edge_tiocmget (struct usb_serial_port *port, struct file *file); static int edge_tiocmget (struct tty_struct *tty, struct file *file);
static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
static int edge_startup (struct usb_serial *serial); static int edge_startup (struct usb_serial *serial);
static void edge_shutdown (struct usb_serial *serial); static void edge_shutdown (struct usb_serial *serial);
...@@ -233,7 +233,8 @@ static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8 ...@@ -233,7 +233,8 @@ static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8
static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param); static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param);
static int calc_baud_rate_divisor (int baud_rate, int *divisor); static int calc_baud_rate_divisor (int baud_rate, int *divisor);
static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate); static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate);
static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios); static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port,
struct ktermios *old_termios);
static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue); static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength); static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
...@@ -639,8 +640,8 @@ static void edge_interrupt_callback (struct urb *urb) ...@@ -639,8 +640,8 @@ static void edge_interrupt_callback (struct urb *urb)
dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
/* tell the tty driver that something has changed */ /* tell the tty driver that something has changed */
if (edge_port->port->tty) if (edge_port->port->port.tty)
tty_wakeup(edge_port->port->tty); tty_wakeup(edge_port->port->port.tty);
// Since we have more credit, check if more data can be sent // Since we have more credit, check if more data can be sent
send_more_port_data(edge_serial, edge_port); send_more_port_data(edge_serial, edge_port);
...@@ -737,7 +738,7 @@ static void edge_bulk_out_data_callback (struct urb *urb) ...@@ -737,7 +738,7 @@ static void edge_bulk_out_data_callback (struct urb *urb)
__func__, status); __func__, status);
} }
tty = edge_port->port->tty; tty = edge_port->port->port.tty;
if (tty && edge_port->open) { if (tty && edge_port->open) {
/* let the tty driver wakeup if it has a special write_wakeup function */ /* let the tty driver wakeup if it has a special write_wakeup function */
...@@ -781,7 +782,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) ...@@ -781,7 +782,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
} }
/* Get pointer to tty */ /* Get pointer to tty */
tty = edge_port->port->tty; tty = edge_port->port->port.tty;
/* tell the tty driver that something has changed */ /* tell the tty driver that something has changed */
if (tty && edge_port->open) if (tty && edge_port->open)
...@@ -803,7 +804,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb) ...@@ -803,7 +804,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
* If successful, we return 0 * If successful, we return 0
* Otherwise we return a negative error number. * Otherwise we return a negative error number.
*****************************************************************************/ *****************************************************************************/
static int edge_open (struct usb_serial_port *port, struct file * filp) static int edge_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct usb_serial *serial; struct usb_serial *serial;
...@@ -815,16 +817,15 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -815,16 +817,15 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
if (edge_port == NULL) if (edge_port == NULL)
return -ENODEV; return -ENODEV;
if (port->tty) if (tty)
port->tty->low_latency = low_latency; tty->low_latency = low_latency;
/* see if we've set up our endpoint info yet (can't set it up in edge_startup /* see if we've set up our endpoint info yet (can't set it up in edge_startup
as the structures were not set up at that time.) */ as the structures were not set up at that time.) */
serial = port->serial; serial = port->serial;
edge_serial = usb_get_serial_data(serial); edge_serial = usb_get_serial_data(serial);
if (edge_serial == NULL) { if (edge_serial == NULL)
return -ENODEV; return -ENODEV;
}
if (edge_serial->interrupt_in_buffer == NULL) { if (edge_serial->interrupt_in_buffer == NULL) {
struct usb_serial_port *port0 = serial->port[0]; struct usb_serial_port *port0 = serial->port[0];
...@@ -908,7 +909,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -908,7 +909,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
if (!edge_port->txfifo.fifo) { if (!edge_port->txfifo.fifo) {
dbg("%s - no memory", __func__); dbg("%s - no memory", __func__);
edge_close (port, filp); edge_close (tty, port, filp);
return -ENOMEM; return -ENOMEM;
} }
...@@ -918,7 +919,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -918,7 +919,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
if (!edge_port->write_urb) { if (!edge_port->write_urb) {
dbg("%s - no memory", __func__); dbg("%s - no memory", __func__);
edge_close (port, filp); edge_close (tty, port, filp);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1038,7 +1039,8 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) ...@@ -1038,7 +1039,8 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
* edge_close * edge_close
* this function is called by the tty driver when a port is closed * this function is called by the tty driver when a port is closed
*****************************************************************************/ *****************************************************************************/
static void edge_close (struct usb_serial_port *port, struct file * filp) static void edge_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
...@@ -1106,7 +1108,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1106,7 +1108,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
* If successful, we return the number of bytes written, otherwise we return * If successful, we return the number of bytes written, otherwise we return
* a negative error number. * a negative error number.
*****************************************************************************/ *****************************************************************************/
static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *data, int count)
{ {
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct TxFifo *fifo; struct TxFifo *fifo;
...@@ -1308,8 +1311,9 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge ...@@ -1308,8 +1311,9 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
* (the txCredits), * (the txCredits),
* Otherwise we return a negative error number. * Otherwise we return a negative error number.
*****************************************************************************/ *****************************************************************************/
static int edge_write_room (struct usb_serial_port *port) static int edge_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int room; int room;
unsigned long flags; unsigned long flags;
...@@ -1347,8 +1351,9 @@ static int edge_write_room (struct usb_serial_port *port) ...@@ -1347,8 +1351,9 @@ static int edge_write_room (struct usb_serial_port *port)
* system, * system,
* Otherwise we return a negative error number. * Otherwise we return a negative error number.
*****************************************************************************/ *****************************************************************************/
static int edge_chars_in_buffer (struct usb_serial_port *port) static int edge_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int num_chars; int num_chars;
unsigned long flags; unsigned long flags;
...@@ -1381,10 +1386,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) ...@@ -1381,10 +1386,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
* this function is called by the tty driver when it wants to stop the data * this function is called by the tty driver when it wants to stop the data
* being read from the port. * being read from the port.
*****************************************************************************/ *****************************************************************************/
static void edge_throttle (struct usb_serial_port *port) static void edge_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status; int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -1397,16 +1402,10 @@ static void edge_throttle (struct usb_serial_port *port) ...@@ -1397,16 +1402,10 @@ static void edge_throttle (struct usb_serial_port *port)
return; return;
} }
tty = port->tty;
if (!tty) {
dbg ("%s - no tty available", __func__);
return;
}
/* if we are implementing XON/XOFF, send the stop character */ /* if we are implementing XON/XOFF, send the stop character */
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
unsigned char stop_char = STOP_CHAR(tty); unsigned char stop_char = STOP_CHAR(tty);
status = edge_write (port, &stop_char, 1); status = edge_write (tty, port, &stop_char, 1);
if (status <= 0) { if (status <= 0) {
return; return;
} }
...@@ -1430,10 +1429,10 @@ static void edge_throttle (struct usb_serial_port *port) ...@@ -1430,10 +1429,10 @@ static void edge_throttle (struct usb_serial_port *port)
* this function is called by the tty driver when it wants to resume the data * this function is called by the tty driver when it wants to resume the data
* being read from the port (called after SerialThrottle is called) * being read from the port (called after SerialThrottle is called)
*****************************************************************************/ *****************************************************************************/
static void edge_unthrottle (struct usb_serial_port *port) static void edge_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty;
int status; int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -1446,31 +1445,18 @@ static void edge_unthrottle (struct usb_serial_port *port) ...@@ -1446,31 +1445,18 @@ static void edge_unthrottle (struct usb_serial_port *port)
return; return;
} }
tty = port->tty;
if (!tty) {
dbg ("%s - no tty available", __func__);
return;
}
/* if we are implementing XON/XOFF, send the start character */ /* if we are implementing XON/XOFF, send the start character */
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
unsigned char start_char = START_CHAR(tty); unsigned char start_char = START_CHAR(tty);
status = edge_write (port, &start_char, 1); status = edge_write(tty, port, &start_char, 1);
if (status <= 0) { if (status <= 0)
return; return;
} }
}
/* if we are implementing RTS/CTS, toggle that line */ /* if we are implementing RTS/CTS, toggle that line */
if (tty->termios->c_cflag & CRTSCTS) { if (tty->termios->c_cflag & CRTSCTS) {
edge_port->shadowMCR |= MCR_RTS; edge_port->shadowMCR |= MCR_RTS;
status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
if (status != 0) {
return;
}
} }
return;
} }
...@@ -1478,11 +1464,10 @@ static void edge_unthrottle (struct usb_serial_port *port) ...@@ -1478,11 +1464,10 @@ static void edge_unthrottle (struct usb_serial_port *port)
* SerialSetTermios * SerialSetTermios
* this function is called by the tty driver when it wants to change the termios structure * this function is called by the tty driver when it wants to change the termios structure
*****************************************************************************/ *****************************************************************************/
static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) static void edge_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
{ {
/* FIXME: This function appears unused ?? */
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned int cflag; unsigned int cflag;
cflag = tty->termios->c_cflag; cflag = tty->termios->c_cflag;
...@@ -1502,9 +1487,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old ...@@ -1502,9 +1487,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
} }
/* change the port settings to the new ones specified */ /* change the port settings to the new ones specified */
change_port_settings (edge_port, old_termios); change_port_settings(tty, edge_port, old_termios);
return;
} }
...@@ -1536,25 +1519,9 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va ...@@ -1536,25 +1519,9 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
return 0; return 0;
} }
static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int __user *value) static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
{
unsigned int result = 0;
struct tty_struct *tty = edge_port->port->tty;
if (!tty)
return -ENOIOCTLCMD;
result = tty->read_cnt;
dbg("%s(%d) = %d", __func__, edge_port->port->number, result);
if (copy_to_user(value, &result, sizeof(int)))
return -EFAULT;
//return 0;
return -ENOIOCTLCMD;
}
static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned int mcr; unsigned int mcr;
...@@ -1582,8 +1549,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig ...@@ -1582,8 +1549,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
return 0; return 0;
} }
static int edge_tiocmget(struct usb_serial_port *port, struct file *file) static int edge_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned int result = 0; unsigned int result = 0;
unsigned int msr; unsigned int msr;
...@@ -1624,9 +1592,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct ...@@ -1624,9 +1592,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
tmp.baud_base = 9600; tmp.baud_base = 9600;
tmp.close_delay = 5*HZ; tmp.close_delay = 5*HZ;
tmp.closing_wait = 30*HZ; tmp.closing_wait = 30*HZ;
// tmp.custom_divisor = state->custom_divisor;
// tmp.hub6 = state->hub6;
// tmp.io_type = state->io_type;
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT; return -EFAULT;
...@@ -1639,8 +1604,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct ...@@ -1639,8 +1604,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
* SerialIoctl * SerialIoctl
* this function handles any ioctl calls to the driver * this function handles any ioctl calls to the driver
*****************************************************************************/ *****************************************************************************/
static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) static int edge_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct async_icount cnow; struct async_icount cnow;
...@@ -1650,25 +1617,14 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned ...@@ -1650,25 +1617,14 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
switch (cmd) { switch (cmd) {
// return number of bytes available
case TIOCINQ:
dbg("%s (%d) TIOCINQ", __func__, port->number);
return get_number_bytes_avail(edge_port, (unsigned int __user *) arg);
break;
case TIOCSERGETLSR: case TIOCSERGETLSR:
dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
return get_lsr_info(edge_port, (unsigned int __user *) arg); return get_lsr_info(edge_port, (unsigned int __user *) arg);
return 0;
case TIOCGSERIAL: case TIOCGSERIAL:
dbg("%s (%d) TIOCGSERIAL", __func__, port->number); dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
return get_serial_info(edge_port, (struct serial_struct __user *) arg); return get_serial_info(edge_port, (struct serial_struct __user *) arg);
case TIOCSSERIAL:
dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
break;
case TIOCMIWAIT: case TIOCMIWAIT:
dbg("%s (%d) TIOCMIWAIT", __func__, port->number); dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
cprev = edge_port->icount; cprev = edge_port->icount;
...@@ -1723,8 +1679,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned ...@@ -1723,8 +1679,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
* SerialBreak * SerialBreak
* this function sends a break to the port * this function sends a break to the port
*****************************************************************************/ *****************************************************************************/
static void edge_break (struct usb_serial_port *port, int break_state) static void edge_break (struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
int status; int status;
...@@ -1866,7 +1823,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha ...@@ -1866,7 +1823,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
port = edge_serial->serial->port[edge_serial->rxPort]; port = edge_serial->serial->port[edge_serial->rxPort];
edge_port = usb_get_serial_port_data(port); edge_port = usb_get_serial_port_data(port);
if (edge_port->open) { if (edge_port->open) {
tty = edge_port->port->tty; tty = edge_port->port->port.tty;
if (tty) { if (tty) {
dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
...@@ -1941,8 +1898,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2 ...@@ -1941,8 +1898,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
handle_new_msr (edge_port, byte2); handle_new_msr (edge_port, byte2);
/* send the current line settings to the port so we are in sync with any further termios calls */ /* send the current line settings to the port so we are in sync with any further termios calls */
if (edge_port->port->tty) /* FIXME: locking on tty */
change_port_settings (edge_port, edge_port->port->tty->termios); if (edge_port->port->port.tty)
change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios);
/* we have completed the open */ /* we have completed the open */
edge_port->openPending = false; edge_port->openPending = false;
...@@ -2078,8 +2036,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l ...@@ -2078,8 +2036,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l
} }
/* Place LSR data byte into Rx buffer */ /* Place LSR data byte into Rx buffer */
if (lsrData && edge_port->port->tty) if (lsrData && edge_port->port->port.tty)
edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
/* update input line counters */ /* update input line counters */
icount = &edge_port->icount; icount = &edge_port->icount;
...@@ -2473,13 +2431,11 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r ...@@ -2473,13 +2431,11 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
* This routine is called to set the UART on the device to match the specified * This routine is called to set the UART on the device to match the specified
* new settings. * new settings.
*****************************************************************************/ *****************************************************************************/
#ifndef CMSPAR
#define CMSPAR 0 static void change_port_settings(struct tty_struct *tty,
#endif struct edgeport_port *edge_port, struct ktermios *old_termios)
static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
{ {
struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
struct tty_struct *tty;
int baud; int baud;
unsigned cflag; unsigned cflag;
__u8 mask = 0xff; __u8 mask = 0xff;
...@@ -2498,13 +2454,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi ...@@ -2498,13 +2454,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
return; return;
} }
tty = edge_port->port->tty;
if ((!tty) ||
(!tty->termios)) {
dbg("%s - no tty structures", __func__);
return;
}
cflag = tty->termios->c_cflag; cflag = tty->termios->c_cflag;
switch (cflag & CSIZE) { switch (cflag & CSIZE) {
......
...@@ -243,9 +243,9 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, ...@@ -243,9 +243,9 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
static void stop_read(struct edgeport_port *edge_port); static void stop_read(struct edgeport_port *edge_port);
static int restart_read(struct edgeport_port *edge_port); static int restart_read(struct edgeport_port *edge_port);
static void edge_set_termios(struct usb_serial_port *port, static void edge_set_termios(struct tty_struct *tty,
struct ktermios *old_termios); struct usb_serial_port *port, struct ktermios *old_termios);
static void edge_send(struct usb_serial_port *port); static void edge_send(struct tty_struct *tty);
/* sysfs attributes */ /* sysfs attributes */
static int edge_create_sysfs_attrs(struct usb_serial_port *port); static int edge_create_sysfs_attrs(struct usb_serial_port *port);
...@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout, ...@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
int flush) int flush)
{ {
int baud_rate; int baud_rate;
struct tty_struct *tty = port->port->tty; struct tty_struct *tty = port->port->port.tty;
wait_queue_t wait; wait_queue_t wait;
unsigned long flags; unsigned long flags;
...@@ -1554,7 +1554,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) ...@@ -1554,7 +1554,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
/* Save the new modem status */ /* Save the new modem status */
edge_port->shadow_msr = msr & 0xf0; edge_port->shadow_msr = msr & 0xf0;
tty = edge_port->port->tty; tty = edge_port->port->port.tty;
/* handle CTS flow control */ /* handle CTS flow control */
if (tty && C_CRTSCTS(tty)) { if (tty && C_CRTSCTS(tty)) {
if (msr & EDGEPORT_MSR_CTS) { if (msr & EDGEPORT_MSR_CTS) {
...@@ -1587,9 +1587,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data, ...@@ -1587,9 +1587,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
/* Place LSR data byte into Rx buffer */ /* Place LSR data byte into Rx buffer */
if (lsr_data && edge_port->port->tty) if (lsr_data && edge_port->port->port.tty)
edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
&data, 1);
/* update input line counters */ /* update input line counters */
icount = &edge_port->icount; icount = &edge_port->icount;
...@@ -1750,7 +1749,7 @@ static void edge_bulk_in_callback(struct urb *urb) ...@@ -1750,7 +1749,7 @@ static void edge_bulk_in_callback(struct urb *urb)
++data; ++data;
} }
tty = edge_port->port->tty; tty = edge_port->port->port.tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
usb_serial_debug_data(debug, &edge_port->port->dev, usb_serial_debug_data(debug, &edge_port->port->dev,
__func__, urb->actual_length, data); __func__, urb->actual_length, data);
...@@ -1819,10 +1818,11 @@ static void edge_bulk_out_callback(struct urb *urb) ...@@ -1819,10 +1818,11 @@ static void edge_bulk_out_callback(struct urb *urb)
} }
/* send any buffered data */ /* send any buffered data */
edge_send(port); edge_send(port->port.tty);
} }
static int edge_open(struct usb_serial_port *port, struct file *filp) static int edge_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
...@@ -1838,7 +1838,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp) ...@@ -1838,7 +1838,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
if (edge_port == NULL) if (edge_port == NULL)
return -ENODEV; return -ENODEV;
port->tty->low_latency = low_latency; if (tty)
tty->low_latency = low_latency;
port_number = port->number - port->serial->minor; port_number = port->number - port->serial->minor;
switch (port_number) { switch (port_number) {
...@@ -1874,7 +1875,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp) ...@@ -1874,7 +1875,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
} }
/* set up the port settings */ /* set up the port settings */
edge_set_termios(port, port->tty->termios); if (tty)
edge_set_termios(tty, port, port->port.tty->termios);
/* open up the port */ /* open up the port */
...@@ -2000,7 +2002,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp) ...@@ -2000,7 +2002,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
return status; return status;
} }
static void edge_close(struct usb_serial_port *port, struct file *filp) static void edge_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
...@@ -2048,8 +2051,8 @@ static void edge_close(struct usb_serial_port *port, struct file *filp) ...@@ -2048,8 +2051,8 @@ static void edge_close(struct usb_serial_port *port, struct file *filp)
dbg("%s - exited", __func__); dbg("%s - exited", __func__);
} }
static int edge_write(struct usb_serial_port *port, const unsigned char *data, static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
int count) const unsigned char *data, int count)
{ {
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -2070,16 +2073,16 @@ static int edge_write(struct usb_serial_port *port, const unsigned char *data, ...@@ -2070,16 +2073,16 @@ static int edge_write(struct usb_serial_port *port, const unsigned char *data,
count = edge_buf_put(edge_port->ep_out_buf, data, count); count = edge_buf_put(edge_port->ep_out_buf, data, count);
spin_unlock_irqrestore(&edge_port->ep_lock, flags); spin_unlock_irqrestore(&edge_port->ep_lock, flags);
edge_send(port); edge_send(tty);
return count; return count;
} }
static void edge_send(struct usb_serial_port *port) static void edge_send(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int count, result; int count, result;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned long flags; unsigned long flags;
...@@ -2133,8 +2136,9 @@ static void edge_send(struct usb_serial_port *port) ...@@ -2133,8 +2136,9 @@ static void edge_send(struct usb_serial_port *port)
tty_wakeup(tty); tty_wakeup(tty);
} }
static int edge_write_room(struct usb_serial_port *port) static int edge_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int room = 0; int room = 0;
unsigned long flags; unsigned long flags;
...@@ -2154,8 +2158,9 @@ static int edge_write_room(struct usb_serial_port *port) ...@@ -2154,8 +2158,9 @@ static int edge_write_room(struct usb_serial_port *port)
return room; return room;
} }
static int edge_chars_in_buffer(struct usb_serial_port *port) static int edge_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int chars = 0; int chars = 0;
unsigned long flags; unsigned long flags;
...@@ -2175,10 +2180,10 @@ static int edge_chars_in_buffer(struct usb_serial_port *port) ...@@ -2175,10 +2180,10 @@ static int edge_chars_in_buffer(struct usb_serial_port *port)
return chars; return chars;
} }
static void edge_throttle(struct usb_serial_port *port) static void edge_throttle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
int status; int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -2189,11 +2194,10 @@ static void edge_throttle(struct usb_serial_port *port) ...@@ -2189,11 +2194,10 @@ static void edge_throttle(struct usb_serial_port *port)
/* if we are implementing XON/XOFF, send the stop character */ /* if we are implementing XON/XOFF, send the stop character */
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
unsigned char stop_char = STOP_CHAR(tty); unsigned char stop_char = STOP_CHAR(tty);
status = edge_write(port, &stop_char, 1); status = edge_write(tty, port, &stop_char, 1);
if (status <= 0) if (status <= 0) {
dev_err(&port->dev, dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
"%s - failed to write stop character, %d\n", }
__func__, status);
} }
/* if we are implementing RTS/CTS, stop reads */ /* if we are implementing RTS/CTS, stop reads */
...@@ -2203,10 +2207,10 @@ static void edge_throttle(struct usb_serial_port *port) ...@@ -2203,10 +2207,10 @@ static void edge_throttle(struct usb_serial_port *port)
} }
static void edge_unthrottle(struct usb_serial_port *port) static void edge_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
int status; int status;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -2217,11 +2221,10 @@ static void edge_unthrottle(struct usb_serial_port *port) ...@@ -2217,11 +2221,10 @@ static void edge_unthrottle(struct usb_serial_port *port)
/* if we are implementing XON/XOFF, send the start character */ /* if we are implementing XON/XOFF, send the start character */
if (I_IXOFF(tty)) { if (I_IXOFF(tty)) {
unsigned char start_char = START_CHAR(tty); unsigned char start_char = START_CHAR(tty);
status = edge_write(port, &start_char, 1); status = edge_write(tty, port, &start_char, 1);
if (status <= 0) if (status <= 0) {
dev_err(&port->dev, dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
"%s - failed to write start character, %d\n", }
__func__, status);
} }
/* if we are implementing RTS/CTS, restart reads */ /* if we are implementing RTS/CTS, restart reads */
/* are the Edgeport will assert the RTS line */ /* are the Edgeport will assert the RTS line */
...@@ -2271,11 +2274,10 @@ static int restart_read(struct edgeport_port *edge_port) ...@@ -2271,11 +2274,10 @@ static int restart_read(struct edgeport_port *edge_port)
return status; return status;
} }
static void change_port_settings(struct edgeport_port *edge_port, static void change_port_settings(struct tty_struct *tty,
struct ktermios *old_termios) struct edgeport_port *edge_port, struct ktermios *old_termios)
{ {
struct ump_uart_config *config; struct ump_uart_config *config;
struct tty_struct *tty;
int baud; int baud;
unsigned cflag; unsigned cflag;
int status; int status;
...@@ -2284,9 +2286,7 @@ static void change_port_settings(struct edgeport_port *edge_port, ...@@ -2284,9 +2286,7 @@ static void change_port_settings(struct edgeport_port *edge_port,
dbg("%s - port %d", __func__, edge_port->port->number); dbg("%s - port %d", __func__, edge_port->port->number);
tty = edge_port->port->tty; config = kmalloc (sizeof (*config), GFP_KERNEL);
config = kmalloc(sizeof(*config), GFP_KERNEL);
if (!config) { if (!config) {
*tty->termios = *old_termios; *tty->termios = *old_termios;
dev_err(&edge_port->port->dev, "%s - out of memory\n", dev_err(&edge_port->port->dev, "%s - out of memory\n",
...@@ -2419,11 +2419,13 @@ static void change_port_settings(struct edgeport_port *edge_port, ...@@ -2419,11 +2419,13 @@ static void change_port_settings(struct edgeport_port *edge_port,
return; return;
} }
static void edge_set_termios(struct usb_serial_port *port, static void edge_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty; unsigned int cflag;
cflag = tty->termios->c_cflag;
dbg("%s - clfag %08x iflag %08x", __func__, dbg("%s - clfag %08x iflag %08x", __func__,
tty->termios->c_cflag, tty->termios->c_iflag); tty->termios->c_cflag, tty->termios->c_iflag);
...@@ -2434,12 +2436,14 @@ static void edge_set_termios(struct usb_serial_port *port, ...@@ -2434,12 +2436,14 @@ static void edge_set_termios(struct usb_serial_port *port,
if (edge_port == NULL) if (edge_port == NULL)
return; return;
/* change the port settings to the new ones specified */ /* change the port settings to the new ones specified */
change_port_settings(edge_port, old_termios); change_port_settings(tty, edge_port, old_termios);
return;
} }
static int edge_tiocmset(struct usb_serial_port *port, struct file *file, static int edge_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned int mcr; unsigned int mcr;
unsigned long flags; unsigned long flags;
...@@ -2469,8 +2473,9 @@ static int edge_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -2469,8 +2473,9 @@ static int edge_tiocmset(struct usb_serial_port *port, struct file *file,
return 0; return 0;
} }
static int edge_tiocmget(struct usb_serial_port *port, struct file *file) static int edge_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned int result = 0; unsigned int result = 0;
unsigned int msr; unsigned int msr;
...@@ -2522,9 +2527,10 @@ static int get_serial_info(struct edgeport_port *edge_port, ...@@ -2522,9 +2527,10 @@ static int get_serial_info(struct edgeport_port *edge_port,
return 0; return 0;
} }
static int edge_ioctl(struct usb_serial_port *port, struct file *file, static int edge_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
struct async_icount cnow; struct async_icount cnow;
struct async_icount cprev; struct async_icount cprev;
...@@ -2569,18 +2575,19 @@ static int edge_ioctl(struct usb_serial_port *port, struct file *file, ...@@ -2569,18 +2575,19 @@ static int edge_ioctl(struct usb_serial_port *port, struct file *file,
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
static void edge_break(struct usb_serial_port *port, int on) static void edge_break(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int status; int status;
int bv = 0; /* Off */ int bv = 0; /* Off */
dbg("%s - state = %d", __func__, on); dbg("%s - state = %d", __func__, break_state);
/* chase the port close */ /* chase the port close */
chase_port(edge_port, 0, 0); chase_port(edge_port, 0, 0);
if (on == -1) if (break_state == -1)
bv = 1; /* On */ bv = 1; /* On */
status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
if (status) if (status)
......
...@@ -74,19 +74,21 @@ static int connect_retries = KP_RETRIES; ...@@ -74,19 +74,21 @@ static int connect_retries = KP_RETRIES;
static int initial_wait; static int initial_wait;
/* Function prototypes for an ipaq */ /* Function prototypes for an ipaq */
static int ipaq_open (struct usb_serial_port *port, struct file *filp); static int ipaq_open(struct tty_struct *tty,
static void ipaq_close (struct usb_serial_port *port, struct file *filp); struct usb_serial_port *port, struct file *filp);
static int ipaq_startup (struct usb_serial *serial); static void ipaq_close(struct tty_struct *tty,
static void ipaq_shutdown (struct usb_serial *serial); struct usb_serial_port *port, struct file *filp);
static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, static int ipaq_startup(struct usb_serial *serial);
int count); static void ipaq_shutdown(struct usb_serial *serial);
static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
int count); int count);
static void ipaq_write_gather(struct usb_serial_port *port); static void ipaq_write_gather(struct usb_serial_port *port);
static void ipaq_read_bulk_callback (struct urb *urb); static void ipaq_read_bulk_callback (struct urb *urb);
static void ipaq_write_bulk_callback(struct urb *urb); static void ipaq_write_bulk_callback(struct urb *urb);
static int ipaq_write_room(struct usb_serial_port *port); static int ipaq_write_room(struct tty_struct *tty);
static int ipaq_chars_in_buffer(struct usb_serial_port *port); static int ipaq_chars_in_buffer(struct tty_struct *tty);
static void ipaq_destroy_lists(struct usb_serial_port *port); static void ipaq_destroy_lists(struct usb_serial_port *port);
...@@ -591,7 +593,8 @@ static spinlock_t write_list_lock; ...@@ -591,7 +593,8 @@ static spinlock_t write_list_lock;
static int bytes_in; static int bytes_in;
static int bytes_out; static int bytes_out;
static int ipaq_open(struct usb_serial_port *port, struct file *filp) static int ipaq_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct ipaq_private *priv; struct ipaq_private *priv;
...@@ -637,10 +640,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -637,10 +640,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
* discipline instead of queueing. * discipline instead of queueing.
*/ */
port->tty->low_latency = 1; if (tty) {
port->tty->raw = 1; tty->low_latency = 1;
port->tty->real_raw = 1; /* FIXME: These two are bogus */
tty->raw = 1;
tty->real_raw = 1;
}
/* /*
* Lose the small buffers usbserial provides. Make larger ones. * Lose the small buffers usbserial provides. Make larger ones.
*/ */
...@@ -714,7 +719,8 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -714,7 +719,8 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
} }
static void ipaq_close(struct usb_serial_port *port, struct file *filp) static void ipaq_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct ipaq_private *priv = usb_get_serial_port_data(port); struct ipaq_private *priv = usb_get_serial_port_data(port);
...@@ -751,7 +757,7 @@ static void ipaq_read_bulk_callback(struct urb *urb) ...@@ -751,7 +757,7 @@ static void ipaq_read_bulk_callback(struct urb *urb)
usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
tty = port->tty; tty = port->port.tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
tty_buffer_request_room(tty, urb->actual_length); tty_buffer_request_room(tty, urb->actual_length);
tty_insert_flip_string(tty, data, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length);
...@@ -770,8 +776,8 @@ static void ipaq_read_bulk_callback(struct urb *urb) ...@@ -770,8 +776,8 @@ static void ipaq_read_bulk_callback(struct urb *urb)
return; return;
} }
static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
int count) const unsigned char *buf, int count)
{ {
const unsigned char *current_position = buf; const unsigned char *current_position = buf;
int bytes_sent = 0; int bytes_sent = 0;
...@@ -905,16 +911,18 @@ static void ipaq_write_bulk_callback(struct urb *urb) ...@@ -905,16 +911,18 @@ static void ipaq_write_bulk_callback(struct urb *urb)
usb_serial_port_softint(port); usb_serial_port_softint(port);
} }
static int ipaq_write_room(struct usb_serial_port *port) static int ipaq_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ipaq_private *priv = usb_get_serial_port_data(port); struct ipaq_private *priv = usb_get_serial_port_data(port);
dbg("%s - freelen %d", __func__, priv->free_len); dbg("%s - freelen %d", __func__, priv->free_len);
return priv->free_len; return priv->free_len;
} }
static int ipaq_chars_in_buffer(struct usb_serial_port *port) static int ipaq_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct ipaq_private *priv = usb_get_serial_port_data(port); struct ipaq_private *priv = usb_get_serial_port_data(port);
dbg("%s - queuelen %d", __func__, priv->queue_len); dbg("%s - queuelen %d", __func__, priv->queue_len);
......
...@@ -179,7 +179,7 @@ static void ipw_read_bulk_callback(struct urb *urb) ...@@ -179,7 +179,7 @@ static void ipw_read_bulk_callback(struct urb *urb)
usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
tty = port->tty; tty = port->port.tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
tty_buffer_request_room(tty, urb->actual_length); tty_buffer_request_room(tty, urb->actual_length);
tty_insert_flip_string(tty, data, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length);
...@@ -199,7 +199,8 @@ static void ipw_read_bulk_callback(struct urb *urb) ...@@ -199,7 +199,8 @@ static void ipw_read_bulk_callback(struct urb *urb)
return; return;
} }
static int ipw_open(struct usb_serial_port *port, struct file *filp) static int ipw_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_device *dev = port->serial->dev; struct usb_device *dev = port->serial->dev;
u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
...@@ -212,8 +213,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) ...@@ -212,8 +213,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
if (!buf_flow_init) if (!buf_flow_init)
return -ENOMEM; return -ENOMEM;
if (port->tty) if (tty)
port->tty->low_latency = 1; tty->low_latency = 1;
/* --1: Tell the modem to initialize (we think) From sniffs this is always the /* --1: Tell the modem to initialize (we think) From sniffs this is always the
* first thing that gets sent to the modem during opening of the device */ * first thing that gets sent to the modem during opening of the device */
...@@ -301,7 +302,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) ...@@ -301,7 +302,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
return 0; return 0;
} }
static void ipw_close(struct usb_serial_port *port, struct file * filp) static void ipw_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
struct usb_device *dev = port->serial->dev; struct usb_device *dev = port->serial->dev;
int result; int result;
...@@ -384,7 +386,8 @@ static void ipw_write_bulk_callback(struct urb *urb) ...@@ -384,7 +386,8 @@ static void ipw_write_bulk_callback(struct urb *urb)
usb_serial_port_softint(port); usb_serial_port_softint(port);
} }
static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count) static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count)
{ {
struct usb_device *dev = port->serial->dev; struct usb_device *dev = port->serial->dev;
int ret; int ret;
......
...@@ -85,15 +85,17 @@ static int buffer_size; ...@@ -85,15 +85,17 @@ static int buffer_size;
/* if overridden by the user, then use the specified number of XBOFs */ /* if overridden by the user, then use the specified number of XBOFs */
static int xbof = -1; static int xbof = -1;
static int ir_startup(struct usb_serial *serial); static int ir_startup (struct usb_serial *serial);
static int ir_open(struct usb_serial_port *port, struct file *filep); static int ir_open(struct tty_struct *tty, struct usb_serial_port *port,
static void ir_close(struct usb_serial_port *port, struct file *filep); struct file *filep);
static int ir_write(struct usb_serial_port *port, static void ir_close(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filep);
static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count); const unsigned char *buf, int count);
static void ir_write_bulk_callback(struct urb *urb); static void ir_write_bulk_callback (struct urb *urb);
static void ir_read_bulk_callback(struct urb *urb); static void ir_read_bulk_callback (struct urb *urb);
static void ir_set_termios(struct usb_serial_port *port, static void ir_set_termios(struct tty_struct *tty,
struct ktermios *old_termios); struct usb_serial_port *port, struct ktermios *old_termios);
/* Not that this lot means you can only have one per system */ /* Not that this lot means you can only have one per system */
static u8 ir_baud; static u8 ir_baud;
...@@ -295,7 +297,8 @@ static int ir_startup(struct usb_serial *serial) ...@@ -295,7 +297,8 @@ static int ir_startup(struct usb_serial *serial)
return 0; return 0;
} }
static int ir_open(struct usb_serial_port *port, struct file *filp) static int ir_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
char *buffer; char *buffer;
int result = 0; int result = 0;
...@@ -343,7 +346,8 @@ static int ir_open(struct usb_serial_port *port, struct file *filp) ...@@ -343,7 +346,8 @@ static int ir_open(struct usb_serial_port *port, struct file *filp)
return result; return result;
} }
static void ir_close(struct usb_serial_port *port, struct file *filp) static void ir_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file * filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -351,7 +355,7 @@ static void ir_close(struct usb_serial_port *port, struct file *filp) ...@@ -351,7 +355,7 @@ static void ir_close(struct usb_serial_port *port, struct file *filp)
usb_kill_urb(port->read_urb); usb_kill_urb(port->read_urb);
} }
static int ir_write(struct usb_serial_port *port, static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
...@@ -360,11 +364,6 @@ static int ir_write(struct usb_serial_port *port, ...@@ -360,11 +364,6 @@ static int ir_write(struct usb_serial_port *port,
dbg("%s - port = %d, count = %d", __func__, port->number, count); dbg("%s - port = %d, count = %d", __func__, port->number, count);
if (!port->tty) {
dev_err(&port->dev, "%s - no tty???\n", __func__);
return 0;
}
if (count == 0) if (count == 0)
return 0; return 0;
...@@ -450,14 +449,13 @@ static void ir_read_bulk_callback(struct urb *urb) ...@@ -450,14 +449,13 @@ static void ir_read_bulk_callback(struct urb *urb)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (!port->open_count) { if (!port->port.count) {
dbg("%s - port closed.", __func__); dbg("%s - port closed.", __func__);
return; return;
} }
switch (status) { switch (status) {
case 0: /* Successful */ case 0: /* Successful */
/* /*
* The first byte of the packet we get from the device * The first byte of the packet we get from the device
* contains a busy indicator and baud rate change. * contains a busy indicator and baud rate change.
...@@ -465,19 +463,11 @@ static void ir_read_bulk_callback(struct urb *urb) ...@@ -465,19 +463,11 @@ static void ir_read_bulk_callback(struct urb *urb)
*/ */
if ((*data & 0x0f) > 0) if ((*data & 0x0f) > 0)
ir_baud = *data & 0x0f; ir_baud = *data & 0x0f;
usb_serial_debug_data(debug, &port->dev, __func__,
usb_serial_debug_data( urb->actual_length, data);
debug, tty = port->port.tty;
&port->dev,
__func__,
urb->actual_length,
data);
tty = port->tty;
if (tty_buffer_request_room(tty, urb->actual_length - 1)) { if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
tty_insert_flip_string(tty, data + 1, tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
urb->actual_length - 1);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
...@@ -488,7 +478,6 @@ static void ir_read_bulk_callback(struct urb *urb) ...@@ -488,7 +478,6 @@ static void ir_read_bulk_callback(struct urb *urb)
*/ */
case -EPROTO: /* taking inspiration from pl2303.c */ case -EPROTO: /* taking inspiration from pl2303.c */
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb( usb_fill_bulk_urb(
port->read_urb, port->read_urb,
...@@ -502,23 +491,19 @@ static void ir_read_bulk_callback(struct urb *urb) ...@@ -502,23 +491,19 @@ static void ir_read_bulk_callback(struct urb *urb)
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result) if (result)
dev_err(&port->dev, dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
"%s - failed resubmitting read urb, error %d\n",
__func__, result); __func__, result);
break; break ;
default: default:
dbg("%s - nonzero read bulk status received: %d", dbg("%s - nonzero read bulk status received: %d",
__func__, __func__, status);
status); break ;
break;
} }
return; return;
} }
static void ir_set_termios(struct usb_serial_port *port, static void ir_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
int result; int result;
...@@ -527,7 +512,7 @@ static void ir_set_termios(struct usb_serial_port *port, ...@@ -527,7 +512,7 @@ static void ir_set_termios(struct usb_serial_port *port,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
baud = tty_get_baud_rate(port->tty); baud = tty_get_baud_rate(tty);
/* /*
* FIXME, we should compare the baud request against the * FIXME, we should compare the baud request against the
...@@ -600,8 +585,8 @@ static void ir_set_termios(struct usb_serial_port *port, ...@@ -600,8 +585,8 @@ static void ir_set_termios(struct usb_serial_port *port,
__func__, result); __func__, result);
/* Only speed changes are supported */ /* Only speed changes are supported */
tty_termios_copy_hw(port->tty->termios, old_termios); tty_termios_copy_hw(tty->termios, old_termios);
tty_encode_baud_rate(port->tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
} }
static int __init ir_init(void) static int __init ir_init(void)
......
...@@ -144,9 +144,10 @@ static void iuu_shutdown(struct usb_serial *serial) ...@@ -144,9 +144,10 @@ static void iuu_shutdown(struct usb_serial *serial)
} }
} }
static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, static int iuu_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct iuu_private *priv = usb_get_serial_port_data(port); struct iuu_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
* When no card , the reader respond with TIOCM_CD * When no card , the reader respond with TIOCM_CD
* This is known as CD autodetect mechanism * This is known as CD autodetect mechanism
*/ */
static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) static int iuu_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct iuu_private *priv = usb_get_serial_port_data(port); struct iuu_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
int rc; int rc;
...@@ -630,7 +632,7 @@ static void read_buf_callback(struct urb *urb) ...@@ -630,7 +632,7 @@ static void read_buf_callback(struct urb *urb)
} }
dbg("%s - %i chars to write", __func__, urb->actual_length); dbg("%s - %i chars to write", __func__, urb->actual_length);
tty = port->tty; tty = port->port.tty;
if (data == NULL) if (data == NULL)
dbg("%s - data is NULL !!!", __func__); dbg("%s - data is NULL !!!", __func__);
if (tty && urb->actual_length && data) { if (tty && urb->actual_length && data) {
...@@ -752,11 +754,10 @@ static void iuu_uart_read_callback(struct urb *urb) ...@@ -752,11 +754,10 @@ static void iuu_uart_read_callback(struct urb *urb)
/* if nothing to write call again rxcmd */ /* if nothing to write call again rxcmd */
dbg("%s - rxcmd recall", __func__); dbg("%s - rxcmd recall", __func__);
iuu_led_activity_off(urb); iuu_led_activity_off(urb);
return;
} }
static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
int count) const u8 *buf, int count)
{ {
struct iuu_private *priv = usb_get_serial_port_data(port); struct iuu_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
...@@ -948,7 +949,8 @@ static int set_control_lines(struct usb_device *dev, u8 value) ...@@ -948,7 +949,8 @@ static int set_control_lines(struct usb_device *dev, u8 value)
return 0; return 0;
} }
static void iuu_close(struct usb_serial_port *port, struct file *filp) static void iuu_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
/* iuu_led (port,255,0,0,0); */ /* iuu_led (port,255,0,0,0); */
struct usb_serial *serial; struct usb_serial *serial;
...@@ -964,8 +966,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) ...@@ -964,8 +966,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
iuu_uart_off(port); iuu_uart_off(port);
if (serial->dev) { if (serial->dev) {
if (port->tty) { if (tty) {
c_cflag = port->tty->termios->c_cflag; c_cflag = tty->termios->c_cflag;
if (c_cflag & HUPCL) { if (c_cflag & HUPCL) {
/* drop DTR and RTS */ /* drop DTR and RTS */
priv = usb_get_serial_port_data(port); priv = usb_get_serial_port_data(port);
...@@ -989,7 +991,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp) ...@@ -989,7 +991,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
} }
} }
static int iuu_open(struct usb_serial_port *port, struct file *filp) static int iuu_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
u8 *buf; u8 *buf;
...@@ -1036,15 +1039,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) ...@@ -1036,15 +1039,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
/* set the termios structure */ /* set the termios structure */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (!priv->termios_initialized) { if (tty && !priv->termios_initialized) {
*(port->tty->termios) = tty_std_termios; *(tty->termios) = tty_std_termios;
port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
| TIOCM_CTS | CSTOPB | PARENB; | TIOCM_CTS | CSTOPB | PARENB;
port->tty->termios->c_lflag = 0; tty->termios->c_ispeed = 9600;
port->tty->termios->c_oflag = 0; tty->termios->c_ospeed = 9600;
port->tty->termios->c_iflag = 0; tty->termios->c_lflag = 0;
tty->termios->c_oflag = 0;
tty->termios->c_iflag = 0;
priv->termios_initialized = 1; priv->termios_initialized = 1;
port->tty->low_latency = 1; tty->low_latency = 1;
priv->poll = 0; priv->poll = 0;
} }
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
...@@ -1148,7 +1153,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp) ...@@ -1148,7 +1153,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
if (result) { if (result) {
dev_err(&port->dev, "%s - failed submitting read urb," dev_err(&port->dev, "%s - failed submitting read urb,"
" error %d\n", __func__, result); " error %d\n", __func__, result);
iuu_close(port, NULL); iuu_close(tty, port, NULL);
return -EPROTO; return -EPROTO;
} else { } else {
dbg("%s - rxcmd OK", __func__); dbg("%s - rxcmd OK", __func__);
......
...@@ -244,20 +244,9 @@ static void __exit keyspan_exit (void) ...@@ -244,20 +244,9 @@ static void __exit keyspan_exit (void)
module_init(keyspan_init); module_init(keyspan_init);
module_exit(keyspan_exit); module_exit(keyspan_exit);
static void keyspan_rx_throttle (struct usb_serial_port *port) static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
{
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)
{ {
struct usb_serial_port *port = tty->driver_data;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
dbg("%s", __func__); dbg("%s", __func__);
...@@ -273,14 +262,13 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state) ...@@ -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, static void keyspan_set_termios (struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
int baud_rate, device_port; int baud_rate, device_port;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details; const struct keyspan_device_details *d_details;
unsigned int cflag; unsigned int cflag;
struct tty_struct *tty = port->tty;
dbg("%s", __func__); dbg("%s", __func__);
...@@ -312,12 +300,11 @@ static void keyspan_set_termios (struct usb_serial_port *port, ...@@ -312,12 +300,11 @@ static void keyspan_set_termios (struct usb_serial_port *port,
keyspan_send_setup(port, 0); 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; 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) | value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
((p_priv->dtr_state) ? TIOCM_DTR : 0) | ((p_priv->dtr_state) ? TIOCM_DTR : 0) |
...@@ -329,18 +316,16 @@ static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file) ...@@ -329,18 +316,16 @@ static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file)
return value; 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) 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) if (set & TIOCM_RTS)
p_priv->rts_state = 1; p_priv->rts_state = 1;
if (set & TIOCM_DTR) if (set & TIOCM_DTR)
p_priv->dtr_state = 1; p_priv->dtr_state = 1;
if (clear & TIOCM_RTS) if (clear & TIOCM_RTS)
p_priv->rts_state = 0; p_priv->rts_state = 0;
if (clear & TIOCM_DTR) if (clear & TIOCM_DTR)
...@@ -349,16 +334,10 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -349,16 +334,10 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
return 0; return 0;
} }
static int keyspan_ioctl(struct usb_serial_port *port, struct file *file, /* Write function is similar for the four protocols used
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 */ with only a minor change for usa90 (usa19hs) required */
static int keyspan_write(struct usb_serial_port *port, static int keyspan_write(struct tty_struct *tty,
const unsigned char *buf, int count) struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details; const struct keyspan_device_details *d_details;
...@@ -448,7 +427,7 @@ static void usa26_indat_callback(struct urb *urb) ...@@ -448,7 +427,7 @@ static void usa26_indat_callback(struct urb *urb)
} }
port = urb->context; port = urb->context;
tty = port->tty; tty = port->port.tty;
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) {
...@@ -479,7 +458,7 @@ static void usa26_indat_callback(struct urb *urb) ...@@ -479,7 +458,7 @@ 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->open_count) if (port->port.count)
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
} }
...@@ -496,7 +475,7 @@ static void usa2x_outdat_callback(struct urb *urb) ...@@ -496,7 +475,7 @@ static void usa2x_outdat_callback(struct urb *urb)
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->open_count) if (port->port.count)
usb_serial_port_softint(port); usb_serial_port_softint(port);
} }
...@@ -567,10 +546,10 @@ static void usa26_instat_callback(struct urb *urb) ...@@ -567,10 +546,10 @@ static void usa26_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 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) { && old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state) if (old_dcd_state)
tty_hangup(port->tty); tty_hangup(port->port.tty);
/* else */ /* else */
/* wake_up_interruptible(&p_priv->open_wait); */ /* wake_up_interruptible(&p_priv->open_wait); */
} }
...@@ -619,7 +598,7 @@ static void usa28_indat_callback(struct urb *urb) ...@@ -619,7 +598,7 @@ static void usa28_indat_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
data = urb->transfer_buffer; data = urb->transfer_buffer;
tty = 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);
...@@ -629,7 +608,7 @@ static void usa28_indat_callback(struct urb *urb) ...@@ -629,7 +608,7 @@ static void usa28_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->open_count) if (port->port.count)
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
} }
...@@ -704,10 +683,10 @@ static void usa28_instat_callback(struct urb *urb) ...@@ -704,10 +683,10 @@ static void usa28_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 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) { && old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state) if (old_dcd_state)
tty_hangup(port->tty); tty_hangup(port->port.tty);
/* else */ /* else */
/* wake_up_interruptible(&p_priv->open_wait); */ /* wake_up_interruptible(&p_priv->open_wait); */
} }
...@@ -797,10 +776,10 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -797,10 +776,10 @@ static void usa49_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 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) { && old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state) if (old_dcd_state)
tty_hangup(port->tty); tty_hangup(port->port.tty);
/* else */ /* else */
/* wake_up_interruptible(&p_priv->open_wait); */ /* wake_up_interruptible(&p_priv->open_wait); */
} }
...@@ -839,7 +818,7 @@ static void usa49_indat_callback(struct urb *urb) ...@@ -839,7 +818,7 @@ static void usa49_indat_callback(struct urb *urb)
} }
port = urb->context; port = urb->context;
tty = port->tty; tty = port->port.tty;
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) {
...@@ -866,7 +845,7 @@ static void usa49_indat_callback(struct urb *urb) ...@@ -866,7 +845,7 @@ 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->open_count) if (port->port.count)
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
} }
...@@ -904,7 +883,7 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -904,7 +883,7 @@ static void usa49wg_indat_callback(struct urb *urb)
return; return;
} }
port = serial->port[data[i++]]; port = serial->port[data[i++]];
tty = port->tty; tty = port->port.tty;
len = data[i++]; len = data[i++];
/* 0x80 bit is error flag */ /* 0x80 bit is error flag */
...@@ -912,7 +891,7 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -912,7 +891,7 @@ static void usa49wg_indat_callback(struct urb *urb)
/* no error on any byte */ /* no error on any byte */
i++; i++;
for (x = 1; x < len ; ++x) for (x = 1; x < len ; ++x)
if (port->open_count) if (port->port.count)
tty_insert_flip_char(tty, tty_insert_flip_char(tty,
data[i++], 0); data[i++], 0);
else else
...@@ -930,13 +909,13 @@ static void usa49wg_indat_callback(struct urb *urb) ...@@ -930,13 +909,13 @@ static void usa49wg_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) */
if (port->open_count) if (port->port.count)
tty_insert_flip_char(tty, tty_insert_flip_char(tty,
data[i+1], flag); data[i+1], flag);
i += 2; i += 2;
} }
} }
if (port->open_count) if (port->port.count)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
} }
} }
...@@ -978,7 +957,7 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -978,7 +957,7 @@ static void usa90_indat_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);
tty = 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
...@@ -1021,7 +1000,7 @@ static void usa90_indat_callback(struct urb *urb) ...@@ -1021,7 +1000,7 @@ 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->open_count) if (port->port.count)
if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
dbg("%s - resubmit read urb failed. (%d)", __func__, err); dbg("%s - resubmit read urb failed. (%d)", __func__, err);
} }
...@@ -1064,10 +1043,10 @@ static void usa90_instat_callback(struct urb *urb) ...@@ -1064,10 +1043,10 @@ static void usa90_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 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) { && old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state) if (old_dcd_state)
tty_hangup(port->tty); tty_hangup(port->port.tty);
/* else */ /* else */
/* wake_up_interruptible(&p_priv->open_wait); */ /* wake_up_interruptible(&p_priv->open_wait); */
} }
...@@ -1139,10 +1118,10 @@ static void usa67_instat_callback(struct urb *urb) ...@@ -1139,10 +1118,10 @@ static void usa67_instat_callback(struct urb *urb)
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
p_priv->dcd_state = ((msg->gpia_dcd) ? 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) { && old_dcd_state != p_priv->dcd_state) {
if (old_dcd_state) if (old_dcd_state)
tty_hangup(port->tty); tty_hangup(port->port.tty);
/* else */ /* else */
/* wake_up_interruptible(&p_priv->open_wait); */ /* wake_up_interruptible(&p_priv->open_wait); */
} }
...@@ -1177,8 +1156,9 @@ static void usa67_glocont_callback(struct urb *urb) ...@@ -1177,8 +1156,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; struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details; const struct keyspan_device_details *d_details;
int flip; int flip;
...@@ -1210,13 +1190,8 @@ static int keyspan_write_room (struct usb_serial_port *port) ...@@ -1210,13 +1190,8 @@ static int keyspan_write_room (struct usb_serial_port *port)
} }
static int keyspan_chars_in_buffer (struct usb_serial_port *port) static int keyspan_open(struct tty_struct *tty,
{ struct usb_serial_port *port, struct file *filp)
return 0;
}
static int keyspan_open (struct usb_serial_port *port, struct file *filp)
{ {
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
struct keyspan_serial_private *s_priv; struct keyspan_serial_private *s_priv;
...@@ -1225,7 +1200,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) ...@@ -1225,7 +1200,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
int i, err; int i, err;
int baud_rate, device_port; int baud_rate, device_port;
struct urb *urb; struct urb *urb;
unsigned int cflag; unsigned int cflag = 0;
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);
...@@ -1271,19 +1246,19 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) ...@@ -1271,19 +1246,19 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
/* 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
* need to send 2 of them */ * need to send 2 of them */
cflag = port->tty->termios->c_cflag;
device_port = port->number - port->serial->minor; device_port = port->number - port->serial->minor;
if (tty) {
cflag = tty->termios->c_cflag;
/* Baud rate calculation takes baud rate as an integer /* Baud rate calculation takes baud rate as an integer
so other rates can be generated if desired. */ so other rates can be generated if desired. */
baud_rate = tty_get_baud_rate(port->tty); baud_rate = tty_get_baud_rate(tty);
/* If no match or invalid, leave as default */ /* If no match or invalid, leave as default */
if (baud_rate >= 0 if (baud_rate >= 0
&& d_details->calculate_baud_rate(baud_rate, d_details->baudclk, && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
p_priv->baud = baud_rate; p_priv->baud = baud_rate;
} }
}
/* set CTS/RTS handshake etc. */ /* set CTS/RTS handshake etc. */
p_priv->cflag = cflag; p_priv->cflag = cflag;
p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
...@@ -1301,7 +1276,8 @@ static inline void stop_urb(struct urb *urb) ...@@ -1301,7 +1276,8 @@ static inline void stop_urb(struct urb *urb)
usb_kill_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; int i;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
...@@ -1338,7 +1314,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) ...@@ -1338,7 +1314,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
stop_urb(p_priv->out_urbs[i]); stop_urb(p_priv->out_urbs[i]);
} }
} }
port->tty = NULL; port->port.tty = NULL;
} }
/* download the firmware to a pre-renumeration device */ /* download the firmware to a pre-renumeration device */
...@@ -2427,7 +2403,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial, ...@@ -2427,7 +2403,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
} }
/* Sending intermediate configs */ /* Sending intermediate configs */
else { else {
if (port->open_count) if (port->port.count)
msg.portEnabled = 1; msg.portEnabled = 1;
msg.txBreak = (p_priv->break_on); msg.txBreak = (p_priv->break_on);
} }
......
...@@ -35,17 +35,18 @@ ...@@ -35,17 +35,18 @@
/* Function prototypes for Keyspan serial converter */ /* Function prototypes for Keyspan serial converter */
static int keyspan_open (struct usb_serial_port *port, static int keyspan_open (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static void keyspan_close (struct usb_serial_port *port, static void keyspan_close (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static int keyspan_startup (struct usb_serial *serial); static int keyspan_startup (struct usb_serial *serial);
static void keyspan_shutdown (struct usb_serial *serial); static void keyspan_shutdown (struct usb_serial *serial);
static void keyspan_rx_throttle (struct usb_serial_port *port); static int keyspan_write_room (struct tty_struct *tty);
static void keyspan_rx_unthrottle (struct usb_serial_port *port);
static int keyspan_write_room (struct usb_serial_port *port);
static int keyspan_write (struct usb_serial_port *port, static int keyspan_write (struct tty_struct *tty,
struct usb_serial_port *port,
const unsigned char *buf, const unsigned char *buf,
int count); int count);
...@@ -53,18 +54,14 @@ static void keyspan_send_setup (struct usb_serial_port *port, ...@@ -53,18 +54,14 @@ static void keyspan_send_setup (struct usb_serial_port *port,
int reset_port); int reset_port);
static int keyspan_chars_in_buffer (struct usb_serial_port *port); static void keyspan_set_termios (struct tty_struct *tty,
static int keyspan_ioctl (struct usb_serial_port *port, struct usb_serial_port *port,
struct file *file,
unsigned int cmd,
unsigned long arg);
static void keyspan_set_termios (struct usb_serial_port *port,
struct ktermios *old); struct ktermios *old);
static void keyspan_break_ctl (struct usb_serial_port *port, static void keyspan_break_ctl (struct tty_struct *tty,
int break_state); int break_state);
static int keyspan_tiocmget (struct usb_serial_port *port, static int keyspan_tiocmget (struct tty_struct *tty,
struct file *file); struct file *file);
static int keyspan_tiocmset (struct usb_serial_port *port, static int keyspan_tiocmset (struct tty_struct *tty,
struct file *file, unsigned int set, struct file *file, unsigned int set,
unsigned int clear); unsigned int clear);
static int keyspan_fake_startup (struct usb_serial *serial); static int keyspan_fake_startup (struct usb_serial *serial);
...@@ -567,10 +564,6 @@ static struct usb_serial_driver keyspan_1port_device = { ...@@ -567,10 +564,6 @@ static struct usb_serial_driver keyspan_1port_device = {
.close = keyspan_close, .close = keyspan_close,
.write = keyspan_write, .write = keyspan_write,
.write_room = keyspan_write_room, .write_room = keyspan_write_room,
.chars_in_buffer = keyspan_chars_in_buffer,
.throttle = keyspan_rx_throttle,
.unthrottle = keyspan_rx_unthrottle,
.ioctl = keyspan_ioctl,
.set_termios = keyspan_set_termios, .set_termios = keyspan_set_termios,
.break_ctl = keyspan_break_ctl, .break_ctl = keyspan_break_ctl,
.tiocmget = keyspan_tiocmget, .tiocmget = keyspan_tiocmget,
...@@ -591,10 +584,6 @@ static struct usb_serial_driver keyspan_2port_device = { ...@@ -591,10 +584,6 @@ static struct usb_serial_driver keyspan_2port_device = {
.close = keyspan_close, .close = keyspan_close,
.write = keyspan_write, .write = keyspan_write,
.write_room = keyspan_write_room, .write_room = keyspan_write_room,
.chars_in_buffer = keyspan_chars_in_buffer,
.throttle = keyspan_rx_throttle,
.unthrottle = keyspan_rx_unthrottle,
.ioctl = keyspan_ioctl,
.set_termios = keyspan_set_termios, .set_termios = keyspan_set_termios,
.break_ctl = keyspan_break_ctl, .break_ctl = keyspan_break_ctl,
.tiocmget = keyspan_tiocmget, .tiocmget = keyspan_tiocmget,
...@@ -615,10 +604,6 @@ static struct usb_serial_driver keyspan_4port_device = { ...@@ -615,10 +604,6 @@ static struct usb_serial_driver keyspan_4port_device = {
.close = keyspan_close, .close = keyspan_close,
.write = keyspan_write, .write = keyspan_write,
.write_room = keyspan_write_room, .write_room = keyspan_write_room,
.chars_in_buffer = keyspan_chars_in_buffer,
.throttle = keyspan_rx_throttle,
.unthrottle = keyspan_rx_unthrottle,
.ioctl = keyspan_ioctl,
.set_termios = keyspan_set_termios, .set_termios = keyspan_set_termios,
.break_ctl = keyspan_break_ctl, .break_ctl = keyspan_break_ctl,
.tiocmget = keyspan_tiocmget, .tiocmget = keyspan_tiocmget,
......
...@@ -171,7 +171,7 @@ static void keyspan_pda_wakeup_write(struct work_struct *work) ...@@ -171,7 +171,7 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
container_of(work, struct keyspan_pda_private, wakeup_work); container_of(work, struct keyspan_pda_private, wakeup_work);
struct usb_serial_port *port = priv->port; struct usb_serial_port *port = priv->port;
tty_wakeup(port->tty); tty_wakeup(port->port.tty);
} }
static void keyspan_pda_request_unthrottle(struct work_struct *work) static void keyspan_pda_request_unthrottle(struct work_struct *work)
...@@ -203,7 +203,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) ...@@ -203,7 +203,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
static void keyspan_pda_rx_interrupt (struct urb *urb) static void keyspan_pda_rx_interrupt (struct urb *urb)
{ {
struct usb_serial_port *port = urb->context; struct usb_serial_port *port = urb->context;
struct tty_struct *tty = port->tty; struct tty_struct *tty = port->port.tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int i; int i;
int retval; int retval;
...@@ -266,7 +266,7 @@ static void keyspan_pda_rx_interrupt (struct urb *urb) ...@@ -266,7 +266,7 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
} }
static void keyspan_pda_rx_throttle (struct usb_serial_port *port) static void keyspan_pda_rx_throttle(struct tty_struct *tty)
{ {
/* stop receiving characters. We just turn off the URB request, and /* stop receiving characters. We just turn off the URB request, and
let chars pile up in the device. If we're doing hardware let chars pile up in the device. If we're doing hardware
...@@ -274,14 +274,15 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port) ...@@ -274,14 +274,15 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port)
fills up. If we're doing XON/XOFF, this would be a good time to fills up. If we're doing XON/XOFF, this would be a good time to
send an XOFF, although it might make sense to foist that off send an XOFF, although it might make sense to foist that off
upon the device too. */ upon the device too. */
struct usb_serial_port *port = tty->driver_data;
dbg("keyspan_pda_rx_throttle port %d", port->number); dbg("keyspan_pda_rx_throttle port %d", port->number);
usb_kill_urb(port->interrupt_in_urb); usb_kill_urb(port->interrupt_in_urb);
} }
static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port) static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
/* just restart the receive interrupt URB */ /* just restart the receive interrupt URB */
dbg("keyspan_pda_rx_unthrottle port %d", port->number); dbg("keyspan_pda_rx_unthrottle port %d", port->number);
port->interrupt_in_urb->dev = port->serial->dev; port->interrupt_in_urb->dev = port->serial->dev;
...@@ -330,8 +331,9 @@ static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) ...@@ -330,8 +331,9 @@ static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud)
} }
static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state) static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int value; int value;
int result; int result;
...@@ -354,8 +356,8 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state ...@@ -354,8 +356,8 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
} }
static void keyspan_pda_set_termios (struct usb_serial_port *port, static void keyspan_pda_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
speed_t speed; speed_t speed;
...@@ -380,7 +382,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, ...@@ -380,7 +382,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
For now, just do baud. */ For now, just do baud. */
speed = tty_get_baud_rate(port->tty); speed = tty_get_baud_rate(tty);
speed = keyspan_pda_setbaud(serial, speed); speed = keyspan_pda_setbaud(serial, speed);
if (speed == 0) { if (speed == 0) {
...@@ -390,8 +392,8 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, ...@@ -390,8 +392,8 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
} }
/* Only speed can change so copy the old h/w parameters /* Only speed can change so copy the old h/w parameters
then encode the new speed */ then encode the new speed */
tty_termios_copy_hw(port->tty->termios, old_termios); tty_termios_copy_hw(tty->termios, old_termios);
tty_encode_baud_rate(port->tty, speed, speed); tty_encode_baud_rate(tty, speed, speed);
} }
...@@ -425,8 +427,9 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial, ...@@ -425,8 +427,9 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial,
return rc; return rc;
} }
static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file) static int keyspan_pda_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int rc; int rc;
unsigned char status; unsigned char status;
...@@ -445,9 +448,10 @@ static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file) ...@@ -445,9 +448,10 @@ static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
return value; return value;
} }
static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file, static int keyspan_pda_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int rc; int rc;
unsigned char status; unsigned char status;
...@@ -469,23 +473,8 @@ static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -469,23 +473,8 @@ static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file,
return rc; return rc;
} }
static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file, static int keyspan_pda_write(struct tty_struct *tty,
unsigned int cmd, unsigned long arg) struct usb_serial_port *port, const unsigned char *buf, int count)
{
switch (cmd) {
case TIOCMIWAIT:
/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
/* TODO */
case TIOCGICOUNT:
/* return count of modemline transitions */
return 0; /* TODO */
}
return -ENOIOCTLCMD;
}
static int keyspan_pda_write(struct usb_serial_port *port,
const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
int request_unthrottle = 0; int request_unthrottle = 0;
...@@ -607,22 +596,21 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb) ...@@ -607,22 +596,21 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb)
} }
static int keyspan_pda_write_room (struct usb_serial_port *port) static int keyspan_pda_write_room(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
priv = usb_get_serial_port_data(port); priv = usb_get_serial_port_data(port);
/* used by n_tty.c for processing of tabs and such. Giving it our /* used by n_tty.c for processing of tabs and such. Giving it our
conservative guess is probably good enough, but needs testing by conservative guess is probably good enough, but needs testing by
running a console through the device. */ running a console through the device. */
return (priv->tx_room); return (priv->tx_room);
} }
static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) static int keyspan_pda_chars_in_buffer(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct keyspan_pda_private *priv; struct keyspan_pda_private *priv;
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
...@@ -640,7 +628,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) ...@@ -640,7 +628,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
} }
static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) static int keyspan_pda_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
unsigned char room; unsigned char room;
...@@ -672,7 +661,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) ...@@ -672,7 +661,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
/* the normal serial device seems to always turn on DTR and RTS here, /* the normal serial device seems to always turn on DTR and RTS here,
so do the same */ so do the same */
if (port->tty->termios->c_cflag & CBAUD) if (tty && (tty->termios->c_cflag & CBAUD))
keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) ); keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) );
else else
keyspan_pda_set_modem_info(serial, 0); keyspan_pda_set_modem_info(serial, 0);
...@@ -690,13 +679,14 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) ...@@ -690,13 +679,14 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
} }
static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) static void keyspan_pda_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
if (serial->dev) { if (serial->dev) {
/* the normal serial device seems to always shut off DTR and RTS now */ /* the normal serial device seems to always shut off DTR and RTS now */
if (port->tty->termios->c_cflag & HUPCL) if (tty->termios->c_cflag & HUPCL)
keyspan_pda_set_modem_info(serial, 0); keyspan_pda_set_modem_info(serial, 0);
/* shutdown our bulk reads and writes */ /* shutdown our bulk reads and writes */
...@@ -832,7 +822,6 @@ static struct usb_serial_driver keyspan_pda_device = { ...@@ -832,7 +822,6 @@ static struct usb_serial_driver keyspan_pda_device = {
.chars_in_buffer = keyspan_pda_chars_in_buffer, .chars_in_buffer = keyspan_pda_chars_in_buffer,
.throttle = keyspan_pda_rx_throttle, .throttle = keyspan_pda_rx_throttle,
.unthrottle = keyspan_pda_rx_unthrottle, .unthrottle = keyspan_pda_rx_unthrottle,
.ioctl = keyspan_pda_ioctl,
.set_termios = keyspan_pda_set_termios, .set_termios = keyspan_pda_set_termios,
.break_ctl = keyspan_pda_break_ctl, .break_ctl = keyspan_pda_break_ctl,
.tiocmget = keyspan_pda_tiocmget, .tiocmget = keyspan_pda_tiocmget,
......
...@@ -74,29 +74,33 @@ static int debug; ...@@ -74,29 +74,33 @@ static int debug;
*/ */
static int klsi_105_startup (struct usb_serial *serial); static int klsi_105_startup (struct usb_serial *serial);
static void klsi_105_shutdown (struct usb_serial *serial); static void klsi_105_shutdown (struct usb_serial *serial);
static int klsi_105_open (struct usb_serial_port *port, static int klsi_105_open (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static void klsi_105_close (struct usb_serial_port *port, static void klsi_105_close (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static int klsi_105_write (struct usb_serial_port *port, static int klsi_105_write (struct tty_struct *tty,
struct usb_serial_port *port,
const unsigned char *buf, const unsigned char *buf,
int count); int count);
static void klsi_105_write_bulk_callback (struct urb *urb); static void klsi_105_write_bulk_callback (struct urb *urb);
static int klsi_105_chars_in_buffer (struct usb_serial_port *port); static int klsi_105_chars_in_buffer (struct tty_struct *tty);
static int klsi_105_write_room (struct usb_serial_port *port); static int klsi_105_write_room (struct tty_struct *tty);
static void klsi_105_read_bulk_callback (struct urb *urb); static void klsi_105_read_bulk_callback (struct urb *urb);
static void klsi_105_set_termios (struct usb_serial_port *port, static void klsi_105_set_termios (struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios *old); struct ktermios *old);
static void klsi_105_throttle (struct usb_serial_port *port); static void klsi_105_throttle (struct tty_struct *tty);
static void klsi_105_unthrottle (struct usb_serial_port *port); static void klsi_105_unthrottle (struct tty_struct *tty);
/* /*
static void klsi_105_break_ctl (struct usb_serial_port *port, static void klsi_105_break_ctl (struct tty_struct *tty,
int break_state ); int break_state );
*/ */
static int klsi_105_tiocmget (struct usb_serial_port *port, static int klsi_105_tiocmget (struct tty_struct *tty,
struct file *file); struct file *file);
static int klsi_105_tiocmset (struct usb_serial_port *port, static int klsi_105_tiocmset (struct tty_struct *tty,
struct file *file, unsigned int set, struct file *file, unsigned int set,
unsigned int clear); unsigned int clear);
...@@ -361,7 +365,8 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -361,7 +365,8 @@ static void klsi_105_shutdown (struct usb_serial *serial)
} }
} /* klsi_105_shutdown */ } /* klsi_105_shutdown */
static int klsi_105_open (struct usb_serial_port *port, struct file *filp) static int klsi_105_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int retval = 0; int retval = 0;
...@@ -375,7 +380,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -375,7 +380,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
/* force low_latency on so that our tty_push actually forces /* force low_latency on so that our tty_push actually forces
* the data through * the data through
* port->tty->low_latency = 1; */ * tty->low_latency = 1; */
/* Do a defined restart: /* Do a defined restart:
* Set up sane default baud rate and send the 'READ_ON' * Set up sane default baud rate and send the 'READ_ON'
...@@ -393,12 +398,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -393,12 +398,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
/* set up termios structure */ /* set up termios structure */
spin_lock_irqsave (&priv->lock, flags); spin_lock_irqsave (&priv->lock, flags);
priv->termios.c_iflag = port->tty->termios->c_iflag; priv->termios.c_iflag = tty->termios->c_iflag;
priv->termios.c_oflag = port->tty->termios->c_oflag; priv->termios.c_oflag = tty->termios->c_oflag;
priv->termios.c_cflag = port->tty->termios->c_cflag; priv->termios.c_cflag = tty->termios->c_cflag;
priv->termios.c_lflag = port->tty->termios->c_lflag; priv->termios.c_lflag = tty->termios->c_lflag;
for (i=0; i<NCCS; i++) for (i=0; i<NCCS; i++)
priv->termios.c_cc[i] = port->tty->termios->c_cc[i]; priv->termios.c_cc[i] = tty->termios->c_cc[i];
priv->cfg.pktlen = cfg.pktlen; priv->cfg.pktlen = cfg.pktlen;
priv->cfg.baudrate = cfg.baudrate; priv->cfg.baudrate = cfg.baudrate;
priv->cfg.databits = cfg.databits; priv->cfg.databits = cfg.databits;
...@@ -452,7 +457,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -452,7 +457,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
} /* klsi_105_open */ } /* klsi_105_open */
static void klsi_105_close (struct usb_serial_port *port, struct file *filp) static void klsi_105_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int rc; int rc;
...@@ -493,8 +499,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) ...@@ -493,8 +499,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
#define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ #define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */
static int klsi_105_write (struct usb_serial_port *port, static int klsi_105_write(struct tty_struct *tty,
const unsigned char *buf, int count) struct usb_serial_port *port, const unsigned char *buf, int count)
{ {
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int result, size; int result, size;
...@@ -584,8 +590,9 @@ static void klsi_105_write_bulk_callback ( struct urb *urb) ...@@ -584,8 +590,9 @@ static void klsi_105_write_bulk_callback ( struct urb *urb)
/* return number of characters currently in the writing process */ /* return number of characters currently in the writing process */
static int klsi_105_chars_in_buffer (struct usb_serial_port *port) static int klsi_105_chars_in_buffer (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int chars = 0; int chars = 0;
int i; int i;
unsigned long flags; unsigned long flags;
...@@ -605,8 +612,9 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port) ...@@ -605,8 +612,9 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
return (chars); return (chars);
} }
static int klsi_105_write_room (struct usb_serial_port *port) static int klsi_105_write_room (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
unsigned long flags; unsigned long flags;
int i; int i;
int room = 0; int room = 0;
...@@ -660,7 +668,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb) ...@@ -660,7 +668,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
} else { } else {
int bytes_sent = ((__u8 *) data)[0] + int bytes_sent = ((__u8 *) data)[0] +
((unsigned int) ((__u8 *) data)[1] << 8); ((unsigned int) ((__u8 *) data)[1] << 8);
tty = port->tty; tty = port->port.tty;
/* we should immediately resubmit the URB, before attempting /* we should immediately resubmit the URB, before attempting
* to pass the data on to the tty layer. But that needs locking * to pass the data on to the tty layer. But that needs locking
* against re-entry an then mixed-up data because of * against re-entry an then mixed-up data because of
...@@ -699,11 +707,11 @@ static void klsi_105_read_bulk_callback (struct urb *urb) ...@@ -699,11 +707,11 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
} /* klsi_105_read_bulk_callback */ } /* klsi_105_read_bulk_callback */
static void klsi_105_set_termios (struct usb_serial_port *port, static void klsi_105_set_termios (struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty = port->tty;
unsigned int iflag = tty->termios->c_iflag; unsigned int iflag = tty->termios->c_iflag;
unsigned int old_iflag = old_termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag;
unsigned int cflag = tty->termios->c_cflag; unsigned int cflag = tty->termios->c_cflag;
...@@ -863,8 +871,9 @@ static void klsi_105_set_termios (struct usb_serial_port *port, ...@@ -863,8 +871,9 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
#if 0 #if 0
static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) static void mct_u232_break_ctl( struct tty_struct *tty, int break_state )
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = (struct mct_u232_private *)port->private; struct mct_u232_private *priv = (struct mct_u232_private *)port->private;
unsigned char lcr = priv->last_lcr; unsigned char lcr = priv->last_lcr;
...@@ -878,8 +887,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -878,8 +887,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
} /* mct_u232_break_ctl */ } /* mct_u232_break_ctl */
#endif #endif
static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
int rc; int rc;
...@@ -900,7 +910,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -900,7 +910,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
return (int)line_state; return (int)line_state;
} }
static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
int retval = -EINVAL; int retval = -EINVAL;
...@@ -929,14 +939,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, ...@@ -929,14 +939,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
return retval; return retval;
} }
static void klsi_105_throttle (struct usb_serial_port *port) static void klsi_105_throttle (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
usb_kill_urb(port->read_urb); usb_kill_urb(port->read_urb);
} }
static void klsi_105_unthrottle (struct usb_serial_port *port) static void klsi_105_unthrottle (struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
int result; int result;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
......
...@@ -70,19 +70,22 @@ static int debug; ...@@ -70,19 +70,22 @@ static int debug;
/* Function prototypes */ /* Function prototypes */
static int kobil_startup (struct usb_serial *serial); static int kobil_startup (struct usb_serial *serial);
static void kobil_shutdown (struct usb_serial *serial); static void kobil_shutdown (struct usb_serial *serial);
static int kobil_open (struct usb_serial_port *port, struct file *filp); static int kobil_open (struct tty_struct *tty,
static void kobil_close (struct usb_serial_port *port, struct file *filp); struct usb_serial_port *port, struct file *filp);
static int kobil_write (struct usb_serial_port *port, static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp);
static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count); const unsigned char *buf, int count);
static int kobil_write_room(struct usb_serial_port *port); static int kobil_write_room(struct tty_struct *tty);
static int kobil_ioctl(struct usb_serial_port *port, struct file *file, static int kobil_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static int kobil_tiocmget(struct usb_serial_port *port, struct file *file); static int kobil_tiocmget(struct tty_struct *tty, struct file *file);
static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear); unsigned int set, unsigned int clear);
static void kobil_read_int_callback( struct urb *urb ); static void kobil_read_int_callback( struct urb *urb );
static void kobil_write_callback( struct urb *purb ); static void kobil_write_callback( struct urb *purb );
static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old); static void kobil_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old);
static struct usb_device_id id_table [] = { static struct usb_device_id id_table [] = {
...@@ -201,8 +204,8 @@ static void kobil_shutdown (struct usb_serial *serial) ...@@ -201,8 +204,8 @@ static void kobil_shutdown (struct usb_serial *serial)
dbg("%s - port %d", __func__, serial->port[0]->number); dbg("%s - port %d", __func__, serial->port[0]->number);
for (i=0; i < serial->num_ports; ++i) { for (i=0; i < serial->num_ports; ++i) {
while (serial->port[i]->open_count > 0) { while (serial->port[i]->port.count > 0) {
kobil_close (serial->port[i], NULL); kobil_close (NULL, serial->port[i], NULL);
} }
kfree(usb_get_serial_port_data(serial->port[i])); kfree(usb_get_serial_port_data(serial->port[i]));
usb_set_serial_port_data(serial->port[i], NULL); usb_set_serial_port_data(serial->port[i], NULL);
...@@ -210,7 +213,8 @@ static void kobil_shutdown (struct usb_serial *serial) ...@@ -210,7 +213,8 @@ static void kobil_shutdown (struct usb_serial *serial)
} }
static int kobil_open (struct usb_serial_port *port, struct file *filp) static int kobil_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
int result = 0; int result = 0;
struct kobil_private *priv; struct kobil_private *priv;
...@@ -229,14 +233,15 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) ...@@ -229,14 +233,15 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
* the data through, otherwise it is scheduled, and with high * the data through, otherwise it is scheduled, and with high
* data rates (like with OHCI) data can get lost. * data rates (like with OHCI) data can get lost.
*/ */
port->tty->low_latency = 1; if (tty) {
tty->low_latency = 1;
// without this, every push_tty_char is echoed :-(
port->tty->termios->c_lflag = 0;
port->tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D)
/* Default to echo off and other sane device settings */
tty->termios->c_lflag = 0;
tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D)
}
// allocate memory for transfer buffer // allocate memory for transfer buffer
transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
if (! transfer_buffer) { if (! transfer_buffer) {
...@@ -330,7 +335,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) ...@@ -330,7 +335,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
} }
static void kobil_close (struct usb_serial_port *port, struct file *filp) static void kobil_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -360,7 +366,7 @@ static void kobil_read_int_callback(struct urb *urb) ...@@ -360,7 +366,7 @@ static void kobil_read_int_callback(struct urb *urb)
return; return;
} }
tty = port->tty; tty = port->port.tty;
if (urb->actual_length) { if (urb->actual_length) {
// BEGIN DEBUG // BEGIN DEBUG
...@@ -395,7 +401,7 @@ static void kobil_write_callback( struct urb *purb ) ...@@ -395,7 +401,7 @@ static void kobil_write_callback( struct urb *purb )
} }
static int kobil_write (struct usb_serial_port *port, static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
int length = 0; int length = 0;
...@@ -417,12 +423,9 @@ static int kobil_write (struct usb_serial_port *port, ...@@ -417,12 +423,9 @@ static int kobil_write (struct usb_serial_port *port,
// Copy data to buffer // Copy data to buffer
memcpy (priv->buf + priv->filled, buf, count); memcpy (priv->buf + priv->filled, buf, count);
usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled);
priv->filled = priv->filled + count; priv->filled = priv->filled + count;
// only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol.
if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) ||
((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
...@@ -478,15 +481,17 @@ static int kobil_write (struct usb_serial_port *port, ...@@ -478,15 +481,17 @@ static int kobil_write (struct usb_serial_port *port,
} }
static int kobil_write_room (struct usb_serial_port *port) static int kobil_write_room (struct tty_struct *tty)
{ {
//dbg("%s - port %d", __func__, port->number); //dbg("%s - port %d", __func__, port->number);
/* FIXME */
return 8; return 8;
} }
static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) static int kobil_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct kobil_private * priv; struct kobil_private * priv;
int result; int result;
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
...@@ -524,9 +529,10 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) ...@@ -524,9 +529,10 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
return result; return result;
} }
static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct kobil_private * priv; struct kobil_private * priv;
int result; int result;
int dtr = 0; int dtr = 0;
...@@ -590,12 +596,13 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, ...@@ -590,12 +596,13 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
return (result < 0) ? result : 0; return (result < 0) ? result : 0;
} }
static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old) static void kobil_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old)
{ {
struct kobil_private * priv; struct kobil_private * priv;
int result; int result;
unsigned short urb_val = 0; unsigned short urb_val = 0;
int c_cflag = port->tty->termios->c_cflag; int c_cflag = tty->termios->c_cflag;
speed_t speed; speed_t speed;
void * settings; void * settings;
...@@ -604,7 +611,7 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old ...@@ -604,7 +611,7 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
// This device doesn't support ioctl calls // This device doesn't support ioctl calls
return; return;
switch (speed = tty_get_baud_rate(port->tty)) { switch (speed = tty_get_baud_rate(tty)) {
case 1200: case 1200:
urb_val = SUSBCR_SBR_1200; urb_val = SUSBCR_SBR_1200;
break; break;
...@@ -634,8 +641,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old ...@@ -634,8 +641,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
urb_val |= SUSBCR_SPASB_NoParity; urb_val |= SUSBCR_SPASB_NoParity;
strcat(settings, "No Parity"); strcat(settings, "No Parity");
} }
port->tty->termios->c_cflag &= ~CMSPAR; tty->termios->c_cflag &= ~CMSPAR;
tty_encode_baud_rate(port->tty, speed, speed); tty_encode_baud_rate(tty, speed, speed);
result = usb_control_msg( port->serial->dev, result = usb_control_msg( port->serial->dev,
usb_rcvctrlpipe(port->serial->dev, 0 ), usb_rcvctrlpipe(port->serial->dev, 0 ),
...@@ -650,8 +657,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old ...@@ -650,8 +657,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
kfree(settings); kfree(settings);
} }
static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
{ {
struct usb_serial_port *port = tty->driver_data;
struct kobil_private * priv = usb_get_serial_port_data(port); struct kobil_private * priv = usb_get_serial_port_data(port);
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
int transfer_buffer_length = 8; int transfer_buffer_length = 8;
...@@ -662,7 +670,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne ...@@ -662,7 +670,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne
return 0; return 0;
switch (cmd) { switch (cmd) {
case TCFLSH: // 0x540B case TCFLSH:
transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
if (! transfer_buffer) if (! transfer_buffer)
return -ENOBUFS; return -ENOBUFS;
...@@ -680,7 +688,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne ...@@ -680,7 +688,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne
dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result);
kfree(transfer_buffer); kfree(transfer_buffer);
return (result < 0) ? -EFAULT : 0; return (result < 0) ? -EIO: 0;
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
...@@ -92,26 +92,25 @@ static int debug; ...@@ -92,26 +92,25 @@ static int debug;
*/ */
static int mct_u232_startup (struct usb_serial *serial); static int mct_u232_startup (struct usb_serial *serial);
static void mct_u232_shutdown (struct usb_serial *serial); static void mct_u232_shutdown (struct usb_serial *serial);
static int mct_u232_open (struct usb_serial_port *port, static int mct_u232_open (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static void mct_u232_close (struct usb_serial_port *port, static void mct_u232_close (struct tty_struct *tty,
struct usb_serial_port *port,
struct file *filp); struct file *filp);
static void mct_u232_read_int_callback (struct urb *urb); static void mct_u232_read_int_callback (struct urb *urb);
static void mct_u232_set_termios (struct usb_serial_port *port, static void mct_u232_set_termios (struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios * old); struct ktermios * old);
static int mct_u232_ioctl (struct usb_serial_port *port, static void mct_u232_break_ctl (struct tty_struct *tty,
struct file * file,
unsigned int cmd,
unsigned long arg);
static void mct_u232_break_ctl (struct usb_serial_port *port,
int break_state ); int break_state );
static int mct_u232_tiocmget (struct usb_serial_port *port, static int mct_u232_tiocmget (struct tty_struct *tty,
struct file *file); struct file *file);
static int mct_u232_tiocmset (struct usb_serial_port *port, static int mct_u232_tiocmset (struct tty_struct *tty,
struct file *file, unsigned int set, struct file *file, unsigned int set,
unsigned int clear); unsigned int clear);
static void mct_u232_throttle (struct usb_serial_port *port); static void mct_u232_throttle (struct tty_struct *tty);
static void mct_u232_unthrottle (struct usb_serial_port *port); static void mct_u232_unthrottle (struct tty_struct *tty);
/* /*
...@@ -149,7 +148,6 @@ static struct usb_serial_driver mct_u232_device = { ...@@ -149,7 +148,6 @@ static struct usb_serial_driver mct_u232_device = {
.throttle = mct_u232_throttle, .throttle = mct_u232_throttle,
.unthrottle = mct_u232_unthrottle, .unthrottle = mct_u232_unthrottle,
.read_int_callback = mct_u232_read_int_callback, .read_int_callback = mct_u232_read_int_callback,
.ioctl = mct_u232_ioctl,
.set_termios = mct_u232_set_termios, .set_termios = mct_u232_set_termios,
.break_ctl = mct_u232_break_ctl, .break_ctl = mct_u232_break_ctl,
.tiocmget = mct_u232_tiocmget, .tiocmget = mct_u232_tiocmget,
...@@ -224,8 +222,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value ...@@ -224,8 +222,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value
} }
} }
static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, static int mct_u232_set_baud_rate(struct tty_struct *tty,
speed_t value) struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
{ {
__le32 divisor; __le32 divisor;
int rc; int rc;
...@@ -243,7 +241,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p ...@@ -243,7 +241,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p
if (rc < 0) /*FIXME: What value speed results */ if (rc < 0) /*FIXME: What value speed results */
err("Set BAUD RATE %d failed (error = %d)", value, rc); err("Set BAUD RATE %d failed (error = %d)", value, rc);
else else
tty_encode_baud_rate(port->tty, speed, speed); tty_encode_baud_rate(tty, speed, speed);
dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor);
/* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which
...@@ -272,7 +270,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p ...@@ -272,7 +270,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p
err("Sending USB device request code %d failed (error = %d)", err("Sending USB device request code %d failed (error = %d)",
MCT_U232_SET_UNKNOWN1_REQUEST, rc); MCT_U232_SET_UNKNOWN1_REQUEST, rc);
if (port && C_CRTSCTS(port->tty)) { if (port && C_CRTSCTS(tty)) {
cts_enable_byte = 1; cts_enable_byte = 1;
} }
...@@ -411,7 +409,8 @@ static void mct_u232_shutdown (struct usb_serial *serial) ...@@ -411,7 +409,8 @@ static void mct_u232_shutdown (struct usb_serial *serial)
} }
} /* mct_u232_shutdown */ } /* mct_u232_shutdown */
static int mct_u232_open (struct usb_serial_port *port, struct file *filp) static int mct_u232_open (struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
...@@ -437,7 +436,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) ...@@ -437,7 +436,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
* either. * either.
*/ */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if (port->tty->termios->c_cflag & CBAUD) if (tty && (tty->termios->c_cflag & CBAUD))
priv->control_state = TIOCM_DTR | TIOCM_RTS; priv->control_state = TIOCM_DTR | TIOCM_RTS;
else else
priv->control_state = 0; priv->control_state = 0;
...@@ -481,15 +480,16 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) ...@@ -481,15 +480,16 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
} /* mct_u232_open */ } /* mct_u232_open */
static void mct_u232_close (struct usb_serial_port *port, struct file *filp) static void mct_u232_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
unsigned int c_cflag; unsigned int c_cflag;
unsigned int control_state; unsigned int control_state;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
dbg("%s port %d", __func__, port->number); dbg("%s port %d", __func__, port->number);
if (port->tty) { if (tty) {
c_cflag = port->tty->termios->c_cflag; c_cflag = tty->termios->c_cflag;
mutex_lock(&port->serial->disc_mutex); mutex_lock(&port->serial->disc_mutex);
if (c_cflag & HUPCL && !port->serial->disconnected) { if (c_cflag & HUPCL && !port->serial->disconnected) {
/* drop DTR and RTS */ /* drop DTR and RTS */
...@@ -553,7 +553,7 @@ static void mct_u232_read_int_callback (struct urb *urb) ...@@ -553,7 +553,7 @@ static void mct_u232_read_int_callback (struct urb *urb)
*/ */
if (urb->transfer_buffer_length > 2) { if (urb->transfer_buffer_length > 2) {
int i; int i;
tty = 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);
...@@ -583,7 +583,7 @@ static void mct_u232_read_int_callback (struct urb *urb) ...@@ -583,7 +583,7 @@ static void mct_u232_read_int_callback (struct urb *urb)
* to look in to this before committing any code. * to look in to this before committing any code.
*/ */
if (priv->last_lsr & MCT_U232_LSR_ERR) { if (priv->last_lsr & MCT_U232_LSR_ERR) {
tty = port->tty; tty = port->port.tty;
/* Overrun Error */ /* Overrun Error */
if (priv->last_lsr & MCT_U232_LSR_OE) { if (priv->last_lsr & MCT_U232_LSR_OE) {
} }
...@@ -606,12 +606,13 @@ static void mct_u232_read_int_callback (struct urb *urb) ...@@ -606,12 +606,13 @@ static void mct_u232_read_int_callback (struct urb *urb)
__func__, retval); __func__, retval);
} /* mct_u232_read_int_callback */ } /* mct_u232_read_int_callback */
static void mct_u232_set_termios (struct usb_serial_port *port, static void mct_u232_set_termios (struct tty_struct *tty,
struct usb_serial_port *port,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
struct ktermios *termios = port->tty->termios; struct ktermios *termios = tty->termios;
unsigned int cflag = termios->c_cflag; unsigned int cflag = termios->c_cflag;
unsigned int old_cflag = old_termios->c_cflag; unsigned int old_cflag = old_termios->c_cflag;
unsigned long flags; unsigned long flags;
...@@ -638,7 +639,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, ...@@ -638,7 +639,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
mct_u232_set_modem_ctrl(serial, control_state); mct_u232_set_modem_ctrl(serial, control_state);
} }
mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
if ((cflag & CBAUD) == B0 ) { if ((cflag & CBAUD) == B0 ) {
dbg("%s: baud is B0", __func__); dbg("%s: baud is B0", __func__);
...@@ -689,8 +690,9 @@ static void mct_u232_set_termios (struct usb_serial_port *port, ...@@ -689,8 +690,9 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
} /* mct_u232_set_termios */ } /* mct_u232_set_termios */
static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned char lcr; unsigned char lcr;
...@@ -709,8 +711,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -709,8 +711,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
} /* mct_u232_break_ctl */ } /* mct_u232_break_ctl */
static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)
{ {
struct usb_serial_port *port = tty->driver_data;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned int control_state; unsigned int control_state;
unsigned long flags; unsigned long flags;
...@@ -724,9 +727,10 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) ...@@ -724,9 +727,10 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
return control_state; return control_state;
} }
static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned int control_state; unsigned int control_state;
...@@ -751,39 +755,13 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, ...@@ -751,39 +755,13 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
return mct_u232_set_modem_ctrl(serial, control_state); return mct_u232_set_modem_ctrl(serial, control_state);
} }
static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, static void mct_u232_throttle(struct tty_struct *tty)
unsigned int cmd, unsigned long arg)
{
dbg("%scmd=0x%x", __func__, cmd);
/* Based on code from acm.c and others */
switch (cmd) {
case TIOCMIWAIT:
/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
/* TODO */
return( 0 );
case TIOCGICOUNT:
/* return count of modemline transitions */
/* TODO */
return 0;
default:
dbg("%s: arg not supported - 0x%04x", __func__,cmd);
return(-ENOIOCTLCMD);
break;
}
return 0;
} /* mct_u232_ioctl */
static void mct_u232_throttle (struct usb_serial_port *port)
{ {
struct usb_serial_port *port = tty->driver_data;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
unsigned int control_state; unsigned int control_state;
struct tty_struct *tty;
tty = port->tty;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -799,16 +777,15 @@ static void mct_u232_throttle (struct usb_serial_port *port) ...@@ -799,16 +777,15 @@ static void mct_u232_throttle (struct usb_serial_port *port)
} }
static void mct_u232_unthrottle (struct usb_serial_port *port) static void mct_u232_unthrottle(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
unsigned int control_state; unsigned int control_state;
struct tty_struct *tty;
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
tty = port->tty;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) { if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) {
priv->rx_flags &= ~THROTTLED; priv->rx_flags &= ~THROTTLED;
......
此差异已折叠。
此差异已折叠。
...@@ -64,7 +64,7 @@ static void navman_read_int_callback(struct urb *urb) ...@@ -64,7 +64,7 @@ static void navman_read_int_callback(struct urb *urb)
usb_serial_debug_data(debug, &port->dev, __func__, usb_serial_debug_data(debug, &port->dev, __func__,
urb->actual_length, data); urb->actual_length, data);
tty = port->tty; tty = port->port.tty;
if (tty && urb->actual_length) { if (tty && urb->actual_length) {
tty_buffer_request_room(tty, urb->actual_length); tty_buffer_request_room(tty, urb->actual_length);
tty_insert_flip_string(tty, data, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length);
...@@ -79,7 +79,8 @@ static void navman_read_int_callback(struct urb *urb) ...@@ -79,7 +79,8 @@ static void navman_read_int_callback(struct urb *urb)
__func__, result); __func__, result);
} }
static int navman_open(struct usb_serial_port *port, struct file *filp) static int navman_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
int result = 0; int result = 0;
...@@ -96,14 +97,15 @@ static int navman_open(struct usb_serial_port *port, struct file *filp) ...@@ -96,14 +97,15 @@ static int navman_open(struct usb_serial_port *port, struct file *filp)
return result; return result;
} }
static void navman_close(struct usb_serial_port *port, struct file *filp) static void navman_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
usb_kill_urb(port->interrupt_in_urb); usb_kill_urb(port->interrupt_in_urb);
} }
static int navman_write(struct usb_serial_port *port, static int navman_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -31,10 +31,11 @@ static struct usb_driver debug_driver = { ...@@ -31,10 +31,11 @@ static struct usb_driver debug_driver = {
.no_dynamic_id = 1, .no_dynamic_id = 1,
}; };
int usb_debug_open(struct usb_serial_port *port, struct file *filp) int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
struct file *filp)
{ {
port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
return usb_serial_generic_open(port, filp); return usb_serial_generic_open(tty, port, filp);
} }
static struct usb_serial_driver debug_device = { static struct usb_serial_driver debug_device = {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册