aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2009-12-24 06:42:10 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 17:53:38 -0500
commita3f8168b7a3a7d9dfb9bb9caa1e009a5ce2a8493 (patch)
treedef82152d9b714f8c80d22d0ad9f33150c345e06 /drivers/usb
parent66e47e6006a558b33c6f15bd2e072d52c40e0159 (diff)
USB: ftdi_sio: clean up modem status handling
Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/ftdi_sio.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index a6e5a0d95566..58698a6f837b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2341,6 +2341,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2341 struct usb_serial_port *port = tty->driver_data; 2341 struct usb_serial_port *port = tty->driver_data;
2342 struct ftdi_private *priv = usb_get_serial_port_data(port); 2342 struct ftdi_private *priv = usb_get_serial_port_data(port);
2343 unsigned char *buf; 2343 unsigned char *buf;
2344 int len;
2344 int ret; 2345 int ret;
2345 2346
2346 dbg("%s TIOCMGET", __func__); 2347 dbg("%s TIOCMGET", __func__);
@@ -2348,18 +2349,13 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2348 buf = kmalloc(2, GFP_KERNEL); 2349 buf = kmalloc(2, GFP_KERNEL);
2349 if (!buf) 2350 if (!buf)
2350 return -ENOMEM; 2351 return -ENOMEM;
2351 2352 /*
2353 * The 8U232AM returns a two byte value (the SIO a 1 byte value) in
2354 * the same format as the data returned from the in point.
2355 */
2352 switch (priv->chip_type) { 2356 switch (priv->chip_type) {
2353 case SIO: 2357 case SIO:
2354 /* Request the status from the device */ 2358 len = 1;
2355 ret = usb_control_msg(port->serial->dev,
2356 usb_rcvctrlpipe(port->serial->dev, 0),
2357 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2358 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2359 0, 0,
2360 buf, 1, WDR_TIMEOUT);
2361 if (ret < 0)
2362 goto out;
2363 break; 2359 break;
2364 case FT8U232AM: 2360 case FT8U232AM:
2365 case FT232BM: 2361 case FT232BM:
@@ -2367,23 +2363,22 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2367 case FT232RL: 2363 case FT232RL:
2368 case FT2232H: 2364 case FT2232H:
2369 case FT4232H: 2365 case FT4232H:
2370 /* the 8U232AM returns a two byte value (the sio is a 1 byte 2366 len = 2;
2371 value) - in the same format as the data returned from the in
2372 point */
2373 ret = usb_control_msg(port->serial->dev,
2374 usb_rcvctrlpipe(port->serial->dev, 0),
2375 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2376 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2377 0, priv->interface,
2378 buf, 2, WDR_TIMEOUT);
2379 if (ret < 0)
2380 goto out;
2381 break; 2367 break;
2382 default: 2368 default:
2383 ret = -EFAULT; 2369 ret = -EFAULT;
2384 goto out; 2370 goto out;
2385 } 2371 }
2386 2372
2373 ret = usb_control_msg(port->serial->dev,
2374 usb_rcvctrlpipe(port->serial->dev, 0),
2375 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2376 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2377 0, priv->interface,
2378 buf, len, WDR_TIMEOUT);
2379 if (ret < 0)
2380 goto out;
2381
2387 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2382 ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2388 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2383 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2389 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2384 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |