aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:25:44 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:25:44 -0500
commitc6c88bbde4d8b2ffe9886b7130b2e23781d424e5 (patch)
tree47c2b61983acc6fbc42d89813729b87bbaf2aed9 /drivers/usb/class
parent0356dbb7fe87ba59558902e536d9f960e87353c1 (diff)
parentc8dd7709c534ab0d713aa698c99132b6c812b57c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
Diffstat (limited to 'drivers/usb/class')
-rw-r--r--drivers/usb/class/audio.c1
-rw-r--r--drivers/usb/class/cdc-acm.c232
-rw-r--r--drivers/usb/class/cdc-acm.h33
-rw-r--r--drivers/usb/class/usb-midi.c1
-rw-r--r--drivers/usb/class/usblp.c45
5 files changed, 217 insertions, 95 deletions
diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
index 50858273f8d3..3ad9ee8b84a9 100644
--- a/drivers/usb/class/audio.c
+++ b/drivers/usb/class/audio.c
@@ -2732,7 +2732,6 @@ static struct usb_device_id usb_audio_ids [] = {
2732MODULE_DEVICE_TABLE (usb, usb_audio_ids); 2732MODULE_DEVICE_TABLE (usb, usb_audio_ids);
2733 2733
2734static struct usb_driver usb_audio_driver = { 2734static struct usb_driver usb_audio_driver = {
2735 .owner = THIS_MODULE,
2736 .name = "audio", 2735 .name = "audio",
2737 .probe = usb_audio_probe, 2736 .probe = usb_audio_probe,
2738 .disconnect = usb_audio_disconnect, 2737 .disconnect = usb_audio_disconnect,
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 1b4751412970..248279e44c99 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -6,6 +6,7 @@
6 * Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com> 6 * Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com>
7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz> 7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
8 * Copyright (c) 2004 Oliver Neukum <oliver@neukum.name> 8 * Copyright (c) 2004 Oliver Neukum <oliver@neukum.name>
9 * Copyright (c) 2005 David Kubicek <dave@awk.cz>
9 * 10 *
10 * USB Abstract Control Model driver for USB modems and ISDN adapters 11 * USB Abstract Control Model driver for USB modems and ISDN adapters
11 * 12 *
@@ -29,6 +30,7 @@
29 * config we want, sysadmin changes bConfigurationValue in sysfs. 30 * config we want, sysadmin changes bConfigurationValue in sysfs.
30 * v0.23 - use softirq for rx processing, as needed by tty layer 31 * v0.23 - use softirq for rx processing, as needed by tty layer
31 * v0.24 - change probe method to evaluate CDC union descriptor 32 * v0.24 - change probe method to evaluate CDC union descriptor
33 * v0.25 - downstream tasks paralelized to maximize throughput
32 */ 34 */
33 35
34/* 36/*
@@ -63,14 +65,15 @@
63#include <linux/usb_cdc.h> 65#include <linux/usb_cdc.h>
64#include <asm/byteorder.h> 66#include <asm/byteorder.h>
65#include <asm/unaligned.h> 67#include <asm/unaligned.h>
68#include <linux/list.h>
66 69
67#include "cdc-acm.h" 70#include "cdc-acm.h"
68 71
69/* 72/*
70 * Version Information 73 * Version Information
71 */ 74 */
72#define DRIVER_VERSION "v0.23" 75#define DRIVER_VERSION "v0.25"
73#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik" 76#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek"
74#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" 77#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
75 78
76static struct usb_driver acm_driver; 79static struct usb_driver acm_driver;
@@ -284,7 +287,9 @@ exit:
284/* data interface returns incoming bytes, or we got unthrottled */ 287/* data interface returns incoming bytes, or we got unthrottled */
285static void acm_read_bulk(struct urb *urb, struct pt_regs *regs) 288static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
286{ 289{
287 struct acm *acm = urb->context; 290 struct acm_rb *buf;
291 struct acm_ru *rcv = urb->context;
292 struct acm *acm = rcv->instance;
288 dbg("Entering acm_read_bulk with status %d\n", urb->status); 293 dbg("Entering acm_read_bulk with status %d\n", urb->status);
289 294
290 if (!ACM_READY(acm)) 295 if (!ACM_READY(acm))
@@ -293,49 +298,109 @@ static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
293 if (urb->status) 298 if (urb->status)
294 dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status); 299 dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status);
295 300
296 /* calling tty_flip_buffer_push() in_irq() isn't allowed */ 301 buf = rcv->buffer;
297 tasklet_schedule(&acm->bh); 302 buf->size = urb->actual_length;
303
304 spin_lock(&acm->read_lock);
305 list_add_tail(&rcv->list, &acm->spare_read_urbs);
306 list_add_tail(&buf->list, &acm->filled_read_bufs);
307 spin_unlock(&acm->read_lock);
308
309 tasklet_schedule(&acm->urb_task);
298} 310}
299 311
300static void acm_rx_tasklet(unsigned long _acm) 312static void acm_rx_tasklet(unsigned long _acm)
301{ 313{
302 struct acm *acm = (void *)_acm; 314 struct acm *acm = (void *)_acm;
303 struct urb *urb = acm->readurb; 315 struct acm_rb *buf;
304 struct tty_struct *tty = acm->tty; 316 struct tty_struct *tty = acm->tty;
305 unsigned char *data = urb->transfer_buffer; 317 struct acm_ru *rcv;
318 //unsigned long flags;
306 int i = 0; 319 int i = 0;
307 dbg("Entering acm_rx_tasklet"); 320 dbg("Entering acm_rx_tasklet");
308 321
309 if (urb->actual_length > 0 && !acm->throttle) { 322 if (!ACM_READY(acm) || acm->throttle)
310 for (i = 0; i < urb->actual_length && !acm->throttle; i++) { 323 return;
311 /* if we insert more than TTY_FLIPBUF_SIZE characters, 324
312 * we drop them. */ 325next_buffer:
313 if (tty->flip.count >= TTY_FLIPBUF_SIZE) { 326 spin_lock(&acm->read_lock);
314 tty_flip_buffer_push(tty); 327 if (list_empty(&acm->filled_read_bufs)) {
315 } 328 spin_unlock(&acm->read_lock);
316 tty_insert_flip_char(tty, data[i], 0); 329 goto urbs;
317 }
318 dbg("Handed %d bytes to tty layer", i+1);
319 tty_flip_buffer_push(tty);
320 } 330 }
331 buf = list_entry(acm->filled_read_bufs.next,
332 struct acm_rb, list);
333 list_del(&buf->list);
334 spin_unlock(&acm->read_lock);
335
336 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d\n", buf, buf->size);
337
338 for (i = 0; i < buf->size && !acm->throttle; i++) {
339 /* if we insert more than TTY_FLIPBUF_SIZE characters,
340 we drop them. */
341 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
342 tty_flip_buffer_push(tty);
343 }
344 tty_insert_flip_char(tty, buf->base[i], 0);
345 }
346 tty_flip_buffer_push(tty);
321 347
322 spin_lock(&acm->throttle_lock); 348 spin_lock(&acm->throttle_lock);
323 if (acm->throttle) { 349 if (acm->throttle) {
324 dbg("Throtteling noticed"); 350 dbg("Throtteling noticed");
325 memmove(data, data + i, urb->actual_length - i); 351 memmove(buf->base, buf->base + i, buf->size - i);
326 urb->actual_length -= i; 352 buf->size -= i;
327 acm->resubmit_to_unthrottle = 1;
328 spin_unlock(&acm->throttle_lock); 353 spin_unlock(&acm->throttle_lock);
354 spin_lock(&acm->read_lock);
355 list_add(&buf->list, &acm->filled_read_bufs);
356 spin_unlock(&acm->read_lock);
329 return; 357 return;
330 } 358 }
331 spin_unlock(&acm->throttle_lock); 359 spin_unlock(&acm->throttle_lock);
332 360
333 urb->actual_length = 0; 361 spin_lock(&acm->read_lock);
334 urb->dev = acm->dev; 362 list_add(&buf->list, &acm->spare_read_bufs);
335 363 spin_unlock(&acm->read_lock);
336 i = usb_submit_urb(urb, GFP_ATOMIC); 364 goto next_buffer;
337 if (i) 365
338 dev_dbg(&acm->data->dev, "bulk rx resubmit %d\n", i); 366urbs:
367 while (!list_empty(&acm->spare_read_bufs)) {
368 spin_lock(&acm->read_lock);
369 if (list_empty(&acm->spare_read_urbs)) {
370 spin_unlock(&acm->read_lock);
371 return;
372 }
373 rcv = list_entry(acm->spare_read_urbs.next,
374 struct acm_ru, list);
375 list_del(&rcv->list);
376 spin_unlock(&acm->read_lock);
377
378 buf = list_entry(acm->spare_read_bufs.next,
379 struct acm_rb, list);
380 list_del(&buf->list);
381
382 rcv->buffer = buf;
383
384 usb_fill_bulk_urb(rcv->urb, acm->dev,
385 acm->rx_endpoint,
386 buf->base,
387 acm->readsize,
388 acm_read_bulk, rcv);
389 rcv->urb->transfer_dma = buf->dma;
390 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
391
392 dbg("acm_rx_tasklet: sending urb 0x%p, rcv 0x%p, buf 0x%p\n", rcv->urb, rcv, buf);
393
394 /* This shouldn't kill the driver as unsuccessful URBs are returned to the
395 free-urbs-pool and resubmited ASAP */
396 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
397 list_add(&buf->list, &acm->spare_read_bufs);
398 spin_lock(&acm->read_lock);
399 list_add(&rcv->list, &acm->spare_read_urbs);
400 spin_unlock(&acm->read_lock);
401 return;
402 }
403 }
339} 404}
340 405
341/* data interface wrote those outgoing bytes */ 406/* data interface wrote those outgoing bytes */
@@ -369,6 +434,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
369{ 434{
370 struct acm *acm; 435 struct acm *acm;
371 int rv = -EINVAL; 436 int rv = -EINVAL;
437 int i;
372 dbg("Entering acm_tty_open.\n"); 438 dbg("Entering acm_tty_open.\n");
373 439
374 down(&open_sem); 440 down(&open_sem);
@@ -382,7 +448,9 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
382 tty->driver_data = acm; 448 tty->driver_data = acm;
383 acm->tty = tty; 449 acm->tty = tty;
384 450
385 451 /* force low_latency on so that our tty_push actually forces the data through,
452 otherwise it is scheduled, and with high data rates data can get lost. */
453 tty->low_latency = 1;
386 454
387 if (acm->used++) { 455 if (acm->used++) {
388 goto done; 456 goto done;
@@ -394,18 +462,20 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
394 goto bail_out; 462 goto bail_out;
395 } 463 }
396 464
397 acm->readurb->dev = acm->dev;
398 if (usb_submit_urb(acm->readurb, GFP_KERNEL)) {
399 dbg("usb_submit_urb(read bulk) failed");
400 goto bail_out_and_unlink;
401 }
402
403 if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS)) 465 if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS))
404 goto full_bailout; 466 goto full_bailout;
405 467
406 /* force low_latency on so that our tty_push actually forces the data through, 468 INIT_LIST_HEAD(&acm->spare_read_urbs);
407 otherwise it is scheduled, and with high data rates data can get lost. */ 469 INIT_LIST_HEAD(&acm->spare_read_bufs);
408 tty->low_latency = 1; 470 INIT_LIST_HEAD(&acm->filled_read_bufs);
471 for (i = 0; i < ACM_NRU; i++) {
472 list_add(&(acm->ru[i].list), &acm->spare_read_urbs);
473 }
474 for (i = 0; i < ACM_NRB; i++) {
475 list_add(&(acm->rb[i].list), &acm->spare_read_bufs);
476 }
477
478 tasklet_schedule(&acm->urb_task);
409 479
410done: 480done:
411err_out: 481err_out:
@@ -413,8 +483,6 @@ err_out:
413 return rv; 483 return rv;
414 484
415full_bailout: 485full_bailout:
416 usb_kill_urb(acm->readurb);
417bail_out_and_unlink:
418 usb_kill_urb(acm->ctrlurb); 486 usb_kill_urb(acm->ctrlurb);
419bail_out: 487bail_out:
420 acm->used--; 488 acm->used--;
@@ -424,18 +492,22 @@ bail_out:
424 492
425static void acm_tty_unregister(struct acm *acm) 493static void acm_tty_unregister(struct acm *acm)
426{ 494{
495 int i;
496
427 tty_unregister_device(acm_tty_driver, acm->minor); 497 tty_unregister_device(acm_tty_driver, acm->minor);
428 usb_put_intf(acm->control); 498 usb_put_intf(acm->control);
429 acm_table[acm->minor] = NULL; 499 acm_table[acm->minor] = NULL;
430 usb_free_urb(acm->ctrlurb); 500 usb_free_urb(acm->ctrlurb);
431 usb_free_urb(acm->readurb);
432 usb_free_urb(acm->writeurb); 501 usb_free_urb(acm->writeurb);
502 for (i = 0; i < ACM_NRU; i++)
503 usb_free_urb(acm->ru[i].urb);
433 kfree(acm); 504 kfree(acm);
434} 505}
435 506
436static void acm_tty_close(struct tty_struct *tty, struct file *filp) 507static void acm_tty_close(struct tty_struct *tty, struct file *filp)
437{ 508{
438 struct acm *acm = tty->driver_data; 509 struct acm *acm = tty->driver_data;
510 int i;
439 511
440 if (!acm || !acm->used) 512 if (!acm || !acm->used)
441 return; 513 return;
@@ -446,7 +518,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
446 acm_set_control(acm, acm->ctrlout = 0); 518 acm_set_control(acm, acm->ctrlout = 0);
447 usb_kill_urb(acm->ctrlurb); 519 usb_kill_urb(acm->ctrlurb);
448 usb_kill_urb(acm->writeurb); 520 usb_kill_urb(acm->writeurb);
449 usb_kill_urb(acm->readurb); 521 for (i = 0; i < ACM_NRU; i++)
522 usb_kill_urb(acm->ru[i].urb);
450 } else 523 } else
451 acm_tty_unregister(acm); 524 acm_tty_unregister(acm);
452 } 525 }
@@ -528,10 +601,7 @@ static void acm_tty_unthrottle(struct tty_struct *tty)
528 spin_lock_bh(&acm->throttle_lock); 601 spin_lock_bh(&acm->throttle_lock);
529 acm->throttle = 0; 602 acm->throttle = 0;
530 spin_unlock_bh(&acm->throttle_lock); 603 spin_unlock_bh(&acm->throttle_lock);
531 if (acm->resubmit_to_unthrottle) { 604 tasklet_schedule(&acm->urb_task);
532 acm->resubmit_to_unthrottle = 0;
533 acm_read_bulk(acm->readurb, NULL);
534 }
535} 605}
536 606
537static void acm_tty_break_ctl(struct tty_struct *tty, int state) 607static void acm_tty_break_ctl(struct tty_struct *tty, int state)
@@ -588,7 +658,7 @@ static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int
588 return -ENOIOCTLCMD; 658 return -ENOIOCTLCMD;
589} 659}
590 660
591static __u32 acm_tty_speed[] = { 661static const __u32 acm_tty_speed[] = {
592 0, 50, 75, 110, 134, 150, 200, 300, 600, 662 0, 50, 75, 110, 134, 150, 200, 300, 600,
593 1200, 1800, 2400, 4800, 9600, 19200, 38400, 663 1200, 1800, 2400, 4800, 9600, 19200, 38400,
594 57600, 115200, 230400, 460800, 500000, 576000, 664 57600, 115200, 230400, 460800, 500000, 576000,
@@ -596,7 +666,7 @@ static __u32 acm_tty_speed[] = {
596 2500000, 3000000, 3500000, 4000000 666 2500000, 3000000, 3500000, 4000000
597}; 667};
598 668
599static __u8 acm_tty_size[] = { 669static const __u8 acm_tty_size[] = {
600 5, 6, 7, 8 670 5, 6, 7, 8
601}; 671};
602 672
@@ -694,6 +764,7 @@ static int acm_probe (struct usb_interface *intf,
694 int call_interface_num = -1; 764 int call_interface_num = -1;
695 int data_interface_num; 765 int data_interface_num;
696 unsigned long quirks; 766 unsigned long quirks;
767 int i;
697 768
698 /* handle quirks deadly to normal probing*/ 769 /* handle quirks deadly to normal probing*/
699 quirks = (unsigned long)id->driver_info; 770 quirks = (unsigned long)id->driver_info;
@@ -833,7 +904,7 @@ skip_normal_probe:
833 } 904 }
834 905
835 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); 906 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
836 readsize = le16_to_cpu(epread->wMaxPacketSize); 907 readsize = le16_to_cpu(epread->wMaxPacketSize)*2;
837 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); 908 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize);
838 acm->control = control_interface; 909 acm->control = control_interface;
839 acm->data = data_interface; 910 acm->data = data_interface;
@@ -842,12 +913,14 @@ skip_normal_probe:
842 acm->ctrl_caps = ac_management_function; 913 acm->ctrl_caps = ac_management_function;
843 acm->ctrlsize = ctrlsize; 914 acm->ctrlsize = ctrlsize;
844 acm->readsize = readsize; 915 acm->readsize = readsize;
845 acm->bh.func = acm_rx_tasklet; 916 acm->urb_task.func = acm_rx_tasklet;
846 acm->bh.data = (unsigned long) acm; 917 acm->urb_task.data = (unsigned long) acm;
847 INIT_WORK(&acm->work, acm_softint, acm); 918 INIT_WORK(&acm->work, acm_softint, acm);
848 spin_lock_init(&acm->throttle_lock); 919 spin_lock_init(&acm->throttle_lock);
849 spin_lock_init(&acm->write_lock); 920 spin_lock_init(&acm->write_lock);
921 spin_lock_init(&acm->read_lock);
850 acm->write_ready = 1; 922 acm->write_ready = 1;
923 acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
851 924
852 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 925 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
853 if (!buf) { 926 if (!buf) {
@@ -856,13 +929,6 @@ skip_normal_probe:
856 } 929 }
857 acm->ctrl_buffer = buf; 930 acm->ctrl_buffer = buf;
858 931
859 buf = usb_buffer_alloc(usb_dev, readsize, GFP_KERNEL, &acm->read_dma);
860 if (!buf) {
861 dev_dbg(&intf->dev, "out of memory (read buffer alloc)\n");
862 goto alloc_fail3;
863 }
864 acm->read_buffer = buf;
865
866 if (acm_write_buffers_alloc(acm) < 0) { 932 if (acm_write_buffers_alloc(acm) < 0) {
867 dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n"); 933 dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n");
868 goto alloc_fail4; 934 goto alloc_fail4;
@@ -873,10 +939,25 @@ skip_normal_probe:
873 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n"); 939 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
874 goto alloc_fail5; 940 goto alloc_fail5;
875 } 941 }
876 acm->readurb = usb_alloc_urb(0, GFP_KERNEL); 942 for (i = 0; i < ACM_NRU; i++) {
877 if (!acm->readurb) { 943 struct acm_ru *rcv = &(acm->ru[i]);
878 dev_dbg(&intf->dev, "out of memory (readurb kmalloc)\n"); 944
879 goto alloc_fail6; 945 if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {
946 dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)\n");
947 goto alloc_fail7;
948 }
949
950 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
951 rcv->instance = acm;
952 }
953 for (i = 0; i < ACM_NRB; i++) {
954 struct acm_rb *buf = &(acm->rb[i]);
955
956 // Using usb_buffer_alloc instead of kmalloc as Oliver suggested
957 if (!(buf->base = usb_buffer_alloc(acm->dev, readsize, GFP_KERNEL, &buf->dma))) {
958 dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)\n");
959 goto alloc_fail7;
960 }
880 } 961 }
881 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); 962 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL);
882 if (!acm->writeurb) { 963 if (!acm->writeurb) {
@@ -889,15 +970,9 @@ skip_normal_probe:
889 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 970 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
890 acm->ctrlurb->transfer_dma = acm->ctrl_dma; 971 acm->ctrlurb->transfer_dma = acm->ctrl_dma;
891 972
892 usb_fill_bulk_urb(acm->readurb, usb_dev, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress),
893 acm->read_buffer, readsize, acm_read_bulk, acm);
894 acm->readurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;
895 acm->readurb->transfer_dma = acm->read_dma;
896
897 usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), 973 usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
898 NULL, acm->writesize, acm_write_bulk, acm); 974 NULL, acm->writesize, acm_write_bulk, acm);
899 acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP; 975 acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;
900 /* acm->writeurb->transfer_dma = 0; */
901 976
902 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor); 977 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
903 978
@@ -917,14 +992,14 @@ skip_normal_probe:
917 return 0; 992 return 0;
918 993
919alloc_fail7: 994alloc_fail7:
920 usb_free_urb(acm->readurb); 995 for (i = 0; i < ACM_NRB; i++)
921alloc_fail6: 996 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
997 for (i = 0; i < ACM_NRU; i++)
998 usb_free_urb(acm->ru[i].urb);
922 usb_free_urb(acm->ctrlurb); 999 usb_free_urb(acm->ctrlurb);
923alloc_fail5: 1000alloc_fail5:
924 acm_write_buffers_free(acm); 1001 acm_write_buffers_free(acm);
925alloc_fail4: 1002alloc_fail4:
926 usb_buffer_free(usb_dev, readsize, acm->read_buffer, acm->read_dma);
927alloc_fail3:
928 usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); 1003 usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
929alloc_fail2: 1004alloc_fail2:
930 kfree(acm); 1005 kfree(acm);
@@ -936,6 +1011,7 @@ static void acm_disconnect(struct usb_interface *intf)
936{ 1011{
937 struct acm *acm = usb_get_intfdata (intf); 1012 struct acm *acm = usb_get_intfdata (intf);
938 struct usb_device *usb_dev = interface_to_usbdev(intf); 1013 struct usb_device *usb_dev = interface_to_usbdev(intf);
1014 int i;
939 1015
940 if (!acm || !acm->dev) { 1016 if (!acm || !acm->dev) {
941 dbg("disconnect on nonexisting interface"); 1017 dbg("disconnect on nonexisting interface");
@@ -946,15 +1022,24 @@ static void acm_disconnect(struct usb_interface *intf)
946 acm->dev = NULL; 1022 acm->dev = NULL;
947 usb_set_intfdata (intf, NULL); 1023 usb_set_intfdata (intf, NULL);
948 1024
1025 tasklet_disable(&acm->urb_task);
1026
949 usb_kill_urb(acm->ctrlurb); 1027 usb_kill_urb(acm->ctrlurb);
950 usb_kill_urb(acm->readurb);
951 usb_kill_urb(acm->writeurb); 1028 usb_kill_urb(acm->writeurb);
1029 for (i = 0; i < ACM_NRU; i++)
1030 usb_kill_urb(acm->ru[i].urb);
1031
1032 INIT_LIST_HEAD(&acm->filled_read_bufs);
1033 INIT_LIST_HEAD(&acm->spare_read_bufs);
1034
1035 tasklet_enable(&acm->urb_task);
952 1036
953 flush_scheduled_work(); /* wait for acm_softint */ 1037 flush_scheduled_work(); /* wait for acm_softint */
954 1038
955 acm_write_buffers_free(acm); 1039 acm_write_buffers_free(acm);
956 usb_buffer_free(usb_dev, acm->readsize, acm->read_buffer, acm->read_dma);
957 usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); 1040 usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
1041 for (i = 0; i < ACM_NRB; i++)
1042 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
958 1043
959 usb_driver_release_interface(&acm_driver, acm->data); 1044 usb_driver_release_interface(&acm_driver, acm->data);
960 1045
@@ -1003,7 +1088,6 @@ static struct usb_device_id acm_ids[] = {
1003MODULE_DEVICE_TABLE (usb, acm_ids); 1088MODULE_DEVICE_TABLE (usb, acm_ids);
1004 1089
1005static struct usb_driver acm_driver = { 1090static struct usb_driver acm_driver = {
1006 .owner = THIS_MODULE,
1007 .name = "cdc_acm", 1091 .name = "cdc_acm",
1008 .probe = acm_probe, 1092 .probe = acm_probe,
1009 .disconnect = acm_disconnect, 1093 .disconnect = acm_disconnect,
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 963a5dfd2096..fd2aaccdcbac 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -59,6 +59,9 @@
59 * when processing onlcr, so we only need 2 buffers. 59 * when processing onlcr, so we only need 2 buffers.
60 */ 60 */
61#define ACM_NWB 2 61#define ACM_NWB 2
62#define ACM_NRU 16
63#define ACM_NRB 16
64
62struct acm_wb { 65struct acm_wb {
63 unsigned char *buf; 66 unsigned char *buf;
64 dma_addr_t dmah; 67 dma_addr_t dmah;
@@ -66,22 +69,43 @@ struct acm_wb {
66 int use; 69 int use;
67}; 70};
68 71
72struct acm_rb {
73 struct list_head list;
74 int size;
75 unsigned char *base;
76 dma_addr_t dma;
77};
78
79struct acm_ru {
80 struct list_head list;
81 struct acm_rb *buffer;
82 struct urb *urb;
83 struct acm *instance;
84};
85
69struct acm { 86struct acm {
70 struct usb_device *dev; /* the corresponding usb device */ 87 struct usb_device *dev; /* the corresponding usb device */
71 struct usb_interface *control; /* control interface */ 88 struct usb_interface *control; /* control interface */
72 struct usb_interface *data; /* data interface */ 89 struct usb_interface *data; /* data interface */
73 struct tty_struct *tty; /* the corresponding tty */ 90 struct tty_struct *tty; /* the corresponding tty */
74 struct urb *ctrlurb, *readurb, *writeurb; /* urbs */ 91 struct urb *ctrlurb, *writeurb; /* urbs */
75 u8 *ctrl_buffer, *read_buffer; /* buffers of urbs */ 92 u8 *ctrl_buffer; /* buffers of urbs */
76 dma_addr_t ctrl_dma, read_dma; /* dma handles of buffers */ 93 dma_addr_t ctrl_dma; /* dma handles of buffers */
77 struct acm_wb wb[ACM_NWB]; 94 struct acm_wb wb[ACM_NWB];
95 struct acm_ru ru[ACM_NRU];
96 struct acm_rb rb[ACM_NRB];
97 int rx_endpoint;
98 spinlock_t read_lock;
99 struct list_head spare_read_urbs;
100 struct list_head spare_read_bufs;
101 struct list_head filled_read_bufs;
78 int write_current; /* current write buffer */ 102 int write_current; /* current write buffer */
79 int write_used; /* number of non-empty write buffers */ 103 int write_used; /* number of non-empty write buffers */
80 int write_ready; /* write urb is not running */ 104 int write_ready; /* write urb is not running */
81 spinlock_t write_lock; 105 spinlock_t write_lock;
82 struct usb_cdc_line_coding line; /* bits, stop, parity */ 106 struct usb_cdc_line_coding line; /* bits, stop, parity */
83 struct work_struct work; /* work queue entry for line discipline waking up */ 107 struct work_struct work; /* work queue entry for line discipline waking up */
84 struct tasklet_struct bh; /* rx processing */ 108 struct tasklet_struct urb_task; /* rx processing */
85 spinlock_t throttle_lock; /* synchronize throtteling and read callback */ 109 spinlock_t throttle_lock; /* synchronize throtteling and read callback */
86 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ 110 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
87 unsigned int ctrlout; /* output control lines (DTR, RTS) */ 111 unsigned int ctrlout; /* output control lines (DTR, RTS) */
@@ -91,7 +115,6 @@ struct acm {
91 unsigned int minor; /* acm minor number */ 115 unsigned int minor; /* acm minor number */
92 unsigned char throttle; /* throttled by tty layer */ 116 unsigned char throttle; /* throttled by tty layer */
93 unsigned char clocal; /* termios CLOCAL */ 117 unsigned char clocal; /* termios CLOCAL */
94 unsigned char resubmit_to_unthrottle; /* throtteling has disabled the read urb */
95 unsigned int ctrl_caps; /* control capabilities from the class specific header */ 118 unsigned int ctrl_caps; /* control capabilities from the class specific header */
96}; 119};
97 120
diff --git a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
index 5f8af35e7633..f13f004d311f 100644
--- a/drivers/usb/class/usb-midi.c
+++ b/drivers/usb/class/usb-midi.c
@@ -2027,7 +2027,6 @@ static struct usb_device_id id_table[] = {
2027}; 2027};
2028 2028
2029static struct usb_driver usb_midi_driver = { 2029static struct usb_driver usb_midi_driver = {
2030 .owner = THIS_MODULE,
2031 .name = "midi", 2030 .name = "midi",
2032 .probe = usb_midi_probe, 2031 .probe = usb_midi_probe,
2033 .disconnect = usb_midi_disconnect, 2032 .disconnect = usb_midi_disconnect,
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 357e75335f17..27e9404547f3 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -199,7 +199,7 @@ struct quirk_printer_struct {
199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */ 199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */ 200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
201 201
202static struct quirk_printer_struct quirk_printers[] = { 202static const struct quirk_printer_struct quirk_printers[] = {
203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */ 203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */ 204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */
205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */ 205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */
@@ -301,7 +301,7 @@ static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs)
301 * Get and print printer errors. 301 * Get and print printer errors.
302 */ 302 */
303 303
304static char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" }; 304static const char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" };
305 305
306static int usblp_check_status(struct usblp *usblp, int err) 306static int usblp_check_status(struct usblp *usblp, int err)
307{ 307{
@@ -438,7 +438,7 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait
438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM); 438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM);
439} 439}
440 440
441static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 441static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
442{ 442{
443 struct usblp *usblp = file->private_data; 443 struct usblp *usblp = file->private_data;
444 int length, err, i; 444 int length, err, i;
@@ -838,7 +838,8 @@ static struct file_operations usblp_fops = {
838 .read = usblp_read, 838 .read = usblp_read,
839 .write = usblp_write, 839 .write = usblp_write,
840 .poll = usblp_poll, 840 .poll = usblp_poll,
841 .ioctl = usblp_ioctl, 841 .unlocked_ioctl = usblp_ioctl,
842 .compat_ioctl = usblp_ioctl,
842 .open = usblp_open, 843 .open = usblp_open,
843 .release = usblp_release, 844 .release = usblp_release,
844}; 845};
@@ -849,6 +850,20 @@ static struct usb_class_driver usblp_class = {
849 .minor_base = USBLP_MINOR_BASE, 850 .minor_base = USBLP_MINOR_BASE,
850}; 851};
851 852
853static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)
854{
855 struct usb_interface *intf = to_usb_interface(dev);
856 struct usblp *usblp = usb_get_intfdata (intf);
857
858 if (usblp->device_id_string[0] == 0 &&
859 usblp->device_id_string[1] == 0)
860 return 0;
861
862 return sprintf(buf, "%s", usblp->device_id_string+2);
863}
864
865static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL);
866
852static int usblp_probe(struct usb_interface *intf, 867static int usblp_probe(struct usb_interface *intf,
853 const struct usb_device_id *id) 868 const struct usb_device_id *id)
854{ 869{
@@ -933,20 +948,12 @@ static int usblp_probe(struct usb_interface *intf,
933 948
934 /* Retrieve and store the device ID string. */ 949 /* Retrieve and store the device ID string. */
935 usblp_cache_device_id_string(usblp); 950 usblp_cache_device_id_string(usblp);
951 device_create_file(&intf->dev, &dev_attr_ieee1284_id);
936 952
937#ifdef DEBUG 953#ifdef DEBUG
938 usblp_check_status(usblp, 0); 954 usblp_check_status(usblp, 0);
939#endif 955#endif
940 956
941 info("usblp%d: USB %sdirectional printer dev %d "
942 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
943 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
944 usblp->ifnum,
945 usblp->protocol[usblp->current_protocol].alt_setting,
946 usblp->current_protocol,
947 le16_to_cpu(usblp->dev->descriptor.idVendor),
948 le16_to_cpu(usblp->dev->descriptor.idProduct));
949
950 usb_set_intfdata (intf, usblp); 957 usb_set_intfdata (intf, usblp);
951 958
952 usblp->present = 1; 959 usblp->present = 1;
@@ -957,11 +964,20 @@ static int usblp_probe(struct usb_interface *intf,
957 goto abort_intfdata; 964 goto abort_intfdata;
958 } 965 }
959 usblp->minor = intf->minor; 966 usblp->minor = intf->minor;
967 info("usblp%d: USB %sdirectional printer dev %d "
968 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
969 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
970 usblp->ifnum,
971 usblp->protocol[usblp->current_protocol].alt_setting,
972 usblp->current_protocol,
973 le16_to_cpu(usblp->dev->descriptor.idVendor),
974 le16_to_cpu(usblp->dev->descriptor.idProduct));
960 975
961 return 0; 976 return 0;
962 977
963abort_intfdata: 978abort_intfdata:
964 usb_set_intfdata (intf, NULL); 979 usb_set_intfdata (intf, NULL);
980 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
965abort: 981abort:
966 if (usblp) { 982 if (usblp) {
967 if (usblp->writebuf) 983 if (usblp->writebuf)
@@ -1156,6 +1172,8 @@ static void usblp_disconnect(struct usb_interface *intf)
1156 BUG (); 1172 BUG ();
1157 } 1173 }
1158 1174
1175 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
1176
1159 down (&usblp_sem); 1177 down (&usblp_sem);
1160 down (&usblp->sem); 1178 down (&usblp->sem);
1161 usblp->present = 0; 1179 usblp->present = 0;
@@ -1186,7 +1204,6 @@ static struct usb_device_id usblp_ids [] = {
1186MODULE_DEVICE_TABLE (usb, usblp_ids); 1204MODULE_DEVICE_TABLE (usb, usblp_ids);
1187 1205
1188static struct usb_driver usblp_driver = { 1206static struct usb_driver usblp_driver = {
1189 .owner = THIS_MODULE,
1190 .name = "usblp", 1207 .name = "usblp",
1191 .probe = usblp_probe, 1208 .probe = usblp_probe,
1192 .disconnect = usblp_disconnect, 1209 .disconnect = usblp_disconnect,