提交 ce0d7d3f 编写于 作者: D Daniel Walker 提交者: Greg Kroah-Hartman

usb: ldusb: ld_usb semaphore to mutex

Signed-off-by: NDaniel Walker <dwalker@mvista.com>
Acked-by: NMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 db11e47d
...@@ -148,7 +148,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in ...@@ -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 */ /* Structure to hold all of our device specific stuff */
struct ld_usb { 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 */ struct usb_interface* intf; /* save off the usb interface pointer */
int open_count; /* number of times this port has been opened */ int open_count; /* number of times this port has been opened */
...@@ -319,7 +319,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) ...@@ -319,7 +319,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
/* lock this device */ /* lock this device */
if (down_interruptible(&dev->sem)) if (mutex_lock_interruptible(&dev->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
/* allow opening only once */ /* allow opening only once */
...@@ -358,7 +358,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) ...@@ -358,7 +358,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
file->private_data = dev; file->private_data = dev;
unlock_exit: unlock_exit:
up(&dev->sem); mutex_unlock(&dev->mutex);
return retval; return retval;
} }
...@@ -378,7 +378,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) ...@@ -378,7 +378,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
goto exit; goto exit;
} }
if (down_interruptible(&dev->sem)) { if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
goto exit; goto exit;
} }
...@@ -389,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) ...@@ -389,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
} }
if (dev->intf == NULL) { if (dev->intf == NULL) {
/* the device was unplugged before the file was released */ /* the device was unplugged before the file was released */
up(&dev->sem); mutex_unlock(&dev->mutex);
/* unlock here as ld_usb_delete frees dev */ /* unlock here as ld_usb_delete frees dev */
ld_usb_delete(dev); ld_usb_delete(dev);
goto exit; goto exit;
...@@ -402,7 +402,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) ...@@ -402,7 +402,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
dev->open_count = 0; dev->open_count = 0;
unlock_exit: unlock_exit:
up(&dev->sem); mutex_unlock(&dev->mutex);
exit: exit:
return retval; return retval;
...@@ -448,7 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, ...@@ -448,7 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
goto exit; goto exit;
/* lock this object */ /* lock this object */
if (down_interruptible(&dev->sem)) { if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
goto exit; goto exit;
} }
...@@ -505,7 +505,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, ...@@ -505,7 +505,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
unlock_exit: unlock_exit:
/* unlock the device */ /* unlock the device */
up(&dev->sem); mutex_unlock(&dev->mutex);
exit: exit:
return retval; return retval;
...@@ -528,7 +528,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, ...@@ -528,7 +528,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
goto exit; goto exit;
/* lock this object */ /* lock this object */
if (down_interruptible(&dev->sem)) { if (mutex_lock_interruptible(&dev->mutex)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
goto exit; goto exit;
} }
...@@ -602,7 +602,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, ...@@ -602,7 +602,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
unlock_exit: unlock_exit:
/* unlock the device */ /* unlock the device */
up(&dev->sem); mutex_unlock(&dev->mutex);
exit: exit:
return retval; return retval;
...@@ -651,7 +651,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * ...@@ -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"); dev_err(&intf->dev, "Out of memory\n");
goto exit; goto exit;
} }
init_MUTEX(&dev->sem); mutex_init(&dev->mutex);
spin_lock_init(&dev->rbsl); spin_lock_init(&dev->rbsl);
dev->intf = intf; dev->intf = intf;
init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->read_wait);
...@@ -765,15 +765,15 @@ static void ld_usb_disconnect(struct usb_interface *intf) ...@@ -765,15 +765,15 @@ static void ld_usb_disconnect(struct usb_interface *intf)
/* give back our minor */ /* give back our minor */
usb_deregister_dev(intf, &ld_usb_class); 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 the device is not opened, then we clean up right now */
if (!dev->open_count) { if (!dev->open_count) {
up(&dev->sem); mutex_unlock(&dev->mutex);
ld_usb_delete(dev); ld_usb_delete(dev);
} else { } else {
dev->intf = NULL; dev->intf = NULL;
up(&dev->sem); mutex_unlock(&dev->mutex);
} }
dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册