diff options
author | Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> | 2014-11-06 03:23:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-06 18:00:44 -0500 |
commit | bd737f8738b7e15930aa7b47c94c28a8d83148ac (patch) | |
tree | 9140a208d4856074a92ffc6543aabcf08a38a762 /drivers/tty/serial/mcf.c | |
parent | a9c20a9cf3190a517b88d8e08d93157256f97673 (diff) |
tty/serial_core: Introduce lock mechanism for RS485
Introduce an homogeneous lock system between setting and using the rs485
data of the uart_port.
This patch should not be split into multiple ones in order to avoid
leaving the tree in an unstable state.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Suggested-by: Alan Cox <alan@linux.intel.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/mcf.c')
-rw-r--r-- | drivers/tty/serial/mcf.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index d7be1f18545b..fdd5c7bd1e8d 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c | |||
@@ -257,12 +257,12 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, | |||
257 | mr2 |= MCFUART_MR2_TXCTS; | 257 | mr2 |= MCFUART_MR2_TXCTS; |
258 | } | 258 | } |
259 | 259 | ||
260 | spin_lock_irqsave(&port->lock, flags); | ||
260 | if (port->rs485.flags & SER_RS485_ENABLED) { | 261 | if (port->rs485.flags & SER_RS485_ENABLED) { |
261 | dev_dbg(port->dev, "Setting UART to RS485\n"); | 262 | dev_dbg(port->dev, "Setting UART to RS485\n"); |
262 | mr2 |= MCFUART_MR2_TXRTS; | 263 | mr2 |= MCFUART_MR2_TXRTS; |
263 | } | 264 | } |
264 | 265 | ||
265 | spin_lock_irqsave(&port->lock, flags); | ||
266 | uart_update_timeout(port, termios->c_cflag, baud); | 266 | uart_update_timeout(port, termios->c_cflag, baud); |
267 | writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); | 267 | writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); |
268 | writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); | 268 | writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); |
@@ -442,10 +442,8 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
442 | static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) | 442 | static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) |
443 | { | 443 | { |
444 | struct mcf_uart *pp = container_of(port, struct mcf_uart, port); | 444 | struct mcf_uart *pp = container_of(port, struct mcf_uart, port); |
445 | unsigned long flags; | ||
446 | unsigned char mr1, mr2; | 445 | unsigned char mr1, mr2; |
447 | 446 | ||
448 | spin_lock_irqsave(&port->lock, flags); | ||
449 | /* Get mode registers */ | 447 | /* Get mode registers */ |
450 | mr1 = readb(port->membase + MCFUART_UMR); | 448 | mr1 = readb(port->membase + MCFUART_UMR); |
451 | mr2 = readb(port->membase + MCFUART_UMR); | 449 | mr2 = readb(port->membase + MCFUART_UMR); |
@@ -460,7 +458,6 @@ static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) | |||
460 | writeb(mr1, port->membase + MCFUART_UMR); | 458 | writeb(mr1, port->membase + MCFUART_UMR); |
461 | writeb(mr2, port->membase + MCFUART_UMR); | 459 | writeb(mr2, port->membase + MCFUART_UMR); |
462 | port->rs485 = *rs485; | 460 | port->rs485 = *rs485; |
463 | spin_unlock_irqrestore(&port->lock, flags); | ||
464 | 461 | ||
465 | return 0; | 462 | return 0; |
466 | } | 463 | } |