tty: Simplify flip buffer list with 0-sized sentinel

Use a 0-sized sentinel to avoid assigning the head ptr from
the driver side thread. This also eliminates testing head/tail
for NULL.

When the sentinel is first 'consumed' by the buffer work
(or by tty_buffer_flush()), it is detached from the list but not
freed nor added to the free list. Both buffer work and
tty_buffer_flush() continue to preserve at least 1 flip buffer
to which head & tail is pointed.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Peter Hurley 2013-06-15 09:36:07 -04:00 committed by Greg Kroah-Hartman
parent 809850b7a5
commit 7391ee1695
2 changed files with 19 additions and 31 deletions

View file

@ -67,6 +67,7 @@ static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs)
struct tty_bufhead {
struct work_struct work;
spinlock_t lock;
struct tty_buffer sentinel;
struct tty_buffer *head; /* Queue head */
struct tty_buffer *tail; /* Active buffer */
struct llist_head free; /* Free queue head */