forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tty: Split tty_port into its own file
Not much in it yet but this will grow a lot Signed-off-by: Alan Cox <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
Showing
3 changed files
with
56 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Tty port functions | ||
*/ | ||
|
||
#include <linux/types.h> | ||
#include <linux/errno.h> | ||
#include <linux/tty.h> | ||
#include <linux/tty_driver.h> | ||
#include <linux/tty_flip.h> | ||
#include <linux/timer.h> | ||
#include <linux/string.h> | ||
#include <linux/slab.h> | ||
#include <linux/sched.h> | ||
#include <linux/init.h> | ||
#include <linux/wait.h> | ||
#include <linux/bitops.h> | ||
#include <linux/delay.h> | ||
#include <linux/module.h> | ||
|
||
void tty_port_init(struct tty_port *port) | ||
{ | ||
memset(port, 0, sizeof(*port)); | ||
init_waitqueue_head(&port->open_wait); | ||
init_waitqueue_head(&port->close_wait); | ||
mutex_init(&port->mutex); | ||
port->close_delay = (50 * HZ) / 100; | ||
port->closing_wait = (3000 * HZ) / 100; | ||
} | ||
EXPORT_SYMBOL(tty_port_init); | ||
|
||
int tty_port_alloc_xmit_buf(struct tty_port *port) | ||
{ | ||
/* We may sleep in get_zeroed_page() */ | ||
mutex_lock(&port->mutex); | ||
if (port->xmit_buf == NULL) | ||
port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); | ||
mutex_unlock(&port->mutex); | ||
if (port->xmit_buf == NULL) | ||
return -ENOMEM; | ||
return 0; | ||
} | ||
EXPORT_SYMBOL(tty_port_alloc_xmit_buf); | ||
|
||
void tty_port_free_xmit_buf(struct tty_port *port) | ||
{ | ||
mutex_lock(&port->mutex); | ||
if (port->xmit_buf != NULL) { | ||
free_page((unsigned long)port->xmit_buf); | ||
port->xmit_buf = NULL; | ||
} | ||
mutex_unlock(&port->mutex); | ||
} | ||
EXPORT_SYMBOL(tty_port_free_xmit_buf); | ||
|
||
|