diff options
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/inode.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index bf0f6520c6df..de8a83803505 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -194,7 +194,7 @@ enum ep_state { | |||
194 | }; | 194 | }; |
195 | 195 | ||
196 | struct ep_data { | 196 | struct ep_data { |
197 | struct semaphore lock; | 197 | struct mutex lock; |
198 | enum ep_state state; | 198 | enum ep_state state; |
199 | atomic_t count; | 199 | atomic_t count; |
200 | struct dev_data *dev; | 200 | struct dev_data *dev; |
@@ -298,10 +298,10 @@ get_ready_ep (unsigned f_flags, struct ep_data *epdata) | |||
298 | int val; | 298 | int val; |
299 | 299 | ||
300 | if (f_flags & O_NONBLOCK) { | 300 | if (f_flags & O_NONBLOCK) { |
301 | if (down_trylock (&epdata->lock) != 0) | 301 | if (!mutex_trylock(&epdata->lock)) |
302 | goto nonblock; | 302 | goto nonblock; |
303 | if (epdata->state != STATE_EP_ENABLED) { | 303 | if (epdata->state != STATE_EP_ENABLED) { |
304 | up (&epdata->lock); | 304 | mutex_unlock(&epdata->lock); |
305 | nonblock: | 305 | nonblock: |
306 | val = -EAGAIN; | 306 | val = -EAGAIN; |
307 | } else | 307 | } else |
@@ -309,7 +309,8 @@ nonblock: | |||
309 | return val; | 309 | return val; |
310 | } | 310 | } |
311 | 311 | ||
312 | if ((val = down_interruptible (&epdata->lock)) < 0) | 312 | val = mutex_lock_interruptible(&epdata->lock); |
313 | if (val < 0) | ||
313 | return val; | 314 | return val; |
314 | 315 | ||
315 | switch (epdata->state) { | 316 | switch (epdata->state) { |
@@ -323,7 +324,7 @@ nonblock: | |||
323 | // FALLTHROUGH | 324 | // FALLTHROUGH |
324 | case STATE_EP_UNBOUND: /* clean disconnect */ | 325 | case STATE_EP_UNBOUND: /* clean disconnect */ |
325 | val = -ENODEV; | 326 | val = -ENODEV; |
326 | up (&epdata->lock); | 327 | mutex_unlock(&epdata->lock); |
327 | } | 328 | } |
328 | return val; | 329 | return val; |
329 | } | 330 | } |
@@ -393,7 +394,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
393 | if (likely (data->ep != NULL)) | 394 | if (likely (data->ep != NULL)) |
394 | usb_ep_set_halt (data->ep); | 395 | usb_ep_set_halt (data->ep); |
395 | spin_unlock_irq (&data->dev->lock); | 396 | spin_unlock_irq (&data->dev->lock); |
396 | up (&data->lock); | 397 | mutex_unlock(&data->lock); |
397 | return -EBADMSG; | 398 | return -EBADMSG; |
398 | } | 399 | } |
399 | 400 | ||
@@ -411,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
411 | value = -EFAULT; | 412 | value = -EFAULT; |
412 | 413 | ||
413 | free1: | 414 | free1: |
414 | up (&data->lock); | 415 | mutex_unlock(&data->lock); |
415 | kfree (kbuf); | 416 | kfree (kbuf); |
416 | return value; | 417 | return value; |
417 | } | 418 | } |
@@ -436,7 +437,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
436 | if (likely (data->ep != NULL)) | 437 | if (likely (data->ep != NULL)) |
437 | usb_ep_set_halt (data->ep); | 438 | usb_ep_set_halt (data->ep); |
438 | spin_unlock_irq (&data->dev->lock); | 439 | spin_unlock_irq (&data->dev->lock); |
439 | up (&data->lock); | 440 | mutex_unlock(&data->lock); |
440 | return -EBADMSG; | 441 | return -EBADMSG; |
441 | } | 442 | } |
442 | 443 | ||
@@ -455,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
455 | VDEBUG (data->dev, "%s write %zu IN, status %d\n", | 456 | VDEBUG (data->dev, "%s write %zu IN, status %d\n", |
456 | data->name, len, (int) value); | 457 | data->name, len, (int) value); |
457 | free1: | 458 | free1: |
458 | up (&data->lock); | 459 | mutex_unlock(&data->lock); |
459 | kfree (kbuf); | 460 | kfree (kbuf); |
460 | return value; | 461 | return value; |
461 | } | 462 | } |
@@ -466,7 +467,8 @@ ep_release (struct inode *inode, struct file *fd) | |||
466 | struct ep_data *data = fd->private_data; | 467 | struct ep_data *data = fd->private_data; |
467 | int value; | 468 | int value; |
468 | 469 | ||
469 | if ((value = down_interruptible(&data->lock)) < 0) | 470 | value = mutex_lock_interruptible(&data->lock); |
471 | if (value < 0) | ||
470 | return value; | 472 | return value; |
471 | 473 | ||
472 | /* clean up if this can be reopened */ | 474 | /* clean up if this can be reopened */ |
@@ -476,7 +478,7 @@ ep_release (struct inode *inode, struct file *fd) | |||
476 | data->hs_desc.bDescriptorType = 0; | 478 | data->hs_desc.bDescriptorType = 0; |
477 | usb_ep_disable(data->ep); | 479 | usb_ep_disable(data->ep); |
478 | } | 480 | } |
479 | up (&data->lock); | 481 | mutex_unlock(&data->lock); |
480 | put_ep (data); | 482 | put_ep (data); |
481 | return 0; | 483 | return 0; |
482 | } | 484 | } |
@@ -507,7 +509,7 @@ static long ep_ioctl(struct file *fd, unsigned code, unsigned long value) | |||
507 | } else | 509 | } else |
508 | status = -ENODEV; | 510 | status = -ENODEV; |
509 | spin_unlock_irq (&data->dev->lock); | 511 | spin_unlock_irq (&data->dev->lock); |
510 | up (&data->lock); | 512 | mutex_unlock(&data->lock); |
511 | return status; | 513 | return status; |
512 | } | 514 | } |
513 | 515 | ||
@@ -673,7 +675,7 @@ fail: | |||
673 | value = -ENODEV; | 675 | value = -ENODEV; |
674 | spin_unlock_irq(&epdata->dev->lock); | 676 | spin_unlock_irq(&epdata->dev->lock); |
675 | 677 | ||
676 | up(&epdata->lock); | 678 | mutex_unlock(&epdata->lock); |
677 | 679 | ||
678 | if (unlikely(value)) { | 680 | if (unlikely(value)) { |
679 | kfree(priv); | 681 | kfree(priv); |
@@ -765,7 +767,8 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
765 | u32 tag; | 767 | u32 tag; |
766 | int value, length = len; | 768 | int value, length = len; |
767 | 769 | ||
768 | if ((value = down_interruptible (&data->lock)) < 0) | 770 | value = mutex_lock_interruptible(&data->lock); |
771 | if (value < 0) | ||
769 | return value; | 772 | return value; |
770 | 773 | ||
771 | if (data->state != STATE_EP_READY) { | 774 | if (data->state != STATE_EP_READY) { |
@@ -854,7 +857,7 @@ fail: | |||
854 | data->desc.bDescriptorType = 0; | 857 | data->desc.bDescriptorType = 0; |
855 | data->hs_desc.bDescriptorType = 0; | 858 | data->hs_desc.bDescriptorType = 0; |
856 | } | 859 | } |
857 | up (&data->lock); | 860 | mutex_unlock(&data->lock); |
858 | return value; | 861 | return value; |
859 | fail0: | 862 | fail0: |
860 | value = -EINVAL; | 863 | value = -EINVAL; |
@@ -870,7 +873,7 @@ ep_open (struct inode *inode, struct file *fd) | |||
870 | struct ep_data *data = inode->i_private; | 873 | struct ep_data *data = inode->i_private; |
871 | int value = -EBUSY; | 874 | int value = -EBUSY; |
872 | 875 | ||
873 | if (down_interruptible (&data->lock) != 0) | 876 | if (mutex_lock_interruptible(&data->lock) != 0) |
874 | return -EINTR; | 877 | return -EINTR; |
875 | spin_lock_irq (&data->dev->lock); | 878 | spin_lock_irq (&data->dev->lock); |
876 | if (data->dev->state == STATE_DEV_UNBOUND) | 879 | if (data->dev->state == STATE_DEV_UNBOUND) |
@@ -885,7 +888,7 @@ ep_open (struct inode *inode, struct file *fd) | |||
885 | DBG (data->dev, "%s state %d\n", | 888 | DBG (data->dev, "%s state %d\n", |
886 | data->name, data->state); | 889 | data->name, data->state); |
887 | spin_unlock_irq (&data->dev->lock); | 890 | spin_unlock_irq (&data->dev->lock); |
888 | up (&data->lock); | 891 | mutex_unlock(&data->lock); |
889 | return value; | 892 | return value; |
890 | } | 893 | } |
891 | 894 | ||
@@ -1631,7 +1634,7 @@ static int activate_ep_files (struct dev_data *dev) | |||
1631 | if (!data) | 1634 | if (!data) |
1632 | goto enomem0; | 1635 | goto enomem0; |
1633 | data->state = STATE_EP_DISABLED; | 1636 | data->state = STATE_EP_DISABLED; |
1634 | init_MUTEX (&data->lock); | 1637 | mutex_init(&data->lock); |
1635 | init_waitqueue_head (&data->wait); | 1638 | init_waitqueue_head (&data->wait); |
1636 | 1639 | ||
1637 | strncpy (data->name, ep->name, sizeof (data->name) - 1); | 1640 | strncpy (data->name, ep->name, sizeof (data->name) - 1); |