diff options
| -rw-r--r-- | drivers/usb/gadget/printer.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 43abf55d8c60..4c3ac5c42237 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
| @@ -82,7 +82,7 @@ static struct class *usb_gadget_class; | |||
| 82 | struct printer_dev { | 82 | struct printer_dev { |
| 83 | spinlock_t lock; /* lock this structure */ | 83 | spinlock_t lock; /* lock this structure */ |
| 84 | /* lock buffer lists during read/write calls */ | 84 | /* lock buffer lists during read/write calls */ |
| 85 | spinlock_t lock_printer_io; | 85 | struct mutex lock_printer_io; |
| 86 | struct usb_gadget *gadget; | 86 | struct usb_gadget *gadget; |
| 87 | struct usb_request *req; /* for control responses */ | 87 | struct usb_request *req; /* for control responses */ |
| 88 | u8 config; | 88 | u8 config; |
| @@ -567,7 +567,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
| 567 | 567 | ||
| 568 | DBG(dev, "printer_read trying to read %d bytes\n", (int)len); | 568 | DBG(dev, "printer_read trying to read %d bytes\n", (int)len); |
| 569 | 569 | ||
| 570 | spin_lock(&dev->lock_printer_io); | 570 | mutex_lock(&dev->lock_printer_io); |
| 571 | spin_lock_irqsave(&dev->lock, flags); | 571 | spin_lock_irqsave(&dev->lock, flags); |
| 572 | 572 | ||
| 573 | /* We will use this flag later to check if a printer reset happened | 573 | /* We will use this flag later to check if a printer reset happened |
| @@ -601,7 +601,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
| 601 | * call or not. | 601 | * call or not. |
| 602 | */ | 602 | */ |
| 603 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { | 603 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { |
| 604 | spin_unlock(&dev->lock_printer_io); | 604 | mutex_unlock(&dev->lock_printer_io); |
| 605 | return -EAGAIN; | 605 | return -EAGAIN; |
| 606 | } | 606 | } |
| 607 | 607 | ||
| @@ -648,7 +648,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
| 648 | if (dev->reset_printer) { | 648 | if (dev->reset_printer) { |
| 649 | list_add(¤t_rx_req->list, &dev->rx_reqs); | 649 | list_add(¤t_rx_req->list, &dev->rx_reqs); |
| 650 | spin_unlock_irqrestore(&dev->lock, flags); | 650 | spin_unlock_irqrestore(&dev->lock, flags); |
| 651 | spin_unlock(&dev->lock_printer_io); | 651 | mutex_unlock(&dev->lock_printer_io); |
| 652 | return -EAGAIN; | 652 | return -EAGAIN; |
| 653 | } | 653 | } |
| 654 | 654 | ||
| @@ -673,7 +673,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
| 673 | dev->current_rx_buf = current_rx_buf; | 673 | dev->current_rx_buf = current_rx_buf; |
| 674 | 674 | ||
| 675 | spin_unlock_irqrestore(&dev->lock, flags); | 675 | spin_unlock_irqrestore(&dev->lock, flags); |
| 676 | spin_unlock(&dev->lock_printer_io); | 676 | mutex_unlock(&dev->lock_printer_io); |
| 677 | 677 | ||
| 678 | DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); | 678 | DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); |
| 679 | 679 | ||
| @@ -697,7 +697,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 697 | if (len == 0) | 697 | if (len == 0) |
| 698 | return -EINVAL; | 698 | return -EINVAL; |
| 699 | 699 | ||
| 700 | spin_lock(&dev->lock_printer_io); | 700 | mutex_lock(&dev->lock_printer_io); |
| 701 | spin_lock_irqsave(&dev->lock, flags); | 701 | spin_lock_irqsave(&dev->lock, flags); |
| 702 | 702 | ||
| 703 | /* Check if a printer reset happens while we have interrupts on */ | 703 | /* Check if a printer reset happens while we have interrupts on */ |
| @@ -713,7 +713,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 713 | * a NON-Blocking call or not. | 713 | * a NON-Blocking call or not. |
| 714 | */ | 714 | */ |
| 715 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { | 715 | if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { |
| 716 | spin_unlock(&dev->lock_printer_io); | 716 | mutex_unlock(&dev->lock_printer_io); |
| 717 | return -EAGAIN; | 717 | return -EAGAIN; |
| 718 | } | 718 | } |
| 719 | 719 | ||
| @@ -752,7 +752,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 752 | 752 | ||
| 753 | if (copy_from_user(req->buf, buf, size)) { | 753 | if (copy_from_user(req->buf, buf, size)) { |
| 754 | list_add(&req->list, &dev->tx_reqs); | 754 | list_add(&req->list, &dev->tx_reqs); |
| 755 | spin_unlock(&dev->lock_printer_io); | 755 | mutex_unlock(&dev->lock_printer_io); |
| 756 | return bytes_copied; | 756 | return bytes_copied; |
| 757 | } | 757 | } |
| 758 | 758 | ||
| @@ -766,14 +766,14 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 766 | if (dev->reset_printer) { | 766 | if (dev->reset_printer) { |
| 767 | list_add(&req->list, &dev->tx_reqs); | 767 | list_add(&req->list, &dev->tx_reqs); |
| 768 | spin_unlock_irqrestore(&dev->lock, flags); | 768 | spin_unlock_irqrestore(&dev->lock, flags); |
| 769 | spin_unlock(&dev->lock_printer_io); | 769 | mutex_unlock(&dev->lock_printer_io); |
| 770 | return -EAGAIN; | 770 | return -EAGAIN; |
| 771 | } | 771 | } |
| 772 | 772 | ||
| 773 | if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { | 773 | if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { |
| 774 | list_add(&req->list, &dev->tx_reqs); | 774 | list_add(&req->list, &dev->tx_reqs); |
| 775 | spin_unlock_irqrestore(&dev->lock, flags); | 775 | spin_unlock_irqrestore(&dev->lock, flags); |
| 776 | spin_unlock(&dev->lock_printer_io); | 776 | mutex_unlock(&dev->lock_printer_io); |
| 777 | return -EAGAIN; | 777 | return -EAGAIN; |
| 778 | } | 778 | } |
| 779 | 779 | ||
| @@ -782,7 +782,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | spin_unlock_irqrestore(&dev->lock, flags); | 784 | spin_unlock_irqrestore(&dev->lock, flags); |
| 785 | spin_unlock(&dev->lock_printer_io); | 785 | mutex_unlock(&dev->lock_printer_io); |
| 786 | 786 | ||
| 787 | DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); | 787 | DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); |
| 788 | 788 | ||
| @@ -820,11 +820,11 @@ printer_poll(struct file *fd, poll_table *wait) | |||
| 820 | unsigned long flags; | 820 | unsigned long flags; |
| 821 | int status = 0; | 821 | int status = 0; |
| 822 | 822 | ||
| 823 | spin_lock(&dev->lock_printer_io); | 823 | mutex_lock(&dev->lock_printer_io); |
| 824 | spin_lock_irqsave(&dev->lock, flags); | 824 | spin_lock_irqsave(&dev->lock, flags); |
| 825 | setup_rx_reqs(dev); | 825 | setup_rx_reqs(dev); |
| 826 | spin_unlock_irqrestore(&dev->lock, flags); | 826 | spin_unlock_irqrestore(&dev->lock, flags); |
| 827 | spin_unlock(&dev->lock_printer_io); | 827 | mutex_unlock(&dev->lock_printer_io); |
| 828 | 828 | ||
| 829 | poll_wait(fd, &dev->rx_wait, wait); | 829 | poll_wait(fd, &dev->rx_wait, wait); |
| 830 | poll_wait(fd, &dev->tx_wait, wait); | 830 | poll_wait(fd, &dev->tx_wait, wait); |
| @@ -1461,7 +1461,7 @@ autoconf_fail: | |||
| 1461 | } | 1461 | } |
| 1462 | 1462 | ||
| 1463 | spin_lock_init(&dev->lock); | 1463 | spin_lock_init(&dev->lock); |
| 1464 | spin_lock_init(&dev->lock_printer_io); | 1464 | mutex_init(&dev->lock_printer_io); |
| 1465 | INIT_LIST_HEAD(&dev->tx_reqs); | 1465 | INIT_LIST_HEAD(&dev->tx_reqs); |
| 1466 | INIT_LIST_HEAD(&dev->tx_reqs_active); | 1466 | INIT_LIST_HEAD(&dev->tx_reqs_active); |
| 1467 | INIT_LIST_HEAD(&dev->rx_reqs); | 1467 | INIT_LIST_HEAD(&dev->rx_reqs); |
| @@ -1594,7 +1594,7 @@ cleanup(void) | |||
| 1594 | { | 1594 | { |
| 1595 | int status; | 1595 | int status; |
| 1596 | 1596 | ||
| 1597 | spin_lock(&usb_printer_gadget.lock_printer_io); | 1597 | mutex_lock(&usb_printer_gadget.lock_printer_io); |
| 1598 | class_destroy(usb_gadget_class); | 1598 | class_destroy(usb_gadget_class); |
| 1599 | unregister_chrdev_region(g_printer_devno, 2); | 1599 | unregister_chrdev_region(g_printer_devno, 2); |
| 1600 | 1600 | ||
| @@ -1602,6 +1602,6 @@ cleanup(void) | |||
| 1602 | if (status) | 1602 | if (status) |
| 1603 | ERROR(dev, "usb_gadget_unregister_driver %x\n", status); | 1603 | ERROR(dev, "usb_gadget_unregister_driver %x\n", status); |
| 1604 | 1604 | ||
| 1605 | spin_unlock(&usb_printer_gadget.lock_printer_io); | 1605 | mutex_unlock(&usb_printer_gadget.lock_printer_io); |
| 1606 | } | 1606 | } |
| 1607 | module_exit(cleanup); | 1607 | module_exit(cleanup); |
