Commit 95da310e authored by Alan Cox's avatar Alan Cox Committed by 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: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 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);
......
This diff is collapsed.
This diff is collapsed.
...@@ -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);
} }
......
This diff is collapsed.
...@@ -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,10 +1144,8 @@ static int garmin_write_bulk (struct usb_serial_port *port, ...@@ -1145,10 +1144,8 @@ 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,
const unsigned char *buf, int count)
static int garmin_write (struct usb_serial_port *port,
const unsigned char *buf, int count)
{ {
int pktid, pktsiz, len; int pktid, pktsiz, len;
struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
...@@ -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;
......
This diff is collapsed.
This diff is collapsed.
...@@ -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,
const unsigned char *buf, int count); struct file *filep);
static void ir_write_bulk_callback(struct urb *urb); static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
static void ir_read_bulk_callback(struct urb *urb); const unsigned char *buf, int count);
static void ir_set_termios(struct usb_serial_port *port, static void ir_write_bulk_callback (struct urb *urb);
struct ktermios *old_termios); static void ir_read_bulk_callback (struct urb *urb);
static void ir_set_termios(struct tty_struct *tty,
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,8 +355,8 @@ static void ir_close(struct usb_serial_port *port, struct file *filp) ...@@ -351,8 +355,8 @@ 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;
int result; int result;
...@@ -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,11 +478,10 @@ static void ir_read_bulk_callback(struct urb *urb) ...@@ -488,11 +478,10 @@ 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,
port->serial->dev, port->serial->dev,
usb_rcvbulkpipe(port->serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
...@@ -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__);
......
This diff is collapsed.
...@@ -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; /* Default to echo off and other sane device settings */
port->tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); tty->termios->c_lflag = 0;
port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) 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;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment