aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/serial_core.c
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2014-11-06 09:23:00 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-06 15:00:44 -0800
commitbd737f8738b7e15930aa7b47c94c28a8d83148ac (patch)
tree9140a208d4856074a92ffc6543aabcf08a38a762 /drivers/tty/serial/serial_core.c
parentserial_core: Remove call to driver-specific TIO[GS]RS485] (diff)
downloadlinux-dev-bd737f8738b7e15930aa7b47c94c28a8d83148ac.tar.xz
linux-dev-bd737f8738b7e15930aa7b47c94c28a8d83148ac.zip
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/serial_core.c')
-rw-r--r--drivers/tty/serial/serial_core.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 99fcdba0e3e9..5c8b8f50f787 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1155,8 +1155,16 @@ static int uart_get_icount(struct tty_struct *tty,
static int uart_get_rs485_config(struct uart_port *port,
struct serial_rs485 __user *rs485)
{
- if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485)))
+ unsigned long flags;
+ struct serial_rs485 aux;
+
+ spin_lock_irqsave(&port->lock, flags);
+ aux = port->rs485;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ if (copy_to_user(rs485, &aux, sizeof(aux)))
return -EFAULT;
+
return 0;
}
@@ -1165,6 +1173,7 @@ static int uart_set_rs485_config(struct uart_port *port,
{
struct serial_rs485 rs485;
int ret;
+ unsigned long flags;
if (!port->rs485_config)
return -ENOIOCTLCMD;
@@ -1172,7 +1181,9 @@ static int uart_set_rs485_config(struct uart_port *port,
if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user)))
return -EFAULT;
+ spin_lock_irqsave(&port->lock, flags);
ret = port->rs485_config(port, &rs485);
+ spin_unlock_irqrestore(&port->lock, flags);
if (ret)
return ret;