aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorLuiz Fernando Capitulino <lcapitulino@mandriva.com.br>2006-03-24 15:12:31 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-14 14:12:20 -0400
commit1ce7dd26e0f0e34bb75ec56f7f546151af34fcf9 (patch)
tree38635f09e5d02ef4cedba02fe1f8892cade6690b /drivers/usb/serial
parent14cd5f8e85e90c9dead2393377b9a2c23131e0ce (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')
-rw-r--r--drivers/usb/serial/usb-serial.c16
-rw-r--r--drivers/usb/serial/usb-serial.h6
2 files changed, 11 insertions, 11 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
225bailout_module_put: 225bailout_module_put:
@@ -227,7 +227,7 @@ bailout_module_put:
227bailout_kref_put: 227bailout_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 }
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
index d7d27c3385b3..dc89d8710460 100644
--- a/drivers/usb/serial/usb-serial.h
+++ b/drivers/usb/serial/usb-serial.h
@@ -16,7 +16,7 @@
16 16
17#include <linux/config.h> 17#include <linux/config.h>
18#include <linux/kref.h> 18#include <linux/kref.h>
19#include <asm/semaphore.h> 19#include <linux/mutex.h>
20 20
21#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 21#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
22#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 22#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
@@ -31,7 +31,7 @@
31 * @serial: pointer back to the struct usb_serial owner of this port. 31 * @serial: pointer back to the struct usb_serial owner of this port.
32 * @tty: pointer to the corresponding tty for this port. 32 * @tty: pointer to the corresponding tty for this port.
33 * @lock: spinlock to grab when updating portions of this structure. 33 * @lock: spinlock to grab when updating portions of this structure.
34 * @sem: semaphore used to synchronize serial_open() and serial_close() 34 * @mutex: mutex used to synchronize serial_open() and serial_close()
35 * access for this port. 35 * access for this port.
36 * @number: the number of the port (the minor number). 36 * @number: the number of the port (the minor number).
37 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port. 37 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port.
@@ -63,7 +63,7 @@ struct usb_serial_port {
63 struct usb_serial * serial; 63 struct usb_serial * serial;
64 struct tty_struct * tty; 64 struct tty_struct * tty;
65 spinlock_t lock; 65 spinlock_t lock;
66 struct semaphore sem; 66 struct mutex mutex;
67 unsigned char number; 67 unsigned char number;
68 68
69 unsigned char * interrupt_in_buffer; 69 unsigned char * interrupt_in_buffer;