diff options
author | Peter Hung <hpeter@gmail.com> | 2015-03-17 05:48:21 -0400 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2015-03-27 12:29:26 -0400 |
commit | 7139c932859f5b35b5a928b445e03f5a43610fa7 (patch) | |
tree | 3340210ec92e0a07eabf2121aeb15572033fb2b2 | |
parent | 8885078949fbb78c6be39ed2c653e4e883568e2f (diff) |
USB: f81232: change lock mechanism
The original driver lock with spin_lock_irqsave()/spin_unlock_irqrestore()
because of it's maybe used in interrupt context f81232_process_read_urb().
We had remove it from previous patch "implement RX bulk-in EP", so we can
change it from busying loop spin_lock to sleepable mutex_lock.
Signed-off-by: Peter Hung <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/f81232.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 4664cf4cc7a8..12840cdc8532 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/serial.h> | 19 | #include <linux/serial.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/moduleparam.h> | 21 | #include <linux/moduleparam.h> |
22 | #include <linux/spinlock.h> | 22 | #include <linux/mutex.h> |
23 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
25 | #include <linux/usb/serial.h> | 25 | #include <linux/usb/serial.h> |
@@ -46,7 +46,7 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
46 | #define UART_CTS 0x80 | 46 | #define UART_CTS 0x80 |
47 | 47 | ||
48 | struct f81232_private { | 48 | struct f81232_private { |
49 | spinlock_t lock; | 49 | struct mutex lock; |
50 | u8 line_control; | 50 | u8 line_control; |
51 | u8 modem_status; | 51 | u8 modem_status; |
52 | }; | 52 | }; |
@@ -231,17 +231,16 @@ static void f81232_close(struct usb_serial_port *port) | |||
231 | static void f81232_dtr_rts(struct usb_serial_port *port, int on) | 231 | static void f81232_dtr_rts(struct usb_serial_port *port, int on) |
232 | { | 232 | { |
233 | struct f81232_private *priv = usb_get_serial_port_data(port); | 233 | struct f81232_private *priv = usb_get_serial_port_data(port); |
234 | unsigned long flags; | ||
235 | u8 control; | 234 | u8 control; |
236 | 235 | ||
237 | spin_lock_irqsave(&priv->lock, flags); | 236 | mutex_lock(&priv->lock); |
238 | /* Change DTR and RTS */ | 237 | /* Change DTR and RTS */ |
239 | if (on) | 238 | if (on) |
240 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); | 239 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); |
241 | else | 240 | else |
242 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | 241 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); |
243 | control = priv->line_control; | 242 | control = priv->line_control; |
244 | spin_unlock_irqrestore(&priv->lock, flags); | 243 | mutex_unlock(&priv->lock); |
245 | set_control_lines(port->serial->dev, control); | 244 | set_control_lines(port->serial->dev, control); |
246 | } | 245 | } |
247 | 246 | ||
@@ -285,7 +284,7 @@ static int f81232_port_probe(struct usb_serial_port *port) | |||
285 | if (!priv) | 284 | if (!priv) |
286 | return -ENOMEM; | 285 | return -ENOMEM; |
287 | 286 | ||
288 | spin_lock_init(&priv->lock); | 287 | mutex_init(&priv->lock); |
289 | 288 | ||
290 | usb_set_serial_port_data(port, priv); | 289 | usb_set_serial_port_data(port, priv); |
291 | 290 | ||