aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorDaniel Walker <dwalker@mvista.com>2008-01-11 11:45:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-01 17:35:02 -0500
commit18bcbcfe9ca2308ebffb40068b51803da9315d97 (patch)
tree11da1847cf54dc79c5976ede115de0761ddc26a0 /drivers/usb
parentda0e8fb00b862aa10265f0c64930b432cd44420b (diff)
USB: misc: legousbtower: semaphore to mutex
The dev->sem conforms to mutex style usage. This patch converts it to use the struct mutex type, and new API. There is also a small style fix around this comment, /* unlock here as tower_delete frees dev */ Where I broke the line up to meet the 80 char limit. Signed-off-by: Daniel Walker <dwalker@mvista.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/misc/legousbtower.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index aab320085ebf..6664043f4645 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -205,7 +205,7 @@ static DEFINE_MUTEX(open_disc_mutex);
205 205
206/* Structure to hold all of our device specific stuff */ 206/* Structure to hold all of our device specific stuff */
207struct lego_usb_tower { 207struct lego_usb_tower {
208 struct semaphore sem; /* locks this structure */ 208 struct mutex lock; /* locks this structure */
209 struct usb_device* udev; /* save off the usb device pointer */ 209 struct usb_device* udev; /* save off the usb device pointer */
210 unsigned char minor; /* the starting minor number for this device */ 210 unsigned char minor; /* the starting minor number for this device */
211 211
@@ -361,7 +361,7 @@ static int tower_open (struct inode *inode, struct file *file)
361 } 361 }
362 362
363 /* lock this device */ 363 /* lock this device */
364 if (down_interruptible (&dev->sem)) { 364 if (mutex_lock_interruptible(&dev->lock)) {
365 mutex_unlock(&open_disc_mutex); 365 mutex_unlock(&open_disc_mutex);
366 retval = -ERESTARTSYS; 366 retval = -ERESTARTSYS;
367 goto exit; 367 goto exit;
@@ -421,7 +421,7 @@ static int tower_open (struct inode *inode, struct file *file)
421 file->private_data = dev; 421 file->private_data = dev;
422 422
423unlock_exit: 423unlock_exit:
424 up (&dev->sem); 424 mutex_unlock(&dev->lock);
425 425
426exit: 426exit:
427 dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); 427 dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval);
@@ -448,7 +448,7 @@ static int tower_release (struct inode *inode, struct file *file)
448 } 448 }
449 449
450 mutex_lock(&open_disc_mutex); 450 mutex_lock(&open_disc_mutex);
451 if (down_interruptible (&dev->sem)) { 451 if (mutex_lock_interruptible(&dev->lock)) {
452 retval = -ERESTARTSYS; 452 retval = -ERESTARTSYS;
453 goto exit; 453 goto exit;
454 } 454 }
@@ -460,7 +460,9 @@ static int tower_release (struct inode *inode, struct file *file)
460 } 460 }
461 if (dev->udev == NULL) { 461 if (dev->udev == NULL) {
462 /* the device was unplugged before the file was released */ 462 /* the device was unplugged before the file was released */
463 up (&dev->sem); /* unlock here as tower_delete frees dev */ 463
464 /* unlock here as tower_delete frees dev */
465 mutex_unlock(&dev->lock);
464 tower_delete (dev); 466 tower_delete (dev);
465 goto exit; 467 goto exit;
466 } 468 }
@@ -473,7 +475,7 @@ static int tower_release (struct inode *inode, struct file *file)
473 dev->open_count = 0; 475 dev->open_count = 0;
474 476
475unlock_exit: 477unlock_exit:
476 up (&dev->sem); 478 mutex_unlock(&dev->lock);
477 479
478exit: 480exit:
479 mutex_unlock(&open_disc_mutex); 481 mutex_unlock(&open_disc_mutex);
@@ -586,7 +588,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count,
586 dev = (struct lego_usb_tower *)file->private_data; 588 dev = (struct lego_usb_tower *)file->private_data;
587 589
588 /* lock this object */ 590 /* lock this object */
589 if (down_interruptible (&dev->sem)) { 591 if (mutex_lock_interruptible(&dev->lock)) {
590 retval = -ERESTARTSYS; 592 retval = -ERESTARTSYS;
591 goto exit; 593 goto exit;
592 } 594 }
@@ -653,7 +655,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count,
653 655
654unlock_exit: 656unlock_exit:
655 /* unlock the device */ 657 /* unlock the device */
656 up (&dev->sem); 658 mutex_unlock(&dev->lock);
657 659
658exit: 660exit:
659 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 661 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval);
@@ -675,7 +677,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
675 dev = (struct lego_usb_tower *)file->private_data; 677 dev = (struct lego_usb_tower *)file->private_data;
676 678
677 /* lock this object */ 679 /* lock this object */
678 if (down_interruptible (&dev->sem)) { 680 if (mutex_lock_interruptible(&dev->lock)) {
679 retval = -ERESTARTSYS; 681 retval = -ERESTARTSYS;
680 goto exit; 682 goto exit;
681 } 683 }
@@ -737,7 +739,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t
737 739
738unlock_exit: 740unlock_exit:
739 /* unlock the device */ 741 /* unlock the device */
740 up (&dev->sem); 742 mutex_unlock(&dev->lock);
741 743
742exit: 744exit:
743 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); 745 dbg(2, "%s: leave, return value %d", __FUNCTION__, retval);
@@ -862,7 +864,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
862 goto exit; 864 goto exit;
863 } 865 }
864 866
865 init_MUTEX (&dev->sem); 867 mutex_init(&dev->lock);
866 868
867 dev->udev = udev; 869 dev->udev = udev;
868 dev->open_count = 0; 870 dev->open_count = 0;
@@ -1007,16 +1009,16 @@ static void tower_disconnect (struct usb_interface *interface)
1007 /* give back our minor */ 1009 /* give back our minor */
1008 usb_deregister_dev (interface, &tower_class); 1010 usb_deregister_dev (interface, &tower_class);
1009 1011
1010 down (&dev->sem); 1012 mutex_lock(&dev->lock);
1011 mutex_unlock(&open_disc_mutex); 1013 mutex_unlock(&open_disc_mutex);
1012 1014
1013 /* if the device is not opened, then we clean up right now */ 1015 /* if the device is not opened, then we clean up right now */
1014 if (!dev->open_count) { 1016 if (!dev->open_count) {
1015 up (&dev->sem); 1017 mutex_unlock(&dev->lock);
1016 tower_delete (dev); 1018 tower_delete (dev);
1017 } else { 1019 } else {
1018 dev->udev = NULL; 1020 dev->udev = NULL;
1019 up (&dev->sem); 1021 mutex_unlock(&dev->lock);
1020 } 1022 }
1021 1023
1022 info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); 1024 info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE));