From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-serial@vger.kernel.org
Cc: Jiri Slaby <jslaby@suse.cz>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
Julian Anastasov <ja@ssi.bg>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 13/48] TTY: introduce deinit helpers for proper ldisc shutdown
Date: Mon, 23 May 2011 12:06:30 -0700 [thread overview]
Message-ID: <1306177625-17885-13-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1306177625-17885-1-git-send-email-gregkh@suse.de>
From: Jiri Slaby <jslaby@suse.cz>
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>
---
drivers/tty/tty_io.c | 14 ++++++++++++++
drivers/tty/tty_ldisc.c | 13 +++++++++++++
include/linux/tty.h | 2 ++
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 026bf2f..f5dd235 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,
}
/**
+ * deinitialize_tty_struct
+ * @tty: tty to deinitialize
+ *
+ * This subroutine deinitializes a tty structure that has been newly
+ * allocated but tty_release cannot be called on that yet.
+ *
+ * Locking: none - tty in question must not be exposed at this point
+ */
+void deinitialize_tty_struct(struct tty_struct *tty)
+{
+ tty_ldisc_deinit(tty);
+}
+
+/**
* tty_put_char - write one character to a tty
* @tty: tty
* @ch: character
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index e19e136..5d01d32 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)
tty_ldisc_assign(tty, ld);
}
+/**
+ * tty_ldisc_init - ldisc cleanup for new tty
+ * @tty: tty that was allocated recently
+ *
+ * The tty structure must not becompletely set up (tty_ldisc_setup) when
+ * this call is made.
+ */
+void tty_ldisc_deinit(struct tty_struct *tty)
+{
+ put_ldisc(tty->ldisc);
+ tty_ldisc_assign(tty, NULL);
+}
+
void tty_ldisc_begin(void)
{
/* Setup the default TTY line discipline. */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 9f469c7..4db4ca7 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);
extern void free_tty_struct(struct tty_struct *tty);
extern void initialize_tty_struct(struct tty_struct *tty,
struct tty_driver *driver, int idx);
+extern void deinitialize_tty_struct(struct tty_struct *tty);
extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
int first_ok);
extern int tty_release(struct inode *inode, struct file *filp);
@@ -525,6 +526,7 @@ extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
extern void tty_ldisc_init(struct tty_struct *tty);
+extern void tty_ldisc_deinit(struct tty_struct *tty);
extern void tty_ldisc_begin(void);
/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
extern void tty_ldisc_enable(struct tty_struct *tty);
--
1.7.4.2
next prev parent reply other threads:[~2011-05-23 19:16 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-23 19:05 [GIT PATCH] TTY/serial driver patches for .40 Greg KH
2011-05-23 19:06 ` [PATCH 01/48] vt: remove uneeded retval check before tty->ops->open inside tty_open Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 02/48] vt: Add K_OFF return value to vt_ioctl KDGKBMODE Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 03/48] drivers/tty/vt/vt_ioctl.c: repair insane ?: expression Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 04/48] tty: VT, remove unused variable Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 05/48] TTY: serial_core, " Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 06/48] Char: cyclades, fix " Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 07/48] TTY: VT, remove unused variables Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 08/48] Char: moxa, " Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 09/48] TTY: rocket, " Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 10/48] TTY: unify tty_init_dev fail path handling Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 11/48] TTY: unify pty_install " Greg Kroah-Hartman
2011-05-23 19:06 ` [PATCH 12/48] TTY: unify pty_unix98_install " Greg Kroah-Hartman
2011-05-23 19:06 ` Greg Kroah-Hartman [this message]
2011-05-23 19:10 ` [PATCH 01/48] vt: remove uneeded retval check before tty->ops->open inside tty_open Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 02/48] vt: Add K_OFF return value to vt_ioctl KDGKBMODE Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 03/48] drivers/tty/vt/vt_ioctl.c: repair insane ?: expression Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 04/48] tty: VT, remove unused variable Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 05/48] TTY: serial_core, " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 06/48] Char: cyclades, fix " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 07/48] TTY: VT, remove unused variables Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 08/48] Char: moxa, " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 09/48] TTY: rocket, " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 10/48] TTY: unify tty_init_dev fail path handling Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 11/48] TTY: unify pty_install " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 12/48] TTY: unify pty_unix98_install " Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 13/48] TTY: introduce deinit helpers for proper ldisc shutdown Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 14/48] TTY: plug in deinitialize_tty_struct Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 15/48] TTY: fix fail path in tty_open Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 16/48] serial: altera_uart: Scan for a free port if platform device id is -1 Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 17/48] Char: moxa, do not touch NORMAL_ACTIVE bit Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 18/48] serial: core, move termios handling to uart_startup Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 19/48] serial: core, do not set DTR/RTS twice on startup Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 20/48] serial: core, remove uart_update_termios Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 21/48] tty: remove invalid location line in file header Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 22/48] Serial: ifx6x60c: Remove duplicate includes of linux/tty.h Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 23/48] tty: Clean console safely Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 24/48] Serial: Remove unused code Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 25/48] tty: make receive_buf() return the amout of bytes received Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 26/48] Char: nozomi, use GFP_KERNEL for kfifo allocation Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 27/48] Char: nozomi, remove port.count checks Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 28/48] Char: nozomi, remove useless tty_sem Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 29/48] Char: moxa, fix locking in moxa_write Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 30/48] TTY: serial_core, remove invalid test Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 31/48] TTY: serial_core, remove superfluous set_task_state Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 32/48] TTY: tty_io, annotate locking functions Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 33/48] drivers/tty/moxa.c: Put correct tty value Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 34/48] n_gsm: Use print_hex_dump_bytes Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 35/48] tty/serial: add support for Xilinx PS UART Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 36/48] parport: Use request_muxed_region for IT87 probe and lock Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 37/48] pch_uart: Support new device ML7223 IOH Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 38/48] ASoC: Update cx20442 for TTY API change Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 39/48] 8250_pci: Add support for the Digi/IBM PCIe 2-port Adapter Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 40/48] pch_phub: Support new device ML7223 Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 41/48] tty: Remove to support serial for S5P6442 Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 42/48] export kernel call get_task_comm() Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 43/48] Kernel documentation for the PTI feature Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 44/48] Intel PTI implementaiton of MIPI 1149.7 Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 45/48] n_tracerouter and n_tracesink ldisc additions Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 46/48] tty/serial: Add explicit PORT_TEGRA type Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 47/48] tty/serial: Fix break handling for PORT_TEGRA Greg Kroah-Hartman
2011-05-23 19:10 ` [PATCH 48/48] serial: 8250_pci: add support for Cronyx Omega PCI multiserial board Greg Kroah-Hartman
2011-05-23 19:27 ` [GIT PATCH] TTY/serial driver patches for .40 Linus Torvalds
2011-05-23 19:43 ` Greg KH
2011-05-26 10:54 ` Guennadi Liakhovetski
2011-05-27 1:00 ` Greg KH
2011-05-30 22:04 ` Peter Hüwe
2011-05-30 22:37 ` Peter Hüwe
2011-05-31 10:24 ` Guennadi Liakhovetski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306177625-17885-13-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ja@ssi.bg \
--cc=jslaby@suse.cz \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).