Blackfin Serial Driver: Use timer to poll CTS PIN instead of workqueue.

This allows other threads to run when the serial driver polls the CTS
PIN in a loop.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>

authored by Sonic Zhang and committed by Bryan Wu f30ac0ce ec64b6c8

+23 -27
+18 -22
drivers/serial/bfin_5xx.c
··· 49 #define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT) 50 51 #define DMA_RX_FLUSH_JIFFIES (HZ / 50) 52 53 #ifdef CONFIG_SERIAL_BFIN_DMA 54 static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart); ··· 291 { 292 struct circ_buf *xmit = &uart->port.info->xmit; 293 294 - if (uart->port.x_char) { 295 - UART_PUT_CHAR(uart, uart->port.x_char); 296 - uart->port.icount.tx++; 297 - uart->port.x_char = 0; 298 - } 299 /* 300 * Check the modem control lines before 301 * transmitting anything. ··· 300 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { 301 bfin_serial_stop_tx(&uart->port); 302 return; 303 } 304 305 while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) { ··· 347 } 348 #endif 349 350 - #ifdef CONFIG_SERIAL_BFIN_CTSRTS 351 - static void bfin_serial_do_work(struct work_struct *work) 352 - { 353 - struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue); 354 - 355 - bfin_serial_mctrl_check(uart); 356 - } 357 - #endif 358 - 359 #ifdef CONFIG_SERIAL_BFIN_DMA 360 static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) 361 { 362 struct circ_buf *xmit = &uart->port.info->xmit; 363 364 uart->tx_done = 0; 365 366 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { 367 uart->tx_count = 0; ··· 371 uart->port.icount.tx++; 372 uart->port.x_char = 0; 373 } 374 - 375 - /* 376 - * Check the modem control lines before 377 - * transmitting anything. 378 - */ 379 - bfin_serial_mctrl_check(uart); 380 381 uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); 382 if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail)) ··· 558 uart_handle_cts_change(&uart->port, status & TIOCM_CTS); 559 if (!(status & TIOCM_CTS)) { 560 tty->hw_stopped = 1; 561 - schedule_work(&uart->cts_workqueue); 562 } else { 563 tty->hw_stopped = 0; 564 } ··· 881 init_timer(&(bfin_serial_ports[i].rx_dma_timer)); 882 #endif 883 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 884 - INIT_WORK(&bfin_serial_ports[i].cts_workqueue, bfin_serial_do_work); 885 bfin_serial_ports[i].cts_pin = 886 bfin_serial_resource[i].uart_cts_pin; 887 bfin_serial_ports[i].rts_pin =
··· 49 #define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT) 50 51 #define DMA_RX_FLUSH_JIFFIES (HZ / 50) 52 + #define CTS_CHECK_JIFFIES (HZ / 50) 53 54 #ifdef CONFIG_SERIAL_BFIN_DMA 55 static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart); ··· 290 { 291 struct circ_buf *xmit = &uart->port.info->xmit; 292 293 /* 294 * Check the modem control lines before 295 * transmitting anything. ··· 304 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { 305 bfin_serial_stop_tx(&uart->port); 306 return; 307 + } 308 + 309 + if (uart->port.x_char) { 310 + UART_PUT_CHAR(uart, uart->port.x_char); 311 + uart->port.icount.tx++; 312 + uart->port.x_char = 0; 313 } 314 315 while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) { ··· 345 } 346 #endif 347 348 #ifdef CONFIG_SERIAL_BFIN_DMA 349 static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) 350 { 351 struct circ_buf *xmit = &uart->port.info->xmit; 352 353 uart->tx_done = 0; 354 + 355 + /* 356 + * Check the modem control lines before 357 + * transmitting anything. 358 + */ 359 + bfin_serial_mctrl_check(uart); 360 361 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { 362 uart->tx_count = 0; ··· 372 uart->port.icount.tx++; 373 uart->port.x_char = 0; 374 } 375 376 uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); 377 if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail)) ··· 565 uart_handle_cts_change(&uart->port, status & TIOCM_CTS); 566 if (!(status & TIOCM_CTS)) { 567 tty->hw_stopped = 1; 568 + uart->cts_timer.data = (unsigned long)(uart); 569 + uart->cts_timer.function = (void *)bfin_serial_mctrl_check; 570 + uart->cts_timer.expires = jiffies + CTS_CHECK_JIFFIES; 571 + add_timer(&(uart->cts_timer)); 572 } else { 573 tty->hw_stopped = 0; 574 } ··· 885 init_timer(&(bfin_serial_ports[i].rx_dma_timer)); 886 #endif 887 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 888 + init_timer(&(bfin_serial_ports[i].cts_timer)); 889 bfin_serial_ports[i].cts_pin = 890 bfin_serial_resource[i].uart_cts_pin; 891 bfin_serial_ports[i].rts_pin =
+1 -1
include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
··· 96 struct work_struct tx_dma_workqueue; 97 #endif 98 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 99 - struct work_struct cts_workqueue; 100 int cts_pin; 101 int rts_pin; 102 #endif
··· 96 struct work_struct tx_dma_workqueue; 97 #endif 98 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 99 + struct timer_list cts_timer; 100 int cts_pin; 101 int rts_pin; 102 #endif
+1 -1
include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
··· 88 # endif 89 #endif 90 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 91 - struct work_struct cts_workqueue; 92 int cts_pin; 93 int rts_pin; 94 #endif
··· 88 # endif 89 #endif 90 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 91 + struct timer_list cts_timer; 92 int cts_pin; 93 int rts_pin; 94 #endif
+1 -1
include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
··· 96 struct work_struct tx_dma_workqueue; 97 #endif 98 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 99 - struct work_struct cts_workqueue; 100 int cts_pin; 101 int rts_pin; 102 #endif
··· 96 struct work_struct tx_dma_workqueue; 97 #endif 98 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 99 + struct timer_list cts_timer; 100 int cts_pin; 101 int rts_pin; 102 #endif
+1 -1
include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
··· 99 struct work_struct tx_dma_workqueue; 100 #endif 101 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 102 - struct work_struct cts_workqueue; 103 int cts_pin; 104 int rts_pin; 105 #endif
··· 99 struct work_struct tx_dma_workqueue; 100 #endif 101 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 102 + struct timer_list cts_timer; 103 int cts_pin; 104 int rts_pin; 105 #endif
+1 -1
include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
··· 88 # endif 89 #endif 90 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 91 - struct work_struct cts_workqueue; 92 int cts_pin; 93 int rts_pin; 94 #endif
··· 88 # endif 89 #endif 90 #ifdef CONFIG_SERIAL_BFIN_CTSRTS 91 + struct timer_list cts_timer; 92 int cts_pin; 93 int rts_pin; 94 #endif