From c481c707fe4b07783d9a2499a9bbbb94497e9b18 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 11 Jun 2009 13:04:27 +0100 Subject: tty: remove buffer special casing Long long ago a 4K kmalloc allocated two pages so the tty layer used the page allocator, except on some machines where the page size was huge. This was removed from the core tty layer with the tty buffer re-implementation but not from tty_audit or the n_tty ldisc. Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/char/n_tty.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/char/n_tty.c') diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index f6f0e4ec2b5..b4b12b4f0ac 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -76,19 +76,12 @@ static inline unsigned char *alloc_buf(void) { gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; - - if (PAGE_SIZE != N_TTY_BUF_SIZE) - return kmalloc(N_TTY_BUF_SIZE, prio); - else - return (unsigned char *)__get_free_page(prio); + return kmalloc(N_TTY_BUF_SIZE, prio); } static inline void free_buf(unsigned char *buf) { - if (PAGE_SIZE != N_TTY_BUF_SIZE) - kfree(buf); - else - free_page((unsigned long) buf); + kfree(buf); } static inline int tty_put_user(struct tty_struct *tty, unsigned char x, -- cgit v1.2.3 From 0b4068a1287b02018d1b3159e7be6f27f3e3e68c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 11 Jun 2009 13:05:49 +0100 Subject: 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 --- drivers/char/n_tty.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'drivers/char/n_tty.c') diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index b4b12b4f0ac..94a5d5020ab 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -73,17 +73,6 @@ #define ECHO_OP_SET_CANON_COL 0x81 #define ECHO_OP_ERASE_TAB 0x82 -static inline unsigned char *alloc_buf(void) -{ - gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; - return kmalloc(N_TTY_BUF_SIZE, prio); -} - -static inline void free_buf(unsigned char *buf) -{ - kfree(buf); -} - static inline int tty_put_user(struct tty_struct *tty, unsigned char x, unsigned char __user *ptr) { @@ -1551,11 +1540,11 @@ static void n_tty_close(struct tty_struct *tty) { n_tty_flush_buffer(tty); if (tty->read_buf) { - free_buf(tty->read_buf); + kfree(tty->read_buf); tty->read_buf = NULL; } if (tty->echo_buf) { - free_buf(tty->echo_buf); + kfree(tty->echo_buf); tty->echo_buf = NULL; } } @@ -1577,17 +1566,16 @@ static int n_tty_open(struct tty_struct *tty) /* These are ugly. Currently a malloc failure here can panic */ if (!tty->read_buf) { - tty->read_buf = alloc_buf(); + tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); if (!tty->read_buf) return -ENOMEM; } if (!tty->echo_buf) { - tty->echo_buf = alloc_buf(); + tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); + if (!tty->echo_buf) return -ENOMEM; } - memset(tty->read_buf, 0, N_TTY_BUF_SIZE); - memset(tty->echo_buf, 0, N_TTY_BUF_SIZE); reset_buffer_flags(tty); tty->column = 0; n_tty_set_termios(tty, NULL); -- cgit v1.2.3