aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2011-03-23 05:48:35 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-19 17:43:01 -0400
commit6716671d8c1c07a8072098764d1b7cbfef7412ad (patch)
tree7aa2e138fb9565ffd37591bfe1887b379f57dfd7
parentc18d77aa00cde1215d9e045ba8f93004fe843f38 (diff)
TTY: introduce deinit helpers for proper ldisc shutdown
Introduce deinitialize_tty_struct which should be called after initialize_tty_struct and before successfull tty_ldisc_setup. It calls tty_ldisc_deinit which is opposite of tty_ldisc_init. It only puts a reference to ldisc and assigns NULL to tty->ldisc. It will be used to shut down ldisc when tty_release cannot be called yet. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Julian Anastasov <ja@ssi.bg> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/tty/tty_io.c14
-rw-r--r--drivers/tty/tty_ldisc.c13
-rw-r--r--include/linux/tty.h2
3 files changed, 29 insertions, 0 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 026bf2f6f5f2..f5dd23520fe3 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2887,6 +2887,20 @@ void initialize_tty_struct(struct tty_struct *tty,
2887} 2887}
2888 2888
2889/** 2889/**
2890 * deinitialize_tty_struct
2891 * @tty: tty to deinitialize
2892 *
2893 * This subroutine deinitializes a tty structure that has been newly
2894 * allocated but tty_release cannot be called on that yet.
2895 *
2896 * Locking: none - tty in question must not be exposed at this point
2897 */
2898void deinitialize_tty_struct(struct tty_struct *tty)
2899{
2900 tty_ldisc_deinit(tty);
2901}
2902
2903/**
2890 * tty_put_char - write one character to a tty 2904 * tty_put_char - write one character to a tty
2891 * @tty: tty 2905 * @tty: tty
2892 * @ch: character 2906 * @ch: character
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index e19e13647116..5d01d32e2cf0 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -956,6 +956,19 @@ void tty_ldisc_init(struct tty_struct *tty)
956 tty_ldisc_assign(tty, ld); 956 tty_ldisc_assign(tty, ld);
957} 957}
958 958
959/**
960 * tty_ldisc_init - ldisc cleanup for new tty
961 * @tty: tty that was allocated recently
962 *
963 * The tty structure must not becompletely set up (tty_ldisc_setup) when
964 * this call is made.
965 */
966void tty_ldisc_deinit(struct tty_struct *tty)
967{
968 put_ldisc(tty->ldisc);
969 tty_ldisc_assign(tty, NULL);
970}
971
959void tty_ldisc_begin(void) 972void tty_ldisc_begin(void)
960{ 973{
961 /* Setup the default TTY line discipline. */ 974 /* Setup the default TTY line discipline. */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 9f469c700550..4db4ca79f895 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -472,6 +472,7 @@ extern int tty_add_file(struct tty_struct *tty, struct file *file);
472extern void free_tty_struct(struct tty_struct *tty); 472extern void free_tty_struct(struct tty_struct *tty);
473extern void initialize_tty_struct(struct tty_struct *tty, 473extern void initialize_tty_struct(struct tty_struct *tty,
474 struct tty_driver *driver, int idx); 474 struct tty_driver *driver, int idx);
475extern void deinitialize_tty_struct(struct tty_struct *tty);
475extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 476extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
476 int first_ok); 477 int first_ok);
477extern int tty_release(struct inode *inode, struct file *filp); 478extern int tty_release(struct inode *inode, struct file *filp);
@@ -525,6 +526,7 @@ extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
525extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty); 526extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
526extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty); 527extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
527extern void tty_ldisc_init(struct tty_struct *tty); 528extern void tty_ldisc_init(struct tty_struct *tty);
529extern void tty_ldisc_deinit(struct tty_struct *tty);
528extern void tty_ldisc_begin(void); 530extern void tty_ldisc_begin(void);
529/* This last one is just for the tty layer internals and shouldn't be used elsewhere */ 531/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
530extern void tty_ldisc_enable(struct tty_struct *tty); 532extern void tty_ldisc_enable(struct tty_struct *tty);