From: Alan Cox Signed-off-by: Alan Cox Signed-off-by: Andrew Morton --- drivers/char/istallion.c | 26 ++++++++--------------- drivers/char/rio/riointr.c | 13 ++++------- drivers/char/riscom8.c | 4 +-- drivers/char/stallion.c | 50 +++++++++++++-------------------------------- 4 files changed, 31 insertions(+), 62 deletions(-) diff -puN drivers/char/istallion.c~tty-layer-buffering-revamp-stallion-rio-fixes drivers/char/istallion.c --- devel/drivers/char/istallion.c~tty-layer-buffering-revamp-stallion-rio-fixes 2005-10-25 23:44:18.000000000 -0700 +++ devel-akpm/drivers/char/istallion.c 2005-10-25 23:44:18.000000000 -0700 @@ -2714,17 +2714,13 @@ static void stli_read(stlibrd_t *brdp, s stlen = size - tail; } - len = MIN(len, (TTY_FLIPBUF_SIZE - tty->flip.count)); + len = tty_buffer_request_room(tty, len); + /* FIXME : iomap ? */ shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); while (len > 0) { stlen = MIN(len, stlen); - memcpy(tty->flip.char_buf_ptr, (char *) (shbuf + tail), stlen); - memset(tty->flip.flag_buf_ptr, 0, stlen); - tty->flip.char_buf_ptr += stlen; - tty->flip.flag_buf_ptr += stlen; - tty->flip.count += stlen; - + tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); len -= stlen; tail += stlen; if (tail >= size) { @@ -2909,16 +2905,12 @@ static int stli_hostcmd(stlibrd_t *brdp, if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { if (tty != (struct tty_struct *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; - if (portp->flags & ASYNC_SAK) { - do_SAK(tty); - EBRDENABLE(brdp); - } - tty_schedule_flip(tty); + tty_insert_flip_char(tty, 0, TTY_BREAK); + if (portp->flags & ASYNC_SAK) { + do_SAK(tty); + EBRDENABLE(brdp); } + tty_schedule_flip(tty); } } @@ -4943,7 +4935,7 @@ static int stli_portcmdstats(stliport_t if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { stli_comstats.ttystate = portp->tty->flags; - stli_comstats.rxbuffered = portp->tty->flip.count; + stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; if (portp->tty->termios != (struct termios *) NULL) { stli_comstats.cflags = portp->tty->termios->c_cflag; stli_comstats.iflags = portp->tty->termios->c_iflag; diff -puN drivers/char/rio/riointr.c~tty-layer-buffering-revamp-stallion-rio-fixes drivers/char/rio/riointr.c --- devel/drivers/char/rio/riointr.c~tty-layer-buffering-revamp-stallion-rio-fixes 2005-10-25 23:44:18.000000000 -0700 +++ devel-akpm/drivers/char/rio/riointr.c 2005-10-25 23:44:18.000000000 -0700 @@ -38,6 +38,7 @@ static char *_riointr_c_sccs_ = "@(#)rio #include #include #include +#include #include #include #include @@ -560,6 +561,7 @@ struct Port * PortP; struct PKT *PacketP; register uint DataCnt; uchar * ptr; + unsigned char *buf; int copied =0; static int intCount, RxIntCnt; @@ -657,8 +659,7 @@ struct Port * PortP; ** and available space. */ - transCount = min_t(unsigned int, PacketP->len & PKT_LEN_MASK, - TTY_FLIPBUF_SIZE - TtyP->flip.count); + transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK); rio_dprintk (RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); /* @@ -678,9 +679,8 @@ struct Port * PortP; #endif ptr = (uchar *) PacketP->data + PortP->RxDataStart; - rio_memcpy_fromio (TtyP->flip.char_buf_ptr, ptr, transCount); - memset(TtyP->flip.flag_buf_ptr, TTY_NORMAL, transCount); - + tty_prepare_flip_string(TtyP, &buf, transCount); + rio_memcpy_fromio (buf, ptr, transCount); #ifdef STATS /* ** keep a count for statistical purposes @@ -690,9 +690,6 @@ struct Port * PortP; PortP->RxDataStart += transCount; PacketP->len -= transCount; copied += transCount; - TtyP->flip.count += transCount; - TtyP->flip.char_buf_ptr += transCount; - TtyP->flip.flag_buf_ptr += transCount; #ifdef ___DEBUG_IT___ diff -puN drivers/char/riscom8.c~tty-layer-buffering-revamp-stallion-rio-fixes drivers/char/riscom8.c --- devel/drivers/char/riscom8.c~tty-layer-buffering-revamp-stallion-rio-fixes 2005-10-25 23:44:18.000000000 -0700 +++ devel-akpm/drivers/char/riscom8.c 2005-10-25 23:44:18.000000000 -0700 @@ -399,7 +399,7 @@ static inline void rc_receive_exc(struct flag = TTY_NORMAL; tty_insert_flip_char(tty, ch, flag); - schedule_delayed_work(&tty->flip.work, 1); + tty_flip_buffer_push(tty); } static inline void rc_receive(struct riscom_board const * bp) @@ -428,7 +428,7 @@ static inline void rc_receive(struct ris } tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL); } - schedule_delayed_work(&tty->flip.work, 1); + tty_flip_buffer_push(tty); } static inline void rc_transmit(struct riscom_board const * bp) diff -puN drivers/char/stallion.c~tty-layer-buffering-revamp-stallion-rio-fixes drivers/char/stallion.c --- devel/drivers/char/stallion.c~tty-layer-buffering-revamp-stallion-rio-fixes 2005-10-25 23:44:18.000000000 -0700 +++ devel-akpm/drivers/char/stallion.c 2005-10-25 23:44:18.000000000 -0700 @@ -2902,7 +2902,8 @@ static int stl_getportstats(stlport_t *p if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { portp->stats.ttystate = portp->tty->flags; - portp->stats.rxbuffered = portp->tty->flip.count; + /* No longer available as a statistic */ + portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */ if (portp->tty->termios != (struct termios *) NULL) { portp->stats.cflags = portp->tty->termios->c_cflag; portp->stats.iflags = portp->tty->termios->c_iflag; @@ -4046,9 +4047,7 @@ static void stl_cd1400rxisr(stlpanel_t * if ((ioack & ACK_TYPMASK) == ACK_TYPRXGOOD) { outb((RDCR + portp->uartaddr), ioaddr); len = inb(ioaddr + EREG_DATA); - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb((RDSR + portp->uartaddr), ioaddr); insb((ioaddr + EREG_DATA), &stl_unwanted[0], len); @@ -4057,12 +4056,10 @@ static void stl_cd1400rxisr(stlpanel_t * } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb((RDSR + portp->uartaddr), ioaddr); - insb((ioaddr + EREG_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + EREG_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -4086,8 +4083,7 @@ static void stl_cd1400rxisr(stlpanel_t * portp->stats.txxoff++; goto stl_rxalldone; } - if ((tty != (struct tty_struct *) NULL) && - ((portp->rxignoremsk & status) == 0)) { + if (tty != NULL && (portp->rxignoremsk & status) == 0) { if (portp->rxmarkmsk & status) { if (status & ST_BREAK) { status = TTY_BREAK; @@ -4107,14 +4103,8 @@ static void stl_cd1400rxisr(stlpanel_t * } else { status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); } } else { printk("STALLION: bad RX interrupt ack value=%x\n", ioack); @@ -5013,9 +5003,7 @@ static void stl_sc26198rxisr(stlport_t * len = inb(ioaddr + XP_DATA) + 1; if ((iack & IVR_TYPEMASK) == IVR_RXDATA) { - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb(GRXFIFO, (ioaddr + XP_ADDR)); insb((ioaddr + XP_DATA), &stl_unwanted[0], len); @@ -5024,12 +5012,10 @@ static void stl_sc26198rxisr(stlport_t * } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb(GRXFIFO, (ioaddr + XP_ADDR)); - insb((ioaddr + XP_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + XP_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -5097,14 +5083,8 @@ static inline void stl_sc26198rxbadch(st status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); if (status == 0) portp->stats.rxtotal++; _