Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95777
b: refs/heads/master
c: ce0d7d3
h: refs/heads/master
i:
  95775: 95b0238
v: v3
  • Loading branch information
Daniel Walker authored and Greg Kroah-Hartman committed May 2, 2008
1 parent b82d49d commit 54ec69a
Show file tree
Hide file tree
Showing 2 changed files with 15 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: db11e47dd7b09b7f76c7eaa236277f23391331e7
refs/heads/master: ce0d7d3f575fc1ba6a89c3c651e710355590daff
28 changes: 14 additions & 14 deletions trunk/drivers/usb/misc/ldusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in

/* Structure to hold all of our device specific stuff */
struct ld_usb {
struct semaphore sem; /* locks this structure */
struct mutex mutex; /* locks this structure */
struct usb_interface* intf; /* save off the usb interface pointer */

int open_count; /* number of times this port has been opened */
Expand Down Expand Up @@ -319,7 +319,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
return -ENODEV;

/* lock this device */
if (down_interruptible(&dev->sem))
if (mutex_lock_interruptible(&dev->mutex))
return -ERESTARTSYS;

/* allow opening only once */
Expand Down Expand Up @@ -358,7 +358,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
file->private_data = dev;

unlock_exit:
up(&dev->sem);
mutex_unlock(&dev->mutex);

return retval;
}
Expand All @@ -378,7 +378,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
goto exit;
}

if (down_interruptible(&dev->sem)) {
if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS;
goto exit;
}
Expand All @@ -389,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
}
if (dev->intf == NULL) {
/* the device was unplugged before the file was released */
up(&dev->sem);
mutex_unlock(&dev->mutex);
/* unlock here as ld_usb_delete frees dev */
ld_usb_delete(dev);
goto exit;
Expand All @@ -402,7 +402,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
dev->open_count = 0;

unlock_exit:
up(&dev->sem);
mutex_unlock(&dev->mutex);

exit:
return retval;
Expand Down Expand Up @@ -448,7 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
goto exit;

/* lock this object */
if (down_interruptible(&dev->sem)) {
if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS;
goto exit;
}
Expand Down Expand Up @@ -505,7 +505,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,

unlock_exit:
/* unlock the device */
up(&dev->sem);
mutex_unlock(&dev->mutex);

exit:
return retval;
Expand All @@ -528,7 +528,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
goto exit;

/* lock this object */
if (down_interruptible(&dev->sem)) {
if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS;
goto exit;
}
Expand Down Expand Up @@ -602,7 +602,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,

unlock_exit:
/* unlock the device */
up(&dev->sem);
mutex_unlock(&dev->mutex);

exit:
return retval;
Expand Down Expand Up @@ -651,7 +651,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
dev_err(&intf->dev, "Out of memory\n");
goto exit;
}
init_MUTEX(&dev->sem);
mutex_init(&dev->mutex);
spin_lock_init(&dev->rbsl);
dev->intf = intf;
init_waitqueue_head(&dev->read_wait);
Expand Down Expand Up @@ -765,15 +765,15 @@ static void ld_usb_disconnect(struct usb_interface *intf)
/* give back our minor */
usb_deregister_dev(intf, &ld_usb_class);

down(&dev->sem);
mutex_lock(&dev->mutex);

/* if the device is not opened, then we clean up right now */
if (!dev->open_count) {
up(&dev->sem);
mutex_unlock(&dev->mutex);
ld_usb_delete(dev);
} else {
dev->intf = NULL;
up(&dev->sem);
mutex_unlock(&dev->mutex);
}

dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",
Expand Down

0 comments on commit 54ec69a

Please sign in to comment.