aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-06-11 08:05:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:51:02 -0400
commit0b4068a1287b02018d1b3159e7be6f27f3e3e68c (patch)
tree2b39a25c25cfda6ccfe705dab6564186471c138a
parentc481c707fe4b07783d9a2499a9bbbb94497e9b18 (diff)
tty: simplify buffer allocator cleanups
Having cleaned up the allocators we might as well remove the inline helpers for some of it Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/n_tty.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b4b12b4f0ac4..94a5d5020abc 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -73,17 +73,6 @@
73#define ECHO_OP_SET_CANON_COL 0x81 73#define ECHO_OP_SET_CANON_COL 0x81
74#define ECHO_OP_ERASE_TAB 0x82 74#define ECHO_OP_ERASE_TAB 0x82
75 75
76static inline unsigned char *alloc_buf(void)
77{
78 gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
79 return kmalloc(N_TTY_BUF_SIZE, prio);
80}
81
82static inline void free_buf(unsigned char *buf)
83{
84 kfree(buf);
85}
86
87static inline int tty_put_user(struct tty_struct *tty, unsigned char x, 76static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
88 unsigned char __user *ptr) 77 unsigned char __user *ptr)
89{ 78{
@@ -1551,11 +1540,11 @@ static void n_tty_close(struct tty_struct *tty)
1551{ 1540{
1552 n_tty_flush_buffer(tty); 1541 n_tty_flush_buffer(tty);
1553 if (tty->read_buf) { 1542 if (tty->read_buf) {
1554 free_buf(tty->read_buf); 1543 kfree(tty->read_buf);
1555 tty->read_buf = NULL; 1544 tty->read_buf = NULL;
1556 } 1545 }
1557 if (tty->echo_buf) { 1546 if (tty->echo_buf) {
1558 free_buf(tty->echo_buf); 1547 kfree(tty->echo_buf);
1559 tty->echo_buf = NULL; 1548 tty->echo_buf = NULL;
1560 } 1549 }
1561} 1550}
@@ -1577,17 +1566,16 @@ static int n_tty_open(struct tty_struct *tty)
1577 1566
1578 /* These are ugly. Currently a malloc failure here can panic */ 1567 /* These are ugly. Currently a malloc failure here can panic */
1579 if (!tty->read_buf) { 1568 if (!tty->read_buf) {
1580 tty->read_buf = alloc_buf(); 1569 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1581 if (!tty->read_buf) 1570 if (!tty->read_buf)
1582 return -ENOMEM; 1571 return -ENOMEM;
1583 } 1572 }
1584 if (!tty->echo_buf) { 1573 if (!tty->echo_buf) {
1585 tty->echo_buf = alloc_buf(); 1574 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1575
1586 if (!tty->echo_buf) 1576 if (!tty->echo_buf)
1587 return -ENOMEM; 1577 return -ENOMEM;
1588 } 1578 }
1589 memset(tty->read_buf, 0, N_TTY_BUF_SIZE);
1590 memset(tty->echo_buf, 0, N_TTY_BUF_SIZE);
1591 reset_buffer_flags(tty); 1579 reset_buffer_flags(tty);
1592 tty->column = 0; 1580 tty->column = 0;
1593 n_tty_set_termios(tty, NULL); 1581 n_tty_set_termios(tty, NULL);