blob: 0c6169fff366374aa929a36737a8e3f3386ab016 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_TTY_FLIP_H
2#define _LINUX_TTY_FLIP_H
3
Alan Cox33f0f882006-01-09 20:54:13 -08004extern int tty_buffer_request_room(struct tty_struct *tty, size_t size);
5extern int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size);
6extern int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size);
7extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
8extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size);
9
Adrian Bunk41c28ff2006-03-23 03:00:56 -080010static inline int tty_insert_flip_char(struct tty_struct *tty,
11 unsigned char ch, char flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012{
Alan Cox33f0f882006-01-09 20:54:13 -080013 struct tty_buffer *tb = tty->buf.tail;
Paul Fulghum808249c2006-02-03 03:04:41 -080014 if (tb && tb->active && tb->used < tb->size) {
Alan Cox33f0f882006-01-09 20:54:13 -080015 tb->flag_buf_ptr[tb->used] = flag;
16 tb->char_buf_ptr[tb->used++] = ch;
17 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 }
Alan Cox33f0f882006-01-09 20:54:13 -080019 return tty_insert_flip_string_flags(tty, &ch, &flag, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020}
21
Adrian Bunk41c28ff2006-03-23 03:00:56 -080022static inline void tty_schedule_flip(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Paul Fulghum808249c2006-02-03 03:04:41 -080024 unsigned long flags;
25 spin_lock_irqsave(&tty->buf.lock, flags);
Paul Fulghum8977d922006-02-10 01:51:14 -080026 if (tty->buf.tail != NULL) {
Paul Fulghum808249c2006-02-03 03:04:41 -080027 tty->buf.tail->active = 0;
Paul Fulghum8977d922006-02-10 01:51:14 -080028 tty->buf.tail->commit = tty->buf.tail->used;
29 }
Paul Fulghum808249c2006-02-03 03:04:41 -080030 spin_unlock_irqrestore(&tty->buf.lock, flags);
Alan Cox33f0f882006-01-09 20:54:13 -080031 schedule_delayed_work(&tty->buf.work, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032}
33
34#undef _INLINE_
35
36
37#endif /* _LINUX_TTY_FLIP_H */
38
39
40
41
42
43
44