Commit 0b4068a1287b02018d1b3159e7be6f27f3e3e68c

Authored by Alan Cox
Committed by Linus Torvalds
1 parent c481c707fe

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>

Showing 1 changed file with 5 additions and 17 deletions Side-by-side Diff

drivers/char/n_tty.c
... ... @@ -73,17 +73,6 @@
73 73 #define ECHO_OP_SET_CANON_COL 0x81
74 74 #define ECHO_OP_ERASE_TAB 0x82
75 75  
76   -static 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   -
82   -static inline void free_buf(unsigned char *buf)
83   -{
84   - kfree(buf);
85   -}
86   -
87 76 static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
88 77 unsigned char __user *ptr)
89 78 {
90 79  
... ... @@ -1551,11 +1540,11 @@
1551 1540 {
1552 1541 n_tty_flush_buffer(tty);
1553 1542 if (tty->read_buf) {
1554   - free_buf(tty->read_buf);
  1543 + kfree(tty->read_buf);
1555 1544 tty->read_buf = NULL;
1556 1545 }
1557 1546 if (tty->echo_buf) {
1558   - free_buf(tty->echo_buf);
  1547 + kfree(tty->echo_buf);
1559 1548 tty->echo_buf = NULL;
1560 1549 }
1561 1550 }
1562 1551  
1563 1552  
... ... @@ -1577,17 +1566,16 @@
1577 1566  
1578 1567 /* These are ugly. Currently a malloc failure here can panic */
1579 1568 if (!tty->read_buf) {
1580   - tty->read_buf = alloc_buf();
  1569 + tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1581 1570 if (!tty->read_buf)
1582 1571 return -ENOMEM;
1583 1572 }
1584 1573 if (!tty->echo_buf) {
1585   - tty->echo_buf = alloc_buf();
  1574 + tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
  1575 +
1586 1576 if (!tty->echo_buf)
1587 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 1579 reset_buffer_flags(tty);
1592 1580 tty->column = 0;
1593 1581 n_tty_set_termios(tty, NULL);