backports: add tty_port_tty_hangup()
authorHauke Mehrtens <hauke@hauke-m.de>
Thu, 3 Oct 2013 14:09:24 +0000 (16:09 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Oct 2013 21:58:37 +0000 (23:58 +0200)
This is needed by ./net/bluetooth/rfcomm/tty.c

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
backport/backport-include/linux/tty.h
backport/compat/backport-3.10.c

index 7b57ca1f91c8b34ee77ec997b38c81e14aafa2f7..88fbfd03242f5e828ff291eba1ed8dad02cd18c7 100644 (file)
@@ -50,6 +50,7 @@ extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
 extern void tty_port_tty_wakeup(struct tty_port *port);
+extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal);
 #endif
 
 #endif /* __BACKPORT_LINUX_TTY_H */
index d8b3bc6216c7252eeb541996f2b5b98621414279..4d449607187b2cdc74c73ed257dc348057c21456 100644 (file)
@@ -108,4 +108,20 @@ void tty_port_tty_wakeup(struct tty_port *port)
        }
 }
 EXPORT_SYMBOL_GPL(tty_port_tty_wakeup);
+
+/**
+ * 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);
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) */