aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-10-18 16:26:44 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-22 19:53:21 -0400
commit2fc20661e3171d45e8e58a61eb5c6b7d8d614fde (patch)
tree7e598268df316dcb637c18d5ec49b30744f1c0a6
parent57c941212d203979720081198ebda41f51812635 (diff)
TTY: move TTY_FLUSH* flags to tty_port
They are only TTY buffers specific. And the buffers will go to tty_port in the next patches. So to remove the need to have both tty_port and tty_struct at some places, let us move the flags to tty_port. 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>
-rw-r--r--drivers/tty/tty_buffer.c18
-rw-r--r--include/linux/tty.h5
2 files changed, 13 insertions, 10 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 8b00f6a34a7d..6f366f257fba 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -134,17 +134,18 @@ static void __tty_buffer_flush(struct tty_struct *tty)
134 134
135void tty_buffer_flush(struct tty_struct *tty) 135void tty_buffer_flush(struct tty_struct *tty)
136{ 136{
137 struct tty_port *port = tty->port;
137 unsigned long flags; 138 unsigned long flags;
138 spin_lock_irqsave(&tty->buf.lock, flags); 139 spin_lock_irqsave(&tty->buf.lock, flags);
139 140
140 /* If the data is being pushed to the tty layer then we can't 141 /* If the data is being pushed to the tty layer then we can't
141 process it here. Instead set a flag and the flush_to_ldisc 142 process it here. Instead set a flag and the flush_to_ldisc
142 path will process the flush request before it exits */ 143 path will process the flush request before it exits */
143 if (test_bit(TTY_FLUSHING, &tty->flags)) { 144 if (test_bit(TTYP_FLUSHING, &port->iflags)) {
144 set_bit(TTY_FLUSHPENDING, &tty->flags); 145 set_bit(TTYP_FLUSHPENDING, &port->iflags);
145 spin_unlock_irqrestore(&tty->buf.lock, flags); 146 spin_unlock_irqrestore(&tty->buf.lock, flags);
146 wait_event(tty->read_wait, 147 wait_event(tty->read_wait,
147 test_bit(TTY_FLUSHPENDING, &tty->flags) == 0); 148 test_bit(TTYP_FLUSHPENDING, &port->iflags) == 0);
148 return; 149 return;
149 } else 150 } else
150 __tty_buffer_flush(tty); 151 __tty_buffer_flush(tty);
@@ -450,6 +451,7 @@ static void flush_to_ldisc(struct work_struct *work)
450{ 451{
451 struct tty_struct *tty = 452 struct tty_struct *tty =
452 container_of(work, struct tty_struct, buf.work); 453 container_of(work, struct tty_struct, buf.work);
454 struct tty_port *port = tty->port;
453 unsigned long flags; 455 unsigned long flags;
454 struct tty_ldisc *disc; 456 struct tty_ldisc *disc;
455 457
@@ -459,7 +461,7 @@ static void flush_to_ldisc(struct work_struct *work)
459 461
460 spin_lock_irqsave(&tty->buf.lock, flags); 462 spin_lock_irqsave(&tty->buf.lock, flags);
461 463
462 if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) { 464 if (!test_and_set_bit(TTYP_FLUSHING, &port->iflags)) {
463 struct tty_buffer *head; 465 struct tty_buffer *head;
464 while ((head = tty->buf.head) != NULL) { 466 while ((head = tty->buf.head) != NULL) {
465 int count; 467 int count;
@@ -477,7 +479,7 @@ static void flush_to_ldisc(struct work_struct *work)
477 /* Ldisc or user is trying to flush the buffers 479 /* Ldisc or user is trying to flush the buffers
478 we are feeding to the ldisc, stop feeding the 480 we are feeding to the ldisc, stop feeding the
479 line discipline as we want to empty the queue */ 481 line discipline as we want to empty the queue */
480 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) 482 if (test_bit(TTYP_FLUSHPENDING, &port->iflags))
481 break; 483 break;
482 if (!tty->receive_room) 484 if (!tty->receive_room)
483 break; 485 break;
@@ -491,14 +493,14 @@ static void flush_to_ldisc(struct work_struct *work)
491 flag_buf, count); 493 flag_buf, count);
492 spin_lock_irqsave(&tty->buf.lock, flags); 494 spin_lock_irqsave(&tty->buf.lock, flags);
493 } 495 }
494 clear_bit(TTY_FLUSHING, &tty->flags); 496 clear_bit(TTYP_FLUSHING, &port->iflags);
495 } 497 }
496 498
497 /* We may have a deferred request to flush the input buffer, 499 /* We may have a deferred request to flush the input buffer,
498 if so pull the chain under the lock and empty the queue */ 500 if so pull the chain under the lock and empty the queue */
499 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) { 501 if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) {
500 __tty_buffer_flush(tty); 502 __tty_buffer_flush(tty);
501 clear_bit(TTY_FLUSHPENDING, &tty->flags); 503 clear_bit(TTYP_FLUSHPENDING, &port->iflags);
502 wake_up(&tty->read_wait); 504 wake_up(&tty->read_wait);
503 } 505 }
504 spin_unlock_irqrestore(&tty->buf.lock, flags); 506 spin_unlock_irqrestore(&tty->buf.lock, flags);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 08787ece3fdc..b4b3c568d242 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -197,6 +197,9 @@ struct tty_port {
197 wait_queue_head_t close_wait; /* Close waiters */ 197 wait_queue_head_t close_wait; /* Close waiters */
198 wait_queue_head_t delta_msr_wait; /* Modem status change */ 198 wait_queue_head_t delta_msr_wait; /* Modem status change */
199 unsigned long flags; /* TTY flags ASY_*/ 199 unsigned long flags; /* TTY flags ASY_*/
200 unsigned long iflags; /* TTYP_ internal flags */
201#define TTYP_FLUSHING 1 /* Flushing to ldisc in progress */
202#define TTYP_FLUSHPENDING 2 /* Queued buffer flush pending */
200 unsigned char console:1; /* port is a console */ 203 unsigned char console:1; /* port is a console */
201 struct mutex mutex; /* Locking */ 204 struct mutex mutex; /* Locking */
202 struct mutex buf_mutex; /* Buffer alloc lock */ 205 struct mutex buf_mutex; /* Buffer alloc lock */
@@ -309,8 +312,6 @@ struct tty_file_private {
309#define TTY_PTY_LOCK 16 /* pty private */ 312#define TTY_PTY_LOCK 16 /* pty private */
310#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ 313#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */
311#define TTY_HUPPED 18 /* Post driver->hangup() */ 314#define TTY_HUPPED 18 /* Post driver->hangup() */
312#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */
313#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */
314#define TTY_HUPPING 21 /* ->hangup() in progress */ 315#define TTY_HUPPING 21 /* ->hangup() in progress */
315 316
316#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) 317#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))