From 95e3e44556025e2916e583c1b4d41461713f45d2 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Tue, 7 Aug 2012 21:47:50 +0200 Subject: [PATCH] --- yaml --- r: 325657 b: refs/heads/master c: 2cb4ca0208722836e921d5ba780b09f29d4026b8 h: refs/heads/master i: 325655: 867302e3b960ce42d0c3d545cad1da15d5f1cf65 v: v3 --- [refs] | 2 +- trunk/drivers/tty/tty_port.c | 22 +++++++++++++++++++++- trunk/include/linux/tty.h | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 792a0493d5bc..cef44880be8a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 72a33bf58c50892bce7ee4f58d487e818dec1c7e +refs/heads/master: 2cb4ca0208722836e921d5ba780b09f29d4026b8 diff --git a/trunk/drivers/tty/tty_port.c b/trunk/drivers/tty/tty_port.c index c2f0592bcb2c..96302f4c7079 100644 --- a/trunk/drivers/tty/tty_port.c +++ b/trunk/drivers/tty/tty_port.c @@ -33,6 +33,26 @@ void tty_port_init(struct tty_port *port) } EXPORT_SYMBOL(tty_port_init); +/** + * tty_port_link_device - link tty and tty_port + * @port: tty_port of the device + * @driver: tty_driver for this device + * @index: index of the tty + * + * Provide the tty layer wit ha link from a tty (specified by @index) to a + * tty_port (@port). Use this only if neither tty_port_register_device nor + * tty_port_install is used in the driver. If used, this has to be called before + * tty_register_driver. + */ +void tty_port_link_device(struct tty_port *port, + struct tty_driver *driver, unsigned index) +{ + if (WARN_ON(index >= driver->num)) + return; + driver->ports[index] = port; +} +EXPORT_SYMBOL_GPL(tty_port_link_device); + /** * tty_port_register_device - register tty device * @port: tty_port of the device @@ -48,7 +68,7 @@ struct device *tty_port_register_device(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device) { - driver->ports[index] = port; + tty_port_link_device(port, driver, index); return tty_register_device(driver, index, device); } EXPORT_SYMBOL_GPL(tty_port_register_device); diff --git a/trunk/include/linux/tty.h b/trunk/include/linux/tty.h index acca24bf06a7..69a787fdfa9c 100644 --- a/trunk/include/linux/tty.h +++ b/trunk/include/linux/tty.h @@ -497,6 +497,8 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay); #define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) extern void tty_port_init(struct tty_port *port); +extern void tty_port_link_device(struct tty_port *port, + struct tty_driver *driver, unsigned index); extern struct device *tty_port_register_device(struct tty_port *port, struct tty_driver *driver, unsigned index, struct device *device);