diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-02-20 16:41:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:39 -0400 |
commit | 04ca89d4948ad4b6ec3b33e9588ae1885643148c (patch) | |
tree | e3be04f82befee4d89dff3283a05d02ba7bfa4bf /drivers/usb | |
parent | a40d8540f4b7874ef674428cf757e8f466d271ca (diff) |
USB: ti_usb_3410_5052: Extend locking to msr and shadow mcr
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 3a3776677339..5b470f76e91b 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -1021,14 +1021,17 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file) | |||
1021 | unsigned int result; | 1021 | unsigned int result; |
1022 | unsigned int msr; | 1022 | unsigned int msr; |
1023 | unsigned int mcr; | 1023 | unsigned int mcr; |
1024 | unsigned long flags; | ||
1024 | 1025 | ||
1025 | dbg("%s - port %d", __FUNCTION__, port->number); | 1026 | dbg("%s - port %d", __FUNCTION__, port->number); |
1026 | 1027 | ||
1027 | if (tport == NULL) | 1028 | if (tport == NULL) |
1028 | return -ENODEV; | 1029 | return -ENODEV; |
1029 | 1030 | ||
1031 | spin_lock_irqsave(&tport->tp_lock, flags); | ||
1030 | msr = tport->tp_msr; | 1032 | msr = tport->tp_msr; |
1031 | mcr = tport->tp_shadow_mcr; | 1033 | mcr = tport->tp_shadow_mcr; |
1034 | spin_unlock_irqrestore(&tport->tp_lock, flags); | ||
1032 | 1035 | ||
1033 | result = ((mcr & TI_MCR_DTR) ? TIOCM_DTR : 0) | 1036 | result = ((mcr & TI_MCR_DTR) ? TIOCM_DTR : 0) |
1034 | | ((mcr & TI_MCR_RTS) ? TIOCM_RTS : 0) | 1037 | | ((mcr & TI_MCR_RTS) ? TIOCM_RTS : 0) |
@@ -1049,12 +1052,14 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file, | |||
1049 | { | 1052 | { |
1050 | struct ti_port *tport = usb_get_serial_port_data(port); | 1053 | struct ti_port *tport = usb_get_serial_port_data(port); |
1051 | unsigned int mcr; | 1054 | unsigned int mcr; |
1055 | unsigned long flags; | ||
1052 | 1056 | ||
1053 | dbg("%s - port %d", __FUNCTION__, port->number); | 1057 | dbg("%s - port %d", __FUNCTION__, port->number); |
1054 | 1058 | ||
1055 | if (tport == NULL) | 1059 | if (tport == NULL) |
1056 | return -ENODEV; | 1060 | return -ENODEV; |
1057 | 1061 | ||
1062 | spin_lock_irqsave(&tport->tp_lock, flags); | ||
1058 | mcr = tport->tp_shadow_mcr; | 1063 | mcr = tport->tp_shadow_mcr; |
1059 | 1064 | ||
1060 | if (set & TIOCM_RTS) | 1065 | if (set & TIOCM_RTS) |
@@ -1070,6 +1075,7 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file, | |||
1070 | mcr &= ~TI_MCR_DTR; | 1075 | mcr &= ~TI_MCR_DTR; |
1071 | if (clear & TIOCM_LOOP) | 1076 | if (clear & TIOCM_LOOP) |
1072 | mcr &= ~TI_MCR_LOOP; | 1077 | mcr &= ~TI_MCR_LOOP; |
1078 | spin_unlock_irqrestore(&tport->tp_lock, flags); | ||
1073 | 1079 | ||
1074 | return ti_set_mcr(tport, mcr); | 1080 | return ti_set_mcr(tport, mcr); |
1075 | } | 1081 | } |
@@ -1357,14 +1363,17 @@ static void ti_send(struct ti_port *tport) | |||
1357 | 1363 | ||
1358 | static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) | 1364 | static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) |
1359 | { | 1365 | { |
1366 | unsigned long flags; | ||
1360 | int status; | 1367 | int status; |
1361 | 1368 | ||
1362 | status = ti_write_byte(tport->tp_tdev, | 1369 | status = ti_write_byte(tport->tp_tdev, |
1363 | tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, | 1370 | tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, |
1364 | TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); | 1371 | TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); |
1365 | 1372 | ||
1373 | spin_lock_irqsave(&tport->tp_lock, flags); | ||
1366 | if (!status) | 1374 | if (!status) |
1367 | tport->tp_shadow_mcr = mcr; | 1375 | tport->tp_shadow_mcr = mcr; |
1376 | spin_unlock_irqrestore(&tport->tp_lock, flags); | ||
1368 | 1377 | ||
1369 | return status; | 1378 | return status; |
1370 | } | 1379 | } |