Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338553
b: refs/heads/master
c: a4afff6
h: refs/heads/master
i:
  338551: 364365a
v: v3
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Oct 30, 2012
1 parent cc93a14 commit 5f76bf6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c2ee545071c10873b057b04a19d3d2aed04b9cf
refs/heads/master: a4afff6b323a20ddf51d08dec0e2ef4fe8f228ee
38 changes: 35 additions & 3 deletions trunk/drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,14 @@ static void ftdi_set_termios(struct tty_struct *tty,
}
}

static int ftdi_tiocmget(struct tty_struct *tty)
/*
* Get modem-control status.
*
* Returns the number of status bytes retrieved (device dependant), or
* negative error code.
*/
static int ftdi_get_modem_status(struct tty_struct *tty,
unsigned char status[2])
{
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port);
Expand Down Expand Up @@ -2371,17 +2378,42 @@ static int ftdi_tiocmget(struct tty_struct *tty)
0, priv->interface,
buf, len, WDR_TIMEOUT);
if (ret < 0) {
dev_err(&port->dev, "failed to get modem status: %d\n", ret);
ret = usb_translate_errors(ret);
goto out;
}

status[0] = buf[0];
if (ret > 1)
status[1] = buf[1];
else
status[1] = 0;

dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0],
status[1]);
out:
kfree(buf);

return ret;
}

static int ftdi_tiocmget(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
struct ftdi_private *priv = usb_get_serial_port_data(port);
unsigned char buf[2];
int ret;

ret = ftdi_get_modem_status(tty, buf);
if (ret < 0)
return ret;

ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
(buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
(buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
(buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
priv->last_dtr_rts;
out:
kfree(buf);

return ret;
}

Expand Down

0 comments on commit 5f76bf6

Please sign in to comment.