diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-07-13 15:25:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-19 20:46:03 -0400 |
commit | 831c70fc13ca8c6074ab0c9d1121a93fd6c5a34a (patch) | |
tree | 2f60655a422b80593991f7c071de54a9180b32fc /drivers/usb | |
parent | 64fb98fc40738ae1a98bcea9ca3145b89fb71524 (diff) |
USB: use mutex instead of semaphore in the USB gadget serial driver
The USB gadget serial driver uses a semaphore as mutex. Use the
mutex API instead of the (binary) semaphore.
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/serial.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 38138bb9ddb0..9cd98e73dc1d 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/device.h> | 33 | #include <linux/device.h> |
34 | #include <linux/tty.h> | 34 | #include <linux/tty.h> |
35 | #include <linux/tty_flip.h> | 35 | #include <linux/tty_flip.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include <asm/byteorder.h> | 38 | #include <asm/byteorder.h> |
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
@@ -258,7 +259,7 @@ static const char *EP_IN_NAME; | |||
258 | static const char *EP_OUT_NAME; | 259 | static const char *EP_OUT_NAME; |
259 | static const char *EP_NOTIFY_NAME; | 260 | static const char *EP_NOTIFY_NAME; |
260 | 261 | ||
261 | static struct semaphore gs_open_close_sem[GS_NUM_PORTS]; | 262 | static struct mutex gs_open_close_lock[GS_NUM_PORTS]; |
262 | 263 | ||
263 | static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; | 264 | static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; |
264 | static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; | 265 | static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; |
@@ -595,7 +596,7 @@ static int __init gs_module_init(void) | |||
595 | tty_set_operations(gs_tty_driver, &gs_tty_ops); | 596 | tty_set_operations(gs_tty_driver, &gs_tty_ops); |
596 | 597 | ||
597 | for (i=0; i < GS_NUM_PORTS; i++) | 598 | for (i=0; i < GS_NUM_PORTS; i++) |
598 | sema_init(&gs_open_close_sem[i], 1); | 599 | mutex_init(&gs_open_close_lock[i]); |
599 | 600 | ||
600 | retval = tty_register_driver(gs_tty_driver); | 601 | retval = tty_register_driver(gs_tty_driver); |
601 | if (retval) { | 602 | if (retval) { |
@@ -635,7 +636,7 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
635 | struct gs_port *port; | 636 | struct gs_port *port; |
636 | struct gs_dev *dev; | 637 | struct gs_dev *dev; |
637 | struct gs_buf *buf; | 638 | struct gs_buf *buf; |
638 | struct semaphore *sem; | 639 | struct mutex *mtx; |
639 | int ret; | 640 | int ret; |
640 | 641 | ||
641 | port_num = tty->index; | 642 | port_num = tty->index; |
@@ -656,10 +657,10 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
656 | return -ENODEV; | 657 | return -ENODEV; |
657 | } | 658 | } |
658 | 659 | ||
659 | sem = &gs_open_close_sem[port_num]; | 660 | mtx = &gs_open_close_lock[port_num]; |
660 | if (down_interruptible(sem)) { | 661 | if (mutex_lock_interruptible(mtx)) { |
661 | printk(KERN_ERR | 662 | printk(KERN_ERR |
662 | "gs_open: (%d,%p,%p) interrupted waiting for semaphore\n", | 663 | "gs_open: (%d,%p,%p) interrupted waiting for mutex\n", |
663 | port_num, tty, file); | 664 | port_num, tty, file); |
664 | return -ERESTARTSYS; | 665 | return -ERESTARTSYS; |
665 | } | 666 | } |
@@ -754,12 +755,12 @@ static int gs_open(struct tty_struct *tty, struct file *file) | |||
754 | 755 | ||
755 | exit_unlock_port: | 756 | exit_unlock_port: |
756 | spin_unlock_irqrestore(&port->port_lock, flags); | 757 | spin_unlock_irqrestore(&port->port_lock, flags); |
757 | up(sem); | 758 | mutex_unlock(mtx); |
758 | return ret; | 759 | return ret; |
759 | 760 | ||
760 | exit_unlock_dev: | 761 | exit_unlock_dev: |
761 | spin_unlock_irqrestore(&dev->dev_lock, flags); | 762 | spin_unlock_irqrestore(&dev->dev_lock, flags); |
762 | up(sem); | 763 | mutex_unlock(mtx); |
763 | return ret; | 764 | return ret; |
764 | 765 | ||
765 | } | 766 | } |
@@ -781,7 +782,7 @@ exit_unlock_dev: | |||
781 | static void gs_close(struct tty_struct *tty, struct file *file) | 782 | static void gs_close(struct tty_struct *tty, struct file *file) |
782 | { | 783 | { |
783 | struct gs_port *port = tty->driver_data; | 784 | struct gs_port *port = tty->driver_data; |
784 | struct semaphore *sem; | 785 | struct mutex *mtx; |
785 | 786 | ||
786 | if (port == NULL) { | 787 | if (port == NULL) { |
787 | printk(KERN_ERR "gs_close: NULL port pointer\n"); | 788 | printk(KERN_ERR "gs_close: NULL port pointer\n"); |
@@ -790,8 +791,8 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
790 | 791 | ||
791 | gs_debug("gs_close: (%d,%p,%p)\n", port->port_num, tty, file); | 792 | gs_debug("gs_close: (%d,%p,%p)\n", port->port_num, tty, file); |
792 | 793 | ||
793 | sem = &gs_open_close_sem[port->port_num]; | 794 | mtx = &gs_open_close_lock[port->port_num]; |
794 | down(sem); | 795 | mutex_lock(mtx); |
795 | 796 | ||
796 | spin_lock_irq(&port->port_lock); | 797 | spin_lock_irq(&port->port_lock); |
797 | 798 | ||
@@ -846,7 +847,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
846 | 847 | ||
847 | exit: | 848 | exit: |
848 | spin_unlock_irq(&port->port_lock); | 849 | spin_unlock_irq(&port->port_lock); |
849 | up(sem); | 850 | mutex_unlock(mtx); |
850 | } | 851 | } |
851 | 852 | ||
852 | /* | 853 | /* |