.. | .. |
---|
10 | 10 | |
---|
11 | 11 | * usb-skeleton.c by Greg Kroah-Hartman <greg@kroah.com> |
---|
12 | 12 | * brlvger.c by Stephane Dalton <sdalton@videotron.ca> |
---|
13 | | - * and St�hane Doyon <s.doyon@videotron.ca> |
---|
| 13 | + * and Stephane Doyon <s.doyon@videotron.ca> |
---|
14 | 14 | * |
---|
15 | 15 | * Released under the GPLv2. |
---|
16 | 16 | */ |
---|
.. | .. |
---|
63 | 63 | MODULE_DESCRIPTION(DRIVER_DESC); |
---|
64 | 64 | MODULE_LICENSE("GPL"); |
---|
65 | 65 | |
---|
66 | | -/* Module parameters */ |
---|
67 | | -static DEFINE_MUTEX(iowarrior_mutex); |
---|
68 | | - |
---|
69 | 66 | static struct usb_driver iowarrior_driver; |
---|
70 | | -static DEFINE_MUTEX(iowarrior_open_disc_lock); |
---|
71 | 67 | |
---|
72 | 68 | /*--------------*/ |
---|
73 | 69 | /* data */ |
---|
.. | .. |
---|
245 | 241 | wake_up_interruptible(&dev->write_wait); |
---|
246 | 242 | } |
---|
247 | 243 | |
---|
248 | | -/** |
---|
| 244 | +/* |
---|
249 | 245 | * iowarrior_delete |
---|
250 | 246 | */ |
---|
251 | 247 | static inline void iowarrior_delete(struct iowarrior *dev) |
---|
.. | .. |
---|
272 | 268 | return (read_idx == intr_idx ? -1 : read_idx); |
---|
273 | 269 | } |
---|
274 | 270 | |
---|
275 | | -/** |
---|
| 271 | +/* |
---|
276 | 272 | * iowarrior_read |
---|
277 | 273 | */ |
---|
278 | 274 | static ssize_t iowarrior_read(struct file *file, char __user *buffer, |
---|
.. | .. |
---|
476 | 472 | return retval; |
---|
477 | 473 | } |
---|
478 | 474 | |
---|
479 | | -/** |
---|
| 475 | +/* |
---|
480 | 476 | * iowarrior_ioctl |
---|
481 | 477 | */ |
---|
482 | 478 | static long iowarrior_ioctl(struct file *file, unsigned int cmd, |
---|
.. | .. |
---|
496 | 492 | if (!buffer) |
---|
497 | 493 | return -ENOMEM; |
---|
498 | 494 | |
---|
499 | | - /* lock this object */ |
---|
500 | | - mutex_lock(&iowarrior_mutex); |
---|
501 | 495 | mutex_lock(&dev->mutex); |
---|
502 | 496 | |
---|
503 | 497 | /* verify that the device wasn't unplugged */ |
---|
.. | .. |
---|
591 | 585 | error_out: |
---|
592 | 586 | /* unlock the device */ |
---|
593 | 587 | mutex_unlock(&dev->mutex); |
---|
594 | | - mutex_unlock(&iowarrior_mutex); |
---|
595 | 588 | kfree(buffer); |
---|
596 | 589 | return retval; |
---|
597 | 590 | } |
---|
598 | 591 | |
---|
599 | | -/** |
---|
| 592 | +/* |
---|
600 | 593 | * iowarrior_open |
---|
601 | 594 | */ |
---|
602 | 595 | static int iowarrior_open(struct inode *inode, struct file *file) |
---|
.. | .. |
---|
606 | 599 | int subminor; |
---|
607 | 600 | int retval = 0; |
---|
608 | 601 | |
---|
609 | | - mutex_lock(&iowarrior_mutex); |
---|
610 | 602 | subminor = iminor(inode); |
---|
611 | 603 | |
---|
612 | 604 | interface = usb_find_interface(&iowarrior_driver, subminor); |
---|
613 | 605 | if (!interface) { |
---|
614 | | - mutex_unlock(&iowarrior_mutex); |
---|
615 | | - printk(KERN_ERR "%s - error, can't find device for minor %d\n", |
---|
| 606 | + pr_err("%s - error, can't find device for minor %d\n", |
---|
616 | 607 | __func__, subminor); |
---|
617 | 608 | return -ENODEV; |
---|
618 | 609 | } |
---|
619 | 610 | |
---|
620 | | - mutex_lock(&iowarrior_open_disc_lock); |
---|
621 | 611 | dev = usb_get_intfdata(interface); |
---|
622 | | - if (!dev) { |
---|
623 | | - mutex_unlock(&iowarrior_open_disc_lock); |
---|
624 | | - mutex_unlock(&iowarrior_mutex); |
---|
| 612 | + if (!dev) |
---|
625 | 613 | return -ENODEV; |
---|
626 | | - } |
---|
627 | 614 | |
---|
628 | 615 | mutex_lock(&dev->mutex); |
---|
629 | | - mutex_unlock(&iowarrior_open_disc_lock); |
---|
630 | 616 | |
---|
631 | 617 | /* Only one process can open each device, no sharing. */ |
---|
632 | 618 | if (dev->opened) { |
---|
.. | .. |
---|
648 | 634 | |
---|
649 | 635 | out: |
---|
650 | 636 | mutex_unlock(&dev->mutex); |
---|
651 | | - mutex_unlock(&iowarrior_mutex); |
---|
652 | 637 | return retval; |
---|
653 | 638 | } |
---|
654 | 639 | |
---|
655 | | -/** |
---|
| 640 | +/* |
---|
656 | 641 | * iowarrior_release |
---|
657 | 642 | */ |
---|
658 | 643 | static int iowarrior_release(struct inode *inode, struct file *file) |
---|
.. | .. |
---|
754 | 739 | /*---------------------------------*/ |
---|
755 | 740 | /* probe and disconnect functions */ |
---|
756 | 741 | /*---------------------------------*/ |
---|
757 | | -/** |
---|
| 742 | +/* |
---|
758 | 743 | * iowarrior_probe |
---|
759 | 744 | * |
---|
760 | 745 | * Called by the usb core when a new device is connected that it thinks |
---|
.. | .. |
---|
832 | 817 | break; |
---|
833 | 818 | |
---|
834 | 819 | case USB_DEVICE_ID_CODEMERCS_IOW100: |
---|
835 | | - dev->report_size = 13; |
---|
| 820 | + dev->report_size = 12; |
---|
836 | 821 | break; |
---|
837 | 822 | } |
---|
838 | 823 | } |
---|
.. | .. |
---|
852 | 837 | dev->int_in_endpoint->bInterval); |
---|
853 | 838 | /* create an internal buffer for interrupt data from the device */ |
---|
854 | 839 | dev->read_queue = |
---|
855 | | - kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER), |
---|
856 | | - GFP_KERNEL); |
---|
| 840 | + kmalloc_array(dev->report_size + 1, MAX_INTERRUPT_BUFFER, |
---|
| 841 | + GFP_KERNEL); |
---|
857 | 842 | if (!dev->read_queue) |
---|
858 | 843 | goto error; |
---|
859 | 844 | /* Get the serial-number of the chip */ |
---|
.. | .. |
---|
880 | 865 | if (retval) { |
---|
881 | 866 | /* something prevented us from registering this driver */ |
---|
882 | 867 | dev_err(&interface->dev, "Not able to get a minor for this device.\n"); |
---|
883 | | - usb_set_intfdata(interface, NULL); |
---|
884 | 868 | goto error; |
---|
885 | 869 | } |
---|
886 | 870 | |
---|
.. | .. |
---|
897 | 881 | return retval; |
---|
898 | 882 | } |
---|
899 | 883 | |
---|
900 | | -/** |
---|
| 884 | +/* |
---|
901 | 885 | * iowarrior_disconnect |
---|
902 | 886 | * |
---|
903 | 887 | * Called by the usb core when the device is removed from the system. |
---|
904 | 888 | */ |
---|
905 | 889 | static void iowarrior_disconnect(struct usb_interface *interface) |
---|
906 | 890 | { |
---|
907 | | - struct iowarrior *dev; |
---|
908 | | - int minor; |
---|
909 | | - |
---|
910 | | - dev = usb_get_intfdata(interface); |
---|
911 | | - mutex_lock(&iowarrior_open_disc_lock); |
---|
912 | | - usb_set_intfdata(interface, NULL); |
---|
913 | | - |
---|
914 | | - minor = dev->minor; |
---|
915 | | - mutex_unlock(&iowarrior_open_disc_lock); |
---|
916 | | - /* give back our minor - this will call close() locks need to be dropped at this point*/ |
---|
| 891 | + struct iowarrior *dev = usb_get_intfdata(interface); |
---|
| 892 | + int minor = dev->minor; |
---|
917 | 893 | |
---|
918 | 894 | usb_deregister_dev(interface, &iowarrior_class); |
---|
919 | 895 | |
---|