summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-30 14:17:14 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-12 00:18:07 +0100
commit568aafc627e2978509e8a80c640ba534d1e843cc (patch)
tree1a24c5c0fc3a56054fa054a0255c04e5b7848daa /drivers/char
parenttty: istallion: tty port open/close methods (diff)
downloadlinux-568aafc627e2978509e8a80c640ba534d1e843cc.tar.xz
linux-568aafc627e2978509e8a80c640ba534d1e843cc.zip
tty: tty_port: Add a kref object to the tty port
Users of tty port need a way to refcount ports when hotplugging is involved. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tty_port.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index 84006de2900f..be492dd66437 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -29,6 +29,7 @@ void tty_port_init(struct tty_port *port)
spin_lock_init(&port->lock);
port->close_delay = (50 * HZ) / 100;
port->closing_wait = (3000 * HZ) / 100;
+ kref_init(&port->kref);
}
EXPORT_SYMBOL(tty_port_init);
@@ -56,6 +57,23 @@ void tty_port_free_xmit_buf(struct tty_port *port)
}
EXPORT_SYMBOL(tty_port_free_xmit_buf);
+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);
+ if (port->ops->destruct)
+ port->ops->destruct(port);
+ else
+ kfree(port);
+}
+
+void tty_port_put(struct tty_port *port)
+{
+ if (port)
+ kref_put(&port->kref, tty_port_destructor);
+}
+EXPORT_SYMBOL(tty_port_put);
/**
* tty_port_tty_get - get a tty reference