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>
#define MIN_TTYB_SIZE 256
#define TTYB_ALIGN_MASK 255
+static void tty_buffer_reset(struct tty_buffer *p, size_t size)
+{
+ p->used = 0;
+ p->size = size;
+ p->next = NULL;
+ p->commit = 0;
+ p->read = 0;
+}
+
/**
* tty_buffer_free_all - free buffers used by a tty
* @tty: tty to free from
p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);
if (p == NULL)
return NULL;
- p->used = 0;
- p->size = size;
- p->next = NULL;
- p->commit = 0;
- p->read = 0;
+
+ tty_buffer_reset(p, size);
port->buf.memory_used += size;
return p;
}
struct tty_buffer *t = *tbh;
*tbh = t->next;
- t->next = NULL;
- t->used = 0;
- t->commit = 0;
- t->read = 0;
+ tty_buffer_reset(t, t->size);
port->buf.memory_used += t->size;
return t;
}