aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_port.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tty_port.c')
-rw-r--r--drivers/char/tty_port.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
new file mode 100644
index 000000000000..6fadb19d630b
--- /dev/null
+++ b/drivers/char/tty_port.c
@@ -0,0 +1,55 @@
1/*
2 * Tty port functions
3 */
4
5#include <linux/types.h>
6#include <linux/errno.h>
7#include <linux/tty.h>
8#include <linux/tty_driver.h>
9#include <linux/tty_flip.h>
10#include <linux/timer.h>
11#include <linux/string.h>
12#include <linux/slab.h>
13#include <linux/sched.h>
14#include <linux/init.h>
15#include <linux/wait.h>
16#include <linux/bitops.h>
17#include <linux/delay.h>
18#include <linux/module.h>
19
20void tty_port_init(struct tty_port *port)
21{
22 memset(port, 0, sizeof(*port));
23 init_waitqueue_head(&port->open_wait);
24 init_waitqueue_head(&port->close_wait);
25 mutex_init(&port->mutex);
26 port->close_delay = (50 * HZ) / 100;
27 port->closing_wait = (3000 * HZ) / 100;
28}
29EXPORT_SYMBOL(tty_port_init);
30
31int tty_port_alloc_xmit_buf(struct tty_port *port)
32{
33 /* We may sleep in get_zeroed_page() */
34 mutex_lock(&port->mutex);
35 if (port->xmit_buf == NULL)
36 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
37 mutex_unlock(&port->mutex);
38 if (port->xmit_buf == NULL)
39 return -ENOMEM;
40 return 0;
41}
42EXPORT_SYMBOL(tty_port_alloc_xmit_buf);
43
44void tty_port_free_xmit_buf(struct tty_port *port)
45{
46 mutex_lock(&port->mutex);
47 if (port->xmit_buf != NULL) {
48 free_page((unsigned long)port->xmit_buf);
49 port->xmit_buf = NULL;
50 }
51 mutex_unlock(&port->mutex);
52}
53EXPORT_SYMBOL(tty_port_free_xmit_buf);
54
55