Commit 17fd4263 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

tty: USB serial termios bits

commit fe1ae7fd upstream.

Various drivers have hacks to mangle termios structures. This stems from
the fact there is no nice setup hook for configuring the termios settings
when the port is created
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fa31221e
...@@ -1184,6 +1184,7 @@ int tty_init_termios(struct tty_struct *tty) ...@@ -1184,6 +1184,7 @@ int tty_init_termios(struct tty_struct *tty)
tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios); tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(tty_init_termios);
/** /**
* tty_driver_install_tty() - install a tty entry in the driver * tty_driver_install_tty() - install a tty entry in the driver
......
...@@ -35,11 +35,6 @@ static struct usb_device_id id_table [] = { ...@@ -35,11 +35,6 @@ static struct usb_device_id id_table [] = {
}; };
MODULE_DEVICE_TABLE(usb, id_table); MODULE_DEVICE_TABLE(usb, id_table);
struct ark3116_private {
spinlock_t lock;
u8 termios_initialized;
};
static inline void ARK3116_SND(struct usb_serial *serial, int seq, static inline void ARK3116_SND(struct usb_serial *serial, int seq,
__u8 request, __u8 requesttype, __u8 request, __u8 requesttype,
__u16 value, __u16 index) __u16 value, __u16 index)
...@@ -82,22 +77,11 @@ static inline void ARK3116_RCV_QUIET(struct usb_serial *serial, ...@@ -82,22 +77,11 @@ static inline void ARK3116_RCV_QUIET(struct usb_serial *serial,
static int ark3116_attach(struct usb_serial *serial) static int ark3116_attach(struct usb_serial *serial)
{ {
char *buf; char *buf;
struct ark3116_private *priv;
int i;
for (i = 0; i < serial->num_ports; ++i) {
priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
if (!priv)
goto cleanup;
spin_lock_init(&priv->lock);
usb_set_serial_port_data(serial->port[i], priv);
}
buf = kmalloc(1, GFP_KERNEL); buf = kmalloc(1, GFP_KERNEL);
if (!buf) { if (!buf) {
dbg("error kmalloc -> out of mem?"); dbg("error kmalloc -> out of mem?");
goto cleanup; return -ENOMEM;
} }
/* 3 */ /* 3 */
...@@ -149,13 +133,16 @@ static int ark3116_attach(struct usb_serial *serial) ...@@ -149,13 +133,16 @@ static int ark3116_attach(struct usb_serial *serial)
kfree(buf); kfree(buf);
return 0; return 0;
}
cleanup: static void ark3116_init_termios(struct tty_struct *tty)
for (--i; i >= 0; --i) { {
kfree(usb_get_serial_port_data(serial->port[i])); struct ktermios *termios = tty->termios;
usb_set_serial_port_data(serial->port[i], NULL); *termios = tty_std_termios;
} termios->c_cflag = B9600 | CS8
return -ENOMEM; | CREAD | HUPCL | CLOCAL;
termios->c_ispeed = 9600;
termios->c_ospeed = 9600;
} }
static void ark3116_set_termios(struct tty_struct *tty, static void ark3116_set_termios(struct tty_struct *tty,
...@@ -163,10 +150,8 @@ static void ark3116_set_termios(struct tty_struct *tty, ...@@ -163,10 +150,8 @@ static void ark3116_set_termios(struct tty_struct *tty,
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 ktermios *termios = tty->termios; struct ktermios *termios = tty->termios;
unsigned int cflag = termios->c_cflag; unsigned int cflag = termios->c_cflag;
unsigned long flags;
int baud; int baud;
int ark3116_baud; int ark3116_baud;
char *buf; char *buf;
...@@ -176,16 +161,6 @@ static void ark3116_set_termios(struct tty_struct *tty, ...@@ -176,16 +161,6 @@ static void ark3116_set_termios(struct tty_struct *tty,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
spin_lock_irqsave(&priv->lock, flags);
if (!priv->termios_initialized) {
*termios = tty_std_termios;
termios->c_cflag = B9600 | CS8
| CREAD | HUPCL | CLOCAL;
termios->c_ispeed = 9600;
termios->c_ospeed = 9600;
priv->termios_initialized = 1;
}
spin_unlock_irqrestore(&priv->lock, flags);
cflag = termios->c_cflag; cflag = termios->c_cflag;
termios->c_cflag &= ~(CMSPAR|CRTSCTS); termios->c_cflag &= ~(CMSPAR|CRTSCTS);
...@@ -455,6 +430,7 @@ static struct usb_serial_driver ark3116_device = { ...@@ -455,6 +430,7 @@ static struct usb_serial_driver ark3116_device = {
.num_ports = 1, .num_ports = 1,
.attach = ark3116_attach, .attach = ark3116_attach,
.set_termios = ark3116_set_termios, .set_termios = ark3116_set_termios,
.init_termios = ark3116_init_termios,
.ioctl = ark3116_ioctl, .ioctl = ark3116_ioctl,
.tiocmget = ark3116_tiocmget, .tiocmget = ark3116_tiocmget,
.open = ark3116_open, .open = ark3116_open,
......
...@@ -659,15 +659,7 @@ static int cypress_open(struct tty_struct *tty, ...@@ -659,15 +659,7 @@ static int cypress_open(struct tty_struct *tty,
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* Set termios */ /* Set termios */
result = cypress_write(tty, port, NULL, 0); cypress_send(port);
if (result) {
dev_err(&port->dev,
"%s - failed setting the control lines - error %d\n",
__func__, result);
return result;
} else
dbg("%s - success setting the control lines", __func__);
if (tty) if (tty)
cypress_set_termios(tty, port, &priv->tmp_termios); cypress_set_termios(tty, port, &priv->tmp_termios);
...@@ -1005,6 +997,8 @@ static void cypress_set_termios(struct tty_struct *tty, ...@@ -1005,6 +997,8 @@ static void cypress_set_termios(struct tty_struct *tty,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
/* We can't clean this one up as we don't know the device type
early enough */
if (!priv->termios_initialized) { if (!priv->termios_initialized) {
if (priv->chiptype == CT_EARTHMATE) { if (priv->chiptype == CT_EARTHMATE) {
*(tty->termios) = tty_std_termios; *(tty->termios) = tty_std_termios;
......
...@@ -90,8 +90,7 @@ static int empeg_chars_in_buffer(struct tty_struct *tty); ...@@ -90,8 +90,7 @@ static int empeg_chars_in_buffer(struct tty_struct *tty);
static void empeg_throttle(struct tty_struct *tty); static void empeg_throttle(struct tty_struct *tty);
static void empeg_unthrottle(struct tty_struct *tty); 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_set_termios(struct tty_struct *tty, static void empeg_init_termios(struct tty_struct *tty);
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);
...@@ -123,7 +122,7 @@ static struct usb_serial_driver empeg_device = { ...@@ -123,7 +122,7 @@ static struct usb_serial_driver empeg_device = {
.throttle = empeg_throttle, .throttle = empeg_throttle,
.unthrottle = empeg_unthrottle, .unthrottle = empeg_unthrottle,
.attach = empeg_startup, .attach = empeg_startup,
.set_termios = empeg_set_termios, .init_termios = empeg_init_termios,
.write = empeg_write, .write = empeg_write,
.write_room = empeg_write_room, .write_room = empeg_write_room,
.chars_in_buffer = empeg_chars_in_buffer, .chars_in_buffer = empeg_chars_in_buffer,
...@@ -150,9 +149,6 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -150,9 +149,6 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
/* Force default termio settings */
empeg_set_termios(tty, port, NULL) ;
bytes_in = 0; bytes_in = 0;
bytes_out = 0; bytes_out = 0;
...@@ -425,11 +421,9 @@ static int empeg_startup(struct usb_serial *serial) ...@@ -425,11 +421,9 @@ static int empeg_startup(struct usb_serial *serial)
} }
static void empeg_set_termios(struct tty_struct *tty, static void empeg_init_termios(struct tty_struct *tty)
struct usb_serial_port *port, struct ktermios *old_termios)
{ {
struct ktermios *termios = tty->termios; struct ktermios *termios = tty->termios;
dbg("%s - port %d", __func__, port->number);
/* /*
* The empeg-car player wants these particular tty settings. * The empeg-car player wants these particular tty settings.
......
...@@ -71,7 +71,6 @@ struct iuu_private { ...@@ -71,7 +71,6 @@ struct iuu_private {
spinlock_t lock; /* store irq state */ spinlock_t lock; /* store irq state */
wait_queue_head_t delta_msr_wait; wait_queue_head_t delta_msr_wait;
u8 line_status; u8 line_status;
u8 termios_initialized;
int tiostatus; /* store IUART SIGNAL for tiocmget call */ int tiostatus; /* store IUART SIGNAL for tiocmget call */
u8 reset; /* if 1 reset is needed */ u8 reset; /* if 1 reset is needed */
int poll; /* number of poll */ int poll; /* number of poll */
...@@ -1018,6 +1017,18 @@ static void iuu_close(struct usb_serial_port *port) ...@@ -1018,6 +1017,18 @@ static void iuu_close(struct usb_serial_port *port)
} }
} }
static void iuu_init_termios(struct tty_struct *tty)
{
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
| TIOCM_CTS | CSTOPB | PARENB;
tty->termios->c_ispeed = 9600;
tty->termios->c_ospeed = 9600;
tty->termios->c_lflag = 0;
tty->termios->c_oflag = 0;
tty->termios->c_iflag = 0;
}
static int iuu_open(struct tty_struct *tty, static int iuu_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp) struct usb_serial_port *port, struct file *filp)
{ {
...@@ -1025,7 +1036,6 @@ static int iuu_open(struct tty_struct *tty, ...@@ -1025,7 +1036,6 @@ static int iuu_open(struct tty_struct *tty,
u8 *buf; u8 *buf;
int result; int result;
u32 actual; u32 actual;
unsigned long flags;
struct iuu_private *priv = usb_get_serial_port_data(port); struct iuu_private *priv = usb_get_serial_port_data(port);
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
...@@ -1064,21 +1074,7 @@ static int iuu_open(struct tty_struct *tty, ...@@ -1064,21 +1074,7 @@ static int iuu_open(struct tty_struct *tty,
port->bulk_in_buffer, 512, port->bulk_in_buffer, 512,
NULL, NULL); NULL, NULL);
/* set the termios structure */ priv->poll = 0;
spin_lock_irqsave(&priv->lock, flags);
if (tty && !priv->termios_initialized) {
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
| TIOCM_CTS | CSTOPB | PARENB;
tty->termios->c_ispeed = 9600;
tty->termios->c_ospeed = 9600;
tty->termios->c_lflag = 0;
tty->termios->c_oflag = 0;
tty->termios->c_iflag = 0;
priv->termios_initialized = 1;
priv->poll = 0;
}
spin_unlock_irqrestore(&priv->lock, flags);
/* initialize writebuf */ /* initialize writebuf */
#define FISH(a, b, c, d) do { \ #define FISH(a, b, c, d) do { \
...@@ -1201,6 +1197,7 @@ static struct usb_serial_driver iuu_device = { ...@@ -1201,6 +1197,7 @@ static struct usb_serial_driver iuu_device = {
.tiocmget = iuu_tiocmget, .tiocmget = iuu_tiocmget,
.tiocmset = iuu_tiocmset, .tiocmset = iuu_tiocmset,
.set_termios = iuu_set_termios, .set_termios = iuu_set_termios,
.init_termios = iuu_init_termios,
.attach = iuu_startup, .attach = iuu_startup,
.release = iuu_release, .release = iuu_release,
}; };
......
...@@ -85,7 +85,7 @@ static void kobil_read_int_callback(struct urb *urb); ...@@ -85,7 +85,7 @@ 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 tty_struct *tty, static void kobil_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old); struct usb_serial_port *port, struct ktermios *old);
static void kobil_init_termios(struct tty_struct *tty);
static struct usb_device_id id_table [] = { static struct usb_device_id id_table [] = {
{ USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) },
...@@ -120,6 +120,7 @@ static struct usb_serial_driver kobil_device = { ...@@ -120,6 +120,7 @@ static struct usb_serial_driver kobil_device = {
.release = kobil_release, .release = kobil_release,
.ioctl = kobil_ioctl, .ioctl = kobil_ioctl,
.set_termios = kobil_set_termios, .set_termios = kobil_set_termios,
.init_termios = kobil_init_termios,
.tiocmget = kobil_tiocmget, .tiocmget = kobil_tiocmget,
.tiocmset = kobil_tiocmset, .tiocmset = kobil_tiocmset,
.open = kobil_open, .open = kobil_open,
...@@ -210,6 +211,15 @@ static void kobil_release(struct usb_serial *serial) ...@@ -210,6 +211,15 @@ static void kobil_release(struct usb_serial *serial)
kfree(usb_get_serial_port_data(serial->port[i])); kfree(usb_get_serial_port_data(serial->port[i]));
} }
static void kobil_init_termios(struct tty_struct *tty)
{
/* Default to echo off and other sane device settings */
tty->termios->c_lflag = 0;
tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
/* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
tty->termios->c_oflag &= ~ONLCR;
}
static int kobil_open(struct tty_struct *tty, static int kobil_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp) struct usb_serial_port *port, struct file *filp)
...@@ -226,16 +236,6 @@ static int kobil_open(struct tty_struct *tty, ...@@ -226,16 +236,6 @@ static int kobil_open(struct tty_struct *tty,
/* someone sets the dev to 0 if the close method has been called */ /* someone sets the dev to 0 if the close method has been called */
port->interrupt_in_urb->dev = port->serial->dev; port->interrupt_in_urb->dev = port->serial->dev;
if (tty) {
/* Default to echo off and other sane device settings */
tty->termios->c_lflag = 0;
tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN |
XCASE);
tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
/* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
tty->termios->c_oflag &= ~ONLCR;
}
/* 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)
......
...@@ -146,6 +146,7 @@ static int oti6858_open(struct tty_struct *tty, ...@@ -146,6 +146,7 @@ static int oti6858_open(struct tty_struct *tty,
static void oti6858_close(struct usb_serial_port *port); static void oti6858_close(struct usb_serial_port *port);
static void oti6858_set_termios(struct tty_struct *tty, static void oti6858_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old); struct usb_serial_port *port, struct ktermios *old);
static void oti6858_init_termios(struct tty_struct *tty);
static int oti6858_ioctl(struct tty_struct *tty, struct file *file, static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static void oti6858_read_int_callback(struct urb *urb); static void oti6858_read_int_callback(struct urb *urb);
...@@ -186,6 +187,7 @@ static struct usb_serial_driver oti6858_device = { ...@@ -186,6 +187,7 @@ static struct usb_serial_driver oti6858_device = {
.write = oti6858_write, .write = oti6858_write,
.ioctl = oti6858_ioctl, .ioctl = oti6858_ioctl,
.set_termios = oti6858_set_termios, .set_termios = oti6858_set_termios,
.init_termios = oti6858_init_termios,
.tiocmget = oti6858_tiocmget, .tiocmget = oti6858_tiocmget,
.tiocmset = oti6858_tiocmset, .tiocmset = oti6858_tiocmset,
.read_bulk_callback = oti6858_read_bulk_callback, .read_bulk_callback = oti6858_read_bulk_callback,
...@@ -206,7 +208,6 @@ struct oti6858_private { ...@@ -206,7 +208,6 @@ struct oti6858_private {
struct { struct {
u8 read_urb_in_use; u8 read_urb_in_use;
u8 write_urb_in_use; u8 write_urb_in_use;
u8 termios_initialized;
} flags; } flags;
struct delayed_work delayed_write_work; struct delayed_work delayed_write_work;
...@@ -447,6 +448,14 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty) ...@@ -447,6 +448,14 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty)
return chars; return chars;
} }
static void oti6858_init_termios(struct tty_struct *tty)
{
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_ispeed = 38400;
tty->termios->c_ospeed = 38400;
}
static void oti6858_set_termios(struct tty_struct *tty, static void oti6858_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
...@@ -464,16 +473,6 @@ static void oti6858_set_termios(struct tty_struct *tty, ...@@ -464,16 +473,6 @@ static void oti6858_set_termios(struct tty_struct *tty,
return; return;
} }
spin_lock_irqsave(&priv->lock, flags);
if (!priv->flags.termios_initialized) {
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_ispeed = 38400;
tty->termios->c_ospeed = 38400;
priv->flags.termios_initialized = 1;
}
spin_unlock_irqrestore(&priv->lock, flags);
cflag = tty->termios->c_cflag; cflag = tty->termios->c_cflag;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
......
...@@ -299,7 +299,6 @@ struct spcp8x5_private { ...@@ -299,7 +299,6 @@ struct spcp8x5_private {
wait_queue_head_t delta_msr_wait; wait_queue_head_t delta_msr_wait;
u8 line_control; u8 line_control;
u8 line_status; u8 line_status;
u8 termios_initialized;
}; };
/* desc : when device plug in,this function would be called. /* desc : when device plug in,this function would be called.
...@@ -498,6 +497,15 @@ static void spcp8x5_close(struct usb_serial_port *port) ...@@ -498,6 +497,15 @@ static void spcp8x5_close(struct usb_serial_port *port)
dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result); dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result);
} }
static void spcp8x5_init_termios(struct tty_struct *tty)
{
/* for the 1st time call this function */
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_ispeed = 115200;
tty->termios->c_ospeed = 115200;
}
/* set the serial param for transfer. we should check if we really need to /* set the serial param for transfer. we should check if we really need to
* transfer. if we set flow control we should do this too. */ * transfer. if we set flow control we should do this too. */
static void spcp8x5_set_termios(struct tty_struct *tty, static void spcp8x5_set_termios(struct tty_struct *tty,
...@@ -514,16 +522,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty, ...@@ -514,16 +522,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
int i; int i;
u8 control; u8 control;
/* for the 1st time call this function */
spin_lock_irqsave(&priv->lock, flags);
if (!priv->termios_initialized) {
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_ispeed = 115200;
tty->termios->c_ospeed = 115200;
priv->termios_initialized = 1;
}
spin_unlock_irqrestore(&priv->lock, flags);
/* check that they really want us to change something */ /* check that they really want us to change something */
if (!tty_termios_hw_change(tty->termios, old_termios)) if (!tty_termios_hw_change(tty->termios, old_termios))
...@@ -1011,6 +1009,7 @@ static struct usb_serial_driver spcp8x5_device = { ...@@ -1011,6 +1009,7 @@ static struct usb_serial_driver spcp8x5_device = {
.carrier_raised = spcp8x5_carrier_raised, .carrier_raised = spcp8x5_carrier_raised,
.write = spcp8x5_write, .write = spcp8x5_write,
.set_termios = spcp8x5_set_termios, .set_termios = spcp8x5_set_termios,
.init_termios = spcp8x5_init_termios,
.ioctl = spcp8x5_ioctl, .ioctl = spcp8x5_ioctl,
.tiocmget = spcp8x5_tiocmget, .tiocmget = spcp8x5_tiocmget,
.tiocmset = spcp8x5_tiocmset, .tiocmset = spcp8x5_tiocmset,
......
...@@ -721,6 +721,41 @@ static const struct tty_port_operations serial_port_ops = { ...@@ -721,6 +721,41 @@ static const struct tty_port_operations serial_port_ops = {
.dtr_rts = serial_dtr_rts, .dtr_rts = serial_dtr_rts,
}; };
/**
* serial_install - install tty
* @driver: the driver (USB in our case)
* @tty: the tty being created
*
* Create the termios objects for this tty. We use the default USB
* serial ones but permit them to be overriddenby serial->type->termios.
* This lets us remove all the ugly hackery
*/
static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
{
int idx = tty->index;
struct usb_serial *serial;
int retval;
/* If the termios setup has yet to be done */
if (tty->driver->termios[idx] == NULL) {
/* perform the standard setup */
retval = tty_init_termios(tty);
if (retval)
return retval;
/* allow the driver to update it */
serial = usb_serial_get_by_index(tty->index);
if (serial->type->init_termios)
serial->type->init_termios(tty);
usb_serial_put(serial);
}
/* Final install (we use the default method) */
tty_driver_kref_get(driver);
tty->count++;
driver->ttys[idx] = tty;
return 0;
}
int usb_serial_probe(struct usb_interface *interface, int usb_serial_probe(struct usb_interface *interface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
...@@ -1228,7 +1263,8 @@ static const struct tty_operations serial_ops = { ...@@ -1228,7 +1263,8 @@ static const struct tty_operations serial_ops = {
.chars_in_buffer = serial_chars_in_buffer, .chars_in_buffer = serial_chars_in_buffer,
.tiocmget = serial_tiocmget, .tiocmget = serial_tiocmget,
.tiocmset = serial_tiocmset, .tiocmset = serial_tiocmset,
.shutdown = serial_do_free, .shutdown = serial_do_free,
.install = serial_install,
.proc_fops = &serial_proc_fops, .proc_fops = &serial_proc_fops,
}; };
......
...@@ -259,7 +259,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, ...@@ -259,7 +259,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
__u8 *data, __u8 datasize); __u8 *data, __u8 datasize);
static int firm_open(struct usb_serial_port *port); static int firm_open(struct usb_serial_port *port);
static int firm_close(struct usb_serial_port *port); static int firm_close(struct usb_serial_port *port);
static int firm_setup_port(struct tty_struct *tty); static void firm_setup_port(struct tty_struct *tty);
static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
static int firm_set_break(struct usb_serial_port *port, __u8 onoff); static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
...@@ -1211,7 +1211,7 @@ static int firm_close(struct usb_serial_port *port) ...@@ -1211,7 +1211,7 @@ static int firm_close(struct usb_serial_port *port)
} }
static int firm_setup_port(struct tty_struct *tty) static void firm_setup_port(struct tty_struct *tty)
{ {
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct whiteheat_port_settings port_settings; struct whiteheat_port_settings port_settings;
...@@ -1286,7 +1286,7 @@ static int firm_setup_port(struct tty_struct *tty) ...@@ -1286,7 +1286,7 @@ static int firm_setup_port(struct tty_struct *tty)
port_settings.lloop = 0; port_settings.lloop = 0;
/* now send the message to the device */ /* now send the message to the device */
return firm_send_command(port, WHITEHEAT_SETUP_PORT, firm_send_command(port, WHITEHEAT_SETUP_PORT,
(__u8 *)&port_settings, sizeof(port_settings)); (__u8 *)&port_settings, sizeof(port_settings));
} }
......
...@@ -261,6 +261,9 @@ struct usb_serial_driver { ...@@ -261,6 +261,9 @@ struct usb_serial_driver {
be an attached tty at this point */ be an attached tty at this point */
void (*dtr_rts)(struct usb_serial_port *port, int on); void (*dtr_rts)(struct usb_serial_port *port, int on);
int (*carrier_raised)(struct usb_serial_port *port); int (*carrier_raised)(struct usb_serial_port *port);
/* Called by the usb serial hooks to allow the user to rework the
termios state */
void (*init_termios)(struct tty_struct *tty);
/* USB events */ /* USB events */
void (*read_int_callback)(struct urb *urb); void (*read_int_callback)(struct urb *urb);
void (*write_int_callback)(struct urb *urb); void (*write_int_callback)(struct urb *urb);
......
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