aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:47:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-13 19:50:19 -0400
commit2cb4ca0208722836e921d5ba780b09f29d4026b8 (patch)
tree85cb521a231de479cf4dea4fe7759723e25a2e57
parent72a33bf58c50892bce7ee4f58d487e818dec1c7e (diff)
TTY: add tty_port_link_device
This is for those drivers which do not have dynamic device creation (do not call tty_port_register_device) and do not want to implement tty->ops->install (will not call tty_port_install). They still have to provide the link somehow though. And this newly added function is exactly to serve that purpose. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/tty_port.c22
-rw-r--r--include/linux/tty.h2
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index c2f0592bcb2c..96302f4c7079 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -34,6 +34,26 @@ void tty_port_init(struct tty_port *port)
34EXPORT_SYMBOL(tty_port_init); 34EXPORT_SYMBOL(tty_port_init);
35 35
36/** 36/**
37 * tty_port_link_device - link tty and tty_port
38 * @port: tty_port of the device
39 * @driver: tty_driver for this device
40 * @index: index of the tty
41 *
42 * Provide the tty layer wit ha link from a tty (specified by @index) to a
43 * tty_port (@port). Use this only if neither tty_port_register_device nor
44 * tty_port_install is used in the driver. If used, this has to be called before
45 * tty_register_driver.
46 */
47void tty_port_link_device(struct tty_port *port,
48 struct tty_driver *driver, unsigned index)
49{
50 if (WARN_ON(index >= driver->num))
51 return;
52 driver->ports[index] = port;
53}
54EXPORT_SYMBOL_GPL(tty_port_link_device);
55
56/**
37 * tty_port_register_device - register tty device 57 * tty_port_register_device - register tty device
38 * @port: tty_port of the device 58 * @port: tty_port of the device
39 * @driver: tty_driver for this device 59 * @driver: tty_driver for this device
@@ -48,7 +68,7 @@ struct device *tty_port_register_device(struct tty_port *port,
48 struct tty_driver *driver, unsigned index, 68 struct tty_driver *driver, unsigned index,
49 struct device *device) 69 struct device *device)
50{ 70{
51 driver->ports[index] = port; 71 tty_port_link_device(port, driver, index);
52 return tty_register_device(driver, index, device); 72 return tty_register_device(driver, index, device);
53} 73}
54EXPORT_SYMBOL_GPL(tty_port_register_device); 74EXPORT_SYMBOL_GPL(tty_port_register_device);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index acca24bf06a7..69a787fdfa9c 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -497,6 +497,8 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);
497#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) 497#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
498 498
499extern void tty_port_init(struct tty_port *port); 499extern void tty_port_init(struct tty_port *port);
500extern void tty_port_link_device(struct tty_port *port,
501 struct tty_driver *driver, unsigned index);
500extern struct device *tty_port_register_device(struct tty_port *port, 502extern struct device *tty_port_register_device(struct tty_port *port,
501 struct tty_driver *driver, unsigned index, 503 struct tty_driver *driver, unsigned index,
502 struct device *device); 504 struct device *device);