aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/tty_buffer.c')
-rw-r--r--drivers/tty/tty_buffer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 143deb62467d..3605103fc1ac 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -202,14 +202,16 @@ static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b)
202/** 202/**
203 * tty_buffer_flush - flush full tty buffers 203 * tty_buffer_flush - flush full tty buffers
204 * @tty: tty to flush 204 * @tty: tty to flush
205 * @ld: optional ldisc ptr (must be referenced)
205 * 206 *
206 * flush all the buffers containing receive data. 207 * flush all the buffers containing receive data. If ld != NULL,
208 * flush the ldisc input buffer.
207 * 209 *
208 * Locking: takes buffer lock to ensure single-threaded flip buffer 210 * Locking: takes buffer lock to ensure single-threaded flip buffer
209 * 'consumer' 211 * 'consumer'
210 */ 212 */
211 213
212void tty_buffer_flush(struct tty_struct *tty) 214void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
213{ 215{
214 struct tty_port *port = tty->port; 216 struct tty_port *port = tty->port;
215 struct tty_bufhead *buf = &port->buf; 217 struct tty_bufhead *buf = &port->buf;
@@ -223,6 +225,10 @@ void tty_buffer_flush(struct tty_struct *tty)
223 buf->head = next; 225 buf->head = next;
224 } 226 }
225 buf->head->read = buf->head->commit; 227 buf->head->read = buf->head->commit;
228
229 if (ld && ld->ops->flush_buffer)
230 ld->ops->flush_buffer(tty);
231
226 atomic_dec(&buf->priority); 232 atomic_dec(&buf->priority);
227 mutex_unlock(&buf->lock); 233 mutex_unlock(&buf->lock);
228} 234}