]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/tty/tty_port.c
TTY: add tty_port_link_device
[karo-tx-linux.git] / drivers / tty / tty_port.c
index c2f0592bcb2cff271cf84a9f3e2b77469b423e8d..96302f4c707984f34f1530a91452144b7008c86f 100644 (file)
@@ -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);