xref: /linux-6.15/include/linux/tty_flip.h (revision 05c7cd39)
1 #ifndef _LINUX_TTY_FLIP_H
2 #define _LINUX_TTY_FLIP_H
3 
4 extern int tty_buffer_request_room(struct tty_port *port, size_t size);
5 extern int tty_insert_flip_string_flags(struct tty_port *port,
6 		const unsigned char *chars, const char *flags, size_t size);
7 extern int tty_insert_flip_string_fixed_flag(struct tty_port *port,
8 		const unsigned char *chars, char flag, size_t size);
9 extern int tty_prepare_flip_string(struct tty_port *port,
10 		unsigned char **chars, size_t size);
11 extern int tty_prepare_flip_string_flags(struct tty_port *port,
12 		unsigned char **chars, char **flags, size_t size);
13 void tty_schedule_flip(struct tty_struct *tty);
14 
15 static inline int tty_insert_flip_char(struct tty_port *port,
16 					unsigned char ch, char flag)
17 {
18 	struct tty_buffer *tb = port->buf.tail;
19 	if (tb && tb->used < tb->size) {
20 		tb->flag_buf_ptr[tb->used] = flag;
21 		tb->char_buf_ptr[tb->used++] = ch;
22 		return 1;
23 	}
24 	return tty_insert_flip_string_flags(port, &ch, &flag, 1);
25 }
26 
27 static inline int tty_insert_flip_string(struct tty_port *port,
28 		const unsigned char *chars, size_t size)
29 {
30 	return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
31 }
32 
33 #endif /* _LINUX_TTY_FLIP_H */
34