summaryrefslogtreecommitdiff
path: root/drivers/tty/tty_port.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-11-15 12:49:54 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-16 05:20:58 +0400
commitde274bfe0fc81def6ddb8a17020a9a4b56477cc4 (patch)
treefb2aeacdb9fc1e94b5aa13beb6a4818c043b43d3 /drivers/tty/tty_port.c
parent9a8e62bc68832dc55a5e6868f812b65567fe66b5 (diff)
downloadlinux-de274bfe0fc81def6ddb8a17020a9a4b56477cc4.tar.xz
TTY: introduce tty_port_destroy
After commit "TTY: move tty buffers to tty_port", the tty buffers are not freed in some drivers. This is because tty_port_destructor is not called whenever a tty_port is freed. This was an assumption I counted with but was unfortunately untrue. Those using refcounting are safe now, but for those which do not we introduce a function to be called right before the tty_port is freed by the drivers. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_port.c')
-rw-r--r--drivers/tty/tty_port.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index fdc42c2d565f..b7ff59d3db88 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -122,12 +122,26 @@ void tty_port_free_xmit_buf(struct tty_port *port)
}
EXPORT_SYMBOL(tty_port_free_xmit_buf);
+/**
+ * tty_port_destroy -- destroy inited port
+ * @port: tty port to be doestroyed
+ *
+ * When a port was initialized using tty_port_init, one has to destroy the
+ * port by this function. Either indirectly by using tty_port refcounting
+ * (tty_port_put) or directly if refcounting is not used.
+ */
+void tty_port_destroy(struct tty_port *port)
+{
+ tty_buffer_free_all(port);
+}
+EXPORT_SYMBOL(tty_port_destroy);
+
static void tty_port_destructor(struct kref *kref)
{
struct tty_port *port = container_of(kref, struct tty_port, kref);
if (port->xmit_buf)
free_page((unsigned long)port->xmit_buf);
- tty_buffer_free_all(port);
+ tty_port_destroy(port);
if (port->ops && port->ops->destruct)
port->ops->destruct(port);
else