summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-01-22 17:24:27 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-02-02 18:11:27 (GMT)
commit0ec3f585cfb503a18b82cd181c9bf32b45a24f5e (patch)
tree24a0cdc1ef40d780d521c3e77416d886426be84a /drivers/tty
parentd1f2f219319813070c022e841f48bfd0fe17fd34 (diff)
downloadlinux-0ec3f585cfb503a18b82cd181c9bf32b45a24f5e.tar.xz
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 8e3302c..b63b9c3 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
return quot;
}
-void
-serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
- struct ktermios *old)
+static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
+ tcflag_t c_cflag)
{
- struct uart_8250_port *up = up_to_u8250p(port);
unsigned char cval;
- unsigned long flags;
- unsigned int baud, quot;
- switch (termios->c_cflag & CSIZE) {
+ switch (c_cflag & CSIZE) {
case CS5:
cval = UART_LCR_WLEN5;
break;
@@ -2465,20 +2461,34 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
break;
}
- if (termios->c_cflag & CSTOPB)
+ if (c_cflag & CSTOPB)
cval |= UART_LCR_STOP;
- if (termios->c_cflag & PARENB) {
+ if (c_cflag & PARENB) {
cval |= UART_LCR_PARITY;
if (up->bugs & UART_BUG_PARITY)
up->fifo_bug = true;
}
- if (!(termios->c_cflag & PARODD))
+ if (!(c_cflag & PARODD))
cval |= UART_LCR_EPAR;
#ifdef CMSPAR
- if (termios->c_cflag & CMSPAR)
+ if (c_cflag & CMSPAR)
cval |= UART_LCR_SPAR;
#endif
+ return cval;
+}
+
+void
+serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
+ struct ktermios *old)
+{
+ struct uart_8250_port *up = up_to_u8250p(port);
+ unsigned char cval;
+ unsigned long flags;
+ unsigned int baud, quot;
+
+ cval = serial8250_compute_lcr(up, termios->c_cflag);
+
/*
* Ask the core to calculate the divisor for us.
*/