aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/jsm/jsm.h7
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c1
-rw-r--r--drivers/tty/serial/jsm/jsm_neo.c29
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c94
4 files changed, 28 insertions, 103 deletions
diff --git a/drivers/tty/serial/jsm/jsm.h b/drivers/tty/serial/jsm/jsm.h
index b704c8ce0d7..5b837e749c1 100644
--- a/drivers/tty/serial/jsm/jsm.h
+++ b/drivers/tty/serial/jsm/jsm.h
@@ -183,10 +183,8 @@ struct jsm_board
183/* Our Read/Error/Write queue sizes */ 183/* Our Read/Error/Write queue sizes */
184#define RQUEUEMASK 0x1FFF /* 8 K - 1 */ 184#define RQUEUEMASK 0x1FFF /* 8 K - 1 */
185#define EQUEUEMASK 0x1FFF /* 8 K - 1 */ 185#define EQUEUEMASK 0x1FFF /* 8 K - 1 */
186#define WQUEUEMASK 0x0FFF /* 4 K - 1 */
187#define RQUEUESIZE (RQUEUEMASK + 1) 186#define RQUEUESIZE (RQUEUEMASK + 1)
188#define EQUEUESIZE RQUEUESIZE 187#define EQUEUESIZE RQUEUESIZE
189#define WQUEUESIZE (WQUEUEMASK + 1)
190 188
191 189
192/************************************************************************ 190/************************************************************************
@@ -226,10 +224,6 @@ struct jsm_channel {
226 u16 ch_e_head; /* Head location of the error queue */ 224 u16 ch_e_head; /* Head location of the error queue */
227 u16 ch_e_tail; /* Tail location of the error queue */ 225 u16 ch_e_tail; /* Tail location of the error queue */
228 226
229 u8 *ch_wqueue; /* Our write queue buffer - malloc'ed */
230 u16 ch_w_head; /* Head location of the write queue */
231 u16 ch_w_tail; /* Tail location of the write queue */
232
233 u64 ch_rxcount; /* total of data received so far */ 227 u64 ch_rxcount; /* total of data received so far */
234 u64 ch_txcount; /* total of data transmitted so far */ 228 u64 ch_txcount; /* total of data transmitted so far */
235 229
@@ -378,7 +372,6 @@ extern int jsm_debug;
378 * Prototypes for non-static functions used in more than one module 372 * Prototypes for non-static functions used in more than one module
379 * 373 *
380 *************************************************************************/ 374 *************************************************************************/
381int jsm_tty_write(struct uart_port *port);
382int jsm_tty_init(struct jsm_board *); 375int jsm_tty_init(struct jsm_board *);
383int jsm_uart_port_init(struct jsm_board *); 376int jsm_uart_port_init(struct jsm_board *);
384int jsm_remove_uart_port(struct jsm_board *); 377int jsm_remove_uart_port(struct jsm_board *);
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 96da17868cf..2aaafa9c58a 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -211,7 +211,6 @@ static void __devexit jsm_remove_one(struct pci_dev *pdev)
211 if (brd->channels[i]) { 211 if (brd->channels[i]) {
212 kfree(brd->channels[i]->ch_rqueue); 212 kfree(brd->channels[i]->ch_rqueue);
213 kfree(brd->channels[i]->ch_equeue); 213 kfree(brd->channels[i]->ch_equeue);
214 kfree(brd->channels[i]->ch_wqueue);
215 kfree(brd->channels[i]); 214 kfree(brd->channels[i]);
216 } 215 }
217 } 216 }
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index 4538c3e3646..bd6e84699e1 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->head]);
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);
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 7a4a914ecff..434bd881fca 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -118,6 +118,19 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
118 udelay(10); 118 udelay(10);
119} 119}
120 120
121/*
122 * jsm_tty_write()
123 *
124 * Take data from the user or kernel and send it out to the FEP.
125 * In here exists all the Transparent Print magic as well.
126 */
127static void jsm_tty_write(struct uart_port *port)
128{
129 struct jsm_channel *channel;
130 channel = container_of(port, struct jsm_channel, uart_port);
131 channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
132}
133
121static void jsm_tty_start_tx(struct uart_port *port) 134static void jsm_tty_start_tx(struct uart_port *port)
122{ 135{
123 struct jsm_channel *channel = (struct jsm_channel *)port; 136 struct jsm_channel *channel = (struct jsm_channel *)port;
@@ -216,14 +229,6 @@ static int jsm_tty_open(struct uart_port *port)
216 return -ENOMEM; 229 return -ENOMEM;
217 } 230 }
218 } 231 }
219 if (!channel->ch_wqueue) {
220 channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
221 if (!channel->ch_wqueue) {
222 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
223 "unable to allocate write queue buf");
224 return -ENOMEM;
225 }
226 }
227 232
228 channel->ch_flags &= ~(CH_OPENING); 233 channel->ch_flags &= ~(CH_OPENING);
229 /* 234 /*
@@ -237,7 +242,6 @@ static int jsm_tty_open(struct uart_port *port)
237 */ 242 */
238 channel->ch_r_head = channel->ch_r_tail = 0; 243 channel->ch_r_head = channel->ch_r_tail = 0;
239 channel->ch_e_head = channel->ch_e_tail = 0; 244 channel->ch_e_head = channel->ch_e_tail = 0;
240 channel->ch_w_head = channel->ch_w_tail = 0;
241 245
242 brd->bd_ops->flush_uart_write(channel); 246 brd->bd_ops->flush_uart_write(channel);
243 brd->bd_ops->flush_uart_read(channel); 247 brd->bd_ops->flush_uart_read(channel);
@@ -836,75 +840,3 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
836 } 840 }
837 } 841 }
838} 842}
839
840/*
841 * jsm_tty_write()
842 *
843 * Take data from the user or kernel and send it out to the FEP.
844 * In here exists all the Transparent Print magic as well.
845 */
846int jsm_tty_write(struct uart_port *port)
847{
848 int bufcount;
849 int data_count = 0,data_count1 =0;
850 u16 head;
851 u16 tail;
852 u16 tmask;
853 u32 remain;
854 int temp_tail = port->state->xmit.tail;
855 struct jsm_channel *channel = (struct jsm_channel *)port;
856
857 tmask = WQUEUEMASK;
858 head = (channel->ch_w_head) & tmask;
859 tail = (channel->ch_w_tail) & tmask;
860
861 if ((bufcount = tail - head - 1) < 0)
862 bufcount += WQUEUESIZE;
863
864 bufcount = min(bufcount, 56);
865 remain = WQUEUESIZE - head;
866
867 data_count = 0;
868 if (bufcount >= remain) {
869 bufcount -= remain;
870 while ((port->state->xmit.head != temp_tail) &&
871 (data_count < remain)) {
872 channel->ch_wqueue[head++] =
873 port->state->xmit.buf[temp_tail];
874
875 temp_tail++;
876 temp_tail &= (UART_XMIT_SIZE - 1);
877 data_count++;
878 }
879 if (data_count == remain) head = 0;
880 }
881
882 data_count1 = 0;
883 if (bufcount > 0) {
884 remain = bufcount;
885 while ((port->state->xmit.head != temp_tail) &&
886 (data_count1 < remain)) {
887 channel->ch_wqueue[head++] =
888 port->state->xmit.buf[temp_tail];
889
890 temp_tail++;
891 temp_tail &= (UART_XMIT_SIZE - 1);
892 data_count1++;
893
894 }
895 }
896
897 port->state->xmit.tail = temp_tail;
898
899 data_count += data_count1;
900 if (data_count) {
901 head &= tmask;
902 channel->ch_w_head = head;
903 }
904
905 if (data_count) {
906 channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
907 }
908
909 return data_count;
910}