Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20191
b: refs/heads/master
c: 8977d92
h: refs/heads/master
i:
  20189: 5871fd8
  20187: 97c2a65
  20183: 44cb108
  20175: d7322b7
  20159: f08ec95
v: v3
  • Loading branch information
Paul Fulghum authored and Linus Torvalds committed Feb 10, 2006
1 parent 0840aa1 commit 3fd877b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f0188f47482efdbd2e005103bb4f0224a835dfad
refs/heads/master: 8977d929e49021d9a6e031310aab01fa72f849c2
30 changes: 22 additions & 8 deletions trunk/drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
p->size = size;
p->next = NULL;
p->active = 0;
p->commit = 0;
p->read = 0;
p->char_buf_ptr = (char *)(p->data);
p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;
/* printk("Flip create %p\n", p); */
Expand Down Expand Up @@ -298,6 +300,8 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
*tbh = t->next;
t->next = NULL;
t->used = 0;
t->commit = 0;
t->read = 0;
/* DEBUG ONLY */
memset(t->data, '*', size);
/* printk("Flip recycle %p\n", t); */
Expand Down Expand Up @@ -335,6 +339,7 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
if (b != NULL) {
b->next = n;
b->active = 0;
b->commit = b->used;
} else
tty->buf.head = n;
tty->buf.tail = n;
Expand Down Expand Up @@ -2752,6 +2757,9 @@ static void flush_to_ldisc(void *private_)
unsigned long flags;
struct tty_ldisc *disc;
struct tty_buffer *tbuf;
int count;
char *char_buf;
unsigned char *flag_buf;

disc = tty_ldisc_ref(tty);
if (disc == NULL) /* !TTY_LDISC */
Expand All @@ -2765,16 +2773,20 @@ static void flush_to_ldisc(void *private_)
goto out;
}
spin_lock_irqsave(&tty->buf.lock, flags);
while((tbuf = tty->buf.head) != NULL && !tbuf->active) {
while((tbuf = tty->buf.head) != NULL) {
while ((count = tbuf->commit - tbuf->read) != 0) {
char_buf = tbuf->char_buf_ptr + tbuf->read;
flag_buf = tbuf->flag_buf_ptr + tbuf->read;
tbuf->read += count;
spin_unlock_irqrestore(&tty->buf.lock, flags);
disc->receive_buf(tty, char_buf, flag_buf, count);
spin_lock_irqsave(&tty->buf.lock, flags);
}
if (tbuf->active)
break;
tty->buf.head = tbuf->next;
if (tty->buf.head == NULL)
tty->buf.tail = NULL;
spin_unlock_irqrestore(&tty->buf.lock, flags);
/* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */
disc->receive_buf(tty, tbuf->char_buf_ptr,
tbuf->flag_buf_ptr,
tbuf->used);
spin_lock_irqsave(&tty->buf.lock, flags);
tty_buffer_free(tty, tbuf);
}
spin_unlock_irqrestore(&tty->buf.lock, flags);
Expand Down Expand Up @@ -2871,8 +2883,10 @@ void tty_flip_buffer_push(struct tty_struct *tty)
{
unsigned long flags;
spin_lock_irqsave(&tty->buf.lock, flags);
if (tty->buf.tail != NULL)
if (tty->buf.tail != NULL) {
tty->buf.tail->active = 0;
tty->buf.tail->commit = tty->buf.tail->used;
}
spin_unlock_irqrestore(&tty->buf.lock, flags);

if (tty->low_latency)
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/kbd_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ static inline void con_schedule_flip(struct tty_struct *t)
{
unsigned long flags;
spin_lock_irqsave(&t->buf.lock, flags);
if (t->buf.tail != NULL)
if (t->buf.tail != NULL) {
t->buf.tail->active = 0;
t->buf.tail->commit = t->buf.tail->used;
}
spin_unlock_irqrestore(&t->buf.lock, flags);
schedule_work(&t->buf.work);
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ struct tty_buffer {
int used;
int size;
int active;
int commit;
int read;
/* Data points here */
unsigned long data[0];
};
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/tty_flip.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ _INLINE_ void tty_schedule_flip(struct tty_struct *tty)
{
unsigned long flags;
spin_lock_irqsave(&tty->buf.lock, flags);
if (tty->buf.tail != NULL)
if (tty->buf.tail != NULL) {
tty->buf.tail->active = 0;
tty->buf.tail->commit = tty->buf.tail->used;
}
spin_unlock_irqrestore(&tty->buf.lock, flags);
schedule_delayed_work(&tty->buf.work, 1);
}
Expand Down

0 comments on commit 3fd877b

Please sign in to comment.