aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/ldusb.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 11580e81e2c6..7aafd53fbcab 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -148,7 +148,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in
148 148
149/* Structure to hold all of our device specific stuff */ 149/* Structure to hold all of our device specific stuff */
150struct ld_usb { 150struct ld_usb {
151 struct semaphore sem; /* locks this structure */ 151 struct mutex mutex; /* locks this structure */
152 struct usb_interface* intf; /* save off the usb interface pointer */ 152 struct usb_interface* intf; /* save off the usb interface pointer */
153 153
154 int open_count; /* number of times this port has been opened */ 154 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 return -ENODEV; 319 return -ENODEV;
320 320
321 /* lock this device */ 321 /* lock this device */
322 if (down_interruptible(&dev->sem)) 322 if (mutex_lock_interruptible(&dev->mutex))
323 return -ERESTARTSYS; 323 return -ERESTARTSYS;
324 324
325 /* allow opening only once */ 325 /* allow opening only once */
@@ -358,7 +358,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
358 file->private_data = dev; 358 file->private_data = dev;
359 359
360unlock_exit: 360unlock_exit:
361 up(&dev->sem); 361 mutex_unlock(&dev->mutex);
362 362
363 return retval; 363 return retval;
364} 364}
@@ -378,7 +378,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
378 goto exit; 378 goto exit;
379 } 379 }
380 380
381 if (down_interruptible(&dev->sem)) { 381 if (mutex_lock_interruptible(&dev->mutex)) {
382 retval = -ERESTARTSYS; 382 retval = -ERESTARTSYS;
383 goto exit; 383 goto exit;
384 } 384 }
@@ -389,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
389 } 389 }
390 if (dev->intf == NULL) { 390 if (dev->intf == NULL) {
391 /* the device was unplugged before the file was released */ 391 /* the device was unplugged before the file was released */
392 up(&dev->sem); 392 mutex_unlock(&dev->mutex);
393 /* unlock here as ld_usb_delete frees dev */ 393 /* unlock here as ld_usb_delete frees dev */
394 ld_usb_delete(dev); 394 ld_usb_delete(dev);
395 goto exit; 395 goto exit;
@@ -402,7 +402,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
402 dev->open_count = 0; 402 dev->open_count = 0;
403 403
404unlock_exit: 404unlock_exit:
405 up(&dev->sem); 405 mutex_unlock(&dev->mutex);
406 406
407exit: 407exit:
408 return retval; 408 return retval;
@@ -448,7 +448,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
448 goto exit; 448 goto exit;
449 449
450 /* lock this object */ 450 /* lock this object */
451 if (down_interruptible(&dev->sem)) { 451 if (mutex_lock_interruptible(&dev->mutex)) {
452 retval = -ERESTARTSYS; 452 retval = -ERESTARTSYS;
453 goto exit; 453 goto exit;
454 } 454 }
@@ -505,7 +505,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
505 505
506unlock_exit: 506unlock_exit:
507 /* unlock the device */ 507 /* unlock the device */
508 up(&dev->sem); 508 mutex_unlock(&dev->mutex);
509 509
510exit: 510exit:
511 return retval; 511 return retval;
@@ -528,7 +528,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
528 goto exit; 528 goto exit;
529 529
530 /* lock this object */ 530 /* lock this object */
531 if (down_interruptible(&dev->sem)) { 531 if (mutex_lock_interruptible(&dev->mutex)) {
532 retval = -ERESTARTSYS; 532 retval = -ERESTARTSYS;
533 goto exit; 533 goto exit;
534 } 534 }
@@ -602,7 +602,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
602 602
603unlock_exit: 603unlock_exit:
604 /* unlock the device */ 604 /* unlock the device */
605 up(&dev->sem); 605 mutex_unlock(&dev->mutex);
606 606
607exit: 607exit:
608 return retval; 608 return retval;
@@ -651,7 +651,7 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
651 dev_err(&intf->dev, "Out of memory\n"); 651 dev_err(&intf->dev, "Out of memory\n");
652 goto exit; 652 goto exit;
653 } 653 }
654 init_MUTEX(&dev->sem); 654 mutex_init(&dev->mutex);
655 spin_lock_init(&dev->rbsl); 655 spin_lock_init(&dev->rbsl);
656 dev->intf = intf; 656 dev->intf = intf;
657 init_waitqueue_head(&dev->read_wait); 657 init_waitqueue_head(&dev->read_wait);
@@ -765,15 +765,15 @@ static void ld_usb_disconnect(struct usb_interface *intf)
765 /* give back our minor */ 765 /* give back our minor */
766 usb_deregister_dev(intf, &ld_usb_class); 766 usb_deregister_dev(intf, &ld_usb_class);
767 767
768 down(&dev->sem); 768 mutex_lock(&dev->mutex);
769 769
770 /* if the device is not opened, then we clean up right now */ 770 /* if the device is not opened, then we clean up right now */
771 if (!dev->open_count) { 771 if (!dev->open_count) {
772 up(&dev->sem); 772 mutex_unlock(&dev->mutex);
773 ld_usb_delete(dev); 773 ld_usb_delete(dev);
774 } else { 774 } else {
775 dev->intf = NULL; 775 dev->intf = NULL;
776 up(&dev->sem); 776 mutex_unlock(&dev->mutex);
777 } 777 }
778 778
779 dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", 779 dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",