Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_TTY_FLIP_H |
| 2 | #define _LINUX_TTY_FLIP_H |
| 3 | |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 4 | extern int tty_buffer_request_room(struct tty_struct *tty, size_t size); |
Thomas Koeller | 1aef821 | 2006-03-25 03:07:03 -0800 | [diff] [blame] | 5 | extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size); |
| 6 | extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size); |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 7 | extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size); |
| 8 | extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size); |
| 9 | |
Adrian Bunk | 41c28ff | 2006-03-23 03:00:56 -0800 | [diff] [blame] | 10 | static inline int tty_insert_flip_char(struct tty_struct *tty, |
| 11 | unsigned char ch, char flag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | { |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 13 | struct tty_buffer *tb = tty->buf.tail; |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 14 | if (tb && tb->active && tb->used < tb->size) { |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 15 | tb->flag_buf_ptr[tb->used] = flag; |
| 16 | tb->char_buf_ptr[tb->used++] = ch; |
| 17 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | } |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 19 | return tty_insert_flip_string_flags(tty, &ch, &flag, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Adrian Bunk | 41c28ff | 2006-03-23 03:00:56 -0800 | [diff] [blame] | 22 | static inline void tty_schedule_flip(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 24 | unsigned long flags; |
| 25 | spin_lock_irqsave(&tty->buf.lock, flags); |
Paul Fulghum | 8977d92 | 2006-02-10 01:51:14 -0800 | [diff] [blame] | 26 | if (tty->buf.tail != NULL) { |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 27 | tty->buf.tail->active = 0; |
Paul Fulghum | 8977d92 | 2006-02-10 01:51:14 -0800 | [diff] [blame] | 28 | tty->buf.tail->commit = tty->buf.tail->used; |
| 29 | } |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 30 | spin_unlock_irqrestore(&tty->buf.lock, flags); |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 31 | schedule_delayed_work(&tty->buf.work, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | #undef _INLINE_ |
| 35 | |
| 36 | |
| 37 | #endif /* _LINUX_TTY_FLIP_H */ |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |