Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82260
b: refs/heads/master
c: 18bcbcf
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Walker authored and Greg Kroah-Hartman committed Feb 1, 2008
1 parent c49b3a4 commit 4c8bee0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da0e8fb00b862aa10265f0c64930b432cd44420b
refs/heads/master: 18bcbcfe9ca2308ebffb40068b51803da9315d97
30 changes: 16 additions & 14 deletions trunk/drivers/usb/misc/legousbtower.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 4c8bee0

Please sign in to comment.