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>
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 5043b12..2e93eb8 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -67,6 +67,7 @@
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 */