1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_TTY_BUFFER_H
3 #define _LINUX_TTY_BUFFER_H
5 #include <linux/atomic.h>
6 #include <linux/llist.h>
7 #include <linux/mutex.h>
8 #include <linux/workqueue.h>
12 struct tty_buffer *next;
13 struct llist_node free;
18 int lookahead; /* Lazy update on recv, can become less than "read" */
21 /* Data points here */
25 static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs)
27 return ((unsigned char *)b->data) + ofs;
30 static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs)
32 return (char *)char_buf_ptr(b, ofs) + b->size;
36 struct tty_buffer *head; /* Queue head */
37 struct work_struct work;
40 struct tty_buffer sentinel;
41 struct llist_head free; /* Free queue head */
42 atomic_t mem_used; /* In-use buffers excluding free list */
44 struct tty_buffer *tail; /* Active buffer */
48 * When a break, frame error, or parity error happens, these codes are
49 * stuffed into the flags buffer.