Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=18bcbcfe9ca2308ebffb40068b51803da9315d97
Commit:     18bcbcfe9ca2308ebffb40068b51803da9315d97
Parent:     da0e8fb00b862aa10265f0c64930b432cd44420b
Author:     Daniel Walker <[EMAIL PROTECTED]>
AuthorDate: Fri Jan 11 08:45:44 2008 -0800
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Feb 1 14:35:02 2008 -0800

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/misc/legousbtower.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index aab3200..6664043 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -205,7 +205,7 @@ static DEFINE_MUTEX(open_disc_mutex);
 
 /* Structure to hold all of our device specific stuff */
 struct lego_usb_tower {
-       struct semaphore        sem;            /* locks this structure */
+       struct mutex            lock;           /* locks this structure */
        struct usb_device*      udev;           /* save off the usb device 
pointer */
        unsigned char           minor;          /* the starting minor number 
for this device */
 
@@ -361,7 +361,7 @@ static int tower_open (struct inode *inode, struct file 
*file)
        }
 
        /* lock this device */
-       if (down_interruptible (&dev->sem)) {
+       if (mutex_lock_interruptible(&dev->lock)) {
                mutex_unlock(&open_disc_mutex);
                retval = -ERESTARTSYS;
                goto exit;
@@ -421,7 +421,7 @@ static int tower_open (struct inode *inode, struct file 
*file)
        file->private_data = dev;
 
 unlock_exit:
-       up (&dev->sem);
+       mutex_unlock(&dev->lock);
 
 exit:
        dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval);
@@ -448,7 +448,7 @@ static int tower_release (struct inode *inode, struct file 
*file)
        }
 
        mutex_lock(&open_disc_mutex);
-       if (down_interruptible (&dev->sem)) {
+       if (mutex_lock_interruptible(&dev->lock)) {
                retval = -ERESTARTSYS;
                goto exit;
        }
@@ -460,7 +460,9 @@ static int tower_release (struct inode *inode, struct file 
*file)
        }
        if (dev->udev == NULL) {
                /* the device was unplugged before the file was released */
-               up (&dev->sem); /* unlock here as tower_delete frees dev */
+
+               /* unlock here as tower_delete frees dev */
+               mutex_unlock(&dev->lock);
                tower_delete (dev);
                goto exit;
        }
@@ -473,7 +475,7 @@ static int tower_release (struct inode *inode, struct file 
*file)
        dev->open_count = 0;
 
 unlock_exit:
-       up (&dev->sem);
+       mutex_unlock(&dev->lock);
 
 exit:
        mutex_unlock(&open_disc_mutex);
@@ -586,7 +588,7 @@ static ssize_t tower_read (struct file *file, char __user 
*buffer, size_t count,
        dev = (struct lego_usb_tower *)file->private_data;
 
        /* lock this object */
-       if (down_interruptible (&dev->sem)) {
+       if (mutex_lock_interruptible(&dev->lock)) {
                retval = -ERESTARTSYS;
                goto exit;
        }
@@ -653,7 +655,7 @@ static ssize_t tower_read (struct file *file, char __user 
*buffer, size_t count,
 
 unlock_exit:
        /* unlock the device */
-       up (&dev->sem);
+       mutex_unlock(&dev->lock);
 
 exit:
        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
        dev = (struct lego_usb_tower *)file->private_data;
 
        /* lock this object */
-       if (down_interruptible (&dev->sem)) {
+       if (mutex_lock_interruptible(&dev->lock)) {
                retval = -ERESTARTSYS;
                goto exit;
        }
@@ -737,7 +739,7 @@ static ssize_t tower_write (struct file *file, const char 
__user *buffer, size_t
 
 unlock_exit:
        /* unlock the device */
-       up (&dev->sem);
+       mutex_unlock(&dev->lock);
 
 exit:
        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
                goto exit;
        }
 
-       init_MUTEX (&dev->sem);
+       mutex_init(&dev->lock);
 
        dev->udev = udev;
        dev->open_count = 0;
@@ -1007,16 +1009,16 @@ static void tower_disconnect (struct usb_interface 
*interface)
        /* give back our minor */
        usb_deregister_dev (interface, &tower_class);
 
-       down (&dev->sem);
+       mutex_lock(&dev->lock);
        mutex_unlock(&open_disc_mutex);
 
        /* if the device is not opened, then we clean up right now */
        if (!dev->open_count) {
-               up (&dev->sem);
+               mutex_unlock(&dev->lock);
                tower_delete (dev);
        } else {
                dev->udev = NULL;
-               up (&dev->sem);
+               mutex_unlock(&dev->lock);
        }
 
        info("LEGO USB Tower #%d now disconnected", (minor - 
LEGO_USB_TOWER_MINOR_BASE));
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to