Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Linus Torvalds
9e48565d e0495736

+56 -37
+1 -1
drivers/char/Makefile
··· 7 7 # 8 8 FONTMAPFILE = cp437.uni 9 9 10 - obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o 10 + obj-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 12 12 obj-$(CONFIG_LEGACY_PTYS) += pty.o 13 13 obj-$(CONFIG_UNIX98_PTYS) += pty.o
-36
drivers/char/tty_io.c
··· 1139 1139 return tty_write(file, buf, count, ppos); 1140 1140 } 1141 1141 1142 - void 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 - } 1151 - EXPORT_SYMBOL(tty_port_init); 1152 - 1153 - int 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 - } 1164 - EXPORT_SYMBOL(tty_port_alloc_xmit_buf); 1165 - 1166 - void 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 - } 1175 - EXPORT_SYMBOL(tty_port_free_xmit_buf); 1176 - 1177 - 1178 1142 static char ptychar[] = "pqrstuvwxyzabcde"; 1179 1143 1180 1144 /**
+55
drivers/char/tty_port.c
··· 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 + 20 + void 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 + } 29 + EXPORT_SYMBOL(tty_port_init); 30 + 31 + int 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 + } 42 + EXPORT_SYMBOL(tty_port_alloc_xmit_buf); 43 + 44 + void 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 + } 53 + EXPORT_SYMBOL(tty_port_free_xmit_buf); 54 + 55 +