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