aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_buffer.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 09:36:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 19:47:07 -0400
commit9dd5139f973f55ab4b2e9aff8171781f1e55b29d (patch)
tree73d115cde8da85d22a9457de1d4f5567f67f0932 /drivers/tty/tty_buffer.c
parent1cef50e317c3395c6e8451f2b82a155db6ef2b42 (diff)
tty: Factor flip buffer initialization into helper function
Factor shared code; prepare for adding 0-sized sentinel flip buffer. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_buffer.c')
-rw-r--r--drivers/tty/tty_buffer.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index a5e396217f76..56d460295c87 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -22,6 +22,15 @@
22#define MIN_TTYB_SIZE 256 22#define MIN_TTYB_SIZE 256
23#define TTYB_ALIGN_MASK 255 23#define TTYB_ALIGN_MASK 255
24 24
25static void tty_buffer_reset(struct tty_buffer *p, size_t size)
26{
27 p->used = 0;
28 p->size = size;
29 p->next = NULL;
30 p->commit = 0;
31 p->read = 0;
32}
33
25/** 34/**
26 * tty_buffer_free_all - free buffers used by a tty 35 * tty_buffer_free_all - free buffers used by a tty
27 * @tty: tty to free from 36 * @tty: tty to free from
@@ -70,11 +79,8 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size)
70 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); 79 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);
71 if (p == NULL) 80 if (p == NULL)
72 return NULL; 81 return NULL;
73 p->used = 0; 82
74 p->size = size; 83 tty_buffer_reset(p, size);
75 p->next = NULL;
76 p->commit = 0;
77 p->read = 0;
78 port->buf.memory_used += size; 84 port->buf.memory_used += size;
79 return p; 85 return p;
80} 86}
@@ -185,10 +191,7 @@ static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size)
185 struct tty_buffer *t = *tbh; 191 struct tty_buffer *t = *tbh;
186 192
187 *tbh = t->next; 193 *tbh = t->next;
188 t->next = NULL; 194 tty_buffer_reset(t, t->size);
189 t->used = 0;
190 t->commit = 0;
191 t->read = 0;
192 port->buf.memory_used += t->size; 195 port->buf.memory_used += t->size;
193 return t; 196 return t;
194 } 197 }