diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 15:21:04 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 15:21:04 -0500 |
commit | 988addf82e4c03739375279de73929580a2d4a6a (patch) | |
tree | 989ae1cd4e264bbad80c65f04480486246e7b9f3 /drivers/usb/misc | |
parent | 004c1c7096659d352b83047a7593e91d8a30e3c5 (diff) | |
parent | 25cf84cf377c0aae5dbcf937ea89bc7893db5176 (diff) |
Merge branch 'origin' into devel-stable
Conflicts:
arch/arm/mach-mx2/devices.c
arch/arm/mach-mx2/devices.h
sound/soc/pxa/pxa-ssp.c
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/Kconfig | 25 | ||||
-rw-r--r-- | drivers/usb/misc/Makefile | 2 | ||||
-rw-r--r-- | drivers/usb/misc/adutux.c | 8 | ||||
-rw-r--r-- | drivers/usb/misc/appledisplay.c | 5 | ||||
-rw-r--r-- | drivers/usb/misc/berry_charge.c | 183 | ||||
-rw-r--r-- | drivers/usb/misc/cypress_cy7c63.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/cytherm.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/emi26.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/emi62.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 11 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/iowarrior.c | 6 | ||||
-rw-r--r-- | drivers/usb/misc/isight_firmware.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/ldusb.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 13 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 11 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/sisusb.c | 20 | ||||
-rw-r--r-- | drivers/usb/misc/trancevibrator.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/usblcd.c | 7 | ||||
-rw-r--r-- | drivers/usb/misc/usbled.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/usbsevseg.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 6 | ||||
-rw-r--r-- | drivers/usb/misc/uss720.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/vstusb.c | 783 |
24 files changed, 71 insertions, 1035 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index abe3aa67ed00..55660eaf947c 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -87,17 +87,6 @@ config USB_LCD | |||
87 | To compile this driver as a module, choose M here: the | 87 | To compile this driver as a module, choose M here: the |
88 | module will be called usblcd. | 88 | module will be called usblcd. |
89 | 89 | ||
90 | config USB_BERRY_CHARGE | ||
91 | tristate "USB BlackBerry recharge support" | ||
92 | depends on USB | ||
93 | help | ||
94 | Say Y here if you want to connect a BlackBerry device to your | ||
95 | computer's USB port and have it automatically switch to "recharge" | ||
96 | mode. | ||
97 | |||
98 | To compile this driver as a module, choose M here: the | ||
99 | module will be called berry_charge. | ||
100 | |||
101 | config USB_LED | 90 | config USB_LED |
102 | tristate "USB LED driver support" | 91 | tristate "USB LED driver support" |
103 | depends on USB | 92 | depends on USB |
@@ -242,17 +231,3 @@ config USB_ISIGHTFW | |||
242 | driver beforehand. Tools for doing so are available at | 231 | driver beforehand. Tools for doing so are available at |
243 | http://bersace03.free.fr | 232 | http://bersace03.free.fr |
244 | 233 | ||
245 | config USB_VST | ||
246 | tristate "USB VST driver" | ||
247 | depends on USB | ||
248 | help | ||
249 | This driver is intended for Vernier Software Technologies | ||
250 | bulk usb devices such as their Ocean-Optics spectrometers or | ||
251 | Labquest. | ||
252 | It is a bulk channel driver with configurable read and write | ||
253 | timeouts. | ||
254 | |||
255 | To compile this driver as a module, choose M here: the | ||
256 | module will be called vstusb. | ||
257 | |||
258 | |||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 0826aab8303f..717703e81425 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -5,7 +5,6 @@ | |||
5 | 5 | ||
6 | obj-$(CONFIG_USB_ADUTUX) += adutux.o | 6 | obj-$(CONFIG_USB_ADUTUX) += adutux.o |
7 | obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o | 7 | obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o |
8 | obj-$(CONFIG_USB_BERRY_CHARGE) += berry_charge.o | ||
9 | obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o | 8 | obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o |
10 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o | 9 | obj-$(CONFIG_USB_CYTHERM) += cytherm.o |
11 | obj-$(CONFIG_USB_EMI26) += emi26.o | 10 | obj-$(CONFIG_USB_EMI26) += emi26.o |
@@ -23,7 +22,6 @@ obj-$(CONFIG_USB_TEST) += usbtest.o | |||
23 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | 22 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
24 | obj-$(CONFIG_USB_USS720) += uss720.o | 23 | obj-$(CONFIG_USB_USS720) += uss720.o |
25 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | 24 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o |
26 | obj-$(CONFIG_USB_VST) += vstusb.o | ||
27 | 25 | ||
28 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 26 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
29 | 27 | ||
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 203526542013..d240de097c62 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -38,7 +38,7 @@ static int debug = 1; | |||
38 | #define dbg(lvl, format, arg...) \ | 38 | #define dbg(lvl, format, arg...) \ |
39 | do { \ | 39 | do { \ |
40 | if (debug >= lvl) \ | 40 | if (debug >= lvl) \ |
41 | printk(KERN_DEBUG __FILE__ " : " format " \n", ## arg); \ | 41 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ |
42 | } while (0) | 42 | } while (0) |
43 | 43 | ||
44 | 44 | ||
@@ -56,7 +56,7 @@ MODULE_PARM_DESC(debug, "Debug enabled or not"); | |||
56 | #define ADU_PRODUCT_ID 0x0064 | 56 | #define ADU_PRODUCT_ID 0x0064 |
57 | 57 | ||
58 | /* table of devices that work with this driver */ | 58 | /* table of devices that work with this driver */ |
59 | static struct usb_device_id device_table [] = { | 59 | static const struct usb_device_id device_table[] = { |
60 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */ | 60 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */ |
61 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */ | 61 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */ |
62 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */ | 62 | { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */ |
@@ -132,8 +132,8 @@ static void adu_debug_data(int level, const char *function, int size, | |||
132 | if (debug < level) | 132 | if (debug < level) |
133 | return; | 133 | return; |
134 | 134 | ||
135 | printk(KERN_DEBUG __FILE__": %s - length = %d, data = ", | 135 | printk(KERN_DEBUG "%s: %s - length = %d, data = ", |
136 | function, size); | 136 | __FILE__, function, size); |
137 | for (i = 0; i < size; ++i) | 137 | for (i = 0; i < size; ++i) |
138 | printk("%.2x ", data[i]); | 138 | printk("%.2x ", data[i]); |
139 | printk("\n"); | 139 | printk("\n"); |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 1eb9e4162cc6..4d2952f1fb13 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -57,7 +57,7 @@ | |||
57 | .bInterfaceProtocol = 0x00 | 57 | .bInterfaceProtocol = 0x00 |
58 | 58 | ||
59 | /* table of devices that work with this driver */ | 59 | /* table of devices that work with this driver */ |
60 | static struct usb_device_id appledisplay_table [] = { | 60 | static const struct usb_device_id appledisplay_table[] = { |
61 | { APPLEDISPLAY_DEVICE(0x9218) }, | 61 | { APPLEDISPLAY_DEVICE(0x9218) }, |
62 | { APPLEDISPLAY_DEVICE(0x9219) }, | 62 | { APPLEDISPLAY_DEVICE(0x9219) }, |
63 | { APPLEDISPLAY_DEVICE(0x921c) }, | 63 | { APPLEDISPLAY_DEVICE(0x921c) }, |
@@ -179,7 +179,7 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd) | |||
179 | return pdata->msgdata[1]; | 179 | return pdata->msgdata[1]; |
180 | } | 180 | } |
181 | 181 | ||
182 | static struct backlight_ops appledisplay_bl_data = { | 182 | static const struct backlight_ops appledisplay_bl_data = { |
183 | .get_brightness = appledisplay_bl_get_brightness, | 183 | .get_brightness = appledisplay_bl_get_brightness, |
184 | .update_status = appledisplay_bl_update_status, | 184 | .update_status = appledisplay_bl_update_status, |
185 | }; | 185 | }; |
@@ -283,6 +283,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
283 | &appledisplay_bl_data); | 283 | &appledisplay_bl_data); |
284 | if (IS_ERR(pdata->bd)) { | 284 | if (IS_ERR(pdata->bd)) { |
285 | dev_err(&iface->dev, "Backlight registration failed\n"); | 285 | dev_err(&iface->dev, "Backlight registration failed\n"); |
286 | retval = PTR_ERR(pdata->bd); | ||
286 | goto error; | 287 | goto error; |
287 | } | 288 | } |
288 | 289 | ||
diff --git a/drivers/usb/misc/berry_charge.c b/drivers/usb/misc/berry_charge.c deleted file mode 100644 index c05a85bc5925..000000000000 --- a/drivers/usb/misc/berry_charge.c +++ /dev/null | |||
@@ -1,183 +0,0 @@ | |||
1 | /* | ||
2 | * USB BlackBerry charging module | ||
3 | * | ||
4 | * Copyright (C) 2007 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation, version 2. | ||
9 | * | ||
10 | * Information on how to switch configs was taken by the bcharge.cc file | ||
11 | * created by the barry.sf.net project. | ||
12 | * | ||
13 | * bcharge.cc has the following copyright: | ||
14 | * Copyright (C) 2006, Net Direct Inc. (http://www.netdirect.ca/) | ||
15 | * and is released under the GPLv2. | ||
16 | * | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/usb.h> | ||
26 | |||
27 | #define RIM_VENDOR 0x0fca | ||
28 | #define BLACKBERRY 0x0001 | ||
29 | #define BLACKBERRY_PEARL_DUAL 0x0004 | ||
30 | #define BLACKBERRY_PEARL 0x0006 | ||
31 | |||
32 | static int debug; | ||
33 | static int pearl_dual_mode = 1; | ||
34 | |||
35 | #ifdef dbg | ||
36 | #undef dbg | ||
37 | #endif | ||
38 | #define dbg(dev, format, arg...) \ | ||
39 | if (debug) \ | ||
40 | dev_printk(KERN_DEBUG , dev , format , ## arg) | ||
41 | |||
42 | static struct usb_device_id id_table [] = { | ||
43 | { USB_DEVICE(RIM_VENDOR, BLACKBERRY) }, | ||
44 | { USB_DEVICE(RIM_VENDOR, BLACKBERRY_PEARL) }, | ||
45 | { USB_DEVICE(RIM_VENDOR, BLACKBERRY_PEARL_DUAL) }, | ||
46 | { }, /* Terminating entry */ | ||
47 | }; | ||
48 | MODULE_DEVICE_TABLE(usb, id_table); | ||
49 | |||
50 | static int magic_charge(struct usb_device *udev) | ||
51 | { | ||
52 | char *dummy_buffer = kzalloc(2, GFP_KERNEL); | ||
53 | int retval; | ||
54 | |||
55 | if (!dummy_buffer) | ||
56 | return -ENOMEM; | ||
57 | |||
58 | /* send two magic commands and then set the configuration. The device | ||
59 | * will then reset itself with the new power usage and should start | ||
60 | * charging. */ | ||
61 | |||
62 | /* Note, with testing, it only seems that the first message is really | ||
63 | * needed (at least for the 8700c), but to be safe, we emulate what | ||
64 | * other operating systems seem to be sending to their device. We | ||
65 | * really need to get some specs for this device to be sure about what | ||
66 | * is going on here. | ||
67 | */ | ||
68 | dbg(&udev->dev, "Sending first magic command\n"); | ||
69 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
70 | 0xa5, 0xc0, 0, 1, dummy_buffer, 2, 100); | ||
71 | if (retval != 2) { | ||
72 | dev_err(&udev->dev, "First magic command failed: %d.\n", | ||
73 | retval); | ||
74 | goto exit; | ||
75 | } | ||
76 | |||
77 | dbg(&udev->dev, "Sending second magic command\n"); | ||
78 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
79 | 0xa2, 0x40, 0, 1, dummy_buffer, 0, 100); | ||
80 | if (retval != 0) { | ||
81 | dev_err(&udev->dev, "Second magic command failed: %d.\n", | ||
82 | retval); | ||
83 | goto exit; | ||
84 | } | ||
85 | |||
86 | dbg(&udev->dev, "Calling set_configuration\n"); | ||
87 | retval = usb_driver_set_configuration(udev, 1); | ||
88 | if (retval) | ||
89 | dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval); | ||
90 | |||
91 | exit: | ||
92 | kfree(dummy_buffer); | ||
93 | return retval; | ||
94 | } | ||
95 | |||
96 | static int magic_dual_mode(struct usb_device *udev) | ||
97 | { | ||
98 | char *dummy_buffer = kzalloc(2, GFP_KERNEL); | ||
99 | int retval; | ||
100 | |||
101 | if (!dummy_buffer) | ||
102 | return -ENOMEM; | ||
103 | |||
104 | /* send magic command so that the Blackberry Pearl device exposes | ||
105 | * two interfaces: both the USB mass-storage one and one which can | ||
106 | * be used for database access. */ | ||
107 | dbg(&udev->dev, "Sending magic pearl command\n"); | ||
108 | retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
109 | 0xa9, 0xc0, 1, 1, dummy_buffer, 2, 100); | ||
110 | dbg(&udev->dev, "Magic pearl command returned %d\n", retval); | ||
111 | |||
112 | dbg(&udev->dev, "Calling set_configuration\n"); | ||
113 | retval = usb_driver_set_configuration(udev, 1); | ||
114 | if (retval) | ||
115 | dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval); | ||
116 | |||
117 | kfree(dummy_buffer); | ||
118 | return retval; | ||
119 | } | ||
120 | |||
121 | static int berry_probe(struct usb_interface *intf, | ||
122 | const struct usb_device_id *id) | ||
123 | { | ||
124 | struct usb_device *udev = interface_to_usbdev(intf); | ||
125 | |||
126 | if (udev->bus_mA < 500) { | ||
127 | dbg(&udev->dev, "Not enough power to charge available\n"); | ||
128 | return -ENODEV; | ||
129 | } | ||
130 | |||
131 | dbg(&udev->dev, "Power is set to %dmA\n", | ||
132 | udev->actconfig->desc.bMaxPower * 2); | ||
133 | |||
134 | /* check the power usage so we don't try to enable something that is | ||
135 | * already enabled */ | ||
136 | if ((udev->actconfig->desc.bMaxPower * 2) == 500) { | ||
137 | dbg(&udev->dev, "device is already charging, power is " | ||
138 | "set to %dmA\n", udev->actconfig->desc.bMaxPower * 2); | ||
139 | return -ENODEV; | ||
140 | } | ||
141 | |||
142 | /* turn the power on */ | ||
143 | magic_charge(udev); | ||
144 | |||
145 | if ((le16_to_cpu(udev->descriptor.idProduct) == BLACKBERRY_PEARL) && | ||
146 | (pearl_dual_mode)) | ||
147 | magic_dual_mode(udev); | ||
148 | |||
149 | /* we don't really want to bind to the device, userspace programs can | ||
150 | * handle the syncing just fine, so get outta here. */ | ||
151 | return -ENODEV; | ||
152 | } | ||
153 | |||
154 | static void berry_disconnect(struct usb_interface *intf) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | static struct usb_driver berry_driver = { | ||
159 | .name = "berry_charge", | ||
160 | .probe = berry_probe, | ||
161 | .disconnect = berry_disconnect, | ||
162 | .id_table = id_table, | ||
163 | }; | ||
164 | |||
165 | static int __init berry_init(void) | ||
166 | { | ||
167 | return usb_register(&berry_driver); | ||
168 | } | ||
169 | |||
170 | static void __exit berry_exit(void) | ||
171 | { | ||
172 | usb_deregister(&berry_driver); | ||
173 | } | ||
174 | |||
175 | module_init(berry_init); | ||
176 | module_exit(berry_exit); | ||
177 | |||
178 | MODULE_LICENSE("GPL"); | ||
179 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>"); | ||
180 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
181 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
182 | module_param(pearl_dual_mode, bool, S_IRUGO | S_IWUSR); | ||
183 | MODULE_PARM_DESC(pearl_dual_mode, "Change Blackberry Pearl to run in dual mode"); | ||
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 5720bfef6a38..1547d8cac5fb 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -56,7 +56,7 @@ | |||
56 | 56 | ||
57 | 57 | ||
58 | /* table of devices that work with this driver */ | 58 | /* table of devices that work with this driver */ |
59 | static struct usb_device_id cypress_table [] = { | 59 | static const struct usb_device_id cypress_table[] = { |
60 | { USB_DEVICE(CYPRESS_VENDOR_ID, CYPRESS_PRODUCT_ID) }, | 60 | { USB_DEVICE(CYPRESS_VENDOR_ID, CYPRESS_PRODUCT_ID) }, |
61 | { } | 61 | { } |
62 | }; | 62 | }; |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 4fb3c38b924b..b9cbbbda8245 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #define USB_SKEL_VENDOR_ID 0x04b4 | 27 | #define USB_SKEL_VENDOR_ID 0x04b4 |
28 | #define USB_SKEL_PRODUCT_ID 0x0002 | 28 | #define USB_SKEL_PRODUCT_ID 0x0002 |
29 | 29 | ||
30 | static struct usb_device_id id_table [] = { | 30 | static const struct usb_device_id id_table[] = { |
31 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, | 31 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, |
32 | { } | 32 | { } |
33 | }; | 33 | }; |
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 879a980ca8c4..a6521c95f683 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -245,7 +245,7 @@ wraperr: | |||
245 | return err; | 245 | return err; |
246 | } | 246 | } |
247 | 247 | ||
248 | static struct usb_device_id id_table [] = { | 248 | static const struct usb_device_id id_table[] = { |
249 | { USB_DEVICE(EMI26_VENDOR_ID, EMI26_PRODUCT_ID) }, | 249 | { USB_DEVICE(EMI26_VENDOR_ID, EMI26_PRODUCT_ID) }, |
250 | { USB_DEVICE(EMI26_VENDOR_ID, EMI26B_PRODUCT_ID) }, | 250 | { USB_DEVICE(EMI26_VENDOR_ID, EMI26B_PRODUCT_ID) }, |
251 | { } /* Terminating entry */ | 251 | { } /* Terminating entry */ |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 59860b328534..fc15ad4c3139 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -259,7 +259,7 @@ wraperr: | |||
259 | return err; | 259 | return err; |
260 | } | 260 | } |
261 | 261 | ||
262 | static __devinitdata struct usb_device_id id_table [] = { | 262 | static const struct usb_device_id id_table[] __devinitconst = { |
263 | { USB_DEVICE(EMI62_VENDOR_ID, EMI62_PRODUCT_ID) }, | 263 | { USB_DEVICE(EMI62_VENDOR_ID, EMI62_PRODUCT_ID) }, |
264 | { } /* Terminating entry */ | 264 | { } /* Terminating entry */ |
265 | }; | 265 | }; |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 9d0675ed0d4c..1edb6d361896 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -86,7 +86,7 @@ static struct list_head ftdi_static_list; | |||
86 | #define USB_FTDI_ELAN_VENDOR_ID 0x0403 | 86 | #define USB_FTDI_ELAN_VENDOR_ID 0x0403 |
87 | #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea | 87 | #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea |
88 | /* table of devices that work with this driver*/ | 88 | /* table of devices that work with this driver*/ |
89 | static struct usb_device_id ftdi_elan_table[] = { | 89 | static const struct usb_device_id ftdi_elan_table[] = { |
90 | {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)}, | 90 | {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)}, |
91 | { /* Terminating entry */ } | 91 | { /* Terminating entry */ } |
92 | }; | 92 | }; |
@@ -623,9 +623,12 @@ static void ftdi_elan_status_work(struct work_struct *work) | |||
623 | */ | 623 | */ |
624 | static int ftdi_elan_open(struct inode *inode, struct file *file) | 624 | static int ftdi_elan_open(struct inode *inode, struct file *file) |
625 | { | 625 | { |
626 | int subminor = iminor(inode); | 626 | int subminor; |
627 | struct usb_interface *interface = usb_find_interface(&ftdi_elan_driver, | 627 | struct usb_interface *interface; |
628 | subminor); | 628 | |
629 | subminor = iminor(inode); | ||
630 | interface = usb_find_interface(&ftdi_elan_driver, subminor); | ||
631 | |||
629 | if (!interface) { | 632 | if (!interface) { |
630 | printk(KERN_ERR "can't find device for minor %d\n", subminor); | 633 | printk(KERN_ERR "can't find device for minor %d\n", subminor); |
631 | return -ENODEV; | 634 | return -ENODEV; |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 1337a9ce80b9..a54c3cb804ce 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #define ID_CHERRY 0x0010 | 48 | #define ID_CHERRY 0x0010 |
49 | 49 | ||
50 | /* device ID table */ | 50 | /* device ID table */ |
51 | static struct usb_device_id idmouse_table[] = { | 51 | static const struct usb_device_id idmouse_table[] = { |
52 | {USB_DEVICE(ID_SIEMENS, ID_IDMOUSE)}, /* Siemens ID Mouse (Professional) */ | 52 | {USB_DEVICE(ID_SIEMENS, ID_IDMOUSE)}, /* Siemens ID Mouse (Professional) */ |
53 | {USB_DEVICE(ID_SIEMENS, ID_CHERRY )}, /* Cherry FingerTIP ID Board */ | 53 | {USB_DEVICE(ID_SIEMENS, ID_CHERRY )}, /* Cherry FingerTIP ID Board */ |
54 | {} /* terminating null entry */ | 54 | {} /* terminating null entry */ |
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index e75bb87ee92b..d3c852363883 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c | |||
@@ -139,7 +139,7 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type, | |||
139 | /* driver registration */ | 139 | /* driver registration */ |
140 | /*---------------------*/ | 140 | /*---------------------*/ |
141 | /* table of devices that work with this driver */ | 141 | /* table of devices that work with this driver */ |
142 | static struct usb_device_id iowarrior_ids[] = { | 142 | static const struct usb_device_id iowarrior_ids[] = { |
143 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40)}, | 143 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40)}, |
144 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24)}, | 144 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24)}, |
145 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOWPV1)}, | 145 | {USB_DEVICE(USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOWPV1)}, |
@@ -602,10 +602,12 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
602 | 602 | ||
603 | dbg("%s", __func__); | 603 | dbg("%s", __func__); |
604 | 604 | ||
605 | lock_kernel(); | ||
605 | subminor = iminor(inode); | 606 | subminor = iminor(inode); |
606 | 607 | ||
607 | interface = usb_find_interface(&iowarrior_driver, subminor); | 608 | interface = usb_find_interface(&iowarrior_driver, subminor); |
608 | if (!interface) { | 609 | if (!interface) { |
610 | unlock_kernel(); | ||
609 | err("%s - error, can't find device for minor %d", __func__, | 611 | err("%s - error, can't find device for minor %d", __func__, |
610 | subminor); | 612 | subminor); |
611 | return -ENODEV; | 613 | return -ENODEV; |
@@ -615,6 +617,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
615 | dev = usb_get_intfdata(interface); | 617 | dev = usb_get_intfdata(interface); |
616 | if (!dev) { | 618 | if (!dev) { |
617 | mutex_unlock(&iowarrior_open_disc_lock); | 619 | mutex_unlock(&iowarrior_open_disc_lock); |
620 | unlock_kernel(); | ||
618 | return -ENODEV; | 621 | return -ENODEV; |
619 | } | 622 | } |
620 | 623 | ||
@@ -641,6 +644,7 @@ static int iowarrior_open(struct inode *inode, struct file *file) | |||
641 | 644 | ||
642 | out: | 645 | out: |
643 | mutex_unlock(&dev->mutex); | 646 | mutex_unlock(&dev->mutex); |
647 | unlock_kernel(); | ||
644 | return retval; | 648 | return retval; |
645 | } | 649 | } |
646 | 650 | ||
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c index b897f6554ecd..06e990adc6cd 100644 --- a/drivers/usb/misc/isight_firmware.c +++ b/drivers/usb/misc/isight_firmware.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | 28 | ||
29 | static struct usb_device_id id_table[] = { | 29 | static const struct usb_device_id id_table[] = { |
30 | {USB_DEVICE(0x05ac, 0x8300)}, | 30 | {USB_DEVICE(0x05ac, 0x8300)}, |
31 | {}, | 31 | {}, |
32 | }; | 32 | }; |
@@ -112,6 +112,8 @@ out: | |||
112 | return ret; | 112 | return ret; |
113 | } | 113 | } |
114 | 114 | ||
115 | MODULE_FIRMWARE("isight.fw"); | ||
116 | |||
115 | static void isight_firmware_disconnect(struct usb_interface *intf) | 117 | static void isight_firmware_disconnect(struct usb_interface *intf) |
116 | { | 118 | { |
117 | } | 119 | } |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 90f130126c10..dd41d8710043 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -69,7 +69,7 @@ | |||
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | /* table of devices that work with this driver */ | 71 | /* table of devices that work with this driver */ |
72 | static struct usb_device_id ld_usb_table [] = { | 72 | static const struct usb_device_id ld_usb_table[] = { |
73 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, | 73 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
74 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, | 74 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
75 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, | 75 | { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, |
@@ -798,7 +798,7 @@ static int __init ld_usb_init(void) | |||
798 | /* register this driver with the USB subsystem */ | 798 | /* register this driver with the USB subsystem */ |
799 | retval = usb_register(&ld_usb_driver); | 799 | retval = usb_register(&ld_usb_driver); |
800 | if (retval) | 800 | if (retval) |
801 | err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval); | 801 | err("usb_register failed for the %s driver. Error number %d\n", __FILE__, retval); |
802 | 802 | ||
803 | return retval; | 803 | return retval; |
804 | } | 804 | } |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index faa6d623de78..8547bf9e3175 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -95,8 +95,11 @@ | |||
95 | 95 | ||
96 | /* Use our own dbg macro */ | 96 | /* Use our own dbg macro */ |
97 | #undef dbg | 97 | #undef dbg |
98 | #define dbg(lvl, format, arg...) do { if (debug >= lvl) printk(KERN_DEBUG __FILE__ ": " format "\n", ## arg); } while (0) | 98 | #define dbg(lvl, format, arg...) \ |
99 | 99 | do { \ | |
100 | if (debug >= lvl) \ | ||
101 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | ||
102 | } while (0) | ||
100 | 103 | ||
101 | /* Version Information */ | 104 | /* Version Information */ |
102 | #define DRIVER_VERSION "v0.96" | 105 | #define DRIVER_VERSION "v0.96" |
@@ -192,7 +195,7 @@ struct tower_get_version_reply { | |||
192 | 195 | ||
193 | 196 | ||
194 | /* table of devices that work with this driver */ | 197 | /* table of devices that work with this driver */ |
195 | static struct usb_device_id tower_table [] = { | 198 | static const struct usb_device_id tower_table[] = { |
196 | { USB_DEVICE(LEGO_USB_TOWER_VENDOR_ID, LEGO_USB_TOWER_PRODUCT_ID) }, | 199 | { USB_DEVICE(LEGO_USB_TOWER_VENDOR_ID, LEGO_USB_TOWER_PRODUCT_ID) }, |
197 | { } /* Terminating entry */ | 200 | { } /* Terminating entry */ |
198 | }; | 201 | }; |
@@ -302,7 +305,7 @@ static inline void lego_usb_tower_debug_data (int level, const char *function, i | |||
302 | if (debug < level) | 305 | if (debug < level) |
303 | return; | 306 | return; |
304 | 307 | ||
305 | printk (KERN_DEBUG __FILE__": %s - length = %d, data = ", function, size); | 308 | printk (KERN_DEBUG "%s: %s - length = %d, data = ", __FILE__, function, size); |
306 | for (i = 0; i < size; ++i) { | 309 | for (i = 0; i < size; ++i) { |
307 | printk ("%.2x ", data[i]); | 310 | printk ("%.2x ", data[i]); |
308 | } | 311 | } |
@@ -1055,7 +1058,7 @@ static int __init lego_usb_tower_init(void) | |||
1055 | /* register this driver with the USB subsystem */ | 1058 | /* register this driver with the USB subsystem */ |
1056 | result = usb_register(&tower_driver); | 1059 | result = usb_register(&tower_driver); |
1057 | if (result < 0) { | 1060 | if (result < 0) { |
1058 | err("usb_register failed for the "__FILE__" driver. Error number %d", result); | 1061 | err("usb_register failed for the %s driver. Error number %d", __FILE__, result); |
1059 | retval = -1; | 1062 | retval = -1; |
1060 | goto exit; | 1063 | goto exit; |
1061 | } | 1064 | } |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 32d0199d0c32..a85771b1563d 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -78,10 +78,13 @@ static int open_rio(struct inode *inode, struct file *file) | |||
78 | { | 78 | { |
79 | struct rio_usb_data *rio = &rio_instance; | 79 | struct rio_usb_data *rio = &rio_instance; |
80 | 80 | ||
81 | /* against disconnect() */ | ||
82 | lock_kernel(); | ||
81 | mutex_lock(&(rio->lock)); | 83 | mutex_lock(&(rio->lock)); |
82 | 84 | ||
83 | if (rio->isopen || !rio->present) { | 85 | if (rio->isopen || !rio->present) { |
84 | mutex_unlock(&(rio->lock)); | 86 | mutex_unlock(&(rio->lock)); |
87 | unlock_kernel(); | ||
85 | return -EBUSY; | 88 | return -EBUSY; |
86 | } | 89 | } |
87 | rio->isopen = 1; | 90 | rio->isopen = 1; |
@@ -91,6 +94,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
91 | mutex_unlock(&(rio->lock)); | 94 | mutex_unlock(&(rio->lock)); |
92 | 95 | ||
93 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); | 96 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
97 | unlock_kernel(); | ||
94 | 98 | ||
95 | return 0; | 99 | return 0; |
96 | } | 100 | } |
@@ -115,7 +119,6 @@ static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) | |||
115 | int retries; | 119 | int retries; |
116 | int retval=0; | 120 | int retval=0; |
117 | 121 | ||
118 | lock_kernel(); | ||
119 | mutex_lock(&(rio->lock)); | 122 | mutex_lock(&(rio->lock)); |
120 | /* Sanity check to make sure rio is connected, powered, etc */ | 123 | /* Sanity check to make sure rio is connected, powered, etc */ |
121 | if (rio->present == 0 || rio->rio_dev == NULL) { | 124 | if (rio->present == 0 || rio->rio_dev == NULL) { |
@@ -254,7 +257,6 @@ static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) | |||
254 | 257 | ||
255 | err_out: | 258 | err_out: |
256 | mutex_unlock(&(rio->lock)); | 259 | mutex_unlock(&(rio->lock)); |
257 | unlock_kernel(); | ||
258 | return retval; | 260 | return retval; |
259 | } | 261 | } |
260 | 262 | ||
@@ -489,6 +491,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
489 | struct rio_usb_data *rio = usb_get_intfdata (intf); | 491 | struct rio_usb_data *rio = usb_get_intfdata (intf); |
490 | 492 | ||
491 | usb_set_intfdata (intf, NULL); | 493 | usb_set_intfdata (intf, NULL); |
494 | lock_kernel(); | ||
492 | if (rio) { | 495 | if (rio) { |
493 | usb_deregister_dev(intf, &usb_rio_class); | 496 | usb_deregister_dev(intf, &usb_rio_class); |
494 | 497 | ||
@@ -498,6 +501,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
498 | /* better let it finish - the release will do whats needed */ | 501 | /* better let it finish - the release will do whats needed */ |
499 | rio->rio_dev = NULL; | 502 | rio->rio_dev = NULL; |
500 | mutex_unlock(&(rio->lock)); | 503 | mutex_unlock(&(rio->lock)); |
504 | unlock_kernel(); | ||
501 | return; | 505 | return; |
502 | } | 506 | } |
503 | kfree(rio->ibuf); | 507 | kfree(rio->ibuf); |
@@ -508,9 +512,10 @@ static void disconnect_rio(struct usb_interface *intf) | |||
508 | rio->present = 0; | 512 | rio->present = 0; |
509 | mutex_unlock(&(rio->lock)); | 513 | mutex_unlock(&(rio->lock)); |
510 | } | 514 | } |
515 | unlock_kernel(); | ||
511 | } | 516 | } |
512 | 517 | ||
513 | static struct usb_device_id rio_table [] = { | 518 | static const struct usb_device_id rio_table[] = { |
514 | { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ | 519 | { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ |
515 | { } /* Terminating entry */ | 520 | { } /* Terminating entry */ |
516 | }; | 521 | }; |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 8b37a4b9839e..aae95a009bd5 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -250,7 +250,7 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, | |||
250 | sisusb->urbstatus[index] |= SU_URB_BUSY; | 250 | sisusb->urbstatus[index] |= SU_URB_BUSY; |
251 | 251 | ||
252 | /* Submit URB */ | 252 | /* Submit URB */ |
253 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 253 | retval = usb_submit_urb(urb, GFP_KERNEL); |
254 | 254 | ||
255 | /* If OK, and if timeout > 0, wait for completion */ | 255 | /* If OK, and if timeout > 0, wait for completion */ |
256 | if ((retval == 0) && timeout) { | 256 | if ((retval == 0) && timeout) { |
@@ -306,7 +306,7 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, | |||
306 | urb->actual_length = 0; | 306 | urb->actual_length = 0; |
307 | 307 | ||
308 | sisusb->completein = 0; | 308 | sisusb->completein = 0; |
309 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 309 | retval = usb_submit_urb(urb, GFP_KERNEL); |
310 | if (retval == 0) { | 310 | if (retval == 0) { |
311 | wait_event_timeout(sisusb->wait_q, sisusb->completein, timeout); | 311 | wait_event_timeout(sisusb->wait_q, sisusb->completein, timeout); |
312 | if (!sisusb->completein) { | 312 | if (!sisusb->completein) { |
@@ -2416,21 +2416,28 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2416 | struct usb_interface *interface; | 2416 | struct usb_interface *interface; |
2417 | int subminor = iminor(inode); | 2417 | int subminor = iminor(inode); |
2418 | 2418 | ||
2419 | if (!(interface = usb_find_interface(&sisusb_driver, subminor))) | 2419 | lock_kernel(); |
2420 | if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { | ||
2421 | unlock_kernel(); | ||
2420 | return -ENODEV; | 2422 | return -ENODEV; |
2423 | } | ||
2421 | 2424 | ||
2422 | if (!(sisusb = usb_get_intfdata(interface))) | 2425 | if (!(sisusb = usb_get_intfdata(interface))) { |
2426 | unlock_kernel(); | ||
2423 | return -ENODEV; | 2427 | return -ENODEV; |
2428 | } | ||
2424 | 2429 | ||
2425 | mutex_lock(&sisusb->lock); | 2430 | mutex_lock(&sisusb->lock); |
2426 | 2431 | ||
2427 | if (!sisusb->present || !sisusb->ready) { | 2432 | if (!sisusb->present || !sisusb->ready) { |
2428 | mutex_unlock(&sisusb->lock); | 2433 | mutex_unlock(&sisusb->lock); |
2434 | unlock_kernel(); | ||
2429 | return -ENODEV; | 2435 | return -ENODEV; |
2430 | } | 2436 | } |
2431 | 2437 | ||
2432 | if (sisusb->isopen) { | 2438 | if (sisusb->isopen) { |
2433 | mutex_unlock(&sisusb->lock); | 2439 | mutex_unlock(&sisusb->lock); |
2440 | unlock_kernel(); | ||
2434 | return -EBUSY; | 2441 | return -EBUSY; |
2435 | } | 2442 | } |
2436 | 2443 | ||
@@ -2439,11 +2446,13 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2439 | if (sisusb_init_gfxdevice(sisusb, 0)) { | 2446 | if (sisusb_init_gfxdevice(sisusb, 0)) { |
2440 | mutex_unlock(&sisusb->lock); | 2447 | mutex_unlock(&sisusb->lock); |
2441 | dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); | 2448 | dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); |
2449 | unlock_kernel(); | ||
2442 | return -EIO; | 2450 | return -EIO; |
2443 | } | 2451 | } |
2444 | } else { | 2452 | } else { |
2445 | mutex_unlock(&sisusb->lock); | 2453 | mutex_unlock(&sisusb->lock); |
2446 | dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); | 2454 | dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n"); |
2455 | unlock_kernel(); | ||
2447 | return -EIO; | 2456 | return -EIO; |
2448 | } | 2457 | } |
2449 | } | 2458 | } |
@@ -2456,6 +2465,7 @@ sisusb_open(struct inode *inode, struct file *file) | |||
2456 | file->private_data = sisusb; | 2465 | file->private_data = sisusb; |
2457 | 2466 | ||
2458 | mutex_unlock(&sisusb->lock); | 2467 | mutex_unlock(&sisusb->lock); |
2468 | unlock_kernel(); | ||
2459 | 2469 | ||
2460 | return 0; | 2470 | return 0; |
2461 | } | 2471 | } |
@@ -3238,7 +3248,7 @@ static void sisusb_disconnect(struct usb_interface *intf) | |||
3238 | kref_put(&sisusb->kref, sisusb_delete); | 3248 | kref_put(&sisusb->kref, sisusb_delete); |
3239 | } | 3249 | } |
3240 | 3250 | ||
3241 | static struct usb_device_id sisusb_table [] = { | 3251 | static const struct usb_device_id sisusb_table[] = { |
3242 | { USB_DEVICE(0x0711, 0x0550) }, | 3252 | { USB_DEVICE(0x0711, 0x0550) }, |
3243 | { USB_DEVICE(0x0711, 0x0900) }, | 3253 | { USB_DEVICE(0x0711, 0x0900) }, |
3244 | { USB_DEVICE(0x0711, 0x0901) }, | 3254 | { USB_DEVICE(0x0711, 0x0901) }, |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 2e14102955c5..5da28eaee314 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */ | 33 | #define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */ |
34 | #define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */ | 34 | #define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */ |
35 | 35 | ||
36 | static struct usb_device_id id_table [] = { | 36 | static const struct usb_device_id id_table[] = { |
37 | { USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) }, | 37 | { USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) }, |
38 | { }, | 38 | { }, |
39 | }; | 39 | }; |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 4fb120357c55..90aede90553e 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #define IOCTL_GET_DRV_VERSION 2 | 30 | #define IOCTL_GET_DRV_VERSION 2 |
31 | 31 | ||
32 | 32 | ||
33 | static struct usb_device_id id_table [] = { | 33 | static const struct usb_device_id id_table[] = { |
34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, | 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, |
35 | { }, | 35 | { }, |
36 | }; | 36 | }; |
@@ -74,10 +74,12 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
74 | struct usb_interface *interface; | 74 | struct usb_interface *interface; |
75 | int subminor, r; | 75 | int subminor, r; |
76 | 76 | ||
77 | lock_kernel(); | ||
77 | subminor = iminor(inode); | 78 | subminor = iminor(inode); |
78 | 79 | ||
79 | interface = usb_find_interface(&lcd_driver, subminor); | 80 | interface = usb_find_interface(&lcd_driver, subminor); |
80 | if (!interface) { | 81 | if (!interface) { |
82 | unlock_kernel(); | ||
81 | err ("USBLCD: %s - error, can't find device for minor %d", | 83 | err ("USBLCD: %s - error, can't find device for minor %d", |
82 | __func__, subminor); | 84 | __func__, subminor); |
83 | return -ENODEV; | 85 | return -ENODEV; |
@@ -87,6 +89,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
87 | dev = usb_get_intfdata(interface); | 89 | dev = usb_get_intfdata(interface); |
88 | if (!dev) { | 90 | if (!dev) { |
89 | mutex_unlock(&open_disc_mutex); | 91 | mutex_unlock(&open_disc_mutex); |
92 | unlock_kernel(); | ||
90 | return -ENODEV; | 93 | return -ENODEV; |
91 | } | 94 | } |
92 | 95 | ||
@@ -98,11 +101,13 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
98 | r = usb_autopm_get_interface(interface); | 101 | r = usb_autopm_get_interface(interface); |
99 | if (r < 0) { | 102 | if (r < 0) { |
100 | kref_put(&dev->kref, lcd_delete); | 103 | kref_put(&dev->kref, lcd_delete); |
104 | unlock_kernel(); | ||
101 | return r; | 105 | return r; |
102 | } | 106 | } |
103 | 107 | ||
104 | /* save our object in the file's private structure */ | 108 | /* save our object in the file's private structure */ |
105 | file->private_data = dev; | 109 | file->private_data = dev; |
110 | unlock_kernel(); | ||
106 | 111 | ||
107 | return 0; | 112 | return 0; |
108 | } | 113 | } |
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 06cb71942dc7..63da2c3c838f 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #define PRODUCT_ID 0x1223 | 24 | #define PRODUCT_ID 0x1223 |
25 | 25 | ||
26 | /* table of devices that work with this driver */ | 26 | /* table of devices that work with this driver */ |
27 | static struct usb_device_id id_table [] = { | 27 | static const struct usb_device_id id_table[] = { |
28 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | 28 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, |
29 | { }, | 29 | { }, |
30 | }; | 30 | }; |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 3db255537e79..a9555cb901a1 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #define MAXLEN 6 | 27 | #define MAXLEN 6 |
28 | 28 | ||
29 | /* table of devices that work with this driver */ | 29 | /* table of devices that work with this driver */ |
30 | static struct usb_device_id id_table[] = { | 30 | static const struct usb_device_id id_table[] = { |
31 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | 31 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, |
32 | { }, | 32 | { }, |
33 | }; | 33 | }; |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 3dab0c0b196f..a21cce6f7403 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -1580,10 +1580,6 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf) | |||
1580 | return -ERESTARTSYS; | 1580 | return -ERESTARTSYS; |
1581 | 1581 | ||
1582 | /* FIXME: What if a system sleep starts while a test is running? */ | 1582 | /* FIXME: What if a system sleep starts while a test is running? */ |
1583 | if (!intf->is_active) { | ||
1584 | mutex_unlock(&dev->lock); | ||
1585 | return -EHOSTUNREACH; | ||
1586 | } | ||
1587 | 1583 | ||
1588 | /* some devices, like ez-usb default devices, need a non-default | 1584 | /* some devices, like ez-usb default devices, need a non-default |
1589 | * altsetting to have any active endpoints. some tests change | 1585 | * altsetting to have any active endpoints. some tests change |
@@ -2101,7 +2097,7 @@ static struct usbtest_info generic_info = { | |||
2101 | #endif | 2097 | #endif |
2102 | 2098 | ||
2103 | 2099 | ||
2104 | static struct usb_device_id id_table [] = { | 2100 | static const struct usb_device_id id_table[] = { |
2105 | 2101 | ||
2106 | /*-------------------------------------------------------------*/ | 2102 | /*-------------------------------------------------------------*/ |
2107 | 2103 | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 9a6c27a01793..f56fed53f2dd 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -770,7 +770,7 @@ static void uss720_disconnect(struct usb_interface *intf) | |||
770 | } | 770 | } |
771 | 771 | ||
772 | /* table of cables that work through this driver */ | 772 | /* table of cables that work through this driver */ |
773 | static struct usb_device_id uss720_table [] = { | 773 | static const struct usb_device_id uss720_table[] = { |
774 | { USB_DEVICE(0x047e, 0x1001) }, | 774 | { USB_DEVICE(0x047e, 0x1001) }, |
775 | { USB_DEVICE(0x0557, 0x2001) }, | 775 | { USB_DEVICE(0x0557, 0x2001) }, |
776 | { USB_DEVICE(0x0729, 0x1284) }, | 776 | { USB_DEVICE(0x0729, 0x1284) }, |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c deleted file mode 100644 index f26ea8dc1577..000000000000 --- a/drivers/usb/misc/vstusb.c +++ /dev/null | |||
@@ -1,783 +0,0 @@ | |||
1 | /***************************************************************************** | ||
2 | * File: drivers/usb/misc/vstusb.c | ||
3 | * | ||
4 | * Purpose: Support for the bulk USB Vernier Spectrophotometers | ||
5 | * | ||
6 | * Author: Johnnie Peters | ||
7 | * Axian Consulting | ||
8 | * Beaverton, OR, USA 97005 | ||
9 | * | ||
10 | * Modified by: EQware Engineering, Inc. | ||
11 | * Oregon City, OR, USA 97045 | ||
12 | * | ||
13 | * Copyright: 2007, 2008 | ||
14 | * Vernier Software & Technology | ||
15 | * Beaverton, OR, USA 97005 | ||
16 | * | ||
17 | * Web: www.vernier.com | ||
18 | * | ||
19 | * This program is free software; you can redistribute it and/or modify | ||
20 | * it under the terms of the GNU General Public License version 2 as | ||
21 | * published by the Free Software Foundation. | ||
22 | * | ||
23 | *****************************************************************************/ | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/errno.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/mutex.h> | ||
30 | #include <linux/uaccess.h> | ||
31 | #include <linux/usb.h> | ||
32 | |||
33 | #include <linux/usb/vstusb.h> | ||
34 | |||
35 | #define DRIVER_VERSION "VST USB Driver Version 1.5" | ||
36 | #define DRIVER_DESC "Vernier Software Technology Bulk USB Driver" | ||
37 | |||
38 | #ifdef CONFIG_USB_DYNAMIC_MINORS | ||
39 | #define VSTUSB_MINOR_BASE 0 | ||
40 | #else | ||
41 | #define VSTUSB_MINOR_BASE 199 | ||
42 | #endif | ||
43 | |||
44 | #define USB_VENDOR_OCEANOPTICS 0x2457 | ||
45 | #define USB_VENDOR_VERNIER 0x08F7 /* Vernier Software & Technology */ | ||
46 | |||
47 | #define USB_PRODUCT_USB2000 0x1002 | ||
48 | #define USB_PRODUCT_ADC1000_FW 0x1003 /* firmware download (renumerates) */ | ||
49 | #define USB_PRODUCT_ADC1000 0x1004 | ||
50 | #define USB_PRODUCT_HR2000_FW 0x1009 /* firmware download (renumerates) */ | ||
51 | #define USB_PRODUCT_HR2000 0x100A | ||
52 | #define USB_PRODUCT_HR4000_FW 0x1011 /* firmware download (renumerates) */ | ||
53 | #define USB_PRODUCT_HR4000 0x1012 | ||
54 | #define USB_PRODUCT_USB650 0x1014 /* "Red Tide" */ | ||
55 | #define USB_PRODUCT_QE65000 0x1018 | ||
56 | #define USB_PRODUCT_USB4000 0x1022 | ||
57 | #define USB_PRODUCT_USB325 0x1024 /* "Vernier Spectrometer" */ | ||
58 | |||
59 | #define USB_PRODUCT_LABPRO 0x0001 | ||
60 | #define USB_PRODUCT_LABQUEST 0x0005 | ||
61 | |||
62 | #define VST_MAXBUFFER (64*1024) | ||
63 | |||
64 | static struct usb_device_id id_table[] = { | ||
65 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB2000)}, | ||
66 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_HR4000)}, | ||
67 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB650)}, | ||
68 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB4000)}, | ||
69 | { USB_DEVICE(USB_VENDOR_OCEANOPTICS, USB_PRODUCT_USB325)}, | ||
70 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABQUEST)}, | ||
71 | { USB_DEVICE(USB_VENDOR_VERNIER, USB_PRODUCT_LABPRO)}, | ||
72 | {}, | ||
73 | }; | ||
74 | |||
75 | MODULE_DEVICE_TABLE(usb, id_table); | ||
76 | |||
77 | struct vstusb_device { | ||
78 | struct kref kref; | ||
79 | struct mutex lock; | ||
80 | struct usb_device *usb_dev; | ||
81 | char present; | ||
82 | char isopen; | ||
83 | struct usb_anchor submitted; | ||
84 | int rd_pipe; | ||
85 | int rd_timeout_ms; | ||
86 | int wr_pipe; | ||
87 | int wr_timeout_ms; | ||
88 | }; | ||
89 | #define to_vst_dev(d) container_of(d, struct vstusb_device, kref) | ||
90 | |||
91 | static struct usb_driver vstusb_driver; | ||
92 | |||
93 | static void vstusb_delete(struct kref *kref) | ||
94 | { | ||
95 | struct vstusb_device *vstdev = to_vst_dev(kref); | ||
96 | |||
97 | usb_put_dev(vstdev->usb_dev); | ||
98 | kfree(vstdev); | ||
99 | } | ||
100 | |||
101 | static int vstusb_open(struct inode *inode, struct file *file) | ||
102 | { | ||
103 | struct vstusb_device *vstdev; | ||
104 | struct usb_interface *interface; | ||
105 | |||
106 | interface = usb_find_interface(&vstusb_driver, iminor(inode)); | ||
107 | |||
108 | if (!interface) { | ||
109 | printk(KERN_ERR KBUILD_MODNAME | ||
110 | ": %s - error, can't find device for minor %d\n", | ||
111 | __func__, iminor(inode)); | ||
112 | return -ENODEV; | ||
113 | } | ||
114 | |||
115 | vstdev = usb_get_intfdata(interface); | ||
116 | |||
117 | if (!vstdev) | ||
118 | return -ENODEV; | ||
119 | |||
120 | /* lock this device */ | ||
121 | mutex_lock(&vstdev->lock); | ||
122 | |||
123 | /* can only open one time */ | ||
124 | if ((!vstdev->present) || (vstdev->isopen)) { | ||
125 | mutex_unlock(&vstdev->lock); | ||
126 | return -EBUSY; | ||
127 | } | ||
128 | |||
129 | /* increment our usage count */ | ||
130 | kref_get(&vstdev->kref); | ||
131 | |||
132 | vstdev->isopen = 1; | ||
133 | |||
134 | /* save device in the file's private structure */ | ||
135 | file->private_data = vstdev; | ||
136 | |||
137 | dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__); | ||
138 | |||
139 | mutex_unlock(&vstdev->lock); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int vstusb_release(struct inode *inode, struct file *file) | ||
145 | { | ||
146 | struct vstusb_device *vstdev; | ||
147 | |||
148 | vstdev = file->private_data; | ||
149 | |||
150 | if (vstdev == NULL) | ||
151 | return -ENODEV; | ||
152 | |||
153 | mutex_lock(&vstdev->lock); | ||
154 | |||
155 | vstdev->isopen = 0; | ||
156 | |||
157 | dev_dbg(&vstdev->usb_dev->dev, "%s: released\n", __func__); | ||
158 | |||
159 | mutex_unlock(&vstdev->lock); | ||
160 | |||
161 | kref_put(&vstdev->kref, vstusb_delete); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static void usb_api_blocking_completion(struct urb *urb) | ||
167 | { | ||
168 | struct completion *completeit = urb->context; | ||
169 | |||
170 | complete(completeit); | ||
171 | } | ||
172 | |||
173 | static int vstusb_fill_and_send_urb(struct urb *urb, | ||
174 | struct usb_device *usb_dev, | ||
175 | unsigned int pipe, void *data, | ||
176 | unsigned int len, struct completion *done) | ||
177 | { | ||
178 | struct usb_host_endpoint *ep; | ||
179 | struct usb_host_endpoint **hostep; | ||
180 | unsigned int pipend; | ||
181 | |||
182 | int status; | ||
183 | |||
184 | hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out; | ||
185 | pipend = usb_pipeendpoint(pipe); | ||
186 | ep = hostep[pipend]; | ||
187 | |||
188 | if (!ep || (len == 0)) | ||
189 | return -EINVAL; | ||
190 | |||
191 | if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
192 | == USB_ENDPOINT_XFER_INT) { | ||
193 | pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); | ||
194 | usb_fill_int_urb(urb, usb_dev, pipe, data, len, | ||
195 | (usb_complete_t)usb_api_blocking_completion, | ||
196 | NULL, ep->desc.bInterval); | ||
197 | } else | ||
198 | usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, | ||
199 | (usb_complete_t)usb_api_blocking_completion, | ||
200 | NULL); | ||
201 | |||
202 | init_completion(done); | ||
203 | urb->context = done; | ||
204 | urb->actual_length = 0; | ||
205 | status = usb_submit_urb(urb, GFP_KERNEL); | ||
206 | |||
207 | return status; | ||
208 | } | ||
209 | |||
210 | static int vstusb_complete_urb(struct urb *urb, struct completion *done, | ||
211 | int timeout, int *actual_length) | ||
212 | { | ||
213 | unsigned long expire; | ||
214 | int status; | ||
215 | |||
216 | expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; | ||
217 | if (!wait_for_completion_interruptible_timeout(done, expire)) { | ||
218 | usb_kill_urb(urb); | ||
219 | status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status; | ||
220 | |||
221 | dev_dbg(&urb->dev->dev, | ||
222 | "%s timed out on ep%d%s len=%d/%d, urb status = %d\n", | ||
223 | current->comm, | ||
224 | usb_pipeendpoint(urb->pipe), | ||
225 | usb_pipein(urb->pipe) ? "in" : "out", | ||
226 | urb->actual_length, | ||
227 | urb->transfer_buffer_length, | ||
228 | urb->status); | ||
229 | |||
230 | } else { | ||
231 | if (signal_pending(current)) { | ||
232 | /* if really an error */ | ||
233 | if (urb->status && !((urb->status == -ENOENT) || | ||
234 | (urb->status == -ECONNRESET) || | ||
235 | (urb->status == -ESHUTDOWN))) { | ||
236 | status = -EINTR; | ||
237 | usb_kill_urb(urb); | ||
238 | } else { | ||
239 | status = 0; | ||
240 | } | ||
241 | |||
242 | dev_dbg(&urb->dev->dev, | ||
243 | "%s: signal pending on ep%d%s len=%d/%d," | ||
244 | "urb status = %d\n", | ||
245 | current->comm, | ||
246 | usb_pipeendpoint(urb->pipe), | ||
247 | usb_pipein(urb->pipe) ? "in" : "out", | ||
248 | urb->actual_length, | ||
249 | urb->transfer_buffer_length, | ||
250 | urb->status); | ||
251 | |||
252 | } else { | ||
253 | status = urb->status; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | if (actual_length) | ||
258 | *actual_length = urb->actual_length; | ||
259 | |||
260 | return status; | ||
261 | } | ||
262 | |||
263 | static ssize_t vstusb_read(struct file *file, char __user *buffer, | ||
264 | size_t count, loff_t *ppos) | ||
265 | { | ||
266 | struct vstusb_device *vstdev; | ||
267 | int cnt = -1; | ||
268 | void *buf; | ||
269 | int retval = 0; | ||
270 | |||
271 | struct urb *urb; | ||
272 | struct usb_device *dev; | ||
273 | unsigned int pipe; | ||
274 | int timeout; | ||
275 | |||
276 | DECLARE_COMPLETION_ONSTACK(done); | ||
277 | |||
278 | vstdev = file->private_data; | ||
279 | |||
280 | if (vstdev == NULL) | ||
281 | return -ENODEV; | ||
282 | |||
283 | /* verify that we actually want to read some data */ | ||
284 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
285 | return -EINVAL; | ||
286 | |||
287 | /* lock this object */ | ||
288 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
289 | return -ERESTARTSYS; | ||
290 | |||
291 | /* anyone home */ | ||
292 | if (!vstdev->present) { | ||
293 | mutex_unlock(&vstdev->lock); | ||
294 | printk(KERN_ERR KBUILD_MODNAME | ||
295 | ": %s: device not present\n", __func__); | ||
296 | return -ENODEV; | ||
297 | } | ||
298 | |||
299 | /* pull out the necessary data */ | ||
300 | dev = vstdev->usb_dev; | ||
301 | pipe = usb_rcvbulkpipe(dev, vstdev->rd_pipe); | ||
302 | timeout = vstdev->rd_timeout_ms; | ||
303 | |||
304 | buf = kmalloc(count, GFP_KERNEL); | ||
305 | if (buf == NULL) { | ||
306 | mutex_unlock(&vstdev->lock); | ||
307 | return -ENOMEM; | ||
308 | } | ||
309 | |||
310 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
311 | if (!urb) { | ||
312 | kfree(buf); | ||
313 | mutex_unlock(&vstdev->lock); | ||
314 | return -ENOMEM; | ||
315 | } | ||
316 | |||
317 | usb_anchor_urb(urb, &vstdev->submitted); | ||
318 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
319 | mutex_unlock(&vstdev->lock); | ||
320 | if (retval) { | ||
321 | usb_unanchor_urb(urb); | ||
322 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
323 | __func__, retval, pipe); | ||
324 | goto exit; | ||
325 | } | ||
326 | |||
327 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
328 | if (retval) { | ||
329 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
330 | __func__, retval, pipe); | ||
331 | goto exit; | ||
332 | } | ||
333 | |||
334 | if (copy_to_user(buffer, buf, cnt)) { | ||
335 | dev_err(&dev->dev, "%s: can't copy_to_user\n", __func__); | ||
336 | retval = -EFAULT; | ||
337 | } else { | ||
338 | retval = cnt; | ||
339 | dev_dbg(&dev->dev, "%s: read %d bytes from pipe %d\n", | ||
340 | __func__, cnt, pipe); | ||
341 | } | ||
342 | |||
343 | exit: | ||
344 | usb_free_urb(urb); | ||
345 | kfree(buf); | ||
346 | return retval; | ||
347 | } | ||
348 | |||
349 | static ssize_t vstusb_write(struct file *file, const char __user *buffer, | ||
350 | size_t count, loff_t *ppos) | ||
351 | { | ||
352 | struct vstusb_device *vstdev; | ||
353 | int cnt = -1; | ||
354 | void *buf; | ||
355 | int retval = 0; | ||
356 | |||
357 | struct urb *urb; | ||
358 | struct usb_device *dev; | ||
359 | unsigned int pipe; | ||
360 | int timeout; | ||
361 | |||
362 | DECLARE_COMPLETION_ONSTACK(done); | ||
363 | |||
364 | vstdev = file->private_data; | ||
365 | |||
366 | if (vstdev == NULL) | ||
367 | return -ENODEV; | ||
368 | |||
369 | /* verify that we actually have some data to write */ | ||
370 | if ((count == 0) || (count > VST_MAXBUFFER)) | ||
371 | return retval; | ||
372 | |||
373 | /* lock this object */ | ||
374 | if (mutex_lock_interruptible(&vstdev->lock)) | ||
375 | return -ERESTARTSYS; | ||
376 | |||
377 | /* anyone home */ | ||
378 | if (!vstdev->present) { | ||
379 | mutex_unlock(&vstdev->lock); | ||
380 | printk(KERN_ERR KBUILD_MODNAME | ||
381 | ": %s: device not present\n", __func__); | ||
382 | return -ENODEV; | ||
383 | } | ||
384 | |||
385 | /* pull out the necessary data */ | ||
386 | dev = vstdev->usb_dev; | ||
387 | pipe = usb_sndbulkpipe(dev, vstdev->wr_pipe); | ||
388 | timeout = vstdev->wr_timeout_ms; | ||
389 | |||
390 | buf = kmalloc(count, GFP_KERNEL); | ||
391 | if (buf == NULL) { | ||
392 | mutex_unlock(&vstdev->lock); | ||
393 | return -ENOMEM; | ||
394 | } | ||
395 | |||
396 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
397 | if (!urb) { | ||
398 | kfree(buf); | ||
399 | mutex_unlock(&vstdev->lock); | ||
400 | return -ENOMEM; | ||
401 | } | ||
402 | |||
403 | if (copy_from_user(buf, buffer, count)) { | ||
404 | mutex_unlock(&vstdev->lock); | ||
405 | dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); | ||
406 | retval = -EFAULT; | ||
407 | goto exit; | ||
408 | } | ||
409 | |||
410 | usb_anchor_urb(urb, &vstdev->submitted); | ||
411 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
412 | mutex_unlock(&vstdev->lock); | ||
413 | if (retval) { | ||
414 | usb_unanchor_urb(urb); | ||
415 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
416 | __func__, retval, pipe); | ||
417 | goto exit; | ||
418 | } | ||
419 | |||
420 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
421 | if (retval) { | ||
422 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
423 | __func__, retval, pipe); | ||
424 | goto exit; | ||
425 | } else { | ||
426 | retval = cnt; | ||
427 | dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n", | ||
428 | __func__, cnt, pipe); | ||
429 | } | ||
430 | |||
431 | exit: | ||
432 | usb_free_urb(urb); | ||
433 | kfree(buf); | ||
434 | return retval; | ||
435 | } | ||
436 | |||
437 | static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
438 | { | ||
439 | int retval = 0; | ||
440 | int cnt = -1; | ||
441 | void __user *data = (void __user *)arg; | ||
442 | struct vstusb_args usb_data; | ||
443 | |||
444 | struct vstusb_device *vstdev; | ||
445 | void *buffer = NULL; /* must be initialized. buffer is | ||
446 | * referenced on exit but not all | ||
447 | * ioctls allocate it */ | ||
448 | |||
449 | struct urb *urb = NULL; /* must be initialized. urb is | ||
450 | * referenced on exit but not all | ||
451 | * ioctls allocate it */ | ||
452 | struct usb_device *dev; | ||
453 | unsigned int pipe; | ||
454 | int timeout; | ||
455 | |||
456 | DECLARE_COMPLETION_ONSTACK(done); | ||
457 | |||
458 | vstdev = file->private_data; | ||
459 | |||
460 | if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) { | ||
461 | dev_warn(&vstdev->usb_dev->dev, | ||
462 | "%s: ioctl command %x, bad ioctl magic %x, " | ||
463 | "expected %x\n", __func__, cmd, | ||
464 | _IOC_TYPE(cmd), VST_IOC_MAGIC); | ||
465 | return -EINVAL; | ||
466 | } | ||
467 | |||
468 | if (vstdev == NULL) | ||
469 | return -ENODEV; | ||
470 | |||
471 | if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) { | ||
472 | dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n", | ||
473 | __func__); | ||
474 | return -EFAULT; | ||
475 | } | ||
476 | |||
477 | /* lock this object */ | ||
478 | if (mutex_lock_interruptible(&vstdev->lock)) { | ||
479 | retval = -ERESTARTSYS; | ||
480 | goto exit; | ||
481 | } | ||
482 | |||
483 | /* anyone home */ | ||
484 | if (!vstdev->present) { | ||
485 | mutex_unlock(&vstdev->lock); | ||
486 | dev_err(&vstdev->usb_dev->dev, "%s: device not present\n", | ||
487 | __func__); | ||
488 | retval = -ENODEV; | ||
489 | goto exit; | ||
490 | } | ||
491 | |||
492 | /* pull out the necessary data */ | ||
493 | dev = vstdev->usb_dev; | ||
494 | |||
495 | switch (cmd) { | ||
496 | |||
497 | case IOCTL_VSTUSB_CONFIG_RW: | ||
498 | |||
499 | vstdev->rd_pipe = usb_data.rd_pipe; | ||
500 | vstdev->rd_timeout_ms = usb_data.rd_timeout_ms; | ||
501 | vstdev->wr_pipe = usb_data.wr_pipe; | ||
502 | vstdev->wr_timeout_ms = usb_data.wr_timeout_ms; | ||
503 | |||
504 | mutex_unlock(&vstdev->lock); | ||
505 | |||
506 | dev_dbg(&dev->dev, "%s: setting pipes/timeouts, " | ||
507 | "rdpipe = %d, rdtimeout = %d, " | ||
508 | "wrpipe = %d, wrtimeout = %d\n", __func__, | ||
509 | vstdev->rd_pipe, vstdev->rd_timeout_ms, | ||
510 | vstdev->wr_pipe, vstdev->wr_timeout_ms); | ||
511 | break; | ||
512 | |||
513 | case IOCTL_VSTUSB_SEND_PIPE: | ||
514 | |||
515 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
516 | mutex_unlock(&vstdev->lock); | ||
517 | retval = -EINVAL; | ||
518 | goto exit; | ||
519 | } | ||
520 | |||
521 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
522 | if (buffer == NULL) { | ||
523 | mutex_unlock(&vstdev->lock); | ||
524 | retval = -ENOMEM; | ||
525 | goto exit; | ||
526 | } | ||
527 | |||
528 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
529 | if (!urb) { | ||
530 | mutex_unlock(&vstdev->lock); | ||
531 | retval = -ENOMEM; | ||
532 | goto exit; | ||
533 | } | ||
534 | |||
535 | timeout = usb_data.timeout_ms; | ||
536 | |||
537 | pipe = usb_sndbulkpipe(dev, usb_data.pipe); | ||
538 | |||
539 | if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) { | ||
540 | dev_err(&dev->dev, "%s: can't copy_from_user\n", | ||
541 | __func__); | ||
542 | mutex_unlock(&vstdev->lock); | ||
543 | retval = -EFAULT; | ||
544 | goto exit; | ||
545 | } | ||
546 | |||
547 | usb_anchor_urb(urb, &vstdev->submitted); | ||
548 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
549 | usb_data.count, &done); | ||
550 | mutex_unlock(&vstdev->lock); | ||
551 | if (retval) { | ||
552 | usb_unanchor_urb(urb); | ||
553 | dev_err(&dev->dev, | ||
554 | "%s: error %d filling and sending urb %d\n", | ||
555 | __func__, retval, pipe); | ||
556 | goto exit; | ||
557 | } | ||
558 | |||
559 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
560 | if (retval) { | ||
561 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
562 | __func__, retval, pipe); | ||
563 | } | ||
564 | |||
565 | break; | ||
566 | case IOCTL_VSTUSB_RECV_PIPE: | ||
567 | |||
568 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
569 | mutex_unlock(&vstdev->lock); | ||
570 | retval = -EINVAL; | ||
571 | goto exit; | ||
572 | } | ||
573 | |||
574 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
575 | if (buffer == NULL) { | ||
576 | mutex_unlock(&vstdev->lock); | ||
577 | retval = -ENOMEM; | ||
578 | goto exit; | ||
579 | } | ||
580 | |||
581 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
582 | if (!urb) { | ||
583 | mutex_unlock(&vstdev->lock); | ||
584 | retval = -ENOMEM; | ||
585 | goto exit; | ||
586 | } | ||
587 | |||
588 | timeout = usb_data.timeout_ms; | ||
589 | |||
590 | pipe = usb_rcvbulkpipe(dev, usb_data.pipe); | ||
591 | |||
592 | usb_anchor_urb(urb, &vstdev->submitted); | ||
593 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
594 | usb_data.count, &done); | ||
595 | mutex_unlock(&vstdev->lock); | ||
596 | if (retval) { | ||
597 | usb_unanchor_urb(urb); | ||
598 | dev_err(&dev->dev, | ||
599 | "%s: error %d filling and sending urb %d\n", | ||
600 | __func__, retval, pipe); | ||
601 | goto exit; | ||
602 | } | ||
603 | |||
604 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
605 | if (retval) { | ||
606 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
607 | __func__, retval, pipe); | ||
608 | goto exit; | ||
609 | } | ||
610 | |||
611 | if (copy_to_user(usb_data.buffer, buffer, cnt)) { | ||
612 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
613 | __func__); | ||
614 | retval = -EFAULT; | ||
615 | goto exit; | ||
616 | } | ||
617 | |||
618 | usb_data.count = cnt; | ||
619 | if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) { | ||
620 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
621 | __func__); | ||
622 | retval = -EFAULT; | ||
623 | } else { | ||
624 | dev_dbg(&dev->dev, "%s: recv %zd bytes from pipe %d\n", | ||
625 | __func__, usb_data.count, usb_data.pipe); | ||
626 | } | ||
627 | |||
628 | break; | ||
629 | |||
630 | default: | ||
631 | mutex_unlock(&vstdev->lock); | ||
632 | dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n", | ||
633 | cmd); | ||
634 | return -EINVAL; | ||
635 | break; | ||
636 | } | ||
637 | exit: | ||
638 | usb_free_urb(urb); | ||
639 | kfree(buffer); | ||
640 | return retval; | ||
641 | } | ||
642 | |||
643 | static const struct file_operations vstusb_fops = { | ||
644 | .owner = THIS_MODULE, | ||
645 | .read = vstusb_read, | ||
646 | .write = vstusb_write, | ||
647 | .unlocked_ioctl = vstusb_ioctl, | ||
648 | .compat_ioctl = vstusb_ioctl, | ||
649 | .open = vstusb_open, | ||
650 | .release = vstusb_release, | ||
651 | }; | ||
652 | |||
653 | static struct usb_class_driver usb_vstusb_class = { | ||
654 | .name = "usb/vstusb%d", | ||
655 | .fops = &vstusb_fops, | ||
656 | .minor_base = VSTUSB_MINOR_BASE, | ||
657 | }; | ||
658 | |||
659 | static int vstusb_probe(struct usb_interface *intf, | ||
660 | const struct usb_device_id *id) | ||
661 | { | ||
662 | struct usb_device *dev = interface_to_usbdev(intf); | ||
663 | struct vstusb_device *vstdev; | ||
664 | int i; | ||
665 | int retval = 0; | ||
666 | |||
667 | /* allocate memory for our device state and intialize it */ | ||
668 | |||
669 | vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL); | ||
670 | if (vstdev == NULL) | ||
671 | return -ENOMEM; | ||
672 | |||
673 | /* must do usb_get_dev() prior to kref_init() since the kref_put() | ||
674 | * release function will do a usb_put_dev() */ | ||
675 | usb_get_dev(dev); | ||
676 | kref_init(&vstdev->kref); | ||
677 | mutex_init(&vstdev->lock); | ||
678 | |||
679 | i = dev->descriptor.bcdDevice; | ||
680 | |||
681 | dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n", | ||
682 | (i & 0xF000) >> 12, (i & 0xF00) >> 8, | ||
683 | (i & 0xF0) >> 4, (i & 0xF), dev->devnum); | ||
684 | |||
685 | vstdev->present = 1; | ||
686 | vstdev->isopen = 0; | ||
687 | vstdev->usb_dev = dev; | ||
688 | init_usb_anchor(&vstdev->submitted); | ||
689 | |||
690 | usb_set_intfdata(intf, vstdev); | ||
691 | retval = usb_register_dev(intf, &usb_vstusb_class); | ||
692 | if (retval) { | ||
693 | dev_err(&intf->dev, | ||
694 | "%s: Not able to get a minor for this device.\n", | ||
695 | __func__); | ||
696 | usb_set_intfdata(intf, NULL); | ||
697 | kref_put(&vstdev->kref, vstusb_delete); | ||
698 | return retval; | ||
699 | } | ||
700 | |||
701 | /* let the user know what node this device is now attached to */ | ||
702 | dev_info(&intf->dev, | ||
703 | "VST USB Device #%d now attached to major %d minor %d\n", | ||
704 | (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor); | ||
705 | |||
706 | dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION); | ||
707 | |||
708 | return retval; | ||
709 | } | ||
710 | |||
711 | static void vstusb_disconnect(struct usb_interface *intf) | ||
712 | { | ||
713 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
714 | |||
715 | usb_deregister_dev(intf, &usb_vstusb_class); | ||
716 | usb_set_intfdata(intf, NULL); | ||
717 | |||
718 | if (vstdev) { | ||
719 | |||
720 | mutex_lock(&vstdev->lock); | ||
721 | vstdev->present = 0; | ||
722 | |||
723 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
724 | |||
725 | mutex_unlock(&vstdev->lock); | ||
726 | |||
727 | kref_put(&vstdev->kref, vstusb_delete); | ||
728 | } | ||
729 | |||
730 | } | ||
731 | |||
732 | static int vstusb_suspend(struct usb_interface *intf, pm_message_t message) | ||
733 | { | ||
734 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
735 | int time; | ||
736 | if (!vstdev) | ||
737 | return 0; | ||
738 | |||
739 | mutex_lock(&vstdev->lock); | ||
740 | time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000); | ||
741 | if (!time) | ||
742 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
743 | mutex_unlock(&vstdev->lock); | ||
744 | |||
745 | return 0; | ||
746 | } | ||
747 | |||
748 | static int vstusb_resume(struct usb_interface *intf) | ||
749 | { | ||
750 | return 0; | ||
751 | } | ||
752 | |||
753 | static struct usb_driver vstusb_driver = { | ||
754 | .name = "vstusb", | ||
755 | .probe = vstusb_probe, | ||
756 | .disconnect = vstusb_disconnect, | ||
757 | .suspend = vstusb_suspend, | ||
758 | .resume = vstusb_resume, | ||
759 | .id_table = id_table, | ||
760 | }; | ||
761 | |||
762 | static int __init vstusb_init(void) | ||
763 | { | ||
764 | int rc; | ||
765 | |||
766 | rc = usb_register(&vstusb_driver); | ||
767 | if (rc) | ||
768 | printk(KERN_ERR "%s: failed to register (%d)", __func__, rc); | ||
769 | |||
770 | return rc; | ||
771 | } | ||
772 | |||
773 | static void __exit vstusb_exit(void) | ||
774 | { | ||
775 | usb_deregister(&vstusb_driver); | ||
776 | } | ||
777 | |||
778 | module_init(vstusb_init); | ||
779 | module_exit(vstusb_exit); | ||
780 | |||
781 | MODULE_AUTHOR("Dennis O'Brien/Stephen Ware"); | ||
782 | MODULE_DESCRIPTION(DRIVER_VERSION); | ||
783 | MODULE_LICENSE("GPL"); | ||