diff options
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/Kconfig | 24 | ||||
-rw-r--r-- | drivers/usb/misc/Makefile | 2 | ||||
-rw-r--r-- | drivers/usb/misc/adutux.c | 22 | ||||
-rw-r--r-- | drivers/usb/misc/appledisplay.c | 26 | ||||
-rw-r--r-- | drivers/usb/misc/cypress_cy7c63.c | 6 | ||||
-rw-r--r-- | drivers/usb/misc/cytherm.c | 9 | ||||
-rw-r--r-- | drivers/usb/misc/emi26.c | 17 | ||||
-rw-r--r-- | drivers/usb/misc/emi62.c | 4 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 5 | ||||
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 23 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 11 | ||||
-rw-r--r-- | drivers/usb/misc/trancevibrator.c | 3 | ||||
-rw-r--r-- | drivers/usb/misc/usblcd.c | 13 | ||||
-rw-r--r-- | drivers/usb/misc/usbsevseg.c | 394 | ||||
-rw-r--r-- | drivers/usb/misc/uss720.c | 19 | ||||
-rw-r--r-- | drivers/usb/misc/vstusb.c | 782 |
17 files changed, 1297 insertions, 73 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 4ea50e0abcbb..e463db5d8188 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -42,6 +42,15 @@ config USB_ADUTUX | |||
42 | To compile this driver as a module, choose M here. The module | 42 | To compile this driver as a module, choose M here. The module |
43 | will be called adutux. | 43 | will be called adutux. |
44 | 44 | ||
45 | config USB_SEVSEG | ||
46 | tristate "USB 7-Segment LED Display" | ||
47 | depends on USB | ||
48 | help | ||
49 | Say Y here if you have a USB 7-Segment Display by Delcom | ||
50 | |||
51 | To compile this driver as a module, choose M here: the | ||
52 | module will be called usbsevseg. | ||
53 | |||
45 | config USB_RIO500 | 54 | config USB_RIO500 |
46 | tristate "USB Diamond Rio500 support" | 55 | tristate "USB Diamond Rio500 support" |
47 | depends on USB | 56 | depends on USB |
@@ -271,3 +280,18 @@ config USB_ISIGHTFW | |||
271 | The firmware for this driver must be extracted from the MacOS | 280 | The firmware for this driver must be extracted from the MacOS |
272 | driver beforehand. Tools for doing so are available at | 281 | driver beforehand. Tools for doing so are available at |
273 | http://bersace03.free.fr | 282 | http://bersace03.free.fr |
283 | |||
284 | config USB_VST | ||
285 | tristate "USB VST driver" | ||
286 | depends on USB | ||
287 | help | ||
288 | This driver is intended for Vernier Software Technologies | ||
289 | bulk usb devices such as their Ocean-Optics spectrometers or | ||
290 | Labquest. | ||
291 | It is a bulk channel driver with configurable read and write | ||
292 | timeouts. | ||
293 | |||
294 | To compile this driver as a module, choose M here: the | ||
295 | module will be called vstusb. | ||
296 | |||
297 | |||
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 45b4e12afb08..1334f7bdd7be 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -26,6 +26,8 @@ obj-$(CONFIG_USB_RIO500) += rio500.o | |||
26 | obj-$(CONFIG_USB_TEST) += usbtest.o | 26 | obj-$(CONFIG_USB_TEST) += usbtest.o |
27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | 27 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
28 | obj-$(CONFIG_USB_USS720) += uss720.o | 28 | obj-$(CONFIG_USB_USS720) += uss720.o |
29 | obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o | ||
30 | obj-$(CONFIG_USB_VST) += vstusb.o | ||
29 | 31 | ||
30 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ | 32 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
31 | 33 | ||
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 965f6eaea6a0..7b6922e08ed1 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c | |||
@@ -283,8 +283,8 @@ static int adu_open(struct inode *inode, struct file *file) | |||
283 | 283 | ||
284 | interface = usb_find_interface(&adu_driver, subminor); | 284 | interface = usb_find_interface(&adu_driver, subminor); |
285 | if (!interface) { | 285 | if (!interface) { |
286 | err("%s - error, can't find device for minor %d", | 286 | printk(KERN_ERR "adutux: %s - error, can't find device for " |
287 | __func__, subminor); | 287 | "minor %d\n", __func__, subminor); |
288 | retval = -ENODEV; | 288 | retval = -ENODEV; |
289 | goto exit_no_device; | 289 | goto exit_no_device; |
290 | } | 290 | } |
@@ -416,7 +416,8 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, | |||
416 | /* verify that the device wasn't unplugged */ | 416 | /* verify that the device wasn't unplugged */ |
417 | if (dev->udev == NULL) { | 417 | if (dev->udev == NULL) { |
418 | retval = -ENODEV; | 418 | retval = -ENODEV; |
419 | err("No device or device unplugged %d", retval); | 419 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
420 | retval); | ||
420 | goto exit; | 421 | goto exit; |
421 | } | 422 | } |
422 | 423 | ||
@@ -576,7 +577,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
576 | /* verify that the device wasn't unplugged */ | 577 | /* verify that the device wasn't unplugged */ |
577 | if (dev->udev == NULL) { | 578 | if (dev->udev == NULL) { |
578 | retval = -ENODEV; | 579 | retval = -ENODEV; |
579 | err("No device or device unplugged %d", retval); | 580 | printk(KERN_ERR "adutux: No device or device unplugged %d\n", |
581 | retval); | ||
580 | goto exit; | 582 | goto exit; |
581 | } | 583 | } |
582 | 584 | ||
@@ -645,7 +647,8 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, | |||
645 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); | 647 | retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL); |
646 | if (retval < 0) { | 648 | if (retval < 0) { |
647 | dev->out_urb_finished = 1; | 649 | dev->out_urb_finished = 1; |
648 | err("Couldn't submit interrupt_out_urb %d", retval); | 650 | dev_err(&dev->udev->dev, "Couldn't submit " |
651 | "interrupt_out_urb %d\n", retval); | ||
649 | goto exit; | 652 | goto exit; |
650 | } | 653 | } |
651 | 654 | ||
@@ -890,13 +893,14 @@ static int __init adu_init(void) | |||
890 | /* register this driver with the USB subsystem */ | 893 | /* register this driver with the USB subsystem */ |
891 | result = usb_register(&adu_driver); | 894 | result = usb_register(&adu_driver); |
892 | if (result < 0) { | 895 | if (result < 0) { |
893 | err("usb_register failed for the "__FILE__" driver. " | 896 | printk(KERN_ERR "usb_register failed for the "__FILE__ |
894 | "Error number %d", result); | 897 | " driver. Error number %d\n", result); |
895 | goto exit; | 898 | goto exit; |
896 | } | 899 | } |
897 | 900 | ||
898 | info("adutux " DRIVER_DESC " " DRIVER_VERSION); | 901 | printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); |
899 | info("adutux is an experimental driver. Use at your own risk"); | 902 | printk(KERN_INFO "adutux is an experimental driver. " |
903 | "Use at your own risk\n"); | ||
900 | 904 | ||
901 | exit: | 905 | exit: |
902 | dbg(2," %s : leave, return value %d", __func__, result); | 906 | dbg(2," %s : leave, return value %d", __func__, result); |
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index a076c24a312a..1d8e39a557d9 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -130,7 +130,8 @@ static void appledisplay_complete(struct urb *urb) | |||
130 | exit: | 130 | exit: |
131 | retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); | 131 | retval = usb_submit_urb(pdata->urb, GFP_ATOMIC); |
132 | if (retval) { | 132 | if (retval) { |
133 | err("%s - usb_submit_urb failed with result %d", | 133 | dev_err(&pdata->udev->dev, |
134 | "%s - usb_submit_urb failed with result %d\n", | ||
134 | __func__, retval); | 135 | __func__, retval); |
135 | } | 136 | } |
136 | } | 137 | } |
@@ -220,7 +221,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
220 | } | 221 | } |
221 | } | 222 | } |
222 | if (!int_in_endpointAddr) { | 223 | if (!int_in_endpointAddr) { |
223 | err("Could not find int-in endpoint"); | 224 | dev_err(&iface->dev, "Could not find int-in endpoint\n"); |
224 | return -EIO; | 225 | return -EIO; |
225 | } | 226 | } |
226 | 227 | ||
@@ -228,7 +229,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
228 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); | 229 | pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); |
229 | if (!pdata) { | 230 | if (!pdata) { |
230 | retval = -ENOMEM; | 231 | retval = -ENOMEM; |
231 | err("Out of memory"); | 232 | dev_err(&iface->dev, "Out of memory\n"); |
232 | goto error; | 233 | goto error; |
233 | } | 234 | } |
234 | 235 | ||
@@ -241,8 +242,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
241 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); | 242 | pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); |
242 | if (!pdata->msgdata) { | 243 | if (!pdata->msgdata) { |
243 | retval = -ENOMEM; | 244 | retval = -ENOMEM; |
244 | err("appledisplay: Allocating buffer for control messages " | 245 | dev_err(&iface->dev, |
245 | "failed"); | 246 | "Allocating buffer for control messages failed\n"); |
246 | goto error; | 247 | goto error; |
247 | } | 248 | } |
248 | 249 | ||
@@ -250,7 +251,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
250 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); | 251 | pdata->urb = usb_alloc_urb(0, GFP_KERNEL); |
251 | if (!pdata->urb) { | 252 | if (!pdata->urb) { |
252 | retval = -ENOMEM; | 253 | retval = -ENOMEM; |
253 | err("appledisplay: Allocating URB failed"); | 254 | dev_err(&iface->dev, "Allocating URB failed\n"); |
254 | goto error; | 255 | goto error; |
255 | } | 256 | } |
256 | 257 | ||
@@ -259,7 +260,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
259 | GFP_KERNEL, &pdata->urb->transfer_dma); | 260 | GFP_KERNEL, &pdata->urb->transfer_dma); |
260 | if (!pdata->urbdata) { | 261 | if (!pdata->urbdata) { |
261 | retval = -ENOMEM; | 262 | retval = -ENOMEM; |
262 | err("appledisplay: Allocating URB buffer failed"); | 263 | dev_err(&iface->dev, "Allocating URB buffer failed\n"); |
263 | goto error; | 264 | goto error; |
264 | } | 265 | } |
265 | 266 | ||
@@ -270,7 +271,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
270 | pdata, 1); | 271 | pdata, 1); |
271 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { | 272 | if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { |
272 | retval = -EIO; | 273 | retval = -EIO; |
273 | err("appledisplay: Submitting URB failed"); | 274 | dev_err(&iface->dev, "Submitting URB failed\n"); |
274 | goto error; | 275 | goto error; |
275 | } | 276 | } |
276 | 277 | ||
@@ -280,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
280 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, | 281 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, |
281 | &appledisplay_bl_data); | 282 | &appledisplay_bl_data); |
282 | if (IS_ERR(pdata->bd)) { | 283 | if (IS_ERR(pdata->bd)) { |
283 | err("appledisplay: Backlight registration failed"); | 284 | dev_err(&iface->dev, "Backlight registration failed\n"); |
284 | goto error; | 285 | goto error; |
285 | } | 286 | } |
286 | 287 | ||
@@ -291,7 +292,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
291 | 292 | ||
292 | if (brightness < 0) { | 293 | if (brightness < 0) { |
293 | retval = brightness; | 294 | retval = brightness; |
294 | err("appledisplay: Error while getting initial brightness: %d", retval); | 295 | dev_err(&iface->dev, |
296 | "Error while getting initial brightness: %d\n", retval); | ||
295 | goto error; | 297 | goto error; |
296 | } | 298 | } |
297 | 299 | ||
@@ -314,7 +316,7 @@ error: | |||
314 | pdata->urbdata, pdata->urb->transfer_dma); | 316 | pdata->urbdata, pdata->urb->transfer_dma); |
315 | usb_free_urb(pdata->urb); | 317 | usb_free_urb(pdata->urb); |
316 | } | 318 | } |
317 | if (pdata->bd) | 319 | if (pdata->bd && !IS_ERR(pdata->bd)) |
318 | backlight_device_unregister(pdata->bd); | 320 | backlight_device_unregister(pdata->bd); |
319 | kfree(pdata->msgdata); | 321 | kfree(pdata->msgdata); |
320 | } | 322 | } |
@@ -352,7 +354,7 @@ static int __init appledisplay_init(void) | |||
352 | { | 354 | { |
353 | wq = create_singlethread_workqueue("appledisplay"); | 355 | wq = create_singlethread_workqueue("appledisplay"); |
354 | if (!wq) { | 356 | if (!wq) { |
355 | err("Could not create work queue\n"); | 357 | printk(KERN_ERR "appledisplay: Could not create work queue\n"); |
356 | return -ENOMEM; | 358 | return -ENOMEM; |
357 | } | 359 | } |
358 | 360 | ||
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 937940404b7a..5720bfef6a38 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c | |||
@@ -278,9 +278,9 @@ static int __init cypress_init(void) | |||
278 | 278 | ||
279 | /* register this driver with the USB subsystem */ | 279 | /* register this driver with the USB subsystem */ |
280 | result = usb_register(&cypress_driver); | 280 | result = usb_register(&cypress_driver); |
281 | if (result) { | 281 | if (result) |
282 | err("Function usb_register failed! Error number: %d\n", result); | 282 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
283 | } | 283 | "Error number: %d\n", result); |
284 | 284 | ||
285 | return result; | 285 | return result; |
286 | } | 286 | } |
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 1cd9e7eba93b..4fb3c38b924b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c | |||
@@ -422,13 +422,14 @@ static int __init usb_cytherm_init(void) | |||
422 | int result; | 422 | int result; |
423 | 423 | ||
424 | result = usb_register(&cytherm_driver); | 424 | result = usb_register(&cytherm_driver); |
425 | if (result) | 425 | if (result) { |
426 | { | 426 | printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " |
427 | err("usb_register failed. Error number %d", result); | 427 | "Error number: %d\n", result); |
428 | return result; | 428 | return result; |
429 | } | 429 | } |
430 | 430 | ||
431 | info(DRIVER_VERSION ":" DRIVER_DESC); | 431 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
432 | DRIVER_DESC "\n"); | ||
432 | return 0; | 433 | return 0; |
433 | } | 434 | } |
434 | 435 | ||
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 4b994a0cd272..e762beb5f3c6 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -50,7 +50,7 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); | 50 | unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); |
51 | 51 | ||
52 | if (!buffer) { | 52 | if (!buffer) { |
53 | err("emi26: kmalloc(%d) failed.", length); | 53 | dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); |
54 | return -ENOMEM; | 54 | return -ENOMEM; |
55 | } | 55 | } |
56 | /* Note: usb_control_msg returns negative value on error or length of the | 56 | /* Note: usb_control_msg returns negative value on error or length of the |
@@ -64,11 +64,11 @@ static int emi26_writememory (struct usb_device *dev, int address, | |||
64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) | 64 | static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit) |
65 | { | 65 | { |
66 | int response; | 66 | int response; |
67 | info("%s - %d", __func__, reset_bit); | 67 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ | 68 | /* printk(KERN_DEBUG "%s - %d", __func__, reset_bit); */ |
69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 69 | response = emi26_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
70 | if (response < 0) { | 70 | if (response < 0) { |
71 | err("emi26: set_reset (%d) failed", reset_bit); | 71 | dev_err(&dev->dev, "set_reset (%d) failed\n", reset_bit); |
72 | } | 72 | } |
73 | return response; | 73 | return response; |
74 | } | 74 | } |
@@ -88,7 +88,8 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
88 | 88 | ||
89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); | 89 | buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); |
90 | if (!buf) { | 90 | if (!buf) { |
91 | err( "%s - error loading firmware: error = %d", __func__, -ENOMEM); | 91 | dev_err(&dev->dev, "%s - error loading firmware: error = %d\n", |
92 | __func__, -ENOMEM); | ||
92 | err = -ENOMEM; | 93 | err = -ENOMEM; |
93 | goto wraperr; | 94 | goto wraperr; |
94 | } | 95 | } |
@@ -106,14 +107,16 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
106 | &dev->dev); | 107 | &dev->dev); |
107 | if (err) { | 108 | if (err) { |
108 | nofw: | 109 | nofw: |
109 | err( "%s - request_firmware() failed", __func__); | 110 | dev_err(&dev->dev, "%s - request_firmware() failed\n", |
111 | __func__); | ||
110 | goto wraperr; | 112 | goto wraperr; |
111 | } | 113 | } |
112 | 114 | ||
113 | /* Assert reset (stop the CPU in the EMI) */ | 115 | /* Assert reset (stop the CPU in the EMI) */ |
114 | err = emi26_set_reset(dev,1); | 116 | err = emi26_set_reset(dev,1); |
115 | if (err < 0) { | 117 | if (err < 0) { |
116 | err( "%s - error loading firmware: error = %d", __func__, err); | 118 | dev_err(&dev->dev,"%s - error loading firmware: error = %d\n", |
119 | __func__, err); | ||
117 | goto wraperr; | 120 | goto wraperr; |
118 | } | 121 | } |
119 | 122 | ||
@@ -254,7 +257,7 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
254 | { | 257 | { |
255 | struct usb_device *dev = interface_to_usbdev(intf); | 258 | struct usb_device *dev = interface_to_usbdev(intf); |
256 | 259 | ||
257 | info("%s start", __func__); | 260 | dev_info(&intf->dev, "%s start\n", __func__); |
258 | 261 | ||
259 | emi26_load_firmware(dev); | 262 | emi26_load_firmware(dev); |
260 | 263 | ||
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 5d859ded5bbf..602ee05ba9ff 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -73,7 +73,7 @@ static int emi62_writememory(struct usb_device *dev, int address, | |||
73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) | 73 | static int emi62_set_reset (struct usb_device *dev, unsigned char reset_bit) |
74 | { | 74 | { |
75 | int response; | 75 | int response; |
76 | info("%s - %d", __func__, reset_bit); | 76 | dev_info(&dev->dev, "%s - %d\n", __func__, reset_bit); |
77 | 77 | ||
78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); | 78 | response = emi62_writememory (dev, CPUCS_REG, &reset_bit, 1, 0xa0); |
79 | if (response < 0) { | 79 | if (response < 0) { |
@@ -271,7 +271,7 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
271 | struct usb_device *dev = interface_to_usbdev(intf); | 271 | struct usb_device *dev = interface_to_usbdev(intf); |
272 | dev_dbg(&intf->dev, "emi62_probe\n"); | 272 | dev_dbg(&intf->dev, "emi62_probe\n"); |
273 | 273 | ||
274 | info("%s start", __func__); | 274 | dev_info(&intf->dev, "%s start\n", __func__); |
275 | 275 | ||
276 | emi62_load_firmware(dev); | 276 | emi62_load_firmware(dev); |
277 | 277 | ||
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 97c280971532..79a7668ef264 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -698,7 +698,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer, | |||
698 | int retval = usb_bulk_msg(ftdi->udev, | 698 | int retval = usb_bulk_msg(ftdi->udev, |
699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 699 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 700 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
701 | &packet_bytes, msecs_to_jiffies(50)); | 701 | &packet_bytes, 50); |
702 | if (packet_bytes > 2) { | 702 | if (packet_bytes > 2) { |
703 | ftdi->bulk_in_left = packet_bytes - 2; | 703 | ftdi->bulk_in_left = packet_bytes - 2; |
704 | ftdi->bulk_in_last = 1; | 704 | ftdi->bulk_in_last = 1; |
@@ -960,7 +960,7 @@ static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi) | |||
960 | int retval = usb_bulk_msg(ftdi->udev, | 960 | int retval = usb_bulk_msg(ftdi->udev, |
961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 961 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 962 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
963 | &packet_bytes, msecs_to_jiffies(500)); | 963 | &packet_bytes, 500); |
964 | char diag[30 *3 + 4]; | 964 | char diag[30 *3 + 4]; |
965 | char *d = diag; | 965 | char *d = diag; |
966 | int m = packet_bytes; | 966 | int m = packet_bytes; |
@@ -1880,7 +1880,7 @@ static int ftdi_elan_flush_input_fifo(struct usb_ftdi *ftdi) | |||
1880 | int retval = usb_bulk_msg(ftdi->udev, | 1880 | int retval = usb_bulk_msg(ftdi->udev, |
1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 1881 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 1882 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
1883 | &packet_bytes, msecs_to_jiffies(100)); | 1883 | &packet_bytes, 100); |
1884 | if (packet_bytes > 2) { | 1884 | if (packet_bytes > 2) { |
1885 | char diag[30 *3 + 4]; | 1885 | char diag[30 *3 + 4]; |
1886 | char *d = diag; | 1886 | char *d = diag; |
@@ -2067,7 +2067,7 @@ static int ftdi_elan_synchronize(struct usb_ftdi *ftdi) | |||
2067 | usb_rcvbulkpipe(ftdi->udev, | 2067 | usb_rcvbulkpipe(ftdi->udev, |
2068 | ftdi->bulk_in_endpointAddr), | 2068 | ftdi->bulk_in_endpointAddr), |
2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2069 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
2070 | &packet_bytes, msecs_to_jiffies(500)); | 2070 | &packet_bytes, 500); |
2071 | if (packet_bytes > 2) { | 2071 | if (packet_bytes > 2) { |
2072 | char diag[30 *3 + 4]; | 2072 | char diag[30 *3 + 4]; |
2073 | char *d = diag; | 2073 | char *d = diag; |
@@ -2176,7 +2176,7 @@ static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi) | |||
2176 | int retval = usb_bulk_msg(ftdi->udev, | 2176 | int retval = usb_bulk_msg(ftdi->udev, |
2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), | 2177 | usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr), |
2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, | 2178 | ftdi->bulk_in_buffer, ftdi->bulk_in_size, |
2179 | &packet_bytes, msecs_to_jiffies(1000)); | 2179 | &packet_bytes, 1000); |
2180 | if (packet_bytes > 2) { | 2180 | if (packet_bytes > 2) { |
2181 | char diag[30 *3 + 4]; | 2181 | char diag[30 *3 + 4]; |
2182 | char *d = diag; | 2182 | char *d = diag; |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 4bcf7fb4e5da..6da8887538c7 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -403,14 +403,15 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
403 | mutex_unlock(&dev->lock); | 403 | mutex_unlock(&dev->lock); |
404 | } | 404 | } |
405 | 405 | ||
406 | info("%s disconnected", DRIVER_DESC); | 406 | dev_info(&interface->dev, "disconnected\n"); |
407 | } | 407 | } |
408 | 408 | ||
409 | static int __init usb_idmouse_init(void) | 409 | static int __init usb_idmouse_init(void) |
410 | { | 410 | { |
411 | int result; | 411 | int result; |
412 | 412 | ||
413 | info(DRIVER_DESC " " DRIVER_VERSION); | 413 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
414 | DRIVER_DESC "\n"); | ||
414 | 415 | ||
415 | /* register this driver with the USB subsystem */ | 416 | /* register this driver with the USB subsystem */ |
416 | result = usb_register(&idmouse_driver); | 417 | result = usb_register(&idmouse_driver); |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 9370326a5940..ab0f3226158b 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -851,9 +851,8 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
851 | 851 | ||
852 | dbg(2, "%s: enter", __func__); | 852 | dbg(2, "%s: enter", __func__); |
853 | 853 | ||
854 | if (udev == NULL) { | 854 | if (udev == NULL) |
855 | info ("udev is NULL."); | 855 | dev_info(&interface->dev, "udev is NULL.\n"); |
856 | } | ||
857 | 856 | ||
858 | /* allocate memory for our device state and initialize it */ | 857 | /* allocate memory for our device state and initialize it */ |
859 | 858 | ||
@@ -954,7 +953,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
954 | dev->minor = interface->minor; | 953 | dev->minor = interface->minor; |
955 | 954 | ||
956 | /* let the user know what node this device is now attached to */ | 955 | /* let the user know what node this device is now attached to */ |
957 | info ("LEGO USB Tower #%d now attached to major %d minor %d", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), USB_MAJOR, dev->minor); | 956 | dev_info(&interface->dev, "LEGO USB Tower #%d now attached to major " |
957 | "%d minor %d\n", (dev->minor - LEGO_USB_TOWER_MINOR_BASE), | ||
958 | USB_MAJOR, dev->minor); | ||
958 | 959 | ||
959 | /* get the firmware version and log it */ | 960 | /* get the firmware version and log it */ |
960 | result = usb_control_msg (udev, | 961 | result = usb_control_msg (udev, |
@@ -971,10 +972,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device | |||
971 | retval = result; | 972 | retval = result; |
972 | goto error; | 973 | goto error; |
973 | } | 974 | } |
974 | info("LEGO USB Tower firmware version is %d.%d build %d", | 975 | dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d " |
975 | get_version_reply.major, | 976 | "build %d\n", get_version_reply.major, |
976 | get_version_reply.minor, | 977 | get_version_reply.minor, |
977 | le16_to_cpu(get_version_reply.build_no)); | 978 | le16_to_cpu(get_version_reply.build_no)); |
978 | 979 | ||
979 | 980 | ||
980 | exit: | 981 | exit: |
@@ -1021,7 +1022,8 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1021 | mutex_unlock(&dev->lock); | 1022 | mutex_unlock(&dev->lock); |
1022 | } | 1023 | } |
1023 | 1024 | ||
1024 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1025 | dev_info(&interface->dev, "LEGO USB Tower #%d now disconnected\n", |
1026 | (minor - LEGO_USB_TOWER_MINOR_BASE)); | ||
1025 | 1027 | ||
1026 | dbg(2, "%s: leave", __func__); | 1028 | dbg(2, "%s: leave", __func__); |
1027 | } | 1029 | } |
@@ -1046,7 +1048,8 @@ static int __init lego_usb_tower_init(void) | |||
1046 | goto exit; | 1048 | goto exit; |
1047 | } | 1049 | } |
1048 | 1050 | ||
1049 | info(DRIVER_DESC " " DRIVER_VERSION); | 1051 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
1052 | DRIVER_DESC "\n"); | ||
1050 | 1053 | ||
1051 | exit: | 1054 | exit: |
1052 | dbg(2, "%s: leave, return value %d", __func__, retval); | 1055 | dbg(2, "%s: leave, return value %d", __func__, retval); |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 248a12aacef6..deb95bb49fd1 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -89,7 +89,7 @@ static int open_rio(struct inode *inode, struct file *file) | |||
89 | 89 | ||
90 | mutex_unlock(&(rio->lock)); | 90 | mutex_unlock(&(rio->lock)); |
91 | 91 | ||
92 | info("Rio opened."); | 92 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
93 | 93 | ||
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
@@ -100,7 +100,7 @@ static int close_rio(struct inode *inode, struct file *file) | |||
100 | 100 | ||
101 | rio->isopen = 0; | 101 | rio->isopen = 0; |
102 | 102 | ||
103 | info("Rio closed."); | 103 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
@@ -451,7 +451,7 @@ static int probe_rio(struct usb_interface *intf, | |||
451 | struct rio_usb_data *rio = &rio_instance; | 451 | struct rio_usb_data *rio = &rio_instance; |
452 | int retval; | 452 | int retval; |
453 | 453 | ||
454 | info("USB Rio found at address %d", dev->devnum); | 454 | dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); |
455 | 455 | ||
456 | retval = usb_register_dev(intf, &usb_rio_class); | 456 | retval = usb_register_dev(intf, &usb_rio_class); |
457 | if (retval) { | 457 | if (retval) { |
@@ -503,7 +503,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
503 | kfree(rio->ibuf); | 503 | kfree(rio->ibuf); |
504 | kfree(rio->obuf); | 504 | kfree(rio->obuf); |
505 | 505 | ||
506 | info("USB Rio disconnected."); | 506 | dev_info(&intf->dev, "USB Rio disconnected.\n"); |
507 | 507 | ||
508 | rio->present = 0; | 508 | rio->present = 0; |
509 | mutex_unlock(&(rio->lock)); | 509 | mutex_unlock(&(rio->lock)); |
@@ -531,7 +531,8 @@ static int __init usb_rio_init(void) | |||
531 | if (retval) | 531 | if (retval) |
532 | goto out; | 532 | goto out; |
533 | 533 | ||
534 | info(DRIVER_VERSION ":" DRIVER_DESC); | 534 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
535 | DRIVER_DESC "\n"); | ||
535 | 536 | ||
536 | out: | 537 | out: |
537 | return retval; | 538 | return retval; |
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 03368edf3f22..2e14102955c5 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -144,7 +144,8 @@ static int __init tv_init(void) | |||
144 | return retval; | 144 | return retval; |
145 | } | 145 | } |
146 | 146 | ||
147 | info(DRIVER_VERSION ":" DRIVER_DESC); | 147 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
148 | DRIVER_DESC "\n"); | ||
148 | return 0; | 149 | return 0; |
149 | } | 150 | } |
150 | 151 | ||
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 2db4228fbb01..e0ff9ccd866b 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -311,7 +311,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
311 | dev->interface = interface; | 311 | dev->interface = interface; |
312 | 312 | ||
313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { | 313 | if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { |
314 | warn(KERN_INFO "USBLCD model not supported."); | 314 | dev_warn(&interface->dev, "USBLCD model not supported.\n"); |
315 | return -ENODEV; | 315 | return -ENODEV; |
316 | } | 316 | } |
317 | 317 | ||
@@ -359,12 +359,13 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id | |||
359 | 359 | ||
360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); | 360 | i = le16_to_cpu(dev->udev->descriptor.bcdDevice); |
361 | 361 | ||
362 | info("USBLCD Version %1d%1d.%1d%1d found at address %d", | 362 | dev_info(&interface->dev, "USBLCD Version %1d%1d.%1d%1d found " |
363 | (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), | 363 | "at address %d\n", (i & 0xF000)>>12, (i & 0xF00)>>8, |
364 | dev->udev->devnum); | 364 | (i & 0xF0)>>4,(i & 0xF), dev->udev->devnum); |
365 | 365 | ||
366 | /* let the user know what node this device is now attached to */ | 366 | /* let the user know what node this device is now attached to */ |
367 | info("USB LCD device now attached to USBLCD-%d", interface->minor); | 367 | dev_info(&interface->dev, "USB LCD device now attached to USBLCD-%d\n", |
368 | interface->minor); | ||
368 | return 0; | 369 | return 0; |
369 | 370 | ||
370 | error: | 371 | error: |
@@ -413,7 +414,7 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
413 | /* decrement our usage count */ | 414 | /* decrement our usage count */ |
414 | kref_put(&dev->kref, lcd_delete); | 415 | kref_put(&dev->kref, lcd_delete); |
415 | 416 | ||
416 | info("USB LCD #%d now disconnected", minor); | 417 | dev_info(&interface->dev, "USB LCD #%d now disconnected\n", minor); |
417 | } | 418 | } |
418 | 419 | ||
419 | static struct usb_driver lcd_driver = { | 420 | static struct usb_driver lcd_driver = { |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c new file mode 100644 index 000000000000..28a6a3a09538 --- /dev/null +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -0,0 +1,394 @@ | |||
1 | /* | ||
2 | * USB 7 Segment Driver | ||
3 | * | ||
4 | * Copyright (C) 2008 Harrison Metzger <harrisonmetz@gmail.com> | ||
5 | * Based on usbled.c by Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation, version 2. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/usb.h> | ||
20 | |||
21 | |||
22 | #define DRIVER_AUTHOR "Harrison Metzger <harrisonmetz@gmail.com>" | ||
23 | #define DRIVER_DESC "USB 7 Segment Driver" | ||
24 | |||
25 | #define VENDOR_ID 0x0fc5 | ||
26 | #define PRODUCT_ID 0x1227 | ||
27 | #define MAXLEN 6 | ||
28 | |||
29 | /* table of devices that work with this driver */ | ||
30 | static struct usb_device_id id_table[] = { | ||
31 | { USB_DEVICE(VENDOR_ID, PRODUCT_ID) }, | ||
32 | { }, | ||
33 | }; | ||
34 | MODULE_DEVICE_TABLE(usb, id_table); | ||
35 | |||
36 | /* the different text display modes the device is capable of */ | ||
37 | static char *display_textmodes[] = {"raw", "hex", "ascii", NULL}; | ||
38 | |||
39 | struct usb_sevsegdev { | ||
40 | struct usb_device *udev; | ||
41 | |||
42 | u8 powered; | ||
43 | u8 mode_msb; | ||
44 | u8 mode_lsb; | ||
45 | u8 decimals[MAXLEN]; | ||
46 | u8 textmode; | ||
47 | u8 text[MAXLEN]; | ||
48 | u16 textlength; | ||
49 | }; | ||
50 | |||
51 | /* sysfs_streq can't replace this completely | ||
52 | * If the device was in hex mode, and the user wanted a 0, | ||
53 | * if str commands are used, we would assume the end of string | ||
54 | * so mem commands are used. | ||
55 | */ | ||
56 | inline size_t my_memlen(const char *buf, size_t count) | ||
57 | { | ||
58 | if (count > 0 && buf[count-1] == '\n') | ||
59 | return count - 1; | ||
60 | else | ||
61 | return count; | ||
62 | } | ||
63 | |||
64 | static void update_display_powered(struct usb_sevsegdev *mydev) | ||
65 | { | ||
66 | int rc; | ||
67 | |||
68 | rc = usb_control_msg(mydev->udev, | ||
69 | usb_sndctrlpipe(mydev->udev, 0), | ||
70 | 0x12, | ||
71 | 0x48, | ||
72 | (80 * 0x100) + 10, /* (power mode) */ | ||
73 | (0x00 * 0x100) + (mydev->powered ? 1 : 0), | ||
74 | NULL, | ||
75 | 0, | ||
76 | 2000); | ||
77 | if (rc < 0) | ||
78 | dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); | ||
79 | } | ||
80 | |||
81 | static void update_display_mode(struct usb_sevsegdev *mydev) | ||
82 | { | ||
83 | int rc; | ||
84 | |||
85 | rc = usb_control_msg(mydev->udev, | ||
86 | usb_sndctrlpipe(mydev->udev, 0), | ||
87 | 0x12, | ||
88 | 0x48, | ||
89 | (82 * 0x100) + 10, /* (set mode) */ | ||
90 | (mydev->mode_msb * 0x100) + mydev->mode_lsb, | ||
91 | NULL, | ||
92 | 0, | ||
93 | 2000); | ||
94 | |||
95 | if (rc < 0) | ||
96 | dev_dbg(&mydev->udev->dev, "mode retval = %d\n", rc); | ||
97 | } | ||
98 | |||
99 | static void update_display_visual(struct usb_sevsegdev *mydev) | ||
100 | { | ||
101 | int rc; | ||
102 | int i; | ||
103 | unsigned char *buffer; | ||
104 | u8 decimals = 0; | ||
105 | |||
106 | buffer = kzalloc(MAXLEN, GFP_KERNEL); | ||
107 | if (!buffer) { | ||
108 | dev_err(&mydev->udev->dev, "out of memory\n"); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | /* The device is right to left, where as you write left to right */ | ||
113 | for (i = 0; i < mydev->textlength; i++) | ||
114 | buffer[i] = mydev->text[mydev->textlength-1-i]; | ||
115 | |||
116 | rc = usb_control_msg(mydev->udev, | ||
117 | usb_sndctrlpipe(mydev->udev, 0), | ||
118 | 0x12, | ||
119 | 0x48, | ||
120 | (85 * 0x100) + 10, /* (write text) */ | ||
121 | (0 * 0x100) + mydev->textmode, /* mode */ | ||
122 | buffer, | ||
123 | mydev->textlength, | ||
124 | 2000); | ||
125 | |||
126 | if (rc < 0) | ||
127 | dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); | ||
128 | |||
129 | kfree(buffer); | ||
130 | |||
131 | /* The device is right to left, where as you write left to right */ | ||
132 | for (i = 0; i < sizeof(mydev->decimals); i++) | ||
133 | decimals |= mydev->decimals[i] << i; | ||
134 | |||
135 | rc = usb_control_msg(mydev->udev, | ||
136 | usb_sndctrlpipe(mydev->udev, 0), | ||
137 | 0x12, | ||
138 | 0x48, | ||
139 | (86 * 0x100) + 10, /* (set decimal) */ | ||
140 | (0 * 0x100) + decimals, /* decimals */ | ||
141 | NULL, | ||
142 | 0, | ||
143 | 2000); | ||
144 | |||
145 | if (rc < 0) | ||
146 | dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); | ||
147 | } | ||
148 | |||
149 | #define MYDEV_ATTR_SIMPLE_UNSIGNED(name, update_fcn) \ | ||
150 | static ssize_t show_attr_##name(struct device *dev, \ | ||
151 | struct device_attribute *attr, char *buf) \ | ||
152 | { \ | ||
153 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
154 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
155 | \ | ||
156 | return sprintf(buf, "%u\n", mydev->name); \ | ||
157 | } \ | ||
158 | \ | ||
159 | static ssize_t set_attr_##name(struct device *dev, \ | ||
160 | struct device_attribute *attr, const char *buf, size_t count) \ | ||
161 | { \ | ||
162 | struct usb_interface *intf = to_usb_interface(dev); \ | ||
163 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); \ | ||
164 | \ | ||
165 | mydev->name = simple_strtoul(buf, NULL, 10); \ | ||
166 | update_fcn(mydev); \ | ||
167 | \ | ||
168 | return count; \ | ||
169 | } \ | ||
170 | static DEVICE_ATTR(name, S_IWUGO | S_IRUGO, show_attr_##name, set_attr_##name); | ||
171 | |||
172 | static ssize_t show_attr_text(struct device *dev, | ||
173 | struct device_attribute *attr, char *buf) | ||
174 | { | ||
175 | struct usb_interface *intf = to_usb_interface(dev); | ||
176 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
177 | |||
178 | return snprintf(buf, mydev->textlength, "%s\n", mydev->text); | ||
179 | } | ||
180 | |||
181 | static ssize_t set_attr_text(struct device *dev, | ||
182 | struct device_attribute *attr, const char *buf, size_t count) | ||
183 | { | ||
184 | struct usb_interface *intf = to_usb_interface(dev); | ||
185 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
186 | size_t end = my_memlen(buf, count); | ||
187 | |||
188 | if (end > sizeof(mydev->text)) | ||
189 | return -EINVAL; | ||
190 | |||
191 | memset(mydev->text, 0, sizeof(mydev->text)); | ||
192 | mydev->textlength = end; | ||
193 | |||
194 | if (end > 0) | ||
195 | memcpy(mydev->text, buf, end); | ||
196 | |||
197 | update_display_visual(mydev); | ||
198 | return count; | ||
199 | } | ||
200 | |||
201 | static DEVICE_ATTR(text, S_IWUGO | S_IRUGO, show_attr_text, set_attr_text); | ||
202 | |||
203 | static ssize_t show_attr_decimals(struct device *dev, | ||
204 | struct device_attribute *attr, char *buf) | ||
205 | { | ||
206 | struct usb_interface *intf = to_usb_interface(dev); | ||
207 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
208 | int i; | ||
209 | int pos; | ||
210 | |||
211 | for (i = 0; i < sizeof(mydev->decimals); i++) { | ||
212 | pos = sizeof(mydev->decimals) - 1 - i; | ||
213 | if (mydev->decimals[i] == 0) | ||
214 | buf[pos] = '0'; | ||
215 | else if (mydev->decimals[i] == 1) | ||
216 | buf[pos] = '1'; | ||
217 | else | ||
218 | buf[pos] = 'x'; | ||
219 | } | ||
220 | |||
221 | buf[sizeof(mydev->decimals)] = '\n'; | ||
222 | return sizeof(mydev->decimals) + 1; | ||
223 | } | ||
224 | |||
225 | static ssize_t set_attr_decimals(struct device *dev, | ||
226 | struct device_attribute *attr, const char *buf, size_t count) | ||
227 | { | ||
228 | struct usb_interface *intf = to_usb_interface(dev); | ||
229 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
230 | size_t end = my_memlen(buf, count); | ||
231 | int i; | ||
232 | |||
233 | if (end > sizeof(mydev->decimals)) | ||
234 | return -EINVAL; | ||
235 | |||
236 | for (i = 0; i < end; i++) | ||
237 | if (buf[i] != '0' && buf[i] != '1') | ||
238 | return -EINVAL; | ||
239 | |||
240 | memset(mydev->decimals, 0, sizeof(mydev->decimals)); | ||
241 | for (i = 0; i < end; i++) | ||
242 | if (buf[i] == '1') | ||
243 | mydev->decimals[end-1-i] = 1; | ||
244 | |||
245 | update_display_visual(mydev); | ||
246 | |||
247 | return count; | ||
248 | } | ||
249 | |||
250 | static DEVICE_ATTR(decimals, S_IWUGO | S_IRUGO, | ||
251 | show_attr_decimals, set_attr_decimals); | ||
252 | |||
253 | static ssize_t show_attr_textmode(struct device *dev, | ||
254 | struct device_attribute *attr, char *buf) | ||
255 | { | ||
256 | struct usb_interface *intf = to_usb_interface(dev); | ||
257 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
258 | int i; | ||
259 | |||
260 | buf[0] = 0; | ||
261 | |||
262 | for (i = 0; display_textmodes[i]; i++) { | ||
263 | if (mydev->textmode == i) { | ||
264 | strcat(buf, " ["); | ||
265 | strcat(buf, display_textmodes[i]); | ||
266 | strcat(buf, "] "); | ||
267 | } else { | ||
268 | strcat(buf, " "); | ||
269 | strcat(buf, display_textmodes[i]); | ||
270 | strcat(buf, " "); | ||
271 | } | ||
272 | } | ||
273 | strcat(buf, "\n"); | ||
274 | |||
275 | |||
276 | return strlen(buf); | ||
277 | } | ||
278 | |||
279 | static ssize_t set_attr_textmode(struct device *dev, | ||
280 | struct device_attribute *attr, const char *buf, size_t count) | ||
281 | { | ||
282 | struct usb_interface *intf = to_usb_interface(dev); | ||
283 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | ||
284 | int i; | ||
285 | |||
286 | for (i = 0; display_textmodes[i]; i++) { | ||
287 | if (sysfs_streq(display_textmodes[i], buf)) { | ||
288 | mydev->textmode = i; | ||
289 | update_display_visual(mydev); | ||
290 | return count; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | return -EINVAL; | ||
295 | } | ||
296 | |||
297 | static DEVICE_ATTR(textmode, S_IWUGO | S_IRUGO, | ||
298 | show_attr_textmode, set_attr_textmode); | ||
299 | |||
300 | |||
301 | MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); | ||
302 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_msb, update_display_mode); | ||
303 | MYDEV_ATTR_SIMPLE_UNSIGNED(mode_lsb, update_display_mode); | ||
304 | |||
305 | static struct attribute *dev_attrs[] = { | ||
306 | &dev_attr_powered.attr, | ||
307 | &dev_attr_text.attr, | ||
308 | &dev_attr_textmode.attr, | ||
309 | &dev_attr_decimals.attr, | ||
310 | &dev_attr_mode_msb.attr, | ||
311 | &dev_attr_mode_lsb.attr, | ||
312 | NULL | ||
313 | }; | ||
314 | |||
315 | static struct attribute_group dev_attr_grp = { | ||
316 | .attrs = dev_attrs, | ||
317 | }; | ||
318 | |||
319 | static int sevseg_probe(struct usb_interface *interface, | ||
320 | const struct usb_device_id *id) | ||
321 | { | ||
322 | struct usb_device *udev = interface_to_usbdev(interface); | ||
323 | struct usb_sevsegdev *mydev = NULL; | ||
324 | int rc = -ENOMEM; | ||
325 | |||
326 | mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL); | ||
327 | if (mydev == NULL) { | ||
328 | dev_err(&interface->dev, "Out of memory\n"); | ||
329 | goto error_mem; | ||
330 | } | ||
331 | |||
332 | mydev->udev = usb_get_dev(udev); | ||
333 | usb_set_intfdata(interface, mydev); | ||
334 | |||
335 | /*set defaults */ | ||
336 | mydev->textmode = 0x02; /* ascii mode */ | ||
337 | mydev->mode_msb = 0x06; /* 6 characters */ | ||
338 | mydev->mode_lsb = 0x3f; /* scanmode for 6 chars */ | ||
339 | |||
340 | rc = sysfs_create_group(&interface->dev.kobj, &dev_attr_grp); | ||
341 | if (rc) | ||
342 | goto error; | ||
343 | |||
344 | dev_info(&interface->dev, "USB 7 Segment device now attached\n"); | ||
345 | return 0; | ||
346 | |||
347 | error: | ||
348 | usb_set_intfdata(interface, NULL); | ||
349 | usb_put_dev(mydev->udev); | ||
350 | kfree(mydev); | ||
351 | error_mem: | ||
352 | return rc; | ||
353 | } | ||
354 | |||
355 | static void sevseg_disconnect(struct usb_interface *interface) | ||
356 | { | ||
357 | struct usb_sevsegdev *mydev; | ||
358 | |||
359 | mydev = usb_get_intfdata(interface); | ||
360 | sysfs_remove_group(&interface->dev.kobj, &dev_attr_grp); | ||
361 | usb_set_intfdata(interface, NULL); | ||
362 | usb_put_dev(mydev->udev); | ||
363 | kfree(mydev); | ||
364 | dev_info(&interface->dev, "USB 7 Segment now disconnected\n"); | ||
365 | } | ||
366 | |||
367 | static struct usb_driver sevseg_driver = { | ||
368 | .name = "usbsevseg", | ||
369 | .probe = sevseg_probe, | ||
370 | .disconnect = sevseg_disconnect, | ||
371 | .id_table = id_table, | ||
372 | }; | ||
373 | |||
374 | static int __init usb_sevseg_init(void) | ||
375 | { | ||
376 | int rc = 0; | ||
377 | |||
378 | rc = usb_register(&sevseg_driver); | ||
379 | if (rc) | ||
380 | err("usb_register failed. Error number %d", rc); | ||
381 | return rc; | ||
382 | } | ||
383 | |||
384 | static void __exit usb_sevseg_exit(void) | ||
385 | { | ||
386 | usb_deregister(&sevseg_driver); | ||
387 | } | ||
388 | |||
389 | module_init(usb_sevseg_init); | ||
390 | module_exit(usb_sevseg_exit); | ||
391 | |||
392 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
393 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
394 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index f1255b0a182d..9a6c27a01793 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -228,11 +228,12 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha | |||
228 | ret = rq->urb->status; | 228 | ret = rq->urb->status; |
229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; | 229 | *val = priv->reg[(reg >= 9) ? 0 : regindex[reg]]; |
230 | if (ret) | 230 | if (ret) |
231 | warn("get_1284_register: usb error %d", ret); | 231 | printk(KERN_WARNING "get_1284_register: " |
232 | "usb error %d\n", ret); | ||
232 | kref_put(&rq->ref_count, destroy_async); | 233 | kref_put(&rq->ref_count, destroy_async); |
233 | return ret; | 234 | return ret; |
234 | } | 235 | } |
235 | warn("get_1284_register timeout"); | 236 | printk(KERN_WARNING "get_1284_register timeout\n"); |
236 | kill_all_async_requests_priv(priv); | 237 | kill_all_async_requests_priv(priv); |
237 | return -EIO; | 238 | return -EIO; |
238 | } | 239 | } |
@@ -716,7 +717,7 @@ static int uss720_probe(struct usb_interface *intf, | |||
716 | spin_lock_init(&priv->asynclock); | 717 | spin_lock_init(&priv->asynclock); |
717 | INIT_LIST_HEAD(&priv->asynclist); | 718 | INIT_LIST_HEAD(&priv->asynclist); |
718 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { | 719 | if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { |
719 | warn("could not register parport"); | 720 | printk(KERN_WARNING "uss720: could not register parport\n"); |
720 | goto probe_abort; | 721 | goto probe_abort; |
721 | } | 722 | } |
722 | 723 | ||
@@ -800,10 +801,14 @@ static int __init uss720_init(void) | |||
800 | if (retval) | 801 | if (retval) |
801 | goto out; | 802 | goto out; |
802 | 803 | ||
803 | info(DRIVER_VERSION ":" DRIVER_DESC); | 804 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
804 | info("NOTE: this is a special purpose driver to allow nonstandard"); | 805 | DRIVER_DESC "\n"); |
805 | info("protocols (eg. bitbang) over USS720 usb to parallel cables"); | 806 | printk(KERN_INFO KBUILD_MODNAME ": NOTE: this is a special purpose " |
806 | info("If you just want to connect to a printer, use usblp instead"); | 807 | "driver to allow nonstandard\n"); |
808 | printk(KERN_INFO KBUILD_MODNAME ": protocols (eg. bitbang) over " | ||
809 | "USS720 usb to parallel cables\n"); | ||
810 | printk(KERN_INFO KBUILD_MODNAME ": If you just want to connect to a " | ||
811 | "printer, use usblp instead\n"); | ||
807 | out: | 812 | out: |
808 | return retval; | 813 | return retval; |
809 | } | 814 | } |
diff --git a/drivers/usb/misc/vstusb.c b/drivers/usb/misc/vstusb.c new file mode 100644 index 000000000000..8648470c81ca --- /dev/null +++ b/drivers/usb/misc/vstusb.c | |||
@@ -0,0 +1,782 @@ | |||
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 | dev_err(&dev->dev, "%s: can't copy_from_user\n", __func__); | ||
405 | retval = -EFAULT; | ||
406 | goto exit; | ||
407 | } | ||
408 | |||
409 | usb_anchor_urb(urb, &vstdev->submitted); | ||
410 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buf, count, &done); | ||
411 | mutex_unlock(&vstdev->lock); | ||
412 | if (retval) { | ||
413 | usb_unanchor_urb(urb); | ||
414 | dev_err(&dev->dev, "%s: error %d filling and sending urb %d\n", | ||
415 | __func__, retval, pipe); | ||
416 | goto exit; | ||
417 | } | ||
418 | |||
419 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
420 | if (retval) { | ||
421 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
422 | __func__, retval, pipe); | ||
423 | goto exit; | ||
424 | } else { | ||
425 | retval = cnt; | ||
426 | dev_dbg(&dev->dev, "%s: sent %d bytes to pipe %d\n", | ||
427 | __func__, cnt, pipe); | ||
428 | } | ||
429 | |||
430 | exit: | ||
431 | usb_free_urb(urb); | ||
432 | kfree(buf); | ||
433 | return retval; | ||
434 | } | ||
435 | |||
436 | static long vstusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
437 | { | ||
438 | int retval = 0; | ||
439 | int cnt = -1; | ||
440 | void __user *data = (void __user *)arg; | ||
441 | struct vstusb_args usb_data; | ||
442 | |||
443 | struct vstusb_device *vstdev; | ||
444 | void *buffer = NULL; /* must be initialized. buffer is | ||
445 | * referenced on exit but not all | ||
446 | * ioctls allocate it */ | ||
447 | |||
448 | struct urb *urb = NULL; /* must be initialized. urb is | ||
449 | * referenced on exit but not all | ||
450 | * ioctls allocate it */ | ||
451 | struct usb_device *dev; | ||
452 | unsigned int pipe; | ||
453 | int timeout; | ||
454 | |||
455 | DECLARE_COMPLETION_ONSTACK(done); | ||
456 | |||
457 | vstdev = file->private_data; | ||
458 | |||
459 | if (_IOC_TYPE(cmd) != VST_IOC_MAGIC) { | ||
460 | dev_warn(&vstdev->usb_dev->dev, | ||
461 | "%s: ioctl command %x, bad ioctl magic %x, " | ||
462 | "expected %x\n", __func__, cmd, | ||
463 | _IOC_TYPE(cmd), VST_IOC_MAGIC); | ||
464 | return -EINVAL; | ||
465 | } | ||
466 | |||
467 | if (vstdev == NULL) | ||
468 | return -ENODEV; | ||
469 | |||
470 | if (copy_from_user(&usb_data, data, sizeof(struct vstusb_args))) { | ||
471 | dev_err(&vstdev->usb_dev->dev, "%s: can't copy_from_user\n", | ||
472 | __func__); | ||
473 | return -EFAULT; | ||
474 | } | ||
475 | |||
476 | /* lock this object */ | ||
477 | if (mutex_lock_interruptible(&vstdev->lock)) { | ||
478 | retval = -ERESTARTSYS; | ||
479 | goto exit; | ||
480 | } | ||
481 | |||
482 | /* anyone home */ | ||
483 | if (!vstdev->present) { | ||
484 | mutex_unlock(&vstdev->lock); | ||
485 | dev_err(&vstdev->usb_dev->dev, "%s: device not present\n", | ||
486 | __func__); | ||
487 | retval = -ENODEV; | ||
488 | goto exit; | ||
489 | } | ||
490 | |||
491 | /* pull out the necessary data */ | ||
492 | dev = vstdev->usb_dev; | ||
493 | |||
494 | switch (cmd) { | ||
495 | |||
496 | case IOCTL_VSTUSB_CONFIG_RW: | ||
497 | |||
498 | vstdev->rd_pipe = usb_data.rd_pipe; | ||
499 | vstdev->rd_timeout_ms = usb_data.rd_timeout_ms; | ||
500 | vstdev->wr_pipe = usb_data.wr_pipe; | ||
501 | vstdev->wr_timeout_ms = usb_data.wr_timeout_ms; | ||
502 | |||
503 | mutex_unlock(&vstdev->lock); | ||
504 | |||
505 | dev_dbg(&dev->dev, "%s: setting pipes/timeouts, " | ||
506 | "rdpipe = %d, rdtimeout = %d, " | ||
507 | "wrpipe = %d, wrtimeout = %d\n", __func__, | ||
508 | vstdev->rd_pipe, vstdev->rd_timeout_ms, | ||
509 | vstdev->wr_pipe, vstdev->wr_timeout_ms); | ||
510 | break; | ||
511 | |||
512 | case IOCTL_VSTUSB_SEND_PIPE: | ||
513 | |||
514 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
515 | mutex_unlock(&vstdev->lock); | ||
516 | retval = -EINVAL; | ||
517 | goto exit; | ||
518 | } | ||
519 | |||
520 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
521 | if (buffer == NULL) { | ||
522 | mutex_unlock(&vstdev->lock); | ||
523 | retval = -ENOMEM; | ||
524 | goto exit; | ||
525 | } | ||
526 | |||
527 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
528 | if (!urb) { | ||
529 | mutex_unlock(&vstdev->lock); | ||
530 | retval = -ENOMEM; | ||
531 | goto exit; | ||
532 | } | ||
533 | |||
534 | timeout = usb_data.timeout_ms; | ||
535 | |||
536 | pipe = usb_sndbulkpipe(dev, usb_data.pipe); | ||
537 | |||
538 | if (copy_from_user(buffer, usb_data.buffer, usb_data.count)) { | ||
539 | dev_err(&dev->dev, "%s: can't copy_from_user\n", | ||
540 | __func__); | ||
541 | mutex_unlock(&vstdev->lock); | ||
542 | retval = -EFAULT; | ||
543 | goto exit; | ||
544 | } | ||
545 | |||
546 | usb_anchor_urb(urb, &vstdev->submitted); | ||
547 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
548 | usb_data.count, &done); | ||
549 | mutex_unlock(&vstdev->lock); | ||
550 | if (retval) { | ||
551 | usb_unanchor_urb(urb); | ||
552 | dev_err(&dev->dev, | ||
553 | "%s: error %d filling and sending urb %d\n", | ||
554 | __func__, retval, pipe); | ||
555 | goto exit; | ||
556 | } | ||
557 | |||
558 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
559 | if (retval) { | ||
560 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
561 | __func__, retval, pipe); | ||
562 | } | ||
563 | |||
564 | break; | ||
565 | case IOCTL_VSTUSB_RECV_PIPE: | ||
566 | |||
567 | if ((usb_data.count == 0) || (usb_data.count > VST_MAXBUFFER)) { | ||
568 | mutex_unlock(&vstdev->lock); | ||
569 | retval = -EINVAL; | ||
570 | goto exit; | ||
571 | } | ||
572 | |||
573 | buffer = kmalloc(usb_data.count, GFP_KERNEL); | ||
574 | if (buffer == NULL) { | ||
575 | mutex_unlock(&vstdev->lock); | ||
576 | retval = -ENOMEM; | ||
577 | goto exit; | ||
578 | } | ||
579 | |||
580 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
581 | if (!urb) { | ||
582 | mutex_unlock(&vstdev->lock); | ||
583 | retval = -ENOMEM; | ||
584 | goto exit; | ||
585 | } | ||
586 | |||
587 | timeout = usb_data.timeout_ms; | ||
588 | |||
589 | pipe = usb_rcvbulkpipe(dev, usb_data.pipe); | ||
590 | |||
591 | usb_anchor_urb(urb, &vstdev->submitted); | ||
592 | retval = vstusb_fill_and_send_urb(urb, dev, pipe, buffer, | ||
593 | usb_data.count, &done); | ||
594 | mutex_unlock(&vstdev->lock); | ||
595 | if (retval) { | ||
596 | usb_unanchor_urb(urb); | ||
597 | dev_err(&dev->dev, | ||
598 | "%s: error %d filling and sending urb %d\n", | ||
599 | __func__, retval, pipe); | ||
600 | goto exit; | ||
601 | } | ||
602 | |||
603 | retval = vstusb_complete_urb(urb, &done, timeout, &cnt); | ||
604 | if (retval) { | ||
605 | dev_err(&dev->dev, "%s: error %d completing urb %d\n", | ||
606 | __func__, retval, pipe); | ||
607 | goto exit; | ||
608 | } | ||
609 | |||
610 | if (copy_to_user(usb_data.buffer, buffer, cnt)) { | ||
611 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
612 | __func__); | ||
613 | retval = -EFAULT; | ||
614 | goto exit; | ||
615 | } | ||
616 | |||
617 | usb_data.count = cnt; | ||
618 | if (copy_to_user(data, &usb_data, sizeof(struct vstusb_args))) { | ||
619 | dev_err(&dev->dev, "%s: can't copy_to_user\n", | ||
620 | __func__); | ||
621 | retval = -EFAULT; | ||
622 | } else { | ||
623 | dev_dbg(&dev->dev, "%s: recv %d bytes from pipe %d\n", | ||
624 | __func__, usb_data.count, usb_data.pipe); | ||
625 | } | ||
626 | |||
627 | break; | ||
628 | |||
629 | default: | ||
630 | mutex_unlock(&vstdev->lock); | ||
631 | dev_warn(&dev->dev, "ioctl_vstusb: invalid ioctl cmd %x\n", | ||
632 | cmd); | ||
633 | return -EINVAL; | ||
634 | break; | ||
635 | } | ||
636 | exit: | ||
637 | usb_free_urb(urb); | ||
638 | kfree(buffer); | ||
639 | return retval; | ||
640 | } | ||
641 | |||
642 | static const struct file_operations vstusb_fops = { | ||
643 | .owner = THIS_MODULE, | ||
644 | .read = vstusb_read, | ||
645 | .write = vstusb_write, | ||
646 | .unlocked_ioctl = vstusb_ioctl, | ||
647 | .compat_ioctl = vstusb_ioctl, | ||
648 | .open = vstusb_open, | ||
649 | .release = vstusb_release, | ||
650 | }; | ||
651 | |||
652 | static struct usb_class_driver usb_vstusb_class = { | ||
653 | .name = "usb/vstusb%d", | ||
654 | .fops = &vstusb_fops, | ||
655 | .minor_base = VSTUSB_MINOR_BASE, | ||
656 | }; | ||
657 | |||
658 | static int vstusb_probe(struct usb_interface *intf, | ||
659 | const struct usb_device_id *id) | ||
660 | { | ||
661 | struct usb_device *dev = interface_to_usbdev(intf); | ||
662 | struct vstusb_device *vstdev; | ||
663 | int i; | ||
664 | int retval = 0; | ||
665 | |||
666 | /* allocate memory for our device state and intialize it */ | ||
667 | |||
668 | vstdev = kzalloc(sizeof(*vstdev), GFP_KERNEL); | ||
669 | if (vstdev == NULL) | ||
670 | return -ENOMEM; | ||
671 | |||
672 | /* must do usb_get_dev() prior to kref_init() since the kref_put() | ||
673 | * release function will do a usb_put_dev() */ | ||
674 | usb_get_dev(dev); | ||
675 | kref_init(&vstdev->kref); | ||
676 | mutex_init(&vstdev->lock); | ||
677 | |||
678 | i = dev->descriptor.bcdDevice; | ||
679 | |||
680 | dev_dbg(&intf->dev, "Version %1d%1d.%1d%1d found at address %d\n", | ||
681 | (i & 0xF000) >> 12, (i & 0xF00) >> 8, | ||
682 | (i & 0xF0) >> 4, (i & 0xF), dev->devnum); | ||
683 | |||
684 | vstdev->present = 1; | ||
685 | vstdev->isopen = 0; | ||
686 | vstdev->usb_dev = dev; | ||
687 | init_usb_anchor(&vstdev->submitted); | ||
688 | |||
689 | usb_set_intfdata(intf, vstdev); | ||
690 | retval = usb_register_dev(intf, &usb_vstusb_class); | ||
691 | if (retval) { | ||
692 | dev_err(&intf->dev, | ||
693 | "%s: Not able to get a minor for this device.\n", | ||
694 | __func__); | ||
695 | usb_set_intfdata(intf, NULL); | ||
696 | kref_put(&vstdev->kref, vstusb_delete); | ||
697 | return retval; | ||
698 | } | ||
699 | |||
700 | /* let the user know what node this device is now attached to */ | ||
701 | dev_info(&intf->dev, | ||
702 | "VST USB Device #%d now attached to major %d minor %d\n", | ||
703 | (intf->minor - VSTUSB_MINOR_BASE), USB_MAJOR, intf->minor); | ||
704 | |||
705 | dev_info(&intf->dev, "%s, %s\n", DRIVER_DESC, DRIVER_VERSION); | ||
706 | |||
707 | return retval; | ||
708 | } | ||
709 | |||
710 | static void vstusb_disconnect(struct usb_interface *intf) | ||
711 | { | ||
712 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
713 | |||
714 | usb_deregister_dev(intf, &usb_vstusb_class); | ||
715 | usb_set_intfdata(intf, NULL); | ||
716 | |||
717 | if (vstdev) { | ||
718 | |||
719 | mutex_lock(&vstdev->lock); | ||
720 | vstdev->present = 0; | ||
721 | |||
722 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
723 | |||
724 | mutex_unlock(&vstdev->lock); | ||
725 | |||
726 | kref_put(&vstdev->kref, vstusb_delete); | ||
727 | } | ||
728 | |||
729 | } | ||
730 | |||
731 | static int vstusb_suspend(struct usb_interface *intf, pm_message_t message) | ||
732 | { | ||
733 | struct vstusb_device *vstdev = usb_get_intfdata(intf); | ||
734 | int time; | ||
735 | if (!vstdev) | ||
736 | return 0; | ||
737 | |||
738 | mutex_lock(&vstdev->lock); | ||
739 | time = usb_wait_anchor_empty_timeout(&vstdev->submitted, 1000); | ||
740 | if (!time) | ||
741 | usb_kill_anchored_urbs(&vstdev->submitted); | ||
742 | mutex_unlock(&vstdev->lock); | ||
743 | |||
744 | return 0; | ||
745 | } | ||
746 | |||
747 | static int vstusb_resume(struct usb_interface *intf) | ||
748 | { | ||
749 | return 0; | ||
750 | } | ||
751 | |||
752 | static struct usb_driver vstusb_driver = { | ||
753 | .name = "vstusb", | ||
754 | .probe = vstusb_probe, | ||
755 | .disconnect = vstusb_disconnect, | ||
756 | .suspend = vstusb_suspend, | ||
757 | .resume = vstusb_resume, | ||
758 | .id_table = id_table, | ||
759 | }; | ||
760 | |||
761 | static int __init vstusb_init(void) | ||
762 | { | ||
763 | int rc; | ||
764 | |||
765 | rc = usb_register(&vstusb_driver); | ||
766 | if (rc) | ||
767 | printk(KERN_ERR "%s: failed to register (%d)", __func__, rc); | ||
768 | |||
769 | return rc; | ||
770 | } | ||
771 | |||
772 | static void __exit vstusb_exit(void) | ||
773 | { | ||
774 | usb_deregister(&vstusb_driver); | ||
775 | } | ||
776 | |||
777 | module_init(vstusb_init); | ||
778 | module_exit(vstusb_exit); | ||
779 | |||
780 | MODULE_AUTHOR("Dennis O'Brien/Stephen Ware"); | ||
781 | MODULE_DESCRIPTION(DRIVER_VERSION); | ||
782 | MODULE_LICENSE("GPL"); | ||