diff options
Diffstat (limited to 'drivers/tty/serial/jsm/jsm_neo.c')
-rw-r--r-- | drivers/tty/serial/jsm/jsm_neo.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c index 4538c3e3646..81dfafa11b0 100644 --- a/drivers/tty/serial/jsm/jsm_neo.c +++ b/drivers/tty/serial/jsm/jsm_neo.c | |||
@@ -496,12 +496,15 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch) | |||
496 | int s; | 496 | int s; |
497 | int qlen; | 497 | int qlen; |
498 | u32 len_written = 0; | 498 | u32 len_written = 0; |
499 | struct circ_buf *circ; | ||
499 | 500 | ||
500 | if (!ch) | 501 | if (!ch) |
501 | return; | 502 | return; |
502 | 503 | ||
504 | circ = &ch->uart_port.state->xmit; | ||
505 | |||
503 | /* No data to write to the UART */ | 506 | /* No data to write to the UART */ |
504 | if (ch->ch_w_tail == ch->ch_w_head) | 507 | if (uart_circ_empty(circ)) |
505 | return; | 508 | return; |
506 | 509 | ||
507 | /* If port is "stopped", don't send any data to the UART */ | 510 | /* If port is "stopped", don't send any data to the UART */ |
@@ -517,11 +520,10 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch) | |||
517 | if (ch->ch_cached_lsr & UART_LSR_THRE) { | 520 | if (ch->ch_cached_lsr & UART_LSR_THRE) { |
518 | ch->ch_cached_lsr &= ~(UART_LSR_THRE); | 521 | ch->ch_cached_lsr &= ~(UART_LSR_THRE); |
519 | 522 | ||
520 | writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_neo_uart->txrx); | 523 | writeb(circ->buf[circ->tail], &ch->ch_neo_uart->txrx); |
521 | jsm_printk(WRITE, INFO, &ch->ch_bd->pci_dev, | 524 | jsm_printk(WRITE, INFO, &ch->ch_bd->pci_dev, |
522 | "Tx data: %x\n", ch->ch_wqueue[ch->ch_w_head]); | 525 | "Tx data: %x\n", circ->buf[circ->tail]); |
523 | ch->ch_w_tail++; | 526 | circ->tail = (circ->tail + 1) & (UART_XMIT_SIZE - 1); |
524 | ch->ch_w_tail &= WQUEUEMASK; | ||
525 | ch->ch_txcount++; | 527 | ch->ch_txcount++; |
526 | } | 528 | } |
527 | return; | 529 | return; |
@@ -536,36 +538,36 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch) | |||
536 | n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel; | 538 | n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel; |
537 | 539 | ||
538 | /* cache head and tail of queue */ | 540 | /* cache head and tail of queue */ |
539 | head = ch->ch_w_head & WQUEUEMASK; | 541 | head = circ->head & (UART_XMIT_SIZE - 1); |
540 | tail = ch->ch_w_tail & WQUEUEMASK; | 542 | tail = circ->tail & (UART_XMIT_SIZE - 1); |
541 | qlen = (head - tail) & WQUEUEMASK; | 543 | qlen = uart_circ_chars_pending(circ); |
542 | 544 | ||
543 | /* Find minimum of the FIFO space, versus queue length */ | 545 | /* Find minimum of the FIFO space, versus queue length */ |
544 | n = min(n, qlen); | 546 | n = min(n, qlen); |
545 | 547 | ||
546 | while (n > 0) { | 548 | while (n > 0) { |
547 | 549 | ||
548 | s = ((head >= tail) ? head : WQUEUESIZE) - tail; | 550 | s = ((head >= tail) ? head : UART_XMIT_SIZE) - tail; |
549 | s = min(s, n); | 551 | s = min(s, n); |
550 | 552 | ||
551 | if (s <= 0) | 553 | if (s <= 0) |
552 | break; | 554 | break; |
553 | 555 | ||
554 | memcpy_toio(&ch->ch_neo_uart->txrxburst, ch->ch_wqueue + tail, s); | 556 | memcpy_toio(&ch->ch_neo_uart->txrxburst, circ->buf + tail, s); |
555 | /* Add and flip queue if needed */ | 557 | /* Add and flip queue if needed */ |
556 | tail = (tail + s) & WQUEUEMASK; | 558 | tail = (tail + s) & (UART_XMIT_SIZE - 1); |
557 | n -= s; | 559 | n -= s; |
558 | ch->ch_txcount += s; | 560 | ch->ch_txcount += s; |
559 | len_written += s; | 561 | len_written += s; |
560 | } | 562 | } |
561 | 563 | ||
562 | /* Update the final tail */ | 564 | /* Update the final tail */ |
563 | ch->ch_w_tail = tail & WQUEUEMASK; | 565 | circ->tail = tail & (UART_XMIT_SIZE - 1); |
564 | 566 | ||
565 | if (len_written >= ch->ch_t_tlevel) | 567 | if (len_written >= ch->ch_t_tlevel) |
566 | ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); | 568 | ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); |
567 | 569 | ||
568 | if (!jsm_tty_write(&ch->uart_port)) | 570 | if (uart_circ_empty(circ)) |
569 | uart_write_wakeup(&ch->uart_port); | 571 | uart_write_wakeup(&ch->uart_port); |
570 | } | 572 | } |
571 | 573 | ||
@@ -946,7 +948,6 @@ static void neo_param(struct jsm_channel *ch) | |||
946 | if ((ch->ch_c_cflag & (CBAUD)) == 0) { | 948 | if ((ch->ch_c_cflag & (CBAUD)) == 0) { |
947 | ch->ch_r_head = ch->ch_r_tail = 0; | 949 | ch->ch_r_head = ch->ch_r_tail = 0; |
948 | ch->ch_e_head = ch->ch_e_tail = 0; | 950 | ch->ch_e_head = ch->ch_e_tail = 0; |
949 | ch->ch_w_head = ch->ch_w_tail = 0; | ||
950 | 951 | ||
951 | neo_flush_uart_write(ch); | 952 | neo_flush_uart_write(ch); |
952 | neo_flush_uart_read(ch); | 953 | neo_flush_uart_read(ch); |