Commit 9b5627d8 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: spcp8x5: fix device initialisation at open

commit 5e4211f1 upstream.

Do not use uninitialised termios data to determine when to configure the
device at open.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
[bwh: Backported to 3.2: tty_struct::termios is a pointer, not a struct]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Cc: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e63aec99
...@@ -337,7 +337,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty, ...@@ -337,7 +337,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
struct spcp8x5_private *priv = usb_get_serial_port_data(port); struct spcp8x5_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
unsigned int cflag = tty->termios->c_cflag; unsigned int cflag = tty->termios->c_cflag;
unsigned int old_cflag = old_termios->c_cflag;
unsigned short uartdata; unsigned short uartdata;
unsigned char buf[2] = {0, 0}; unsigned char buf[2] = {0, 0};
int baud; int baud;
...@@ -346,15 +345,15 @@ static void spcp8x5_set_termios(struct tty_struct *tty, ...@@ -346,15 +345,15 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
/* 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 (old_termios && !tty_termios_hw_change(tty->termios, old_termios))
return; return;
/* set DTR/RTS active */ /* set DTR/RTS active */
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
control = priv->line_control; control = priv->line_control;
if ((old_cflag & CBAUD) == B0) { if (old_termios && (old_termios->c_cflag & CBAUD) == B0) {
priv->line_control |= MCR_DTR; priv->line_control |= MCR_DTR;
if (!(old_cflag & CRTSCTS)) if (!(old_termios->c_cflag & CRTSCTS))
priv->line_control |= MCR_RTS; priv->line_control |= MCR_RTS;
} }
if (control != priv->line_control) { if (control != priv->line_control) {
...@@ -442,7 +441,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty, ...@@ -442,7 +441,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
* status of the device. */ * status of the device. */
static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port) static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
{ {
struct ktermios tmp_termios;
struct usb_serial *serial = port->serial; struct usb_serial *serial = port->serial;
struct spcp8x5_private *priv = usb_get_serial_port_data(port); struct spcp8x5_private *priv = usb_get_serial_port_data(port);
int ret; int ret;
...@@ -465,7 +463,7 @@ static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -465,7 +463,7 @@ static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
/* Setup termios */ /* Setup termios */
if (tty) if (tty)
spcp8x5_set_termios(tty, port, &tmp_termios); spcp8x5_set_termios(tty, port, NULL);
spcp8x5_get_msr(serial->dev, &status, priv->type); spcp8x5_get_msr(serial->dev, &status, priv->type);
......
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