|
@@ -1744,6 +1744,37 @@ static int tty_release_checks(struct tty_struct *tty, int idx)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * tty_release_struct - release a tty struct
|
|
|
+ * @tty: tty device
|
|
|
+ * @idx: index of the tty
|
|
|
+ *
|
|
|
+ * Performs the final steps to release and free a tty device. It is
|
|
|
+ * roughly the reverse of tty_init_dev.
|
|
|
+ */
|
|
|
+void tty_release_struct(struct tty_struct *tty, int idx)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * Ask the line discipline code to release its structures
|
|
|
+ */
|
|
|
+ tty_ldisc_release(tty);
|
|
|
+
|
|
|
+ /* Wait for pending work before tty destruction commmences */
|
|
|
+ tty_flush_works(tty);
|
|
|
+
|
|
|
+ tty_debug_hangup(tty, "freeing structure\n");
|
|
|
+ /*
|
|
|
+ * The release_tty function takes care of the details of clearing
|
|
|
+ * the slots and preserving the termios structure. The tty_unlock_pair
|
|
|
+ * should be safe as we keep a kref while the tty is locked (so the
|
|
|
+ * unlock never unlocks a freed tty).
|
|
|
+ */
|
|
|
+ mutex_lock(&tty_mutex);
|
|
|
+ release_tty(tty, idx);
|
|
|
+ mutex_unlock(&tty_mutex);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(tty_release_struct);
|
|
|
+
|
|
|
/**
|
|
|
* tty_release - vfs callback for close
|
|
|
* @inode: inode of tty
|
|
@@ -1898,25 +1929,8 @@ int tty_release(struct inode *inode, struct file *filp)
|
|
|
return 0;
|
|
|
|
|
|
tty_debug_hangup(tty, "final close\n");
|
|
|
- /*
|
|
|
- * Ask the line discipline code to release its structures
|
|
|
- */
|
|
|
- tty_ldisc_release(tty);
|
|
|
-
|
|
|
- /* Wait for pending work before tty destruction commmences */
|
|
|
- tty_flush_works(tty);
|
|
|
-
|
|
|
- tty_debug_hangup(tty, "freeing structure\n");
|
|
|
- /*
|
|
|
- * The release_tty function takes care of the details of clearing
|
|
|
- * the slots and preserving the termios structure. The tty_unlock_pair
|
|
|
- * should be safe as we keep a kref while the tty is locked (so the
|
|
|
- * unlock never unlocks a freed tty).
|
|
|
- */
|
|
|
- mutex_lock(&tty_mutex);
|
|
|
- release_tty(tty, idx);
|
|
|
- mutex_unlock(&tty_mutex);
|
|
|
|
|
|
+ tty_release_struct(tty, idx);
|
|
|
return 0;
|
|
|
}
|
|
|
|