tty: Bring the usb tty port structure into more use

This allows us to clean stuff up, but is probably also going to cause
some app breakage with buggy apps as we now implement proper POSIX behaviour
for USB ports matching all the other ports. This does also mean other apps
that break on USB will now work properly.

Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox
2009-06-11 12:26:29 +01:00
committed by Linus Torvalds
parent 1ec739be75
commit 335f8514f2
39 changed files with 470 additions and 664 deletions

View File

@ -651,6 +651,35 @@ static int keyspan_pda_chars_in_buffer(struct tty_struct *tty)
}
static void keyspan_pda_dtr_rts(struct usb_serial_port *port, int on)
{
struct usb_serial *serial = port->serial;
if (serial->dev) {
if (on)
keyspan_pda_set_modem_info(serial, (1<<7) | (1<< 2));
else
keyspan_pda_set_modem_info(serial, 0);
}
}
static int keyspan_pda_carrier_raised(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
unsigned char modembits;
/* If we can read the modem status and the DCD is low then
carrier is not raised yet */
if (keyspan_pda_get_modem_info(serial, &modembits) >= 0) {
if (!(modembits & (1>>6)))
return 0;
}
/* Carrier raised, or we failed (eg disconnected) so
progress accordingly */
return 1;
}
static int keyspan_pda_open(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
{
@ -682,13 +711,6 @@ static int keyspan_pda_open(struct tty_struct *tty,
priv->tx_room = room;
priv->tx_throttled = room ? 0 : 1;
/* the normal serial device seems to always turn on DTR and RTS here,
so do the same */
if (tty && (tty->termios->c_cflag & CBAUD))
keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2));
else
keyspan_pda_set_modem_info(serial, 0);
/*Start reading from the device*/
port->interrupt_in_urb->dev = serial->dev;
rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
@ -700,19 +722,11 @@ static int keyspan_pda_open(struct tty_struct *tty,
error:
return rc;
}
static void keyspan_pda_close(struct tty_struct *tty,
struct usb_serial_port *port, struct file *filp)
static void keyspan_pda_close(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
if (serial->dev) {
/* the normal serial device seems to always shut
off DTR and RTS now */
if (tty->termios->c_cflag & HUPCL)
keyspan_pda_set_modem_info(serial, 0);
/* shutdown our bulk reads and writes */
usb_kill_urb(port->write_urb);
usb_kill_urb(port->interrupt_in_urb);
@ -839,6 +853,8 @@ static struct usb_serial_driver keyspan_pda_device = {
.usb_driver = &keyspan_pda_driver,
.id_table = id_table_std,
.num_ports = 1,
.dtr_rts = keyspan_pda_dtr_rts,
.carrier_raised = keyspan_pda_carrier_raised,
.open = keyspan_pda_open,
.close = keyspan_pda_close,
.write = keyspan_pda_write,