From 2f69335710884ae6112fc8196ebe29b5cda7b79b Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:02 +0100 Subject: TTY: convert more flipping functions Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty pointer in many call sites. Only tty_port will be needed and hence no more tty_port_tty_get calls in those paths. Now 4 string flipping ones are on turn: * tty_insert_flip_string_flags * tty_insert_flip_string_fixed_flag * tty_prepare_flip_string * tty_prepare_flip_string_flags Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/staging/fwserial') diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 61ee29083b26..85dbdc1eccec 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -507,7 +507,8 @@ static void fwtty_emit_breaks(struct work_struct *work) while (n) { t = min(n, 16); - c = tty_insert_flip_string_fixed_flag(tty, buf, TTY_BREAK, t); + c = tty_insert_flip_string_fixed_flag(&port->port, buf, + TTY_BREAK, t); n -= c; brk += c; if (c < t) @@ -535,7 +536,7 @@ static void fwtty_pushrx(struct work_struct *work) spin_lock_bh(&port->lock); list_for_each_entry_safe(buf, next, &port->buf_list, list) { - n = tty_insert_flip_string_fixed_flag(tty, buf->data, + n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, TTY_NORMAL, buf->n); c += n; port->buffered -= n; @@ -630,7 +631,8 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) } if (!test_bit(BUFFERING_RX, &port->flags)) { - c = tty_insert_flip_string_fixed_flag(tty, data, TTY_NORMAL, n); + c = tty_insert_flip_string_fixed_flag(&port->port, data, + TTY_NORMAL, n); if (c > 0) tty_flip_buffer_push(tty); n -= c; -- cgit v1.2.3 From 92a19f9cec9a80ad93c06e115822deb729e2c6ad Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:03 +0100 Subject: TTY: switch tty_insert_flip_char Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. tty_insert_flip_char is the next one to proceed. This one is used all over the code, so the patch is huge. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/fwserial') diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 85dbdc1eccec..a2a0c43dec1c 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -617,7 +617,7 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) lsr &= port->status_mask; if (lsr & ~port->ignore_mask & UART_LSR_OE) { - if (!tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { + if (!tty_insert_flip_char(&port->port, 0, TTY_OVERRUN)) { err = -EIO; goto out; } -- cgit v1.2.3 From 2e124b4a390ca85325fae75764bef92f0547fa25 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 3 Jan 2013 15:53:06 +0100 Subject: TTY: switch tty_flip_buffer_push Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. Now, the one where most of tty_port_tty_get gets removed: tty_flip_buffer_push. IOW we also closed all the races in drivers not using tty_port_tty_get at all yet. Also we move tty_flip_buffer_push declaration from include/linux/tty.h to include/linux/tty_flip.h to all others while we are changing it anyway. Signed-off-by: Jiri Slaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 41 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 26 deletions(-) (limited to 'drivers/staging/fwserial') diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index a2a0c43dec1c..b403393c49c3 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -489,16 +489,11 @@ static void fwtty_do_hangup(struct work_struct *work) static void fwtty_emit_breaks(struct work_struct *work) { struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); - struct tty_struct *tty; static const char buf[16]; unsigned long now = jiffies; unsigned long elapsed = now - port->break_last; int n, t, c, brk = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - /* generate breaks at the line rate (but at least 1) */ n = (elapsed * port->cps) / HZ + 1; port->break_last = now; @@ -514,9 +509,7 @@ static void fwtty_emit_breaks(struct work_struct *work) if (c < t) break; } - tty_flip_buffer_push(tty); - - tty_kref_put(tty); + tty_flip_buffer_push(&port->port); if (port->mstatus & (UART_LSR_BI << 24)) schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); @@ -530,10 +523,6 @@ static void fwtty_pushrx(struct work_struct *work) struct buffered_rx *buf, *next; int n, c = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - spin_lock_bh(&port->lock); list_for_each_entry_safe(buf, next, &port->buf_list, list) { n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, @@ -545,7 +534,11 @@ static void fwtty_pushrx(struct work_struct *work) memmove(buf->data, buf->data + n, buf->n - n); buf->n -= n; } - __fwtty_throttle(port, tty); + tty = tty_port_tty_get(&port->port); + if (tty) { + __fwtty_throttle(port, tty); + tty_kref_put(tty); + } break; } else { list_del(&buf->list); @@ -553,13 +546,11 @@ static void fwtty_pushrx(struct work_struct *work) } } if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); if (list_empty(&port->buf_list)) clear_bit(BUFFERING_RX, &port->flags); spin_unlock_bh(&port->lock); - - tty_kref_put(tty); } static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) @@ -594,10 +585,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) unsigned lsr; int err = 0; - tty = tty_port_tty_get(&port->port); - if (!tty) - return -ENOENT; - fwtty_dbg(port, "%d", n); profile_size_distrib(port->stats.reads, n); @@ -634,16 +621,20 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) c = tty_insert_flip_string_fixed_flag(&port->port, data, TTY_NORMAL, n); if (c > 0) - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&port->port); n -= c; if (n) { /* start buffering and throttling */ n -= fwtty_buffer_rx(port, &data[c], n); - spin_lock_bh(&port->lock); - __fwtty_throttle(port, tty); - spin_unlock_bh(&port->lock); + tty = tty_port_tty_get(&port->port); + if (tty) { + spin_lock_bh(&port->lock); + __fwtty_throttle(port, tty); + spin_unlock_bh(&port->lock); + tty_kref_put(tty); + } } } else n -= fwtty_buffer_rx(port, data, n); @@ -654,8 +645,6 @@ static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) } out: - tty_kref_put(tty); - port->icount.rx += len; port->stats.lost += n; return err; -- cgit v1.2.3 From 4f73bc4dd3e8563ef4109f293a092820dff66d92 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 17 Jan 2013 22:44:22 -0800 Subject: tty: Added a CONFIG_TTY option to allow removal of TTY The option allows you to remove TTY and compile without errors. This saves space on systems that won't support TTY interfaces anyway. bloat-o-meter output is below. The bulk of this patch consists of Kconfig changes adding "depends on TTY" to various serial devices and similar drivers that require the TTY layer. Ideally, these dependencies would occur on a common intermediate symbol such as SERIO, but most drivers "select SERIO" rather than "depends on SERIO", and "select" does not respect dependencies. bloat-o-meter output comparing our previous minimal to new minimal by removing TTY. The list is filtered to not show removed entries with awk '$3 != "-"' as the list was very long. add/remove: 0/226 grow/shrink: 2/14 up/down: 6/-35356 (-35350) function old new delta chr_dev_init 166 170 +4 allow_signal 80 82 +2 static.__warned 143 142 -1 disallow_signal 63 62 -1 __set_special_pids 95 94 -1 unregister_console 126 121 -5 start_kernel 546 541 -5 register_console 593 588 -5 copy_from_user 45 40 -5 sys_setsid 128 120 -8 sys_vhangup 32 19 -13 do_exit 1543 1526 -17 bitmap_zero 60 40 -20 arch_local_irq_save 137 117 -20 release_task 674 652 -22 static.spin_unlock_irqrestore 308 260 -48 Signed-off-by: Joe Millenbach Reviewed-by: Jamey Sharp Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/fwserial') diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig index 580406cb1808..9cdb3cdc4b66 100644 --- a/drivers/staging/fwserial/Kconfig +++ b/drivers/staging/fwserial/Kconfig @@ -1,6 +1,6 @@ config FIREWIRE_SERIAL tristate "TTY over Firewire" - depends on FIREWIRE + depends on FIREWIRE && TTY help This enables TTY over IEEE 1394, providing high-speed serial connectivity to cabled peers. -- cgit v1.2.3