aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-01-22 12:24:27 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-02-02 13:11:27 -0500
commit0ec3f585cfb503a18b82cd181c9bf32b45a24f5e (patch)
tree24a0cdc1ef40d780d521c3e77416d886426be84a /drivers/tty
parentd1f2f219319813070c022e841f48bfd0fe17fd34 (diff)
serial: 8250: Refactor LCR computation
Refactor the computation of the LCR register value from termios c_cflag into a new local function, serial8250_compute_lcr(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_core.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 8e3302c6bbff..b63b9c352cc2 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2440,16 +2440,12 @@ static unsigned int serial8250_get_divisor(struct uart_8250_port *up, unsigned i
2440 return quot; 2440 return quot;
2441} 2441}
2442 2442
2443void 2443static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
2444serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, 2444 tcflag_t c_cflag)
2445 struct ktermios *old)
2446{ 2445{
2447 struct uart_8250_port *up = up_to_u8250p(port);
2448 unsigned char cval; 2446 unsigned char cval;
2449 unsigned long flags;
2450 unsigned int baud, quot;
2451 2447
2452 switch (termios->c_cflag & CSIZE) { 2448 switch (c_cflag & CSIZE) {
2453 case CS5: 2449 case CS5:
2454 cval = UART_LCR_WLEN5; 2450 cval = UART_LCR_WLEN5;
2455 break; 2451 break;
@@ -2465,20 +2461,34 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2465 break; 2461 break;
2466 } 2462 }
2467 2463
2468 if (termios->c_cflag & CSTOPB) 2464 if (c_cflag & CSTOPB)
2469 cval |= UART_LCR_STOP; 2465 cval |= UART_LCR_STOP;
2470 if (termios->c_cflag & PARENB) { 2466 if (c_cflag & PARENB) {
2471 cval |= UART_LCR_PARITY; 2467 cval |= UART_LCR_PARITY;
2472 if (up->bugs & UART_BUG_PARITY) 2468 if (up->bugs & UART_BUG_PARITY)
2473 up->fifo_bug = true; 2469 up->fifo_bug = true;
2474 } 2470 }
2475 if (!(termios->c_cflag & PARODD)) 2471 if (!(c_cflag & PARODD))
2476 cval |= UART_LCR_EPAR; 2472 cval |= UART_LCR_EPAR;
2477#ifdef CMSPAR 2473#ifdef CMSPAR
2478 if (termios->c_cflag & CMSPAR) 2474 if (c_cflag & CMSPAR)
2479 cval |= UART_LCR_SPAR; 2475 cval |= UART_LCR_SPAR;
2480#endif 2476#endif
2481 2477
2478 return cval;
2479}
2480
2481void
2482serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2483 struct ktermios *old)
2484{
2485 struct uart_8250_port *up = up_to_u8250p(port);
2486 unsigned char cval;
2487 unsigned long flags;
2488 unsigned int baud, quot;
2489
2490 cval = serial8250_compute_lcr(up, termios->c_cflag);
2491
2482 /* 2492 /*
2483 * Ask the core to calculate the divisor for us. 2493 * Ask the core to calculate the divisor for us.
2484 */ 2494 */