diff options
author | Alan Cox <alan@linux.intel.com> | 2009-09-19 16:13:33 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 16:13:33 -0400 |
commit | fe1ae7fdd2ee603f2d95f04e09a68f7f79045127 (patch) | |
tree | 1234647e3bd970cfb105dab1c4f0ad2cd14ce179 /drivers/usb/serial/usb-serial.c | |
parent | ba15ab0e8de0d4439a91342ad52d55ca9e313f3d (diff) |
tty: USB serial termios bits
Various drivers have hacks to mangle termios structures. This stems from
the fact there is no nice setup hook for configuring the termios settings
when the port is created
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 3dda6841e724..80c1f4d8e910 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -721,6 +721,41 @@ static const struct tty_port_operations serial_port_ops = { | |||
721 | .dtr_rts = serial_dtr_rts, | 721 | .dtr_rts = serial_dtr_rts, |
722 | }; | 722 | }; |
723 | 723 | ||
724 | /** | ||
725 | * serial_install - install tty | ||
726 | * @driver: the driver (USB in our case) | ||
727 | * @tty: the tty being created | ||
728 | * | ||
729 | * Create the termios objects for this tty. We use the default USB | ||
730 | * serial ones but permit them to be overriddenby serial->type->termios. | ||
731 | * This lets us remove all the ugly hackery | ||
732 | */ | ||
733 | |||
734 | static int serial_install(struct tty_driver *driver, struct tty_struct *tty) | ||
735 | { | ||
736 | int idx = tty->index; | ||
737 | struct usb_serial *serial; | ||
738 | int retval; | ||
739 | |||
740 | /* If the termios setup has yet to be done */ | ||
741 | if (tty->driver->termios[idx] == NULL) { | ||
742 | /* perform the standard setup */ | ||
743 | retval = tty_init_termios(tty); | ||
744 | if (retval) | ||
745 | return retval; | ||
746 | /* allow the driver to update it */ | ||
747 | serial = usb_serial_get_by_index(tty->index); | ||
748 | if (serial->type->init_termios) | ||
749 | serial->type->init_termios(tty); | ||
750 | usb_serial_put(serial); | ||
751 | } | ||
752 | /* Final install (we use the default method) */ | ||
753 | tty_driver_kref_get(driver); | ||
754 | tty->count++; | ||
755 | driver->ttys[idx] = tty; | ||
756 | return 0; | ||
757 | } | ||
758 | |||
724 | int usb_serial_probe(struct usb_interface *interface, | 759 | int usb_serial_probe(struct usb_interface *interface, |
725 | const struct usb_device_id *id) | 760 | const struct usb_device_id *id) |
726 | { | 761 | { |
@@ -1228,7 +1263,8 @@ static const struct tty_operations serial_ops = { | |||
1228 | .chars_in_buffer = serial_chars_in_buffer, | 1263 | .chars_in_buffer = serial_chars_in_buffer, |
1229 | .tiocmget = serial_tiocmget, | 1264 | .tiocmget = serial_tiocmget, |
1230 | .tiocmset = serial_tiocmset, | 1265 | .tiocmset = serial_tiocmset, |
1231 | .shutdown = serial_do_free, | 1266 | .shutdown = serial_do_free, |
1267 | .install = serial_install, | ||
1232 | .proc_fops = &serial_proc_fops, | 1268 | .proc_fops = &serial_proc_fops, |
1233 | }; | 1269 | }; |
1234 | 1270 | ||