aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:37:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:40 -0400
commit9e48565d217a8a96cc7577308ad41e9e4b806a62 (patch)
tree2ff5f745d72e0d33a93cdc51622f011f0031eb76
parente04957365b21066285557e42ffe16d8330d46c02 (diff)
tty: Split tty_port into its own file
Not much in it yet but this will grow a lot Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/tty_io.c36
-rw-r--r--drivers/char/tty_port.c55
3 files changed, 56 insertions, 37 deletions
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 77ea41b88ea8..1a4247dccac4 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -7,7 +7,7 @@
7# 7#
8FONTMAPFILE = cp437.uni 8FONTMAPFILE = cp437.uni
9 9
10obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o 10obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o tty_port.o
11 11
12obj-$(CONFIG_LEGACY_PTYS) += pty.o 12obj-$(CONFIG_LEGACY_PTYS) += pty.o
13obj-$(CONFIG_UNIX98_PTYS) += pty.o 13obj-$(CONFIG_UNIX98_PTYS) += pty.o
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 3a726936aa5b..732316899ca4 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1139,42 +1139,6 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
1139 return tty_write(file, buf, count, ppos); 1139 return tty_write(file, buf, count, ppos);
1140} 1140}
1141 1141
1142void tty_port_init(struct tty_port *port)
1143{
1144 memset(port, 0, sizeof(*port));
1145 init_waitqueue_head(&port->open_wait);
1146 init_waitqueue_head(&port->close_wait);
1147 mutex_init(&port->mutex);
1148 port->close_delay = (50 * HZ) / 100;
1149 port->closing_wait = (3000 * HZ) / 100;
1150}
1151EXPORT_SYMBOL(tty_port_init);
1152
1153int tty_port_alloc_xmit_buf(struct tty_port *port)
1154{
1155 /* We may sleep in get_zeroed_page() */
1156 mutex_lock(&port->mutex);
1157 if (port->xmit_buf == NULL)
1158 port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
1159 mutex_unlock(&port->mutex);
1160 if (port->xmit_buf == NULL)
1161 return -ENOMEM;
1162 return 0;
1163}
1164EXPORT_SYMBOL(tty_port_alloc_xmit_buf);
1165
1166void tty_port_free_xmit_buf(struct tty_port *port)
1167{
1168 mutex_lock(&port->mutex);
1169 if (port->xmit_buf != NULL) {
1170 free_page((unsigned long)port->xmit_buf);
1171 port->xmit_buf = NULL;
1172 }
1173 mutex_unlock(&port->mutex);
1174}
1175EXPORT_SYMBOL(tty_port_free_xmit_buf);
1176
1177
1178static char ptychar[] = "pqrstuvwxyzabcde"; 1142static char ptychar[] = "pqrstuvwxyzabcde";
1179 1143
1180/** 1144/**
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