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

USB: ftdi_sio: clean up modem status handling

Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 66e47e60
...@@ -2341,6 +2341,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -2341,6 +2341,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
struct usb_serial_port *port = tty->driver_data; struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port); struct ftdi_private *priv = usb_get_serial_port_data(port);
unsigned char *buf; unsigned char *buf;
int len;
int ret; int ret;
dbg("%s TIOCMGET", __func__); dbg("%s TIOCMGET", __func__);
...@@ -2348,18 +2349,13 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -2348,18 +2349,13 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
buf = kmalloc(2, GFP_KERNEL); buf = kmalloc(2, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
/*
* The 8U232AM returns a two byte value (the SIO a 1 byte value) in
* the same format as the data returned from the in point.
*/
switch (priv->chip_type) { switch (priv->chip_type) {
case SIO: case SIO:
/* Request the status from the device */ len = 1;
ret = usb_control_msg(port->serial->dev,
usb_rcvctrlpipe(port->serial->dev, 0),
FTDI_SIO_GET_MODEM_STATUS_REQUEST,
FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
0, 0,
buf, 1, WDR_TIMEOUT);
if (ret < 0)
goto out;
break; break;
case FT8U232AM: case FT8U232AM:
case FT232BM: case FT232BM:
...@@ -2367,23 +2363,22 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -2367,23 +2363,22 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
case FT232RL: case FT232RL:
case FT2232H: case FT2232H:
case FT4232H: case FT4232H:
/* the 8U232AM returns a two byte value (the sio is a 1 byte len = 2;
value) - in the same format as the data returned from the in
point */
ret = usb_control_msg(port->serial->dev,
usb_rcvctrlpipe(port->serial->dev, 0),
FTDI_SIO_GET_MODEM_STATUS_REQUEST,
FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
0, priv->interface,
buf, 2, WDR_TIMEOUT);
if (ret < 0)
goto out;
break; break;
default: default:
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
ret = usb_control_msg(port->serial->dev,
usb_rcvctrlpipe(port->serial->dev, 0),
FTDI_SIO_GET_MODEM_STATUS_REQUEST,
FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
0, priv->interface,
buf, len, WDR_TIMEOUT);
if (ret < 0)
goto out;
ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
(buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
......
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