aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-16 16:53:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:12:35 -0400
commit6f67048cd010afe19d79d821f16055d9c704c6f0 (patch)
tree1fbd4717f97632a4753ea98555e285483e35cd45 /drivers/char
parentd87a6d951c6c09d191d9c10903deb3cc353fcd2c (diff)
tty: Introduce a tty_port common structure
Every tty driver has its own concept of a port structure and because they all differ we cannot extract commonality. Begin fixing this by creating a structure drivers can elect to use so that over time we can push fields into this and create commonality and then introduce common methods. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tty_io.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 54c4ada460ee..739c9c59fc62 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2088,6 +2088,40 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
2088 return tty_write(file, buf, count, ppos); 2088 return tty_write(file, buf, count, ppos);
2089} 2089}
2090 2090
2091void tty_port_init(struct tty_port *port)
2092{
2093 memset(port, 0, sizeof(*port));
2094 init_waitqueue_head(&port->open_wait);
2095 init_waitqueue_head(&port->close_wait);
2096 mutex_init(&port->mutex);
2097}
2098EXPORT_SYMBOL(tty_port_init);
2099
2100int tty_port_alloc_xmit_buf(struct tty_port *port)
2101{
2102 /* We may sleep in get_zeroed_page() */
2103 mutex_lock(&port->mutex);
2104 if (port->xmit_buf == NULL)
2105 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
2106 mutex_unlock(&port->mutex);
2107 if (port->xmit_buf == NULL)
2108 return -ENOMEM;
2109 return 0;
2110}
2111EXPORT_SYMBOL(tty_port_alloc_xmit_buf);
2112
2113void tty_port_free_xmit_buf(struct tty_port *port)
2114{
2115 mutex_lock(&port->mutex);
2116 if (port->xmit_buf != NULL) {
2117 free_page((unsigned long)port->xmit_buf);
2118 port->xmit_buf = NULL;
2119 }
2120 mutex_unlock(&port->mutex);
2121}
2122EXPORT_SYMBOL(tty_port_free_xmit_buf);
2123
2124
2091static char ptychar[] = "pqrstuvwxyzabcde"; 2125static char ptychar[] = "pqrstuvwxyzabcde";
2092 2126
2093/** 2127/**