forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/usb/misc/iowarrior.c
....@@ -10,7 +10,7 @@
1010
1111 * usb-skeleton.c by Greg Kroah-Hartman <greg@kroah.com>
1212 * 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>
1414 *
1515 * Released under the GPLv2.
1616 */
....@@ -63,11 +63,7 @@
6363 MODULE_DESCRIPTION(DRIVER_DESC);
6464 MODULE_LICENSE("GPL");
6565
66
-/* Module parameters */
67
-static DEFINE_MUTEX(iowarrior_mutex);
68
-
6966 static struct usb_driver iowarrior_driver;
70
-static DEFINE_MUTEX(iowarrior_open_disc_lock);
7167
7268 /*--------------*/
7369 /* data */
....@@ -245,7 +241,7 @@
245241 wake_up_interruptible(&dev->write_wait);
246242 }
247243
248
-/**
244
+/*
249245 * iowarrior_delete
250246 */
251247 static inline void iowarrior_delete(struct iowarrior *dev)
....@@ -272,7 +268,7 @@
272268 return (read_idx == intr_idx ? -1 : read_idx);
273269 }
274270
275
-/**
271
+/*
276272 * iowarrior_read
277273 */
278274 static ssize_t iowarrior_read(struct file *file, char __user *buffer,
....@@ -476,7 +472,7 @@
476472 return retval;
477473 }
478474
479
-/**
475
+/*
480476 * iowarrior_ioctl
481477 */
482478 static long iowarrior_ioctl(struct file *file, unsigned int cmd,
....@@ -496,8 +492,6 @@
496492 if (!buffer)
497493 return -ENOMEM;
498494
499
- /* lock this object */
500
- mutex_lock(&iowarrior_mutex);
501495 mutex_lock(&dev->mutex);
502496
503497 /* verify that the device wasn't unplugged */
....@@ -591,12 +585,11 @@
591585 error_out:
592586 /* unlock the device */
593587 mutex_unlock(&dev->mutex);
594
- mutex_unlock(&iowarrior_mutex);
595588 kfree(buffer);
596589 return retval;
597590 }
598591
599
-/**
592
+/*
600593 * iowarrior_open
601594 */
602595 static int iowarrior_open(struct inode *inode, struct file *file)
....@@ -606,27 +599,20 @@
606599 int subminor;
607600 int retval = 0;
608601
609
- mutex_lock(&iowarrior_mutex);
610602 subminor = iminor(inode);
611603
612604 interface = usb_find_interface(&iowarrior_driver, subminor);
613605 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",
616607 __func__, subminor);
617608 return -ENODEV;
618609 }
619610
620
- mutex_lock(&iowarrior_open_disc_lock);
621611 dev = usb_get_intfdata(interface);
622
- if (!dev) {
623
- mutex_unlock(&iowarrior_open_disc_lock);
624
- mutex_unlock(&iowarrior_mutex);
612
+ if (!dev)
625613 return -ENODEV;
626
- }
627614
628615 mutex_lock(&dev->mutex);
629
- mutex_unlock(&iowarrior_open_disc_lock);
630616
631617 /* Only one process can open each device, no sharing. */
632618 if (dev->opened) {
....@@ -648,11 +634,10 @@
648634
649635 out:
650636 mutex_unlock(&dev->mutex);
651
- mutex_unlock(&iowarrior_mutex);
652637 return retval;
653638 }
654639
655
-/**
640
+/*
656641 * iowarrior_release
657642 */
658643 static int iowarrior_release(struct inode *inode, struct file *file)
....@@ -754,7 +739,7 @@
754739 /*---------------------------------*/
755740 /* probe and disconnect functions */
756741 /*---------------------------------*/
757
-/**
742
+/*
758743 * iowarrior_probe
759744 *
760745 * Called by the usb core when a new device is connected that it thinks
....@@ -832,7 +817,7 @@
832817 break;
833818
834819 case USB_DEVICE_ID_CODEMERCS_IOW100:
835
- dev->report_size = 13;
820
+ dev->report_size = 12;
836821 break;
837822 }
838823 }
....@@ -852,8 +837,8 @@
852837 dev->int_in_endpoint->bInterval);
853838 /* create an internal buffer for interrupt data from the device */
854839 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);
857842 if (!dev->read_queue)
858843 goto error;
859844 /* Get the serial-number of the chip */
....@@ -880,7 +865,6 @@
880865 if (retval) {
881866 /* something prevented us from registering this driver */
882867 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
883
- usb_set_intfdata(interface, NULL);
884868 goto error;
885869 }
886870
....@@ -897,23 +881,15 @@
897881 return retval;
898882 }
899883
900
-/**
884
+/*
901885 * iowarrior_disconnect
902886 *
903887 * Called by the usb core when the device is removed from the system.
904888 */
905889 static void iowarrior_disconnect(struct usb_interface *interface)
906890 {
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;
917893
918894 usb_deregister_dev(interface, &iowarrior_class);
919895