aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-10-18 16:26:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-22 19:50:54 -0400
commit70ece7a731598ac760c2a34421fcb2de18d2713f (patch)
treedf29c391e619bb98ba720da166978ff0ea47fe81 /drivers/tty
parent6c633f27ccf783e9a782b84e34aeaeb7949a3359 (diff)
TTY: n_tty, add ldisc data to n_tty
All n_tty related members from tty_struct will be moved here. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/n_tty.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 3ebab0cfceb2..3d1594e10d00 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -73,6 +73,10 @@
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
76struct n_tty_data {
77 char dummy;
78};
79
76static inline int tty_put_user(struct tty_struct *tty, unsigned char x, 80static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
77 unsigned char __user *ptr) 81 unsigned char __user *ptr)
78{ 82{
@@ -1556,11 +1560,15 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1556 1560
1557static void n_tty_close(struct tty_struct *tty) 1561static void n_tty_close(struct tty_struct *tty)
1558{ 1562{
1563 struct n_tty_data *ldata = tty->disc_data;
1564
1559 n_tty_flush_buffer(tty); 1565 n_tty_flush_buffer(tty);
1560 kfree(tty->read_buf); 1566 kfree(tty->read_buf);
1561 kfree(tty->echo_buf); 1567 kfree(tty->echo_buf);
1568 kfree(ldata);
1562 tty->read_buf = NULL; 1569 tty->read_buf = NULL;
1563 tty->echo_buf = NULL; 1570 tty->echo_buf = NULL;
1571 tty->disc_data = NULL;
1564} 1572}
1565 1573
1566/** 1574/**
@@ -1575,23 +1583,32 @@ static void n_tty_close(struct tty_struct *tty)
1575 1583
1576static int n_tty_open(struct tty_struct *tty) 1584static int n_tty_open(struct tty_struct *tty)
1577{ 1585{
1586 struct n_tty_data *ldata;
1587
1588 ldata = kzalloc(sizeof(*ldata), GFP_KERNEL);
1589 if (!ldata)
1590 goto err;
1591
1578 /* These are ugly. Currently a malloc failure here can panic */ 1592 /* These are ugly. Currently a malloc failure here can panic */
1579 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1593 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1580 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1594 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1581 if (!tty->read_buf || !tty->echo_buf) 1595 if (!tty->read_buf || !tty->echo_buf)
1582 goto err_free_bufs; 1596 goto err_free_bufs;
1583 1597
1598 tty->disc_data = ldata;
1584 reset_buffer_flags(tty); 1599 reset_buffer_flags(tty);
1585 tty_unthrottle(tty); 1600 tty_unthrottle(tty);
1586 tty->column = 0; 1601 tty->column = 0;
1587 n_tty_set_termios(tty, NULL); 1602 n_tty_set_termios(tty, NULL);
1588 tty->minimum_to_wake = 1; 1603 tty->minimum_to_wake = 1;
1589 tty->closing = 0; 1604 tty->closing = 0;
1605
1590 return 0; 1606 return 0;
1591err_free_bufs: 1607err_free_bufs:
1592 kfree(tty->read_buf); 1608 kfree(tty->read_buf);
1593 kfree(tty->echo_buf); 1609 kfree(tty->echo_buf);
1594 1610 kfree(ldata);
1611err:
1595 return -ENOMEM; 1612 return -ENOMEM;
1596} 1613}
1597 1614