diff options
author | Luiz Fernando Capitulino <lcapitulino@mandriva.com.br> | 2006-03-24 15:12:31 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-04-14 14:12:20 -0400 |
commit | 1ce7dd26e0f0e34bb75ec56f7f546151af34fcf9 (patch) | |
tree | 38635f09e5d02ef4cedba02fe1f8892cade6690b /drivers/usb/serial/usb-serial.c | |
parent | 14cd5f8e85e90c9dead2393377b9a2c23131e0ce (diff) |
[PATCH] USB serial: Converts port semaphore to mutexes.
The usbserial's port semaphore used to synchronize serial_open()
and serial_close() are strict mutexes, convert them to the mutex
implementation.
Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 097f4e8488fe..071f86a59c08 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -27,10 +27,10 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <linux/list.h> | 31 | #include <linux/list.h> |
31 | #include <linux/smp_lock.h> | 32 | #include <linux/smp_lock.h> |
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
33 | #include <asm/semaphore.h> | ||
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include "usb-serial.h" | 35 | #include "usb-serial.h" |
36 | #include "pl2303.h" | 36 | #include "pl2303.h" |
@@ -192,7 +192,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
192 | if (!port) | 192 | if (!port) |
193 | return -ENODEV; | 193 | return -ENODEV; |
194 | 194 | ||
195 | if (down_interruptible(&port->sem)) | 195 | if (mutex_lock_interruptible(&port->mutex)) |
196 | return -ERESTARTSYS; | 196 | return -ERESTARTSYS; |
197 | 197 | ||
198 | ++port->open_count; | 198 | ++port->open_count; |
@@ -219,7 +219,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
219 | goto bailout_module_put; | 219 | goto bailout_module_put; |
220 | } | 220 | } |
221 | 221 | ||
222 | up(&port->sem); | 222 | mutex_unlock(&port->mutex); |
223 | return 0; | 223 | return 0; |
224 | 224 | ||
225 | bailout_module_put: | 225 | bailout_module_put: |
@@ -227,7 +227,7 @@ bailout_module_put: | |||
227 | bailout_kref_put: | 227 | bailout_kref_put: |
228 | kref_put(&serial->kref, destroy_serial); | 228 | kref_put(&serial->kref, destroy_serial); |
229 | port->open_count = 0; | 229 | port->open_count = 0; |
230 | up(&port->sem); | 230 | mutex_unlock(&port->mutex); |
231 | return retval; | 231 | return retval; |
232 | } | 232 | } |
233 | 233 | ||
@@ -240,10 +240,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
240 | 240 | ||
241 | dbg("%s - port %d", __FUNCTION__, port->number); | 241 | dbg("%s - port %d", __FUNCTION__, port->number); |
242 | 242 | ||
243 | down(&port->sem); | 243 | mutex_lock(&port->mutex); |
244 | 244 | ||
245 | if (port->open_count == 0) { | 245 | if (port->open_count == 0) { |
246 | up(&port->sem); | 246 | mutex_unlock(&port->mutex); |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | 249 | ||
@@ -262,7 +262,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
262 | module_put(port->serial->type->driver.owner); | 262 | module_put(port->serial->type->driver.owner); |
263 | } | 263 | } |
264 | 264 | ||
265 | up(&port->sem); | 265 | mutex_unlock(&port->mutex); |
266 | kref_put(&port->serial->kref, destroy_serial); | 266 | kref_put(&port->serial->kref, destroy_serial); |
267 | } | 267 | } |
268 | 268 | ||
@@ -783,7 +783,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
783 | port->number = i + serial->minor; | 783 | port->number = i + serial->minor; |
784 | port->serial = serial; | 784 | port->serial = serial; |
785 | spin_lock_init(&port->lock); | 785 | spin_lock_init(&port->lock); |
786 | sema_init(&port->sem, 1); | 786 | mutex_init(&port->mutex); |
787 | INIT_WORK(&port->work, usb_serial_port_softint, port); | 787 | INIT_WORK(&port->work, usb_serial_port_softint, port); |
788 | serial->port[i] = port; | 788 | serial->port[i] = port; |
789 | } | 789 | } |