]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/tty/tty_port.c
TTY: add tty_port_tty_hangup helper
[karo-tx-linux.git] / drivers / tty / tty_port.c
index 8bb757c62ee2044746cd9e93a052325bc28907db..7f38eeaafac3d1036c2307d99fb25d265a253503 100644 (file)
@@ -232,6 +232,23 @@ void tty_port_hangup(struct tty_port *port)
 }
 EXPORT_SYMBOL(tty_port_hangup);
 
+/**
+ * tty_port_tty_hangup - helper to hang up a tty
+ *
+ * @port: tty port
+ * @check_clocal: hang only ttys with CLOCAL unset?
+ */
+void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
+{
+       struct tty_struct *tty = tty_port_tty_get(port);
+
+       if (tty && (!check_clocal || !C_CLOCAL(tty))) {
+               tty_hangup(tty);
+               tty_kref_put(tty);
+       }
+}
+EXPORT_SYMBOL_GPL(tty_port_tty_hangup);
+
 /**
  * tty_port_tty_wakeup - helper to wake up a tty
  *