aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-08-04 22:50:27 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-08-04 22:50:27 -0400
commitd932cb7e630cae3b6b5307b767d296ff1a597c5e (patch)
treef930d068a12a256fabef0864bcdf8e85f095369e /drivers/usb
parent73b59a3b1c09e4bfc678400b77b96134dcfbf112 (diff)
parentf5d635f649607b09b0b4620d25d028fd2b1b7ea5 (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Kconfig3
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/class/cdc-acm.c49
-rw-r--r--drivers/usb/core/Kconfig3
-rw-r--r--drivers/usb/core/devio.c20
-rw-r--r--drivers/usb/core/file.c13
-rw-r--r--drivers/usb/core/hub.c10
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/gadget/Kconfig2
-rw-r--r--drivers/usb/gadget/at91_udc.c176
-rw-r--r--drivers/usb/gadget/at91_udc.h1
-rw-r--r--drivers/usb/gadget/dummy_hcd.c6
-rw-r--r--drivers/usb/gadget/epautoconf.c16
-rw-r--r--drivers/usb/gadget/ether.c8
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/rndis.c2
-rw-r--r--drivers/usb/gadget/rndis.h2
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/ehci-au1xxx.c23
-rw-r--r--drivers/usb/host/ehci-hcd.c9
-rw-r--r--drivers/usb/host/ohci-at91.c88
-rw-r--r--drivers/usb/host/ohci-au1xxx.c7
-rw-r--r--drivers/usb/host/ohci-ep93xx.c225
-rw-r--r--drivers/usb/host/ohci-hcd.c8
-rw-r--r--drivers/usb/host/ohci-hub.c4
-rw-r--r--drivers/usb/host/pci-quirks.c8
-rw-r--r--drivers/usb/host/uhci-q.c4
-rw-r--r--drivers/usb/input/ati_remote.c5
-rw-r--r--drivers/usb/input/hid-core.c4
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile2
-rw-r--r--drivers/usb/misc/cy7c63.c244
-rw-r--r--drivers/usb/misc/cypress_cy7c63.c284
-rw-r--r--drivers/usb/misc/usblcd.c6
-rw-r--r--drivers/usb/mon/mon_text.c7
-rw-r--r--drivers/usb/net/rtl8150.c86
-rw-r--r--drivers/usb/serial/Kconfig35
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/airprime.c2
-rw-r--r--drivers/usb/serial/anydata.c123
-rw-r--r--drivers/usb/serial/ark3116.c2
-rw-r--r--drivers/usb/serial/belkin_sa.c2
-rw-r--r--drivers/usb/serial/bus.c2
-rw-r--r--drivers/usb/serial/console.c3
-rw-r--r--drivers/usb/serial/cp2101.c2
-rw-r--r--drivers/usb/serial/cyberjack.c2
-rw-r--r--drivers/usb/serial/cypress_m8.c2
-rw-r--r--drivers/usb/serial/digi_acceleport.c2
-rw-r--r--drivers/usb/serial/empeg.c2
-rw-r--r--drivers/usb/serial/ezusb.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c109
-rw-r--r--drivers/usb/serial/ftdi_sio.h19
-rw-r--r--drivers/usb/serial/funsoft.c2
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c3
-rw-r--r--drivers/usb/serial/hp4x.c2
-rw-r--r--drivers/usb/serial/io_edgeport.c2
-rw-r--r--drivers/usb/serial/io_ti.c2
-rw-r--r--drivers/usb/serial/ipaq.c26
-rw-r--r--drivers/usb/serial/ipw.c4
-rw-r--r--drivers/usb/serial/ir-usb.c2
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/serial/keyspan_pda.c3
-rw-r--r--drivers/usb/serial/kl5kusb105.c2
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/mct_u232.c2
-rw-r--r--drivers/usb/serial/navman.c2
-rw-r--r--drivers/usb/serial/omninet.c2
-rw-r--r--drivers/usb/serial/option.c82
-rw-r--r--drivers/usb/serial/pl2303.c5
-rw-r--r--drivers/usb/serial/pl2303.h9
-rw-r--r--drivers/usb/serial/safe_serial.c2
-rw-r--r--drivers/usb/serial/sierra.c75
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c2
-rw-r--r--drivers/usb/serial/usb-serial.c25
-rw-r--r--drivers/usb/serial/usb-serial.h300
-rw-r--r--drivers/usb/serial/visor.c39
-rw-r--r--drivers/usb/serial/whiteheat.c2
-rw-r--r--drivers/usb/storage/scsiglue.c12
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h89
-rw-r--r--drivers/usb/storage/usb.c42
-rw-r--r--drivers/usb/storage/usb.h4
84 files changed, 1321 insertions, 1086 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 7fdbc5dad5fd..005043197527 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -23,7 +23,8 @@ config USB_ARCH_HAS_OHCI
23 default y if ARCH_LH7A404 23 default y if ARCH_LH7A404
24 default y if ARCH_S3C2410 24 default y if ARCH_S3C2410
25 default y if PXA27x 25 default y if PXA27x
26 default y if ARCH_AT91RM9200 26 default y if ARCH_EP93XX
27 default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261)
27 # PPC: 28 # PPC:
28 default y if STB03xxx 29 default y if STB03xxx
29 default y if PPC_MPC52xx 30 default y if PPC_MPC52xx
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index c7123bf71c58..4710eb02ed64 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -48,7 +48,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/
48obj-$(CONFIG_USB_SERIAL) += serial/ 48obj-$(CONFIG_USB_SERIAL) += serial/
49 49
50obj-$(CONFIG_USB_AUERSWALD) += misc/ 50obj-$(CONFIG_USB_AUERSWALD) += misc/
51obj-$(CONFIG_USB_CY7C63) += misc/ 51obj-$(CONFIG_USB_CYPRESS_CY7C63)+= misc/
52obj-$(CONFIG_USB_CYTHERM) += misc/ 52obj-$(CONFIG_USB_CYTHERM) += misc/
53obj-$(CONFIG_USB_EMI26) += misc/ 53obj-$(CONFIG_USB_EMI26) += misc/
54obj-$(CONFIG_USB_EMI62) += misc/ 54obj-$(CONFIG_USB_EMI62) += misc/
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3670d77e912c..ca90326f2f5c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -291,13 +291,13 @@ static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
291 struct acm_ru *rcv = urb->context; 291 struct acm_ru *rcv = urb->context;
292 struct acm *acm = rcv->instance; 292 struct acm *acm = rcv->instance;
293 int status = urb->status; 293 int status = urb->status;
294 dbg("Entering acm_read_bulk with status %d\n", urb->status); 294 dbg("Entering acm_read_bulk with status %d", urb->status);
295 295
296 if (!ACM_READY(acm)) 296 if (!ACM_READY(acm))
297 return; 297 return;
298 298
299 if (status) 299 if (status)
300 dev_dbg(&acm->data->dev, "bulk rx status %d\n", status); 300 dev_dbg(&acm->data->dev, "bulk rx status %d", status);
301 301
302 buf = rcv->buffer; 302 buf = rcv->buffer;
303 buf->size = urb->actual_length; 303 buf->size = urb->actual_length;
@@ -343,7 +343,7 @@ next_buffer:
343 list_del(&buf->list); 343 list_del(&buf->list);
344 spin_unlock(&acm->read_lock); 344 spin_unlock(&acm->read_lock);
345 345
346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d\n", buf, buf->size); 346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size);
347 347
348 tty_buffer_request_room(tty, buf->size); 348 tty_buffer_request_room(tty, buf->size);
349 if (!acm->throttle) 349 if (!acm->throttle)
@@ -394,7 +394,7 @@ urbs:
394 rcv->urb->transfer_dma = buf->dma; 394 rcv->urb->transfer_dma = buf->dma;
395 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 395 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
396 396
397 dbg("acm_rx_tasklet: sending urb 0x%p, rcv 0x%p, buf 0x%p\n", rcv->urb, rcv, buf); 397 dbg("acm_rx_tasklet: sending urb 0x%p, rcv 0x%p, buf 0x%p", rcv->urb, rcv, buf);
398 398
399 /* This shouldn't kill the driver as unsuccessful URBs are returned to the 399 /* This shouldn't kill the driver as unsuccessful URBs are returned to the
400 free-urbs-pool and resubmited ASAP */ 400 free-urbs-pool and resubmited ASAP */
@@ -413,7 +413,7 @@ static void acm_write_bulk(struct urb *urb, struct pt_regs *regs)
413{ 413{
414 struct acm *acm = (struct acm *)urb->context; 414 struct acm *acm = (struct acm *)urb->context;
415 415
416 dbg("Entering acm_write_bulk with status %d\n", urb->status); 416 dbg("Entering acm_write_bulk with status %d", urb->status);
417 417
418 acm_write_done(acm); 418 acm_write_done(acm);
419 acm_write_start(acm); 419 acm_write_start(acm);
@@ -424,7 +424,7 @@ static void acm_write_bulk(struct urb *urb, struct pt_regs *regs)
424static void acm_softint(void *private) 424static void acm_softint(void *private)
425{ 425{
426 struct acm *acm = private; 426 struct acm *acm = private;
427 dbg("Entering acm_softint.\n"); 427 dbg("Entering acm_softint.");
428 428
429 if (!ACM_READY(acm)) 429 if (!ACM_READY(acm))
430 return; 430 return;
@@ -440,7 +440,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
440 struct acm *acm; 440 struct acm *acm;
441 int rv = -EINVAL; 441 int rv = -EINVAL;
442 int i; 442 int i;
443 dbg("Entering acm_tty_open.\n"); 443 dbg("Entering acm_tty_open.");
444 444
445 mutex_lock(&open_mutex); 445 mutex_lock(&open_mutex);
446 446
@@ -541,7 +541,7 @@ static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int c
541 int wbn; 541 int wbn;
542 struct acm_wb *wb; 542 struct acm_wb *wb;
543 543
544 dbg("Entering acm_tty_write to write %d bytes,\n", count); 544 dbg("Entering acm_tty_write to write %d bytes,", count);
545 545
546 if (!ACM_READY(acm)) 546 if (!ACM_READY(acm))
547 return -EINVAL; 547 return -EINVAL;
@@ -793,7 +793,7 @@ static int acm_probe (struct usb_interface *intf,
793 793
794 if (!buflen) { 794 if (!buflen) {
795 if (intf->cur_altsetting->endpoint->extralen && intf->cur_altsetting->endpoint->extra) { 795 if (intf->cur_altsetting->endpoint->extralen && intf->cur_altsetting->endpoint->extra) {
796 dev_dbg(&intf->dev,"Seeking extra descriptors on endpoint\n"); 796 dev_dbg(&intf->dev,"Seeking extra descriptors on endpoint");
797 buflen = intf->cur_altsetting->endpoint->extralen; 797 buflen = intf->cur_altsetting->endpoint->extralen;
798 buffer = intf->cur_altsetting->endpoint->extra; 798 buffer = intf->cur_altsetting->endpoint->extra;
799 } else { 799 } else {
@@ -842,24 +842,24 @@ next_desc:
842 842
843 if (!union_header) { 843 if (!union_header) {
844 if (call_interface_num > 0) { 844 if (call_interface_num > 0) {
845 dev_dbg(&intf->dev,"No union descriptor, using call management descriptor\n"); 845 dev_dbg(&intf->dev,"No union descriptor, using call management descriptor");
846 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num)); 846 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num));
847 control_interface = intf; 847 control_interface = intf;
848 } else { 848 } else {
849 dev_dbg(&intf->dev,"No union descriptor, giving up\n"); 849 dev_dbg(&intf->dev,"No union descriptor, giving up");
850 return -ENODEV; 850 return -ENODEV;
851 } 851 }
852 } else { 852 } else {
853 control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0); 853 control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
854 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0)); 854 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0));
855 if (!control_interface || !data_interface) { 855 if (!control_interface || !data_interface) {
856 dev_dbg(&intf->dev,"no interfaces\n"); 856 dev_dbg(&intf->dev,"no interfaces");
857 return -ENODEV; 857 return -ENODEV;
858 } 858 }
859 } 859 }
860 860
861 if (data_interface_num != call_interface_num) 861 if (data_interface_num != call_interface_num)
862 dev_dbg(&intf->dev,"Seperate call control interface. That is not fully supported.\n"); 862 dev_dbg(&intf->dev,"Seperate call control interface. That is not fully supported.");
863 863
864skip_normal_probe: 864skip_normal_probe:
865 865
@@ -867,7 +867,7 @@ skip_normal_probe:
867 if (data_interface->cur_altsetting->desc.bInterfaceClass != CDC_DATA_INTERFACE_TYPE) { 867 if (data_interface->cur_altsetting->desc.bInterfaceClass != CDC_DATA_INTERFACE_TYPE) {
868 if (control_interface->cur_altsetting->desc.bInterfaceClass == CDC_DATA_INTERFACE_TYPE) { 868 if (control_interface->cur_altsetting->desc.bInterfaceClass == CDC_DATA_INTERFACE_TYPE) {
869 struct usb_interface *t; 869 struct usb_interface *t;
870 dev_dbg(&intf->dev,"Your device has switched interfaces.\n"); 870 dev_dbg(&intf->dev,"Your device has switched interfaces.");
871 871
872 t = control_interface; 872 t = control_interface;
873 control_interface = data_interface; 873 control_interface = data_interface;
@@ -878,7 +878,7 @@ skip_normal_probe:
878 } 878 }
879 879
880 if (usb_interface_claimed(data_interface)) { /* valid in this context */ 880 if (usb_interface_claimed(data_interface)) { /* valid in this context */
881 dev_dbg(&intf->dev,"The data interface isn't available\n"); 881 dev_dbg(&intf->dev,"The data interface isn't available");
882 return -EBUSY; 882 return -EBUSY;
883 } 883 }
884 884
@@ -895,7 +895,7 @@ skip_normal_probe:
895 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) { 895 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) {
896 /* descriptors are swapped */ 896 /* descriptors are swapped */
897 struct usb_endpoint_descriptor *t; 897 struct usb_endpoint_descriptor *t;
898 dev_dbg(&intf->dev,"The data interface has switched endpoints\n"); 898 dev_dbg(&intf->dev,"The data interface has switched endpoints");
899 899
900 t = epread; 900 t = epread;
901 epread = epwrite; 901 epread = epwrite;
@@ -910,7 +910,7 @@ skip_normal_probe:
910 } 910 }
911 911
912 if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) { 912 if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) {
913 dev_dbg(&intf->dev, "out of memory (acm kzalloc)\n"); 913 dev_dbg(&intf->dev, "out of memory (acm kzalloc)");
914 goto alloc_fail; 914 goto alloc_fail;
915 } 915 }
916 916
@@ -936,26 +936,26 @@ skip_normal_probe:
936 936
937 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 937 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
938 if (!buf) { 938 if (!buf) {
939 dev_dbg(&intf->dev, "out of memory (ctrl buffer alloc)\n"); 939 dev_dbg(&intf->dev, "out of memory (ctrl buffer alloc)");
940 goto alloc_fail2; 940 goto alloc_fail2;
941 } 941 }
942 acm->ctrl_buffer = buf; 942 acm->ctrl_buffer = buf;
943 943
944 if (acm_write_buffers_alloc(acm) < 0) { 944 if (acm_write_buffers_alloc(acm) < 0) {
945 dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n"); 945 dev_dbg(&intf->dev, "out of memory (write buffer alloc)");
946 goto alloc_fail4; 946 goto alloc_fail4;
947 } 947 }
948 948
949 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL); 949 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
950 if (!acm->ctrlurb) { 950 if (!acm->ctrlurb) {
951 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n"); 951 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)");
952 goto alloc_fail5; 952 goto alloc_fail5;
953 } 953 }
954 for (i = 0; i < num_rx_buf; i++) { 954 for (i = 0; i < num_rx_buf; i++) {
955 struct acm_ru *rcv = &(acm->ru[i]); 955 struct acm_ru *rcv = &(acm->ru[i]);
956 956
957 if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) { 957 if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {
958 dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)\n"); 958 dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)");
959 goto alloc_fail7; 959 goto alloc_fail7;
960 } 960 }
961 961
@@ -966,13 +966,13 @@ skip_normal_probe:
966 struct acm_rb *buf = &(acm->rb[i]); 966 struct acm_rb *buf = &(acm->rb[i]);
967 967
968 if (!(buf->base = usb_buffer_alloc(acm->dev, readsize, GFP_KERNEL, &buf->dma))) { 968 if (!(buf->base = usb_buffer_alloc(acm->dev, readsize, GFP_KERNEL, &buf->dma))) {
969 dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)\n"); 969 dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)");
970 goto alloc_fail7; 970 goto alloc_fail7;
971 } 971 }
972 } 972 }
973 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); 973 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL);
974 if (!acm->writeurb) { 974 if (!acm->writeurb) {
975 dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)\n"); 975 dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)");
976 goto alloc_fail7; 976 goto alloc_fail7;
977 } 977 }
978 978
@@ -1086,6 +1086,9 @@ static struct usb_device_id acm_ids[] = {
1086 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ 1086 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
1087 .driver_info = SINGLE_RX_URB, /* firmware bug */ 1087 .driver_info = SINGLE_RX_URB, /* firmware bug */
1088 }, 1088 },
1089 { USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */
1090 .driver_info = SINGLE_RX_URB, /* firmware bug */
1091 },
1089 /* control interfaces with various AT-command sets */ 1092 /* control interfaces with various AT-command sets */
1090 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1093 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
1091 USB_CDC_ACM_PROTO_AT_V25TER) }, 1094 USB_CDC_ACM_PROTO_AT_V25TER) },
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index a08787e253aa..6e3b5358a760 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -31,9 +31,6 @@ config USB_DEVICEFS
31 For the format of the various /proc/bus/usb/ files, please read 31 For the format of the various /proc/bus/usb/ files, please read
32 <file:Documentation/usb/proc_usb_info.txt>. 32 <file:Documentation/usb/proc_usb_info.txt>.
33 33
34 Please note that this code is completely unrelated to devfs, the
35 "/dev file system support".
36
37 Most users want to say Y here. 34 Most users want to say Y here.
38 35
39config USB_BANDWIDTH 36config USB_BANDWIDTH
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index f7bdd94b3aa8..218621b9958e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -517,19 +517,19 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig
517 517
518static struct usb_device *usbdev_lookup_minor(int minor) 518static struct usb_device *usbdev_lookup_minor(int minor)
519{ 519{
520 struct device *device; 520 struct class_device *class_dev;
521 struct usb_device *udev = NULL; 521 struct usb_device *dev = NULL;
522 522
523 down(&usb_device_class->sem); 523 down(&usb_device_class->sem);
524 list_for_each_entry(device, &usb_device_class->devices, node) { 524 list_for_each_entry(class_dev, &usb_device_class->children, node) {
525 if (device->devt == MKDEV(USB_DEVICE_MAJOR, minor)) { 525 if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) {
526 udev = device->platform_data; 526 dev = class_dev->class_data;
527 break; 527 break;
528 } 528 }
529 } 529 }
530 up(&usb_device_class->sem); 530 up(&usb_device_class->sem);
531 531
532 return udev; 532 return dev;
533}; 533};
534 534
535/* 535/*
@@ -1580,16 +1580,16 @@ static void usbdev_add(struct usb_device *dev)
1580{ 1580{
1581 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); 1581 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);
1582 1582
1583 dev->usbfs_dev = device_create(usb_device_class, &dev->dev, 1583 dev->class_dev = class_device_create(usb_device_class, NULL,
1584 MKDEV(USB_DEVICE_MAJOR, minor), 1584 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
1585 "usbdev%d.%d", dev->bus->busnum, dev->devnum); 1585 "usbdev%d.%d", dev->bus->busnum, dev->devnum);
1586 1586
1587 dev->usbfs_dev->platform_data = dev; 1587 dev->class_dev->class_data = dev;
1588} 1588}
1589 1589
1590static void usbdev_remove(struct usb_device *dev) 1590static void usbdev_remove(struct usb_device *dev)
1591{ 1591{
1592 device_unregister(dev->usbfs_dev); 1592 class_device_unregister(dev->class_dev);
1593} 1593}
1594 1594
1595static int usbdev_notify(struct notifier_block *self, unsigned long action, 1595static int usbdev_notify(struct notifier_block *self, unsigned long action,
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index abee0f5b6a66..8de4f8c99d61 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -194,13 +194,14 @@ int usb_register_dev(struct usb_interface *intf,
194 ++temp; 194 ++temp;
195 else 195 else
196 temp = name; 196 temp = name;
197 intf->usb_dev = device_create(usb_class->class, &intf->dev, 197 intf->class_dev = class_device_create(usb_class->class, NULL,
198 MKDEV(USB_MAJOR, minor), "%s", temp); 198 MKDEV(USB_MAJOR, minor),
199 if (IS_ERR(intf->usb_dev)) { 199 &intf->dev, "%s", temp);
200 if (IS_ERR(intf->class_dev)) {
200 spin_lock (&minor_lock); 201 spin_lock (&minor_lock);
201 usb_minors[intf->minor] = NULL; 202 usb_minors[intf->minor] = NULL;
202 spin_unlock (&minor_lock); 203 spin_unlock (&minor_lock);
203 retval = PTR_ERR(intf->usb_dev); 204 retval = PTR_ERR(intf->class_dev);
204 } 205 }
205exit: 206exit:
206 return retval; 207 return retval;
@@ -241,8 +242,8 @@ void usb_deregister_dev(struct usb_interface *intf,
241 spin_unlock (&minor_lock); 242 spin_unlock (&minor_lock);
242 243
243 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); 244 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
244 device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor)); 245 class_device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
245 intf->usb_dev = NULL; 246 intf->class_dev = NULL;
246 intf->minor = -1; 247 intf->minor = -1;
247 destroy_usb_class(); 248 destroy_usb_class();
248} 249}
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 875596e98e42..26c8cb5f3e67 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1790,7 +1790,10 @@ static int finish_device_resume(struct usb_device *udev)
1790 * and device drivers will know about any resume quirks. 1790 * and device drivers will know about any resume quirks.
1791 */ 1791 */
1792 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); 1792 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
1793 if (status < 2) 1793 if (status >= 0)
1794 status = (status == 2 ? 0 : -ENODEV);
1795
1796 if (status)
1794 dev_dbg(&udev->dev, 1797 dev_dbg(&udev->dev,
1795 "gone after usb resume? status %d\n", 1798 "gone after usb resume? status %d\n",
1796 status); 1799 status);
@@ -1879,7 +1882,12 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1879 dev_dbg(hub->intfdev, 1882 dev_dbg(hub->intfdev,
1880 "port %d status %04x.%04x after resume, %d\n", 1883 "port %d status %04x.%04x after resume, %d\n",
1881 port1, portchange, devstatus, status); 1884 port1, portchange, devstatus, status);
1885 if (status >= 0)
1886 status = -ENODEV;
1882 } else { 1887 } else {
1888 if (portchange & USB_PORT_STAT_C_SUSPEND)
1889 clear_port_feature(hub->hdev, port1,
1890 USB_PORT_FEAT_C_SUSPEND);
1883 /* TRSMRCY = 10 msec */ 1891 /* TRSMRCY = 10 msec */
1884 msleep(10); 1892 msleep(10);
1885 if (udev) 1893 if (udev)
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index f48c3dbc367a..3182c2224ba2 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -695,7 +695,7 @@ static void usbfs_remove_device(struct usb_device *dev)
695 wake_up_all(&ds->wait); 695 wake_up_all(&ds->wait);
696 list_del_init(&ds->list); 696 list_del_init(&ds->list);
697 if (ds->discsignr) { 697 if (ds->discsignr) {
698 sinfo.si_signo = SIGPIPE; 698 sinfo.si_signo = ds->discsignr;
699 sinfo.si_errno = EPIPE; 699 sinfo.si_errno = EPIPE;
700 sinfo.si_code = SI_ASYNCIO; 700 sinfo.si_code = SI_ASYNCIO;
701 sinfo.si_addr = ds->disccontext; 701 sinfo.si_addr = ds->disccontext;
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 363b2ad74ae6..1a32d96774b4 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -207,7 +207,7 @@ config USB_AT91
207 207
208config USB_GADGET_DUMMY_HCD 208config USB_GADGET_DUMMY_HCD
209 boolean "Dummy HCD (DEVELOPMENT)" 209 boolean "Dummy HCD (DEVELOPMENT)"
210 depends on USB && EXPERIMENTAL 210 depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
211 select USB_GADGET_DUALSPEED 211 select USB_GADGET_DUALSPEED
212 help 212 help
213 This host controller driver emulates USB, looping all data transfer 213 This host controller driver emulates USB, looping all data transfer
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 1c459ff037ce..cfebca05ead5 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -57,19 +57,23 @@
57 57
58/* 58/*
59 * This controller is simple and PIO-only. It's used in many AT91-series 59 * This controller is simple and PIO-only. It's used in many AT91-series
60 * ARMv4T controllers, including the at91rm9200 (arm920T, with MMU), 60 * full speed USB controllers, including the at91rm9200 (arm920T, with MMU),
61 * at91sam9261 (arm926ejs, with MMU), and several no-mmu versions. 61 * at91sam926x (arm926ejs, with MMU), and several no-mmu versions.
62 * 62 *
63 * This driver expects the board has been wired with two GPIOs suppporting 63 * This driver expects the board has been wired with two GPIOs suppporting
64 * a VBUS sensing IRQ, and a D+ pullup. (They may be omitted, but the 64 * a VBUS sensing IRQ, and a D+ pullup. (They may be omitted, but the
65 * testing hasn't covered such cases.) The pullup is most important; it 65 * testing hasn't covered such cases.)
66 *
67 * The pullup is most important (so it's integrated on sam926x parts). It
66 * provides software control over whether the host enumerates the device. 68 * provides software control over whether the host enumerates the device.
69 *
67 * The VBUS sensing helps during enumeration, and allows both USB clocks 70 * The VBUS sensing helps during enumeration, and allows both USB clocks
68 * (and the transceiver) to stay gated off until they're necessary, saving 71 * (and the transceiver) to stay gated off until they're necessary, saving
69 * power. During USB suspend, the 48 MHz clock is gated off. 72 * power. During USB suspend, the 48 MHz clock is gated off in hardware;
73 * it may also be gated off by software during some Linux sleep states.
70 */ 74 */
71 75
72#define DRIVER_VERSION "8 March 2005" 76#define DRIVER_VERSION "3 May 2006"
73 77
74static const char driver_name [] = "at91_udc"; 78static const char driver_name [] = "at91_udc";
75static const char ep0name[] = "ep0"; 79static const char ep0name[] = "ep0";
@@ -316,9 +320,15 @@ static void done(struct at91_ep *ep, struct at91_request *req, int status)
316 * 320 *
317 * There are also state bits like FORCESTALL, EPEDS, DIR, and EPTYPE 321 * There are also state bits like FORCESTALL, EPEDS, DIR, and EPTYPE
318 * that shouldn't normally be changed. 322 * that shouldn't normally be changed.
323 *
324 * NOTE at91sam9260 docs mention synch between UDPCK and MCK clock domains,
325 * implying a need to wait for one write to complete (test relevant bits)
326 * before starting the next write. This shouldn't be an issue given how
327 * infrequently we write, except maybe for write-then-read idioms.
319 */ 328 */
320#define SET_FX (AT91_UDP_TXPKTRDY) 329#define SET_FX (AT91_UDP_TXPKTRDY)
321#define CLR_FX (RX_DATA_READY | AT91_UDP_RXSETUP | AT91_UDP_STALLSENT | AT91_UDP_TXCOMP) 330#define CLR_FX (RX_DATA_READY | AT91_UDP_RXSETUP \
331 | AT91_UDP_STALLSENT | AT91_UDP_TXCOMP)
322 332
323/* pull OUT packet data from the endpoint's fifo */ 333/* pull OUT packet data from the endpoint's fifo */
324static int read_fifo (struct at91_ep *ep, struct at91_request *req) 334static int read_fifo (struct at91_ep *ep, struct at91_request *req)
@@ -472,7 +482,8 @@ static void nuke(struct at91_ep *ep, int status)
472 482
473/*-------------------------------------------------------------------------*/ 483/*-------------------------------------------------------------------------*/
474 484
475static int at91_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) 485static int at91_ep_enable(struct usb_ep *_ep,
486 const struct usb_endpoint_descriptor *desc)
476{ 487{
477 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); 488 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep);
478 struct at91_udc *dev = ep->udc; 489 struct at91_udc *dev = ep->udc;
@@ -582,11 +593,12 @@ static int at91_ep_disable (struct usb_ep * _ep)
582 * interesting for request or buffer allocation. 593 * interesting for request or buffer allocation.
583 */ 594 */
584 595
585static struct usb_request *at91_ep_alloc_request (struct usb_ep *_ep, unsigned int gfp_flags) 596static struct usb_request *
597at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags)
586{ 598{
587 struct at91_request *req; 599 struct at91_request *req;
588 600
589 req = kcalloc(1, sizeof (struct at91_request), SLAB_KERNEL); 601 req = kcalloc(1, sizeof (struct at91_request), gfp_flags);
590 if (!req) 602 if (!req)
591 return NULL; 603 return NULL;
592 604
@@ -862,6 +874,7 @@ static void stop_activity(struct at91_udc *udc)
862 if (udc->gadget.speed == USB_SPEED_UNKNOWN) 874 if (udc->gadget.speed == USB_SPEED_UNKNOWN)
863 driver = NULL; 875 driver = NULL;
864 udc->gadget.speed = USB_SPEED_UNKNOWN; 876 udc->gadget.speed = USB_SPEED_UNKNOWN;
877 udc->suspended = 0;
865 878
866 for (i = 0; i < NUM_ENDPOINTS; i++) { 879 for (i = 0; i < NUM_ENDPOINTS; i++) {
867 struct at91_ep *ep = &udc->ep[i]; 880 struct at91_ep *ep = &udc->ep[i];
@@ -889,8 +902,8 @@ static void clk_off(struct at91_udc *udc)
889 return; 902 return;
890 udc->clocked = 0; 903 udc->clocked = 0;
891 udc->gadget.speed = USB_SPEED_UNKNOWN; 904 udc->gadget.speed = USB_SPEED_UNKNOWN;
892 clk_disable(udc->iclk);
893 clk_disable(udc->fclk); 905 clk_disable(udc->fclk);
906 clk_disable(udc->iclk);
894} 907}
895 908
896/* 909/*
@@ -911,9 +924,6 @@ static void pullup(struct at91_udc *udc, int is_on)
911 at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 924 at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
912 at91_set_gpio_value(udc->board.pullup_pin, 0); 925 at91_set_gpio_value(udc->board.pullup_pin, 0);
913 clk_off(udc); 926 clk_off(udc);
914
915 // REVISIT: with transceiver disabled, will D- float
916 // so that a host would falsely detect a device?
917 } 927 }
918} 928}
919 929
@@ -1290,7 +1300,8 @@ static void handle_ep0(struct at91_udc *udc)
1290 if (udc->wait_for_addr_ack) { 1300 if (udc->wait_for_addr_ack) {
1291 u32 tmp; 1301 u32 tmp;
1292 1302
1293 at91_udp_write(AT91_UDP_FADDR, AT91_UDP_FEN | udc->addr); 1303 at91_udp_write(AT91_UDP_FADDR,
1304 AT91_UDP_FEN | udc->addr);
1294 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 1305 tmp = at91_udp_read(AT91_UDP_GLB_STAT);
1295 tmp &= ~AT91_UDP_FADDEN; 1306 tmp &= ~AT91_UDP_FADDEN;
1296 if (udc->addr) 1307 if (udc->addr)
@@ -1361,9 +1372,10 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc, struct pt_regs *r)
1361 u32 rescans = 5; 1372 u32 rescans = 5;
1362 1373
1363 while (rescans--) { 1374 while (rescans--) {
1364 u32 status = at91_udp_read(AT91_UDP_ISR); 1375 u32 status;
1365 1376
1366 status &= at91_udp_read(AT91_UDP_IMR); 1377 status = at91_udp_read(AT91_UDP_ISR)
1378 & at91_udp_read(AT91_UDP_IMR);
1367 if (!status) 1379 if (!status)
1368 break; 1380 break;
1369 1381
@@ -1379,18 +1391,17 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc, struct pt_regs *r)
1379 stop_activity(udc); 1391 stop_activity(udc);
1380 1392
1381 /* enable ep0 */ 1393 /* enable ep0 */
1382 at91_udp_write(AT91_UDP_CSR(0), AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL); 1394 at91_udp_write(AT91_UDP_CSR(0),
1395 AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL);
1383 udc->gadget.speed = USB_SPEED_FULL; 1396 udc->gadget.speed = USB_SPEED_FULL;
1384 udc->suspended = 0; 1397 udc->suspended = 0;
1385 at91_udp_write(AT91_UDP_IER, AT91_UDP_EP(0)); 1398 at91_udp_write(AT91_UDP_IER, AT91_UDP_EP(0));
1386 1399
1387 /* 1400 /*
1388 * NOTE: this driver keeps clocks off unless the 1401 * NOTE: this driver keeps clocks off unless the
1389 * USB host is present. That saves power, and also 1402 * USB host is present. That saves power, but for
1390 * eliminates IRQs (reset, resume, suspend) that can 1403 * boards that don't support VBUS detection, both
1391 * otherwise flood from the controller. If your 1404 * clocks need to be active most of the time.
1392 * board doesn't support VBUS detection, suspend and
1393 * resume irq logic may need more attention...
1394 */ 1405 */
1395 1406
1396 /* host initiated suspend (3+ms bus idle) */ 1407 /* host initiated suspend (3+ms bus idle) */
@@ -1452,13 +1463,19 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc, struct pt_regs *r)
1452 1463
1453/*-------------------------------------------------------------------------*/ 1464/*-------------------------------------------------------------------------*/
1454 1465
1466static void nop_release(struct device *dev)
1467{
1468 /* nothing to free */
1469}
1470
1455static struct at91_udc controller = { 1471static struct at91_udc controller = {
1456 .gadget = { 1472 .gadget = {
1457 .ops = &at91_udc_ops, 1473 .ops = &at91_udc_ops,
1458 .ep0 = &controller.ep[0].ep, 1474 .ep0 = &controller.ep[0].ep,
1459 .name = driver_name, 1475 .name = driver_name,
1460 .dev = { 1476 .dev = {
1461 .bus_id = "gadget" 1477 .bus_id = "gadget",
1478 .release = nop_release,
1462 } 1479 }
1463 }, 1480 },
1464 .ep[0] = { 1481 .ep[0] = {
@@ -1468,7 +1485,8 @@ static struct at91_udc controller = {
1468 }, 1485 },
1469 .udc = &controller, 1486 .udc = &controller,
1470 .maxpacket = 8, 1487 .maxpacket = 8,
1471 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(0)), 1488 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1489 + AT91_UDP_CSR(0)),
1472 .int_mask = 1 << 0, 1490 .int_mask = 1 << 0,
1473 }, 1491 },
1474 .ep[1] = { 1492 .ep[1] = {
@@ -1479,7 +1497,8 @@ static struct at91_udc controller = {
1479 .udc = &controller, 1497 .udc = &controller,
1480 .is_pingpong = 1, 1498 .is_pingpong = 1,
1481 .maxpacket = 64, 1499 .maxpacket = 64,
1482 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(1)), 1500 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1501 + AT91_UDP_CSR(1)),
1483 .int_mask = 1 << 1, 1502 .int_mask = 1 << 1,
1484 }, 1503 },
1485 .ep[2] = { 1504 .ep[2] = {
@@ -1490,7 +1509,8 @@ static struct at91_udc controller = {
1490 .udc = &controller, 1509 .udc = &controller,
1491 .is_pingpong = 1, 1510 .is_pingpong = 1,
1492 .maxpacket = 64, 1511 .maxpacket = 64,
1493 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(2)), 1512 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1513 + AT91_UDP_CSR(2)),
1494 .int_mask = 1 << 2, 1514 .int_mask = 1 << 2,
1495 }, 1515 },
1496 .ep[3] = { 1516 .ep[3] = {
@@ -1501,7 +1521,8 @@ static struct at91_udc controller = {
1501 }, 1521 },
1502 .udc = &controller, 1522 .udc = &controller,
1503 .maxpacket = 8, 1523 .maxpacket = 8,
1504 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(3)), 1524 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1525 + AT91_UDP_CSR(3)),
1505 .int_mask = 1 << 3, 1526 .int_mask = 1 << 3,
1506 }, 1527 },
1507 .ep[4] = { 1528 .ep[4] = {
@@ -1512,7 +1533,8 @@ static struct at91_udc controller = {
1512 .udc = &controller, 1533 .udc = &controller,
1513 .is_pingpong = 1, 1534 .is_pingpong = 1,
1514 .maxpacket = 256, 1535 .maxpacket = 256,
1515 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(4)), 1536 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1537 + AT91_UDP_CSR(4)),
1516 .int_mask = 1 << 4, 1538 .int_mask = 1 << 4,
1517 }, 1539 },
1518 .ep[5] = { 1540 .ep[5] = {
@@ -1523,10 +1545,11 @@ static struct at91_udc controller = {
1523 .udc = &controller, 1545 .udc = &controller,
1524 .is_pingpong = 1, 1546 .is_pingpong = 1,
1525 .maxpacket = 256, 1547 .maxpacket = 256,
1526 .creg = (void __iomem *)(AT91_VA_BASE_UDP + AT91_UDP_CSR(5)), 1548 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1549 + AT91_UDP_CSR(5)),
1527 .int_mask = 1 << 5, 1550 .int_mask = 1 << 5,
1528 }, 1551 },
1529 /* ep6 and ep7 are also reserved */ 1552 /* ep6 and ep7 are also reserved (custom silicon might use them) */
1530}; 1553};
1531 1554
1532static irqreturn_t at91_vbus_irq(int irq, void *_udc, struct pt_regs *r) 1555static irqreturn_t at91_vbus_irq(int irq, void *_udc, struct pt_regs *r)
@@ -1593,6 +1616,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
1593 1616
1594 local_irq_disable(); 1617 local_irq_disable();
1595 udc->enabled = 0; 1618 udc->enabled = 0;
1619 at91_udp_write(AT91_UDP_IDR, ~0);
1596 pullup(udc, 0); 1620 pullup(udc, 0);
1597 local_irq_enable(); 1621 local_irq_enable();
1598 1622
@@ -1624,6 +1648,16 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1624 return -ENODEV; 1648 return -ENODEV;
1625 } 1649 }
1626 1650
1651 if (pdev->num_resources != 2) {
1652 DBG("invalid num_resources");
1653 return -ENODEV;
1654 }
1655 if ((pdev->resource[0].flags != IORESOURCE_MEM)
1656 || (pdev->resource[1].flags != IORESOURCE_IRQ)) {
1657 DBG("invalid resource type");
1658 return -ENODEV;
1659 }
1660
1627 if (!request_mem_region(AT91_BASE_UDP, SZ_16K, driver_name)) { 1661 if (!request_mem_region(AT91_BASE_UDP, SZ_16K, driver_name)) {
1628 DBG("someone's using UDC memory\n"); 1662 DBG("someone's using UDC memory\n");
1629 return -EBUSY; 1663 return -EBUSY;
@@ -1649,19 +1683,26 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1649 if (retval < 0) 1683 if (retval < 0)
1650 goto fail0; 1684 goto fail0;
1651 1685
1652 /* disable everything until there's a gadget driver and vbus */ 1686 /* don't do anything until we have both gadget driver and VBUS */
1653 pullup(udc, 0); 1687 clk_enable(udc->iclk);
1688 at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
1689 at91_udp_write(AT91_UDP_IDR, 0xffffffff);
1690 clk_disable(udc->iclk);
1654 1691
1655 /* request UDC and maybe VBUS irqs */ 1692 /* request UDC and maybe VBUS irqs */
1656 if (request_irq(AT91_ID_UDP, at91_udc_irq, IRQF_DISABLED, driver_name, udc)) { 1693 udc->udp_irq = platform_get_irq(pdev, 0);
1657 DBG("request irq %d failed\n", AT91_ID_UDP); 1694 if (request_irq(udc->udp_irq, at91_udc_irq,
1695 IRQF_DISABLED, driver_name, udc)) {
1696 DBG("request irq %d failed\n", udc->udp_irq);
1658 retval = -EBUSY; 1697 retval = -EBUSY;
1659 goto fail1; 1698 goto fail1;
1660 } 1699 }
1661 if (udc->board.vbus_pin > 0) { 1700 if (udc->board.vbus_pin > 0) {
1662 if (request_irq(udc->board.vbus_pin, at91_vbus_irq, IRQF_DISABLED, driver_name, udc)) { 1701 if (request_irq(udc->board.vbus_pin, at91_vbus_irq,
1663 DBG("request vbus irq %d failed\n", udc->board.vbus_pin); 1702 IRQF_DISABLED, driver_name, udc)) {
1664 free_irq(AT91_ID_UDP, udc); 1703 DBG("request vbus irq %d failed\n",
1704 udc->board.vbus_pin);
1705 free_irq(udc->udp_irq, udc);
1665 retval = -EBUSY; 1706 retval = -EBUSY;
1666 goto fail1; 1707 goto fail1;
1667 } 1708 }
@@ -1670,6 +1711,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1670 udc->vbus = 1; 1711 udc->vbus = 1;
1671 } 1712 }
1672 dev_set_drvdata(dev, udc); 1713 dev_set_drvdata(dev, udc);
1714 device_init_wakeup(dev, 1);
1673 create_debug_file(udc); 1715 create_debug_file(udc);
1674 1716
1675 INFO("%s version %s\n", driver_name, DRIVER_VERSION); 1717 INFO("%s version %s\n", driver_name, DRIVER_VERSION);
@@ -1678,14 +1720,14 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1678fail1: 1720fail1:
1679 device_unregister(&udc->gadget.dev); 1721 device_unregister(&udc->gadget.dev);
1680fail0: 1722fail0:
1681 release_mem_region(AT91_VA_BASE_UDP, SZ_16K); 1723 release_mem_region(AT91_BASE_UDP, SZ_16K);
1682 DBG("%s probe failed, %d\n", driver_name, retval); 1724 DBG("%s probe failed, %d\n", driver_name, retval);
1683 return retval; 1725 return retval;
1684} 1726}
1685 1727
1686static int __devexit at91udc_remove(struct platform_device *dev) 1728static int __devexit at91udc_remove(struct platform_device *pdev)
1687{ 1729{
1688 struct at91_udc *udc = platform_get_drvdata(dev); 1730 struct at91_udc *udc = platform_get_drvdata(pdev);
1689 1731
1690 DBG("remove\n"); 1732 DBG("remove\n");
1691 1733
@@ -1694,10 +1736,11 @@ static int __devexit at91udc_remove(struct platform_device *dev)
1694 if (udc->driver != 0) 1736 if (udc->driver != 0)
1695 usb_gadget_unregister_driver(udc->driver); 1737 usb_gadget_unregister_driver(udc->driver);
1696 1738
1739 device_init_wakeup(&pdev->dev, 0);
1697 remove_debug_file(udc); 1740 remove_debug_file(udc);
1698 if (udc->board.vbus_pin > 0) 1741 if (udc->board.vbus_pin > 0)
1699 free_irq(udc->board.vbus_pin, udc); 1742 free_irq(udc->board.vbus_pin, udc);
1700 free_irq(AT91_ID_UDP, udc); 1743 free_irq(udc->udp_irq, udc);
1701 device_unregister(&udc->gadget.dev); 1744 device_unregister(&udc->gadget.dev);
1702 release_mem_region(AT91_BASE_UDP, SZ_16K); 1745 release_mem_region(AT91_BASE_UDP, SZ_16K);
1703 1746
@@ -1708,31 +1751,36 @@ static int __devexit at91udc_remove(struct platform_device *dev)
1708} 1751}
1709 1752
1710#ifdef CONFIG_PM 1753#ifdef CONFIG_PM
1711static int at91udc_suspend(struct platform_device *dev, pm_message_t mesg) 1754static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)
1712{ 1755{
1713 struct at91_udc *udc = platform_get_drvdata(dev); 1756 struct at91_udc *udc = platform_get_drvdata(pdev);
1757 int wake = udc->driver && device_may_wakeup(&pdev->dev);
1714 1758
1715 /* 1759 /* Unless we can act normally to the host (letting it wake us up
1716 * The "safe" suspend transitions are opportunistic ... e.g. when 1760 * whenever it has work for us) force disconnect. Wakeup requires
1717 * the USB link is suspended (48MHz clock autogated off), or when 1761 * PLLB for USB events (signaling for reset, wakeup, or incoming
1718 * it's disconnected (programmatically gated off, elsewhere). 1762 * tokens) and VBUS irqs (on systems which support them).
1719 * Then we can suspend, and the chip can enter slow clock mode.
1720 *
1721 * The problem case is some component (user mode?) suspending this
1722 * device while it's active, with the 48 MHz clock in use. There
1723 * are two basic approaches: (a) veto suspend levels involving slow
1724 * clock mode, (b) disconnect, so 48 MHz will no longer be in use
1725 * and we can enter slow clock mode. This uses (b) for now, since
1726 * it's simplest until AT91 PM exists and supports the other option.
1727 */ 1763 */
1728 if (udc->vbus && !udc->suspended) 1764 if ((!udc->suspended && udc->addr)
1765 || !wake
1766 || at91_suspend_entering_slow_clock()) {
1729 pullup(udc, 0); 1767 pullup(udc, 0);
1768 disable_irq_wake(udc->udp_irq);
1769 } else
1770 enable_irq_wake(udc->udp_irq);
1771
1772 if (udc->board.vbus_pin > 0) {
1773 if (wake)
1774 enable_irq_wake(udc->board.vbus_pin);
1775 else
1776 disable_irq_wake(udc->board.vbus_pin);
1777 }
1730 return 0; 1778 return 0;
1731} 1779}
1732 1780
1733static int at91udc_resume(struct platform_device *dev) 1781static int at91udc_resume(struct platform_device *pdev)
1734{ 1782{
1735 struct at91_udc *udc = platform_get_drvdata(dev); 1783 struct at91_udc *udc = platform_get_drvdata(pdev);
1736 1784
1737 /* maybe reconnect to host; if so, clocks on */ 1785 /* maybe reconnect to host; if so, clocks on */
1738 pullup(udc, 1); 1786 pullup(udc, 1);
@@ -1748,7 +1796,7 @@ static struct platform_driver at91_udc = {
1748 .remove = __devexit_p(at91udc_remove), 1796 .remove = __devexit_p(at91udc_remove),
1749 .shutdown = at91udc_shutdown, 1797 .shutdown = at91udc_shutdown,
1750 .suspend = at91udc_suspend, 1798 .suspend = at91udc_suspend,
1751 .resume = at91udc_resume, 1799 .resume = at91udc_resume,
1752 .driver = { 1800 .driver = {
1753 .name = (char *) driver_name, 1801 .name = (char *) driver_name,
1754 .owner = THIS_MODULE, 1802 .owner = THIS_MODULE,
@@ -1767,6 +1815,6 @@ static void __devexit udc_exit_module(void)
1767} 1815}
1768module_exit(udc_exit_module); 1816module_exit(udc_exit_module);
1769 1817
1770MODULE_DESCRIPTION("AT91RM9200 udc driver"); 1818MODULE_DESCRIPTION("AT91 udc driver");
1771MODULE_AUTHOR("Thomas Rathbone, David Brownell"); 1819MODULE_AUTHOR("Thomas Rathbone, David Brownell");
1772MODULE_LICENSE("GPL"); 1820MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index 5a4799cedd19..882af42e86cc 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -141,6 +141,7 @@ struct at91_udc {
141 struct clk *iclk, *fclk; 141 struct clk *iclk, *fclk;
142 struct platform_device *pdev; 142 struct platform_device *pdev;
143 struct proc_dir_entry *pde; 143 struct proc_dir_entry *pde;
144 int udp_irq;
144}; 145};
145 146
146static inline struct at91_udc *to_udc(struct usb_gadget *g) 147static inline struct at91_udc *to_udc(struct usb_gadget *g)
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 4be47195bd38..7d1c22c34957 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -609,7 +609,8 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req)
609 if (!dum->driver) 609 if (!dum->driver)
610 return -ESHUTDOWN; 610 return -ESHUTDOWN;
611 611
612 spin_lock_irqsave (&dum->lock, flags); 612 local_irq_save (flags);
613 spin_lock (&dum->lock);
613 list_for_each_entry (req, &ep->queue, queue) { 614 list_for_each_entry (req, &ep->queue, queue) {
614 if (&req->req == _req) { 615 if (&req->req == _req) {
615 list_del_init (&req->queue); 616 list_del_init (&req->queue);
@@ -618,7 +619,7 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req)
618 break; 619 break;
619 } 620 }
620 } 621 }
621 spin_unlock_irqrestore (&dum->lock, flags); 622 spin_unlock (&dum->lock);
622 623
623 if (retval == 0) { 624 if (retval == 0) {
624 dev_dbg (udc_dev(dum), 625 dev_dbg (udc_dev(dum),
@@ -626,6 +627,7 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req)
626 req, _ep->name, _req->length, _req->buf); 627 req, _ep->name, _req->length, _req->buf);
627 _req->complete (_ep, _req); 628 _req->complete (_ep, _req);
628 } 629 }
630 local_irq_restore (flags);
629 return retval; 631 return retval;
630} 632}
631 633
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index f7c6d758e1b0..53d584589c26 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -34,12 +34,12 @@
34 34
35 35
36/* we must assign addresses for configurable endpoints (like net2280) */ 36/* we must assign addresses for configurable endpoints (like net2280) */
37static __initdata unsigned epnum; 37static __devinitdata unsigned epnum;
38 38
39// #define MANY_ENDPOINTS 39// #define MANY_ENDPOINTS
40#ifdef MANY_ENDPOINTS 40#ifdef MANY_ENDPOINTS
41/* more than 15 configurable endpoints */ 41/* more than 15 configurable endpoints */
42static __initdata unsigned in_epnum; 42static __devinitdata unsigned in_epnum;
43#endif 43#endif
44 44
45 45
@@ -59,7 +59,7 @@ static __initdata unsigned in_epnum;
59 * NOTE: each endpoint is unidirectional, as specified by its USB 59 * NOTE: each endpoint is unidirectional, as specified by its USB
60 * descriptor; and isn't specific to a configuration or altsetting. 60 * descriptor; and isn't specific to a configuration or altsetting.
61 */ 61 */
62static int __init 62static int __devinit
63ep_matches ( 63ep_matches (
64 struct usb_gadget *gadget, 64 struct usb_gadget *gadget,
65 struct usb_ep *ep, 65 struct usb_ep *ep,
@@ -73,7 +73,7 @@ ep_matches (
73 /* endpoint already claimed? */ 73 /* endpoint already claimed? */
74 if (0 != ep->driver_data) 74 if (0 != ep->driver_data)
75 return 0; 75 return 0;
76 76
77 /* only support ep0 for portable CONTROL traffic */ 77 /* only support ep0 for portable CONTROL traffic */
78 type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 78 type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
79 if (USB_ENDPOINT_XFER_CONTROL == type) 79 if (USB_ENDPOINT_XFER_CONTROL == type)
@@ -186,7 +186,7 @@ ep_matches (
186 return 1; 186 return 1;
187} 187}
188 188
189static struct usb_ep * __init 189static struct usb_ep * __devinit
190find_ep (struct usb_gadget *gadget, const char *name) 190find_ep (struct usb_gadget *gadget, const char *name)
191{ 191{
192 struct usb_ep *ep; 192 struct usb_ep *ep;
@@ -228,7 +228,7 @@ find_ep (struct usb_gadget *gadget, const char *name)
228 * 228 *
229 * On failure, this returns a null endpoint descriptor. 229 * On failure, this returns a null endpoint descriptor.
230 */ 230 */
231struct usb_ep * __init usb_ep_autoconfig ( 231struct usb_ep * __devinit usb_ep_autoconfig (
232 struct usb_gadget *gadget, 232 struct usb_gadget *gadget,
233 struct usb_endpoint_descriptor *desc 233 struct usb_endpoint_descriptor *desc
234) 234)
@@ -276,7 +276,7 @@ struct usb_ep * __init usb_ep_autoconfig (
276 return ep; 276 return ep;
277 } 277 }
278 278
279 /* Second, look at endpoints until an unclaimed one looks usable */ 279 /* Second, look at endpoints until an unclaimed one looks usable */
280 list_for_each_entry (ep, &gadget->ep_list, ep_list) { 280 list_for_each_entry (ep, &gadget->ep_list, ep_list) {
281 if (ep_matches (gadget, ep, desc)) 281 if (ep_matches (gadget, ep, desc))
282 return ep; 282 return ep;
@@ -295,7 +295,7 @@ struct usb_ep * __init usb_ep_autoconfig (
295 * state such as ep->driver_data and the record of assigned endpoints 295 * state such as ep->driver_data and the record of assigned endpoints
296 * used by usb_ep_autoconfig(). 296 * used by usb_ep_autoconfig().
297 */ 297 */
298void __init usb_ep_autoconfig_reset (struct usb_gadget *gadget) 298void __devinit usb_ep_autoconfig_reset (struct usb_gadget *gadget)
299{ 299{
300 struct usb_ep *ep; 300 struct usb_ep *ep;
301 301
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 8320fcef0425..4fe1bec1c255 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2131,7 +2131,7 @@ eth_req_free (struct usb_ep *ep, struct usb_request *req)
2131} 2131}
2132 2132
2133 2133
2134static void __exit 2134static void /* __init_or_exit */
2135eth_unbind (struct usb_gadget *gadget) 2135eth_unbind (struct usb_gadget *gadget)
2136{ 2136{
2137 struct eth_dev *dev = get_gadget_data (gadget); 2137 struct eth_dev *dev = get_gadget_data (gadget);
@@ -2158,7 +2158,7 @@ eth_unbind (struct usb_gadget *gadget)
2158 set_gadget_data (gadget, NULL); 2158 set_gadget_data (gadget, NULL);
2159} 2159}
2160 2160
2161static u8 __init nibble (unsigned char c) 2161static u8 __devinit nibble (unsigned char c)
2162{ 2162{
2163 if (likely (isdigit (c))) 2163 if (likely (isdigit (c)))
2164 return c - '0'; 2164 return c - '0';
@@ -2168,7 +2168,7 @@ static u8 __init nibble (unsigned char c)
2168 return 0; 2168 return 0;
2169} 2169}
2170 2170
2171static int __init get_ether_addr(const char *str, u8 *dev_addr) 2171static int __devinit get_ether_addr(const char *str, u8 *dev_addr)
2172{ 2172{
2173 if (str) { 2173 if (str) {
2174 unsigned i; 2174 unsigned i;
@@ -2189,7 +2189,7 @@ static int __init get_ether_addr(const char *str, u8 *dev_addr)
2189 return 1; 2189 return 1;
2190} 2190}
2191 2191
2192static int __init 2192static int __devinit
2193eth_bind (struct usb_gadget *gadget) 2193eth_bind (struct usb_gadget *gadget)
2194{ 2194{
2195 struct eth_dev *dev; 2195 struct eth_dev *dev;
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index b1a9cf06f3e6..8d7f1e84cd7b 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3691,7 +3691,7 @@ static void lun_release(struct device *dev)
3691 kref_put(&fsg->ref, fsg_release); 3691 kref_put(&fsg->ref, fsg_release);
3692} 3692}
3693 3693
3694static void __exit fsg_unbind(struct usb_gadget *gadget) 3694static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
3695{ 3695{
3696 struct fsg_dev *fsg = get_gadget_data(gadget); 3696 struct fsg_dev *fsg = get_gadget_data(gadget);
3697 int i; 3697 int i;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 354670d12308..408c3380d602 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1398,7 +1398,7 @@ static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
1398#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1398#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1399 1399
1400 1400
1401int __init rndis_init (void) 1401int __devinit rndis_init (void)
1402{ 1402{
1403 u8 i; 1403 u8 i;
1404 1404
diff --git a/drivers/usb/gadget/rndis.h b/drivers/usb/gadget/rndis.h
index 2956608be751..4c3c7259f019 100644
--- a/drivers/usb/gadget/rndis.h
+++ b/drivers/usb/gadget/rndis.h
@@ -264,7 +264,7 @@ int rndis_signal_disconnect (int configNr);
264int rndis_state (int configNr); 264int rndis_state (int configNr);
265extern void rndis_set_host_mac (int configNr, const u8 *addr); 265extern void rndis_set_host_mac (int configNr, const u8 *addr);
266 266
267int __init rndis_init (void); 267int __devinit rndis_init (void);
268void rndis_exit (void); 268void rndis_exit (void);
269 269
270#endif /* _LINUX_RNDIS_H */ 270#endif /* _LINUX_RNDIS_H */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 30d7664d449d..e762aa19ab0a 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -1473,7 +1473,7 @@ autoconf_fail:
1473 * Called on module unload. Frees the control request and device 1473 * Called on module unload. Frees the control request and device
1474 * structure. 1474 * structure.
1475 */ 1475 */
1476static void __exit gs_unbind(struct usb_gadget *gadget) 1476static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1477{ 1477{
1478 struct gs_dev *dev = get_gadget_data(gadget); 1478 struct gs_dev *dev = get_gadget_data(gadget);
1479 1479
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 3a08a7ab4ce0..b7018ee487ea 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1121,7 +1121,7 @@ zero_autoresume (unsigned long _dev)
1121 1121
1122/*-------------------------------------------------------------------------*/ 1122/*-------------------------------------------------------------------------*/
1123 1123
1124static void __exit 1124static void /* __init_or_exit */
1125zero_unbind (struct usb_gadget *gadget) 1125zero_unbind (struct usb_gadget *gadget)
1126{ 1126{
1127 struct zero_dev *dev = get_gadget_data (gadget); 1127 struct zero_dev *dev = get_gadget_data (gadget);
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index d66867aa527e..26ed757d22a6 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -41,8 +41,6 @@
41#endif 41#endif
42#define USBH_DISABLE (USB_MCFG_EBMEN | USB_MCFG_EMEMEN) 42#define USBH_DISABLE (USB_MCFG_EBMEN | USB_MCFG_EMEMEN)
43 43
44#endif /* Au1200 */
45
46extern int usb_disabled(void); 44extern int usb_disabled(void);
47 45
48/*-------------------------------------------------------------------------*/ 46/*-------------------------------------------------------------------------*/
@@ -107,9 +105,9 @@ int usb_ehci_au1xxx_probe(const struct hc_driver *driver,
107 105
108 /* Au1200 AB USB does not support coherent memory */ 106 /* Au1200 AB USB does not support coherent memory */
109 if (!(read_c0_prid() & 0xff)) { 107 if (!(read_c0_prid() & 0xff)) {
110 pr_info("%s: this is chip revision AB!\n", dev->dev.name); 108 pr_info("%s: this is chip revision AB!\n", dev->name);
111 pr_info("%s: update your board or re-configure the kernel\n", 109 pr_info("%s: update your board or re-configure the kernel\n",
112 dev->dev.name); 110 dev->name);
113 return -ENODEV; 111 return -ENODEV;
114 } 112 }
115#endif 113#endif
@@ -228,9 +226,8 @@ static const struct hc_driver ehci_au1xxx_hc_driver = {
228 226
229/*-------------------------------------------------------------------------*/ 227/*-------------------------------------------------------------------------*/
230 228
231static int ehci_hcd_au1xxx_drv_probe(struct device *dev) 229static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
232{ 230{
233 struct platform_device *pdev = to_platform_device(dev);
234 struct usb_hcd *hcd = NULL; 231 struct usb_hcd *hcd = NULL;
235 int ret; 232 int ret;
236 233
@@ -243,10 +240,9 @@ static int ehci_hcd_au1xxx_drv_probe(struct device *dev)
243 return ret; 240 return ret;
244} 241}
245 242
246static int ehci_hcd_au1xxx_drv_remove(struct device *dev) 243static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
247{ 244{
248 struct platform_device *pdev = to_platform_device(dev); 245 struct usb_hcd *hcd = platform_get_drvdata(pdev);
249 struct usb_hcd *hcd = dev_get_drvdata(dev);
250 246
251 usb_ehci_au1xxx_remove(hcd, pdev); 247 usb_ehci_au1xxx_remove(hcd, pdev);
252 return 0; 248 return 0;
@@ -269,12 +265,13 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
269} 265}
270*/ 266*/
271MODULE_ALIAS("au1xxx-ehci"); 267MODULE_ALIAS("au1xxx-ehci");
272/* FIXME use "struct platform_driver" */ 268static struct platform_driver ehci_hcd_au1xxx_driver = {
273static struct device_driver ehci_hcd_au1xxx_driver = {
274 .name = "au1xxx-ehci",
275 .bus = &platform_bus_type,
276 .probe = ehci_hcd_au1xxx_drv_probe, 269 .probe = ehci_hcd_au1xxx_drv_probe,
277 .remove = ehci_hcd_au1xxx_drv_remove, 270 .remove = ehci_hcd_au1xxx_drv_remove,
278 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ 271 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */
279 /*.resume = ehci_hcd_au1xxx_drv_resume, */ 272 /*.resume = ehci_hcd_au1xxx_drv_resume, */
273 .driver = {
274 .name = "au1xxx-ehci",
275 .bus = &platform_bus_type
276 }
280}; 277};
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index cee6f538de0a..d63177a8eaea 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -625,10 +625,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
625 writel (status | CMD_RUN, &ehci->regs->command); 625 writel (status | CMD_RUN, &ehci->regs->command);
626 626
627 while (i--) { 627 while (i--) {
628 status = readl (&ehci->regs->port_status [i]); 628 int pstatus = readl (&ehci->regs->port_status [i]);
629 if (status & PORT_OWNER) 629
630 if (pstatus & PORT_OWNER)
630 continue; 631 continue;
631 if (!(status & PORT_RESUME) 632 if (!(pstatus & PORT_RESUME)
632 || ehci->reset_done [i] != 0) 633 || ehci->reset_done [i] != 0)
633 continue; 634 continue;
634 635
@@ -891,7 +892,7 @@ MODULE_LICENSE ("GPL");
891#define PCI_DRIVER ehci_pci_driver 892#define PCI_DRIVER ehci_pci_driver
892#endif 893#endif
893 894
894#ifdef CONFIG_PPC_83xx 895#ifdef CONFIG_MPC834x
895#include "ehci-fsl.c" 896#include "ehci-fsl.c"
896#define PLATFORM_DRIVER ehci_fsl_driver 897#define PLATFORM_DRIVER ehci_fsl_driver
897#endif 898#endif
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cdbafb710000..85cc059705a6 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2004 SAN People (Pty) Ltd. 4 * Copyright (C) 2004 SAN People (Pty) Ltd.
5 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> 5 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
6 * 6 *
7 * AT91RM9200 Bus Glue 7 * AT91 Bus Glue
8 * 8 *
9 * Based on fragments of 2.4 driver by Rick Bronson. 9 * Based on fragments of 2.4 driver by Rick Bronson.
10 * Based on ohci-omap.c 10 * Based on ohci-omap.c
@@ -19,12 +19,13 @@
19#include <asm/hardware.h> 19#include <asm/hardware.h>
20#include <asm/arch/board.h> 20#include <asm/arch/board.h>
21 21
22#ifndef CONFIG_ARCH_AT91RM9200 22#ifndef CONFIG_ARCH_AT91
23#error "CONFIG_ARCH_AT91RM9200 must be defined." 23#error "CONFIG_ARCH_AT91 must be defined."
24#endif 24#endif
25 25
26/* interface and function clocks */ 26/* interface and function clocks */
27static struct clk *iclk, *fclk; 27static struct clk *iclk, *fclk;
28static int clocked;
28 29
29extern int usb_disabled(void); 30extern int usb_disabled(void);
30 31
@@ -35,13 +36,14 @@ static void at91_start_hc(struct platform_device *pdev)
35 struct usb_hcd *hcd = platform_get_drvdata(pdev); 36 struct usb_hcd *hcd = platform_get_drvdata(pdev);
36 struct ohci_regs __iomem *regs = hcd->regs; 37 struct ohci_regs __iomem *regs = hcd->regs;
37 38
38 dev_dbg(&pdev->dev, "starting AT91RM9200 OHCI USB Controller\n"); 39 dev_dbg(&pdev->dev, "start\n");
39 40
40 /* 41 /*
41 * Start the USB clocks. 42 * Start the USB clocks.
42 */ 43 */
43 clk_enable(iclk); 44 clk_enable(iclk);
44 clk_enable(fclk); 45 clk_enable(fclk);
46 clocked = 1;
45 47
46 /* 48 /*
47 * The USB host controller must remain in reset. 49 * The USB host controller must remain in reset.
@@ -54,7 +56,7 @@ static void at91_stop_hc(struct platform_device *pdev)
54 struct usb_hcd *hcd = platform_get_drvdata(pdev); 56 struct usb_hcd *hcd = platform_get_drvdata(pdev);
55 struct ohci_regs __iomem *regs = hcd->regs; 57 struct ohci_regs __iomem *regs = hcd->regs;
56 58
57 dev_dbg(&pdev->dev, "stopping AT91RM9200 OHCI USB Controller\n"); 59 dev_dbg(&pdev->dev, "stop\n");
58 60
59 /* 61 /*
60 * Put the USB host controller into reset. 62 * Put the USB host controller into reset.
@@ -66,6 +68,7 @@ static void at91_stop_hc(struct platform_device *pdev)
66 */ 68 */
67 clk_disable(fclk); 69 clk_disable(fclk);
68 clk_disable(iclk); 70 clk_disable(iclk);
71 clocked = 0;
69} 72}
70 73
71 74
@@ -78,14 +81,15 @@ static int usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
78 81
79 82
80/** 83/**
81 * usb_hcd_at91_probe - initialize AT91RM9200-based HCDs 84 * usb_hcd_at91_probe - initialize AT91-based HCDs
82 * Context: !in_interrupt() 85 * Context: !in_interrupt()
83 * 86 *
84 * Allocates basic resources for this USB host controller, and 87 * Allocates basic resources for this USB host controller, and
85 * then invokes the start() method for the HCD associated with it 88 * then invokes the start() method for the HCD associated with it
86 * through the hotplug entry's driver_data. 89 * through the hotplug entry's driver_data.
87 */ 90 */
88int usb_hcd_at91_probe (const struct hc_driver *driver, struct platform_device *pdev) 91static int usb_hcd_at91_probe(const struct hc_driver *driver,
92 struct platform_device *pdev)
89{ 93{
90 int retval; 94 int retval;
91 struct usb_hcd *hcd = NULL; 95 struct usb_hcd *hcd = NULL;
@@ -95,12 +99,13 @@ int usb_hcd_at91_probe (const struct hc_driver *driver, struct platform_device *
95 return -ENODEV; 99 return -ENODEV;
96 } 100 }
97 101
98 if ((pdev->resource[0].flags != IORESOURCE_MEM) || (pdev->resource[1].flags != IORESOURCE_IRQ)) { 102 if ((pdev->resource[0].flags != IORESOURCE_MEM)
103 || (pdev->resource[1].flags != IORESOURCE_IRQ)) {
99 pr_debug("hcd probe: invalid resource type\n"); 104 pr_debug("hcd probe: invalid resource type\n");
100 return -ENODEV; 105 return -ENODEV;
101 } 106 }
102 107
103 hcd = usb_create_hcd(driver, &pdev->dev, "at91rm9200"); 108 hcd = usb_create_hcd(driver, &pdev->dev, "at91");
104 if (!hcd) 109 if (!hcd)
105 return -ENOMEM; 110 return -ENOMEM;
106 hcd->rsrc_start = pdev->resource[0].start; 111 hcd->rsrc_start = pdev->resource[0].start;
@@ -149,21 +154,23 @@ int usb_hcd_at91_probe (const struct hc_driver *driver, struct platform_device *
149/* may be called with controller, bus, and devices active */ 154/* may be called with controller, bus, and devices active */
150 155
151/** 156/**
152 * usb_hcd_at91_remove - shutdown processing for AT91RM9200-based HCDs 157 * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs
153 * @dev: USB Host Controller being removed 158 * @dev: USB Host Controller being removed
154 * Context: !in_interrupt() 159 * Context: !in_interrupt()
155 * 160 *
156 * Reverses the effect of usb_hcd_at91_probe(), first invoking 161 * Reverses the effect of usb_hcd_at91_probe(), first invoking
157 * the HCD's stop() method. It is always called from a thread 162 * the HCD's stop() method. It is always called from a thread
158 * context, normally "rmmod", "apmd", or something similar. 163 * context, "rmmod" or something similar.
159 * 164 *
160 */ 165 */
161static int usb_hcd_at91_remove (struct usb_hcd *hcd, struct platform_device *pdev) 166static int usb_hcd_at91_remove(struct usb_hcd *hcd,
167 struct platform_device *pdev)
162{ 168{
163 usb_remove_hcd(hcd); 169 usb_remove_hcd(hcd);
164 at91_stop_hc(pdev); 170 at91_stop_hc(pdev);
165 iounmap(hcd->regs); 171 iounmap(hcd->regs);
166 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 172 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
173 disable_irq_wake(hcd->irq);
167 174
168 clk_put(fclk); 175 clk_put(fclk);
169 clk_put(iclk); 176 clk_put(iclk);
@@ -178,19 +185,21 @@ static int usb_hcd_at91_remove (struct usb_hcd *hcd, struct platform_device *pde
178static int __devinit 185static int __devinit
179ohci_at91_start (struct usb_hcd *hcd) 186ohci_at91_start (struct usb_hcd *hcd)
180{ 187{
181// struct at91_ohci_data *board = hcd->self.controller->platform_data; 188 struct at91_usbh_data *board = hcd->self.controller->platform_data;
182 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 189 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
190 struct usb_device *root = hcd->self.root_hub;
183 int ret; 191 int ret;
184 192
185 if ((ret = ohci_init(ohci)) < 0) 193 if ((ret = ohci_init(ohci)) < 0)
186 return ret; 194 return ret;
187 195
196 root->maxchild = board->ports;
197
188 if ((ret = ohci_run(ohci)) < 0) { 198 if ((ret = ohci_run(ohci)) < 0) {
189 err("can't start %s", hcd->self.bus_name); 199 err("can't start %s", hcd->self.bus_name);
190 ohci_stop(hcd); 200 ohci_stop(hcd);
191 return ret; 201 return ret;
192 } 202 }
193// hcd->self.root_hub->maxchild = board->ports;
194 return 0; 203 return 0;
195} 204}
196 205
@@ -198,7 +207,7 @@ ohci_at91_start (struct usb_hcd *hcd)
198 207
199static const struct hc_driver ohci_at91_hc_driver = { 208static const struct hc_driver ohci_at91_hc_driver = {
200 .description = hcd_name, 209 .description = hcd_name,
201 .product_desc = "AT91RM9200 OHCI", 210 .product_desc = "AT91 OHCI",
202 .hcd_priv_size = sizeof(struct ohci_hcd), 211 .hcd_priv_size = sizeof(struct ohci_hcd),
203 212
204 /* 213 /*
@@ -240,33 +249,54 @@ static const struct hc_driver ohci_at91_hc_driver = {
240 249
241/*-------------------------------------------------------------------------*/ 250/*-------------------------------------------------------------------------*/
242 251
243static int ohci_hcd_at91_drv_probe(struct platform_device *dev) 252static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
244{ 253{
245 return usb_hcd_at91_probe(&ohci_at91_hc_driver, dev); 254 device_init_wakeup(&pdev->dev, 1);
255 return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
246} 256}
247 257
248static int ohci_hcd_at91_drv_remove(struct platform_device *dev) 258static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
249{ 259{
250 return usb_hcd_at91_remove(platform_get_drvdata(dev), dev); 260 device_init_wakeup(&pdev->dev, 0);
261 return usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
251} 262}
252 263
253#ifdef CONFIG_PM 264#ifdef CONFIG_PM
254 265
255/* REVISIT suspend/resume look "too" simple here */
256
257static int 266static int
258ohci_hcd_at91_drv_suspend(struct platform_device *dev, pm_message_t mesg) 267ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
259{ 268{
260 clk_disable(fclk); 269 struct usb_hcd *hcd = platform_get_drvdata(pdev);
261 clk_disable(iclk); 270 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
271
272 if (device_may_wakeup(&pdev->dev))
273 enable_irq_wake(hcd->irq);
274 else
275 disable_irq_wake(hcd->irq);
276
277 /*
278 * The integrated transceivers seem unable to notice disconnect,
279 * reconnect, or wakeup without the 48 MHz clock active. so for
280 * correctness, always discard connection state (using reset).
281 *
282 * REVISIT: some boards will be able to turn VBUS off...
283 */
284 if (at91_suspend_entering_slow_clock()) {
285 ohci_usb_reset (ohci);
286 clk_disable(fclk);
287 clk_disable(iclk);
288 clocked = 0;
289 }
262 290
263 return 0; 291 return 0;
264} 292}
265 293
266static int ohci_hcd_at91_drv_resume(struct platform_device *dev) 294static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
267{ 295{
268 clk_enable(iclk); 296 if (!clocked) {
269 clk_enable(fclk); 297 clk_enable(iclk);
298 clk_enable(fclk);
299 }
270 300
271 return 0; 301 return 0;
272} 302}
@@ -275,7 +305,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *dev)
275#define ohci_hcd_at91_drv_resume NULL 305#define ohci_hcd_at91_drv_resume NULL
276#endif 306#endif
277 307
278MODULE_ALIAS("at91rm9200-ohci"); 308MODULE_ALIAS("at91_ohci");
279 309
280static struct platform_driver ohci_hcd_at91_driver = { 310static struct platform_driver ohci_hcd_at91_driver = {
281 .probe = ohci_hcd_at91_drv_probe, 311 .probe = ohci_hcd_at91_drv_probe,
@@ -283,7 +313,7 @@ static struct platform_driver ohci_hcd_at91_driver = {
283 .suspend = ohci_hcd_at91_drv_suspend, 313 .suspend = ohci_hcd_at91_drv_suspend,
284 .resume = ohci_hcd_at91_drv_resume, 314 .resume = ohci_hcd_at91_drv_resume,
285 .driver = { 315 .driver = {
286 .name = "at91rm9200-ohci", 316 .name = "at91_ohci",
287 .owner = THIS_MODULE, 317 .owner = THIS_MODULE,
288 }, 318 },
289}; 319};
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 689261e44018..822914e2f43b 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -101,13 +101,16 @@ static void au1xxx_start_ohc(struct platform_device *dev)
101 101
102#endif /* Au1200 */ 102#endif /* Au1200 */
103 103
104#ifndef CONFIG_SOC_AU1200
104 /* wait for reset complete (read register twice; see au1500 errata) */ 105 /* wait for reset complete (read register twice; see au1500 errata) */
105 while (au_readl(USB_HOST_CONFIG), 106 while (au_readl(USB_HOST_CONFIG),
106 !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD)) 107 !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
108#endif
107 udelay(1000); 109 udelay(1000);
108 110
109 printk(KERN_DEBUG __FILE__ 111 printk(KERN_DEBUG __FILE__
110 ": Clock to USB host has been enabled \n"); 112 ": Clock to USB host has been enabled \n");
113#endif
111} 114}
112 115
113static void au1xxx_stop_ohc(struct platform_device *dev) 116static void au1xxx_stop_ohc(struct platform_device *dev)
@@ -157,9 +160,9 @@ static int usb_ohci_au1xxx_probe(const struct hc_driver *driver,
157 /* Au1200 AB USB does not support coherent memory */ 160 /* Au1200 AB USB does not support coherent memory */
158 if (!(read_c0_prid() & 0xff)) { 161 if (!(read_c0_prid() & 0xff)) {
159 pr_info("%s: this is chip revision AB !!\n", 162 pr_info("%s: this is chip revision AB !!\n",
160 dev->dev.name); 163 dev->name);
161 pr_info("%s: update your board or re-configure the kernel\n", 164 pr_info("%s: update your board or re-configure the kernel\n",
162 dev->dev.name); 165 dev->name);
163 return -ENODEV; 166 return -ENODEV;
164 } 167 }
165#endif 168#endif
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
new file mode 100644
index 000000000000..6531c4d26527
--- /dev/null
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -0,0 +1,225 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 *
8 * Bus Glue for ep93xx.
9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Russell King et al.
12 *
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
15 *
16 * Modified for pxa27x from ohci-lh7a404.c
17 * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
18 *
19 * Modified for ep93xx from ohci-pxa27x.c
20 * by Lennert Buytenhek <buytenh@wantstofly.org> 28-2-2006
21 * Based on an earlier driver by Ray Lehtiniemi
22 *
23 * This file is licenced under the GPL.
24 */
25
26#include <linux/clk.h>
27#include <linux/device.h>
28#include <linux/signal.h>
29#include <linux/platform_device.h>
30
31#include <asm/mach-types.h>
32#include <asm/hardware.h>
33
34static struct clk *usb_host_clock;
35
36static void ep93xx_start_hc(struct device *dev)
37{
38 clk_enable(usb_host_clock);
39}
40
41static void ep93xx_stop_hc(struct device *dev)
42{
43 clk_disable(usb_host_clock);
44}
45
46static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
47 struct platform_device *pdev)
48{
49 int retval;
50 struct usb_hcd *hcd;
51
52 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
53 pr_debug("resource[1] is not IORESOURCE_IRQ");
54 return -ENOMEM;
55 }
56
57 hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
58 if (hcd == NULL)
59 return -ENOMEM;
60
61 hcd->rsrc_start = pdev->resource[0].start;
62 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
63 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
64 usb_put_hcd(hcd);
65 retval = -EBUSY;
66 goto err1;
67 }
68
69 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
70 if (hcd->regs == NULL) {
71 pr_debug("ioremap failed");
72 retval = -ENOMEM;
73 goto err2;
74 }
75
76 usb_host_clock = clk_get(&pdev->dev, "usb_host");
77 ep93xx_start_hc(&pdev->dev);
78
79 ohci_hcd_init(hcd_to_ohci(hcd));
80
81 retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT);
82 if (retval == 0)
83 return retval;
84
85 ep93xx_stop_hc(&pdev->dev);
86 iounmap(hcd->regs);
87err2:
88 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
89err1:
90 usb_put_hcd(hcd);
91
92 return retval;
93}
94
95static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
96 struct platform_device *pdev)
97{
98 usb_remove_hcd(hcd);
99 ep93xx_stop_hc(&pdev->dev);
100 clk_put(usb_host_clock);
101 iounmap(hcd->regs);
102 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
103 usb_put_hcd(hcd);
104}
105
106static int __devinit ohci_ep93xx_start(struct usb_hcd *hcd)
107{
108 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
109 int ret;
110
111 if ((ret = ohci_init(ohci)) < 0)
112 return ret;
113
114 if ((ret = ohci_run(ohci)) < 0) {
115 err("can't start %s", hcd->self.bus_name);
116 ohci_stop(hcd);
117 return ret;
118 }
119
120 return 0;
121}
122
123static struct hc_driver ohci_ep93xx_hc_driver = {
124 .description = hcd_name,
125 .product_desc = "EP93xx OHCI",
126 .hcd_priv_size = sizeof(struct ohci_hcd),
127 .irq = ohci_irq,
128 .flags = HCD_USB11 | HCD_MEMORY,
129 .start = ohci_ep93xx_start,
130 .stop = ohci_stop,
131 .urb_enqueue = ohci_urb_enqueue,
132 .urb_dequeue = ohci_urb_dequeue,
133 .endpoint_disable = ohci_endpoint_disable,
134 .get_frame_number = ohci_get_frame,
135 .hub_status_data = ohci_hub_status_data,
136 .hub_control = ohci_hub_control,
137#ifdef CONFIG_PM
138 .bus_suspend = ohci_bus_suspend,
139 .bus_resume = ohci_bus_resume,
140#endif
141 .start_port_reset = ohci_start_port_reset,
142};
143
144extern int usb_disabled(void);
145
146static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev)
147{
148 int ret;
149
150 ret = -ENODEV;
151 if (!usb_disabled())
152 ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev);
153
154 return ret;
155}
156
157static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev)
158{
159 struct usb_hcd *hcd = platform_get_drvdata(pdev);
160
161 usb_hcd_ep93xx_remove(hcd, pdev);
162
163 return 0;
164}
165
166#ifdef CONFIG_PM
167static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_t state)
168{
169 struct usb_hcd *hcd = platform_get_drvdata(pdev);
170 struct ochi_hcd *ohci = hcd_to_ohci(hcd);
171
172 if (time_before(jiffies, ohci->next_statechange))
173 msleep(5);
174 ohci->next_statechange = jiffies;
175
176 ep93xx_stop_hc(&pdev->dev);
177 hcd->state = HC_STATE_SUSPENDED;
178 pdev->dev.power.power_state = PMSG_SUSPEND;
179
180 return 0;
181}
182
183static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
184{
185 struct usb_hcd *hcd = platform_get_drvdata(pdev);
186 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
187 int status;
188
189 if (time_before(jiffies, ohci->next_statechange))
190 msleep(5);
191 ohci->next_statechange = jiffies;
192
193 ep93xx_start_hc(&pdev->dev);
194 pdev->dev.power.power_state = PMSG_ON;
195 usb_hcd_resume_root_hub(hcd);
196
197 return 0;
198}
199#endif
200
201
202static struct platform_driver ohci_hcd_ep93xx_driver = {
203 .probe = ohci_hcd_ep93xx_drv_probe,
204 .remove = ohci_hcd_ep93xx_drv_remove,
205#ifdef CONFIG_PM
206 .suspend = ohci_hcd_ep93xx_drv_suspend,
207 .resume = ohci_hcd_ep93xx_drv_resume,
208#endif
209 .driver = {
210 .name = "ep93xx-ohci",
211 },
212};
213
214static int __init ohci_hcd_ep93xx_init(void)
215{
216 return platform_driver_register(&ohci_hcd_ep93xx_driver);
217}
218
219static void __exit ohci_hcd_ep93xx_cleanup(void)
220{
221 platform_driver_unregister(&ohci_hcd_ep93xx_driver);
222}
223
224module_init(ohci_hcd_ep93xx_init);
225module_exit(ohci_hcd_ep93xx_cleanup);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 8fb842ed5f6e..94d8cf4b36c1 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -901,6 +901,10 @@ MODULE_LICENSE ("GPL");
901#include "ohci-pxa27x.c" 901#include "ohci-pxa27x.c"
902#endif 902#endif
903 903
904#ifdef CONFIG_ARCH_EP93XX
905#include "ohci-ep93xx.c"
906#endif
907
904#ifdef CONFIG_SOC_AU1X00 908#ifdef CONFIG_SOC_AU1X00
905#include "ohci-au1xxx.c" 909#include "ohci-au1xxx.c"
906#endif 910#endif
@@ -909,7 +913,7 @@ MODULE_LICENSE ("GPL");
909#include "ohci-ppc-soc.c" 913#include "ohci-ppc-soc.c"
910#endif 914#endif
911 915
912#ifdef CONFIG_ARCH_AT91RM9200 916#if defined(CONFIG_ARCH_AT91RM9200) || defined(CONFIG_ARCH_AT91SAM9261)
913#include "ohci-at91.c" 917#include "ohci-at91.c"
914#endif 918#endif
915 919
@@ -919,9 +923,11 @@ MODULE_LICENSE ("GPL");
919 || defined(CONFIG_ARCH_OMAP) \ 923 || defined(CONFIG_ARCH_OMAP) \
920 || defined (CONFIG_ARCH_LH7A404) \ 924 || defined (CONFIG_ARCH_LH7A404) \
921 || defined (CONFIG_PXA27x) \ 925 || defined (CONFIG_PXA27x) \
926 || defined (CONFIG_ARCH_EP93XX) \
922 || defined (CONFIG_SOC_AU1X00) \ 927 || defined (CONFIG_SOC_AU1X00) \
923 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ 928 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
924 || defined (CONFIG_ARCH_AT91RM9200) \ 929 || defined (CONFIG_ARCH_AT91RM9200) \
930 || defined (CONFIG_ARCH_AT91SAM9261) \
925 ) 931 )
926#error "missing bus glue for ohci-hcd" 932#error "missing bus glue for ohci-hcd"
927#endif 933#endif
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 0bb972b58336..5b0a23fd798b 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -581,14 +581,14 @@ static int ohci_hub_control (
581 break; 581 break;
582 case GetHubStatus: 582 case GetHubStatus:
583 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE); 583 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE);
584 *(__le32 *) buf = cpu_to_le32 (temp); 584 put_unaligned(cpu_to_le32 (temp), (__le32 *) buf);
585 break; 585 break;
586 case GetPortStatus: 586 case GetPortStatus:
587 if (!wIndex || wIndex > ports) 587 if (!wIndex || wIndex > ports)
588 goto error; 588 goto error;
589 wIndex--; 589 wIndex--;
590 temp = roothub_portstatus (ohci, wIndex); 590 temp = roothub_portstatus (ohci, wIndex);
591 *(__le32 *) buf = cpu_to_le32 (temp); 591 put_unaligned(cpu_to_le32 (temp), (__le32 *) buf);
592 592
593#ifndef OHCI_VERBOSE_DEBUG 593#ifndef OHCI_VERBOSE_DEBUG
594 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */ 594 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index dff60568b4a1..20861650905e 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -167,8 +167,6 @@ static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx)
167static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) 167static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
168{ 168{
169 void __iomem *base; 169 void __iomem *base;
170 int wait_time;
171 u32 control;
172 170
173 if (!mmio_resource_enabled(pdev, 0)) 171 if (!mmio_resource_enabled(pdev, 0))
174 return; 172 return;
@@ -179,9 +177,10 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
179 177
180/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ 178/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
181#ifndef __hppa__ 179#ifndef __hppa__
182 control = readl(base + OHCI_CONTROL); 180{
181 u32 control = readl(base + OHCI_CONTROL);
183 if (control & OHCI_CTRL_IR) { 182 if (control & OHCI_CTRL_IR) {
184 wait_time = 500; /* arbitrary; 5 seconds */ 183 int wait_time = 500; /* arbitrary; 5 seconds */
185 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE); 184 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
186 writel(OHCI_OCR, base + OHCI_CMDSTATUS); 185 writel(OHCI_OCR, base + OHCI_CMDSTATUS);
187 while (wait_time > 0 && 186 while (wait_time > 0 &&
@@ -198,6 +197,7 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
198 /* reset controller, preserving RWC */ 197 /* reset controller, preserving RWC */
199 writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL); 198 writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
200 } 199 }
200}
201#endif 201#endif
202 202
203 /* 203 /*
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index c9d72ac0a1d7..66c3f61bc9d1 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -943,7 +943,9 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
943 /* We received a short packet */ 943 /* We received a short packet */
944 if (urb->transfer_flags & URB_SHORT_NOT_OK) 944 if (urb->transfer_flags & URB_SHORT_NOT_OK)
945 ret = -EREMOTEIO; 945 ret = -EREMOTEIO;
946 else if (ctrlstat & TD_CTRL_SPD) 946
947 /* Fixup needed only if this isn't the URB's last TD */
948 else if (&td->list != urbp->td_list.prev)
947 ret = 1; 949 ret = 1;
948 } 950 }
949 951
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 05d2d6012eb2..df198cf76f52 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -152,9 +152,8 @@ static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
152 * events. The hardware generates 5 events for the first keypress 152 * events. The hardware generates 5 events for the first keypress
153 * and we have to take this into account for an accurate repeat 153 * and we have to take this into account for an accurate repeat
154 * behaviour. 154 * behaviour.
155 * (HZ / 20) == 50 ms and works well for me.
156 */ 155 */
157#define FILTER_TIME (HZ / 20) 156#define FILTER_TIME 60 /* msec */
158 157
159struct ati_remote { 158struct ati_remote {
160 struct input_dev *idev; 159 struct input_dev *idev;
@@ -467,7 +466,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
467 /* Filter duplicate events which happen "too close" together. */ 466 /* Filter duplicate events which happen "too close" together. */
468 if ((ati_remote->old_data[0] == data[1]) && 467 if ((ati_remote->old_data[0] == data[1]) &&
469 (ati_remote->old_data[1] == data[2]) && 468 (ati_remote->old_data[1] == data[2]) &&
470 time_before(jiffies, ati_remote->old_jiffies + FILTER_TIME)) { 469 time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(FILTER_TIME))) {
471 ati_remote->repeat_count++; 470 ati_remote->repeat_count++;
472 } else { 471 } else {
473 ati_remote->repeat_count = 0; 472 ati_remote->repeat_count = 0;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index b9fb9687f926..8ea9c915fbf9 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1507,6 +1507,9 @@ void hid_init_reports(struct hid_device *hid)
1507#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 1507#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
1508#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 1508#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
1509 1509
1510#define USB_VENDOR_ID_WISEGROUP_LTD 0x6677
1511#define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802
1512
1510#define USB_VENDOR_ID_CODEMERCS 0x07c0 1513#define USB_VENDOR_ID_CODEMERCS 0x07c0
1511#define USB_DEVICE_ID_CODEMERCS_IOW40 0x1500 1514#define USB_DEVICE_ID_CODEMERCS_IOW40 0x1500
1512#define USB_DEVICE_ID_CODEMERCS_IOW24 0x1501 1515#define USB_DEVICE_ID_CODEMERCS_IOW24 0x1501
@@ -1670,6 +1673,7 @@ static const struct hid_blacklist {
1670 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 1673 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
1671 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 1674 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
1672 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 1675 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
1676 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
1673 1677
1674 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL }, 1678 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
1675 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, 1679 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index daa486dde8cf..88928a4be805 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -88,19 +88,19 @@ config USB_LED
88 To compile this driver as a module, choose M here: the 88 To compile this driver as a module, choose M here: the
89 module will be called usbled. 89 module will be called usbled.
90 90
91config USB_CY7C63 91config USB_CYPRESS_CY7C63
92 tristate "Cypress CY7C63xxx USB driver support" 92 tristate "Cypress CY7C63xxx USB driver support"
93 depends on USB 93 depends on USB
94 help 94 help
95 Say Y here if you want to connect a Cypress CY7C63xxx 95 Say Y here if you want to connect a Cypress CY7C63xxx
96 micro controller to your computer's USB port. This driver 96 micro controller to your computer's USB port. Currently this
97 supports the pre-programmed devices (incl. firmware) by 97 driver supports the pre-programmed devices (incl. firmware)
98 AK Modul-Bus Computer GmbH. 98 by AK Modul-Bus Computer GmbH.
99 99
100 Please see: http://www.ak-modul-bus.de/stat/mikrocontroller.html 100 Please see: http://www.ak-modul-bus.de/stat/mikrocontroller.html
101 101
102 To compile this driver as a module, choose M here: the 102 To compile this driver as a module, choose M here: the
103 module will be called cy7c63. 103 module will be called cypress_cy7c63.
104 104
105config USB_CYTHERM 105config USB_CYTHERM
106 tristate "Cypress USB thermometer driver support" 106 tristate "Cypress USB thermometer driver support"
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index f25a97227297..2927260c5812 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -4,7 +4,7 @@
4# 4#
5 5
6obj-$(CONFIG_USB_AUERSWALD) += auerswald.o 6obj-$(CONFIG_USB_AUERSWALD) += auerswald.o
7obj-$(CONFIG_USB_CY7C63) += cy7c63.o 7obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
8obj-$(CONFIG_USB_CYTHERM) += cytherm.o 8obj-$(CONFIG_USB_CYTHERM) += cytherm.o
9obj-$(CONFIG_USB_EMI26) += emi26.o 9obj-$(CONFIG_USB_EMI26) += emi26.o
10obj-$(CONFIG_USB_EMI62) += emi62.o 10obj-$(CONFIG_USB_EMI62) += emi62.o
diff --git a/drivers/usb/misc/cy7c63.c b/drivers/usb/misc/cy7c63.c
deleted file mode 100644
index 8a1c10b89b76..000000000000
--- a/drivers/usb/misc/cy7c63.c
+++ /dev/null
@@ -1,244 +0,0 @@
1/*
2* cy7c63.c
3*
4* Copyright (c) 2006 Oliver Bock (bock@fh-wolfenbuettel.de)
5*
6* This driver is based on the Cypress Thermometer USB Driver by
7* Marcus Maul and the 2.0 version of Greg Kroah-Hartman's
8* USB Skeleton driver.
9*
10* Is is a generic driver for the Cypress CY7C63000 family.
11* For the time being it enables you to toggle the single I/O ports
12* of the device.
13*
14* Supported vendors: AK Modul-Bus Computer GmbH
15* Supported devices: CY7C63001A-PC (to be continued...)
16* Supported functions: Read/Write Ports (to be continued...)
17*
18* Chipsets families: CY7C63000, CY7C63001, CY7C63100, CY7C63101
19*
20*
21* This program is free software; you can redistribute it and/or
22* modify it under the terms of the GNU General Public License as
23* published by the Free Software Foundation, version 2.
24*/
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/usb.h>
30
31#define DRIVER_AUTHOR "Oliver Bock (bock@fh-wolfenbuettel.de)"
32#define DRIVER_DESC "Cypress CY7C63xxx USB driver"
33
34#define CY7C63_VENDOR_ID 0xa2c
35#define CY7C63_PRODUCT_ID 0x8
36
37#define CY7C63_READ_PORT 0x4
38#define CY7C63_WRITE_PORT 0x5
39#define CY7C63_READ_RAM 0x2
40#define CY7C63_WRITE_RAM 0x3
41#define CY7C63_READ_ROM 0x1
42
43#define CY7C63_READ_PORT_ID0 0
44#define CY7C63_WRITE_PORT_ID0 0
45#define CY7C63_READ_PORT_ID1 0x2
46#define CY7C63_WRITE_PORT_ID1 1
47
48#define CY7C63_MAX_REQSIZE 8
49
50
51/* table of devices that work with this driver */
52static struct usb_device_id cy7c63_table [] = {
53 { USB_DEVICE(CY7C63_VENDOR_ID, CY7C63_PRODUCT_ID) },
54 { }
55};
56MODULE_DEVICE_TABLE(usb, cy7c63_table);
57
58/* structure to hold all of our device specific stuff */
59struct cy7c63 {
60 struct usb_device * udev;
61 char port0;
62 char port1;
63};
64
65/* used to send usb control messages to device */
66int vendor_command(struct cy7c63 *dev, unsigned char request,
67 unsigned char address, unsigned char data) {
68
69 int retval = 0;
70 unsigned int pipe;
71 unsigned char *iobuf;
72
73 /* allocate some memory for the i/o buffer*/
74 iobuf = kzalloc(CY7C63_MAX_REQSIZE, GFP_KERNEL);
75 if (!iobuf) {
76 dev_err(&dev->udev->dev, "Out of memory!\n");
77 retval = -ENOMEM;
78 goto error;
79 }
80
81 dev_dbg(&dev->udev->dev, "Sending usb_control_msg (data: %d)\n", data);
82
83 /* prepare usb control message and send it upstream */
84 pipe = usb_rcvctrlpipe(dev->udev, 0);
85 retval = usb_control_msg(dev->udev, pipe, request,
86 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
87 address, data, iobuf, CY7C63_MAX_REQSIZE,
88 USB_CTRL_GET_TIMEOUT);
89
90 /* store returned data (more READs to be added!) */
91 switch (request) {
92 case CY7C63_READ_PORT:
93 if (address == CY7C63_READ_PORT_ID0) {
94 dev->port0 = iobuf[1];
95 dev_dbg(&dev->udev->dev,
96 "READ_PORT0 returned: %d\n",dev->port0);
97 }
98 else if (address == CY7C63_READ_PORT_ID1) {
99 dev->port1 = iobuf[1];
100 dev_dbg(&dev->udev->dev,
101 "READ_PORT1 returned: %d\n",dev->port1);
102 }
103 break;
104 }
105
106 kfree(iobuf);
107error:
108 return retval;
109}
110
111#define get_set_port(num,read_id,write_id) \
112static ssize_t set_port##num(struct device *dev, struct device_attribute *attr, \
113 const char *buf, size_t count) { \
114 \
115 int value; \
116 int result = 0; \
117 \
118 struct usb_interface *intf = to_usb_interface(dev); \
119 struct cy7c63 *cyp = usb_get_intfdata(intf); \
120 \
121 dev_dbg(&cyp->udev->dev, "WRITE_PORT%d called\n", num); \
122 \
123 /* validate input data */ \
124 if (sscanf(buf, "%d", &value) < 1) { \
125 result = -EINVAL; \
126 goto error; \
127 } \
128 if (value>255 || value<0) { \
129 result = -EINVAL; \
130 goto error; \
131 } \
132 \
133 result = vendor_command(cyp, CY7C63_WRITE_PORT, write_id, \
134 (unsigned char)value); \
135 \
136 dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n",result); \
137error: \
138 return result < 0 ? result : count; \
139} \
140 \
141static ssize_t get_port##num(struct device *dev, \
142 struct device_attribute *attr, char *buf) { \
143 \
144 int result = 0; \
145 \
146 struct usb_interface *intf = to_usb_interface(dev); \
147 struct cy7c63 *cyp = usb_get_intfdata(intf); \
148 \
149 dev_dbg(&cyp->udev->dev, "READ_PORT%d called\n", num); \
150 \
151 result = vendor_command(cyp, CY7C63_READ_PORT, read_id, 0); \
152 \
153 dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n", result); \
154 \
155 return sprintf(buf, "%d", cyp->port##num); \
156} \
157static DEVICE_ATTR(port##num, S_IWUGO | S_IRUGO, get_port##num, set_port##num);
158
159get_set_port(0, CY7C63_READ_PORT_ID0, CY7C63_WRITE_PORT_ID0);
160get_set_port(1, CY7C63_READ_PORT_ID1, CY7C63_WRITE_PORT_ID1);
161
162static int cy7c63_probe(struct usb_interface *interface,
163 const struct usb_device_id *id) {
164
165 struct cy7c63 *dev = NULL;
166 int retval = -ENOMEM;
167
168 /* allocate memory for our device state and initialize it */
169 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
170 if (dev == NULL) {
171 dev_err(&dev->udev->dev, "Out of memory!\n");
172 goto error;
173 }
174
175 dev->udev = usb_get_dev(interface_to_usbdev(interface));
176
177 /* save our data pointer in this interface device */
178 usb_set_intfdata(interface, dev);
179
180 /* create device attribute files */
181 device_create_file(&interface->dev, &dev_attr_port0);
182 device_create_file(&interface->dev, &dev_attr_port1);
183
184 /* let the user know what node this device is now attached to */
185 dev_info(&interface->dev,
186 "Cypress CY7C63xxx device now attached\n");
187
188 retval = 0;
189error:
190 return retval;
191}
192
193static void cy7c63_disconnect(struct usb_interface *interface) {
194
195 struct cy7c63 *dev;
196
197 dev = usb_get_intfdata(interface);
198 usb_set_intfdata(interface, NULL);
199
200 /* remove device attribute files */
201 device_remove_file(&interface->dev, &dev_attr_port0);
202 device_remove_file(&interface->dev, &dev_attr_port1);
203
204 usb_put_dev(dev->udev);
205
206 dev_info(&interface->dev,
207 "Cypress CY7C63xxx device now disconnected\n");
208
209 kfree(dev);
210}
211
212static struct usb_driver cy7c63_driver = {
213 .name = "cy7c63",
214 .probe = cy7c63_probe,
215 .disconnect = cy7c63_disconnect,
216 .id_table = cy7c63_table,
217};
218
219static int __init cy7c63_init(void) {
220
221 int result;
222
223 /* register this driver with the USB subsystem */
224 result = usb_register(&cy7c63_driver);
225 if (result) {
226 err("Function usb_register failed! Error number: %d\n", result);
227 }
228
229 return result;
230}
231
232static void __exit cy7c63_exit(void) {
233
234 /* deregister this driver with the USB subsystem */
235 usb_deregister(&cy7c63_driver);
236}
237
238module_init(cy7c63_init);
239module_exit(cy7c63_exit);
240
241MODULE_AUTHOR(DRIVER_AUTHOR);
242MODULE_DESCRIPTION(DRIVER_DESC);
243
244MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
new file mode 100644
index 000000000000..a4062a6adbb8
--- /dev/null
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -0,0 +1,284 @@
1/*
2* cypress_cy7c63.c
3*
4* Copyright (c) 2006 Oliver Bock (o.bock@fh-wolfenbuettel.de)
5*
6* This driver is based on the Cypress USB Driver by Marcus Maul
7* (cyport) and the 2.0 version of Greg Kroah-Hartman's
8* USB Skeleton driver.
9*
10* This is a generic driver for the Cypress CY7C63xxx family.
11* For the time being it enables you to read from and write to
12* the single I/O ports of the device.
13*
14* Supported vendors: AK Modul-Bus Computer GmbH
15* (Firmware "Port-Chip")
16*
17* Supported devices: CY7C63001A-PC
18* CY7C63001C-PXC
19* CY7C63001C-SXC
20*
21* Supported functions: Read/Write Ports
22*
23*
24* This program is free software; you can redistribute it and/or
25* modify it under the terms of the GNU General Public License as
26* published by the Free Software Foundation, version 2.
27*/
28
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/kernel.h>
32#include <linux/usb.h>
33
34#define DRIVER_AUTHOR "Oliver Bock (o.bock@fh-wolfenbuettel.de)"
35#define DRIVER_DESC "Cypress CY7C63xxx USB driver"
36
37#define CYPRESS_VENDOR_ID 0xa2c
38#define CYPRESS_PRODUCT_ID 0x8
39
40#define CYPRESS_READ_PORT 0x4
41#define CYPRESS_WRITE_PORT 0x5
42
43#define CYPRESS_READ_RAM 0x2
44#define CYPRESS_WRITE_RAM 0x3
45#define CYPRESS_READ_ROM 0x1
46
47#define CYPRESS_READ_PORT_ID0 0
48#define CYPRESS_WRITE_PORT_ID0 0
49#define CYPRESS_READ_PORT_ID1 0x2
50#define CYPRESS_WRITE_PORT_ID1 1
51
52#define CYPRESS_MAX_REQSIZE 8
53
54
55/* table of devices that work with this driver */
56static struct usb_device_id cypress_table [] = {
57 { USB_DEVICE(CYPRESS_VENDOR_ID, CYPRESS_PRODUCT_ID) },
58 { }
59};
60MODULE_DEVICE_TABLE(usb, cypress_table);
61
62/* structure to hold all of our device specific stuff */
63struct cypress {
64 struct usb_device * udev;
65 unsigned char port[2];
66};
67
68/* used to send usb control messages to device */
69static int vendor_command(struct cypress *dev, unsigned char request,
70 unsigned char address, unsigned char data)
71{
72 int retval = 0;
73 unsigned int pipe;
74 unsigned char *iobuf;
75
76 /* allocate some memory for the i/o buffer*/
77 iobuf = kzalloc(CYPRESS_MAX_REQSIZE, GFP_KERNEL);
78 if (!iobuf) {
79 dev_err(&dev->udev->dev, "Out of memory!\n");
80 retval = -ENOMEM;
81 goto error;
82 }
83
84 dev_dbg(&dev->udev->dev, "Sending usb_control_msg (data: %d)\n", data);
85
86 /* prepare usb control message and send it upstream */
87 pipe = usb_rcvctrlpipe(dev->udev, 0);
88 retval = usb_control_msg(dev->udev, pipe, request,
89 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
90 address, data, iobuf, CYPRESS_MAX_REQSIZE,
91 USB_CTRL_GET_TIMEOUT);
92
93 /* store returned data (more READs to be added) */
94 switch (request) {
95 case CYPRESS_READ_PORT:
96 if (address == CYPRESS_READ_PORT_ID0) {
97 dev->port[0] = iobuf[1];
98 dev_dbg(&dev->udev->dev,
99 "READ_PORT0 returned: %d\n",
100 dev->port[0]);
101 }
102 else if (address == CYPRESS_READ_PORT_ID1) {
103 dev->port[1] = iobuf[1];
104 dev_dbg(&dev->udev->dev,
105 "READ_PORT1 returned: %d\n",
106 dev->port[1]);
107 }
108 break;
109 }
110
111 kfree(iobuf);
112error:
113 return retval;
114}
115
116/* write port value */
117static ssize_t write_port(struct device *dev, struct device_attribute *attr,
118 const char *buf, size_t count,
119 int port_num, int write_id)
120{
121 int value = -1;
122 int result = 0;
123
124 struct usb_interface *intf = to_usb_interface(dev);
125 struct cypress *cyp = usb_get_intfdata(intf);
126
127 dev_dbg(&cyp->udev->dev, "WRITE_PORT%d called\n", port_num);
128
129 /* validate input data */
130 if (sscanf(buf, "%d", &value) < 1) {
131 result = -EINVAL;
132 goto error;
133 }
134 if (value < 0 || value > 255) {
135 result = -EINVAL;
136 goto error;
137 }
138
139 result = vendor_command(cyp, CYPRESS_WRITE_PORT, write_id,
140 (unsigned char)value);
141
142 dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n", result);
143error:
144 return result < 0 ? result : count;
145}
146
147/* attribute callback handler (write) */
148static ssize_t set_port0_handler(struct device *dev,
149 struct device_attribute *attr,
150 const char *buf, size_t count)
151{
152 return write_port(dev, attr, buf, count, 0, CYPRESS_WRITE_PORT_ID0);
153}
154
155/* attribute callback handler (write) */
156static ssize_t set_port1_handler(struct device *dev,
157 struct device_attribute *attr,
158 const char *buf, size_t count)
159{
160 return write_port(dev, attr, buf, count, 1, CYPRESS_WRITE_PORT_ID1);
161}
162
163/* read port value */
164static ssize_t read_port(struct device *dev, struct device_attribute *attr,
165 char *buf, int port_num, int read_id)
166{
167 int result = 0;
168
169 struct usb_interface *intf = to_usb_interface(dev);
170 struct cypress *cyp = usb_get_intfdata(intf);
171
172 dev_dbg(&cyp->udev->dev, "READ_PORT%d called\n", port_num);
173
174 result = vendor_command(cyp, CYPRESS_READ_PORT, read_id, 0);
175
176 dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n", result);
177
178 return sprintf(buf, "%d", cyp->port[port_num]);
179}
180
181/* attribute callback handler (read) */
182static ssize_t get_port0_handler(struct device *dev,
183 struct device_attribute *attr, char *buf)
184{
185 return read_port(dev, attr, buf, 0, CYPRESS_READ_PORT_ID0);
186}
187
188/* attribute callback handler (read) */
189static ssize_t get_port1_handler(struct device *dev,
190 struct device_attribute *attr, char *buf)
191{
192 return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1);
193}
194
195static DEVICE_ATTR(port0, S_IWUGO | S_IRUGO,
196 get_port0_handler, set_port0_handler);
197
198static DEVICE_ATTR(port1, S_IWUGO | S_IRUGO,
199 get_port1_handler, set_port1_handler);
200
201
202static int cypress_probe(struct usb_interface *interface,
203 const struct usb_device_id *id)
204{
205 struct cypress *dev = NULL;
206 int retval = -ENOMEM;
207
208 /* allocate memory for our device state and initialize it */
209 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
210 if (dev == NULL) {
211 dev_err(&dev->udev->dev, "Out of memory!\n");
212 goto error;
213 }
214
215 dev->udev = usb_get_dev(interface_to_usbdev(interface));
216
217 /* save our data pointer in this interface device */
218 usb_set_intfdata(interface, dev);
219
220 /* create device attribute files */
221 device_create_file(&interface->dev, &dev_attr_port0);
222 device_create_file(&interface->dev, &dev_attr_port1);
223
224 /* let the user know that the device is now attached */
225 dev_info(&interface->dev,
226 "Cypress CY7C63xxx device now attached\n");
227
228 retval = 0;
229error:
230 return retval;
231}
232
233static void cypress_disconnect(struct usb_interface *interface)
234{
235 struct cypress *dev;
236
237 dev = usb_get_intfdata(interface);
238 usb_set_intfdata(interface, NULL);
239
240 /* remove device attribute files */
241 device_remove_file(&interface->dev, &dev_attr_port0);
242 device_remove_file(&interface->dev, &dev_attr_port1);
243
244 usb_put_dev(dev->udev);
245
246 dev_info(&interface->dev,
247 "Cypress CY7C63xxx device now disconnected\n");
248
249 kfree(dev);
250}
251
252static struct usb_driver cypress_driver = {
253 .name = "cypress_cy7c63",
254 .probe = cypress_probe,
255 .disconnect = cypress_disconnect,
256 .id_table = cypress_table,
257};
258
259static int __init cypress_init(void)
260{
261 int result;
262
263 /* register this driver with the USB subsystem */
264 result = usb_register(&cypress_driver);
265 if (result) {
266 err("Function usb_register failed! Error number: %d\n", result);
267 }
268
269 return result;
270}
271
272static void __exit cypress_exit(void)
273{
274 /* deregister this driver with the USB subsystem */
275 usb_deregister(&cypress_driver);
276}
277
278module_init(cypress_init);
279module_exit(cypress_exit);
280
281MODULE_AUTHOR(DRIVER_AUTHOR);
282MODULE_DESCRIPTION(DRIVER_DESC);
283
284MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index c82c402285a0..e095772dd8e9 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -200,10 +200,8 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz
200 200
201 /* create a urb, and a buffer for it, and copy the data to the urb */ 201 /* create a urb, and a buffer for it, and copy the data to the urb */
202 urb = usb_alloc_urb(0, GFP_KERNEL); 202 urb = usb_alloc_urb(0, GFP_KERNEL);
203 if (!urb) { 203 if (!urb)
204 retval = -ENOMEM; 204 return -ENOMEM;
205 goto error;
206 }
207 205
208 buf = usb_buffer_alloc(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); 206 buf = usb_buffer_alloc(dev->udev, count, GFP_KERNEL, &urb->transfer_dma);
209 if (!buf) { 207 if (!buf) {
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index e02c1a30c4cd..f961a770cee2 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -64,7 +64,6 @@ struct mon_reader_text {
64}; 64};
65 65
66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long); 66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long);
67static void mon_text_dtor(void *, kmem_cache_t *, unsigned long);
68 67
69/* 68/*
70 * mon_text_submit 69 * mon_text_submit
@@ -268,7 +267,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
268 (long)rp); 267 (long)rp);
269 rp->e_slab = kmem_cache_create(rp->slab_name, 268 rp->e_slab = kmem_cache_create(rp->slab_name,
270 sizeof(struct mon_event_text), sizeof(long), 0, 269 sizeof(struct mon_event_text), sizeof(long), 0,
271 mon_text_ctor, mon_text_dtor); 270 mon_text_ctor, NULL);
272 if (rp->e_slab == NULL) { 271 if (rp->e_slab == NULL) {
273 rc = -ENOMEM; 272 rc = -ENOMEM;
274 goto err_slab; 273 goto err_slab;
@@ -459,7 +458,3 @@ static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags)
459 memset(mem, 0xe5, sizeof(struct mon_event_text)); 458 memset(mem, 0xe5, sizeof(struct mon_event_text));
460} 459}
461 460
462static void mon_text_dtor(void *mem, kmem_cache_t *slab, unsigned long sflags)
463{
464 ;
465}
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 718f8e2b552b..bd09232ce13c 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -128,11 +128,13 @@
128#define VENDOR_ID_MELCO 0x0411 128#define VENDOR_ID_MELCO 0x0411
129#define VENDOR_ID_MICRONET 0x3980 129#define VENDOR_ID_MICRONET 0x3980
130#define VENDOR_ID_LONGSHINE 0x07b8 130#define VENDOR_ID_LONGSHINE 0x07b8
131#define VENDOR_ID_ZYXEL 0x0586
131 132
132#define PRODUCT_ID_RTL8150 0x8150 133#define PRODUCT_ID_RTL8150 0x8150
133#define PRODUCT_ID_LUAKTX 0x0012 134#define PRODUCT_ID_LUAKTX 0x0012
134#define PRODUCT_ID_LCS8138TX 0x401a 135#define PRODUCT_ID_LCS8138TX 0x401a
135#define PRODUCT_ID_SP128AR 0x0003 136#define PRODUCT_ID_SP128AR 0x0003
137#define PRODUCT_ID_PRESTIGE 0x401a
136 138
137#undef EEPROM_WRITE 139#undef EEPROM_WRITE
138 140
@@ -142,6 +144,7 @@ static struct usb_device_id rtl8150_table[] = {
142 {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)}, 144 {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)},
143 {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)}, 145 {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)},
144 {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)}, 146 {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)},
147 {USB_DEVICE(VENDOR_ID_ZYXEL, PRODUCT_ID_PRESTIGE)},
145 {} 148 {}
146}; 149};
147 150
@@ -172,6 +175,8 @@ static inline struct sk_buff *pull_skb(rtl8150_t *);
172static void rtl8150_disconnect(struct usb_interface *intf); 175static void rtl8150_disconnect(struct usb_interface *intf);
173static int rtl8150_probe(struct usb_interface *intf, 176static int rtl8150_probe(struct usb_interface *intf,
174 const struct usb_device_id *id); 177 const struct usb_device_id *id);
178static int rtl8150_suspend(struct usb_interface *intf, pm_message_t message);
179static int rtl8150_resume(struct usb_interface *intf);
175 180
176static const char driver_name [] = "rtl8150"; 181static const char driver_name [] = "rtl8150";
177 182
@@ -180,6 +185,8 @@ static struct usb_driver rtl8150_driver = {
180 .probe = rtl8150_probe, 185 .probe = rtl8150_probe,
181 .disconnect = rtl8150_disconnect, 186 .disconnect = rtl8150_disconnect,
182 .id_table = rtl8150_table, 187 .id_table = rtl8150_table,
188 .suspend = rtl8150_suspend,
189 .resume = rtl8150_resume
183}; 190};
184 191
185/* 192/*
@@ -235,9 +242,11 @@ static int async_set_registers(rtl8150_t * dev, u16 indx, u16 size)
235 usb_fill_control_urb(dev->ctrl_urb, dev->udev, 242 usb_fill_control_urb(dev->ctrl_urb, dev->udev,
236 usb_sndctrlpipe(dev->udev, 0), (char *) &dev->dr, 243 usb_sndctrlpipe(dev->udev, 0), (char *) &dev->dr,
237 &dev->rx_creg, size, ctrl_callback, dev); 244 &dev->rx_creg, size, ctrl_callback, dev);
238 if ((ret = usb_submit_urb(dev->ctrl_urb, GFP_ATOMIC))) 245 if ((ret = usb_submit_urb(dev->ctrl_urb, GFP_ATOMIC))) {
246 if (ret == -ENODEV)
247 netif_device_detach(dev->netdev);
239 err("control request submission failed: %d", ret); 248 err("control request submission failed: %d", ret);
240 else 249 } else
241 set_bit(RX_REG_SET, &dev->flags); 250 set_bit(RX_REG_SET, &dev->flags);
242 251
243 return ret; 252 return ret;
@@ -413,6 +422,7 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs)
413 struct sk_buff *skb; 422 struct sk_buff *skb;
414 struct net_device *netdev; 423 struct net_device *netdev;
415 u16 rx_stat; 424 u16 rx_stat;
425 int status;
416 426
417 dev = urb->context; 427 dev = urb->context;
418 if (!dev) 428 if (!dev)
@@ -462,7 +472,10 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs)
462goon: 472goon:
463 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), 473 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
464 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); 474 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
465 if (usb_submit_urb(dev->rx_urb, GFP_ATOMIC)) { 475 status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
476 if (status == -ENODEV)
477 netif_device_detach(dev->netdev);
478 else if (status) {
466 set_bit(RX_URB_FAIL, &dev->flags); 479 set_bit(RX_URB_FAIL, &dev->flags);
467 goto resched; 480 goto resched;
468 } else { 481 } else {
@@ -478,6 +491,7 @@ static void rx_fixup(unsigned long data)
478{ 491{
479 rtl8150_t *dev; 492 rtl8150_t *dev;
480 struct sk_buff *skb; 493 struct sk_buff *skb;
494 int status;
481 495
482 dev = (rtl8150_t *)data; 496 dev = (rtl8150_t *)data;
483 497
@@ -496,10 +510,13 @@ static void rx_fixup(unsigned long data)
496 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), 510 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
497 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); 511 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
498try_again: 512try_again:
499 if (usb_submit_urb(dev->rx_urb, GFP_ATOMIC)) { 513 status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
514 if (status == -ENODEV) {
515 netif_device_detach(dev->netdev);
516 } else if (status) {
500 set_bit(RX_URB_FAIL, &dev->flags); 517 set_bit(RX_URB_FAIL, &dev->flags);
501 goto tlsched; 518 goto tlsched;
502 } else { 519 } else {
503 clear_bit(RX_URB_FAIL, &dev->flags); 520 clear_bit(RX_URB_FAIL, &dev->flags);
504 } 521 }
505 522
@@ -571,12 +588,43 @@ static void intr_callback(struct urb *urb, struct pt_regs *regs)
571 588
572resubmit: 589resubmit:
573 status = usb_submit_urb (urb, SLAB_ATOMIC); 590 status = usb_submit_urb (urb, SLAB_ATOMIC);
574 if (status) 591 if (status == -ENODEV)
592 netif_device_detach(dev->netdev);
593 else if (status)
575 err ("can't resubmit intr, %s-%s/input0, status %d", 594 err ("can't resubmit intr, %s-%s/input0, status %d",
576 dev->udev->bus->bus_name, 595 dev->udev->bus->bus_name,
577 dev->udev->devpath, status); 596 dev->udev->devpath, status);
578} 597}
579 598
599static int rtl8150_suspend(struct usb_interface *intf, pm_message_t message)
600{
601 rtl8150_t *dev = usb_get_intfdata(intf);
602
603 netif_device_detach(dev->netdev);
604
605 if (netif_running(dev->netdev)) {
606 usb_kill_urb(dev->rx_urb);
607 usb_kill_urb(dev->intr_urb);
608 }
609 return 0;
610}
611
612static int rtl8150_resume(struct usb_interface *intf)
613{
614 rtl8150_t *dev = usb_get_intfdata(intf);
615
616 netif_device_attach(dev->netdev);
617 if (netif_running(dev->netdev)) {
618 dev->rx_urb->status = 0;
619 dev->rx_urb->actual_length = 0;
620 read_bulk_callback(dev->rx_urb, NULL);
621
622 dev->intr_urb->status = 0;
623 dev->intr_urb->actual_length = 0;
624 intr_callback(dev->intr_urb, NULL);
625 }
626 return 0;
627}
580 628
581/* 629/*
582** 630**
@@ -687,9 +735,14 @@ static int rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev)
687 usb_fill_bulk_urb(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), 735 usb_fill_bulk_urb(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2),
688 skb->data, count, write_bulk_callback, dev); 736 skb->data, count, write_bulk_callback, dev);
689 if ((res = usb_submit_urb(dev->tx_urb, GFP_ATOMIC))) { 737 if ((res = usb_submit_urb(dev->tx_urb, GFP_ATOMIC))) {
690 warn("failed tx_urb %d\n", res); 738 /* Can we get/handle EPIPE here? */
691 dev->stats.tx_errors++; 739 if (res == -ENODEV)
692 netif_start_queue(netdev); 740 netif_device_detach(dev->netdev);
741 else {
742 warn("failed tx_urb %d\n", res);
743 dev->stats.tx_errors++;
744 netif_start_queue(netdev);
745 }
693 } else { 746 } else {
694 dev->stats.tx_packets++; 747 dev->stats.tx_packets++;
695 dev->stats.tx_bytes += skb->len; 748 dev->stats.tx_bytes += skb->len;
@@ -726,16 +779,25 @@ static int rtl8150_open(struct net_device *netdev)
726 779
727 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), 780 usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
728 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); 781 dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
729 if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) 782 if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) {
783 if (res == -ENODEV)
784 netif_device_detach(dev->netdev);
730 warn("%s: rx_urb submit failed: %d", __FUNCTION__, res); 785 warn("%s: rx_urb submit failed: %d", __FUNCTION__, res);
786 return res;
787 }
731 usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), 788 usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3),
732 dev->intr_buff, INTBUFSIZE, intr_callback, 789 dev->intr_buff, INTBUFSIZE, intr_callback,
733 dev, dev->intr_interval); 790 dev, dev->intr_interval);
734 if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) 791 if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) {
792 if (res == -ENODEV)
793 netif_device_detach(dev->netdev);
735 warn("%s: intr_urb submit failed: %d", __FUNCTION__, res); 794 warn("%s: intr_urb submit failed: %d", __FUNCTION__, res);
736 netif_start_queue(netdev); 795 usb_kill_urb(dev->rx_urb);
796 return res;
797 }
737 enable_net_traffic(dev); 798 enable_net_traffic(dev);
738 set_carrier(netdev); 799 set_carrier(netdev);
800 netif_start_queue(netdev);
739 801
740 return res; 802 return res;
741} 803}
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 8bd44fda5eaf..f5b9438c94f0 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -62,15 +62,6 @@ config USB_SERIAL_AIRPRIME
62 To compile this driver as a module, choose M here: the 62 To compile this driver as a module, choose M here: the
63 module will be called airprime. 63 module will be called airprime.
64 64
65config USB_SERIAL_ANYDATA
66 tristate "USB AnyData CDMA Wireless Driver"
67 depends on USB_SERIAL
68 help
69 Say Y here if you want to use a AnyData CDMA device.
70
71 To compile this driver as a module, choose M here: the
72 module will be called anydata.
73
74config USB_SERIAL_ARK3116 65config USB_SERIAL_ARK3116
75 tristate "USB ARK Micro 3116 USB Serial Driver (EXPERIMENTAL)" 66 tristate "USB ARK Micro 3116 USB Serial Driver (EXPERIMENTAL)"
76 depends on USB_SERIAL && EXPERIMENTAL 67 depends on USB_SERIAL && EXPERIMENTAL
@@ -456,6 +447,17 @@ config USB_SERIAL_SAFE_PADDED
456 bool "USB Secure Encapsulated Driver - Padded" 447 bool "USB Secure Encapsulated Driver - Padded"
457 depends on USB_SERIAL_SAFE 448 depends on USB_SERIAL_SAFE
458 449
450config USB_SERIAL_SIERRAWIRELESS
451 tristate "USB Sierra Wireless Driver"
452 depends on USB_SERIAL
453 help
454 Say M here if you want to use a Sierra Wireless device (if
455 using an PC 5220 or AC580 please use the Airprime driver
456 instead).
457
458 To compile this driver as a module, choose M here: the
459 module will be called sierra.
460
459config USB_SERIAL_TI 461config USB_SERIAL_TI
460 tristate "USB TI 3410/5052 Serial Driver" 462 tristate "USB TI 3410/5052 Serial Driver"
461 depends on USB_SERIAL 463 depends on USB_SERIAL
@@ -491,15 +493,18 @@ config USB_SERIAL_XIRCOM
491 module will be called keyspan_pda. 493 module will be called keyspan_pda.
492 494
493config USB_SERIAL_OPTION 495config USB_SERIAL_OPTION
494 tristate "USB driver for GSM modems" 496 tristate "USB driver for GSM and CDMA modems"
495 depends on USB_SERIAL 497 depends on USB_SERIAL
496 help 498 help
497 Say Y here if you have an "Option" GSM PCMCIA card 499 Say Y here if you have a GSM or CDMA modem that's connected to USB.
498 (or an OEM version: branded Huawei, Audiovox, or Novatel). 500
501 This driver also supports several PCMCIA cards which have a
502 built-in OHCI-USB adapter and an internally-connected GSM modem.
503 The USB bus on these cards is not accessible externally.
499 504
500 These cards feature a built-in OHCI-USB adapter and an 505 Supported devices include (some of?) those made by:
501 internally-connected GSM modem. The USB bus is not 506 Option, Huawei, Audiovox, Sierra Wireless, Novatel Wireless, or
502 accessible externally. 507 Anydata.
503 508
504 To compile this driver as a module, choose M here: the 509 To compile this driver as a module, choose M here: the
505 module will be called option. 510 module will be called option.
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 5a0960fc9d3e..8efed2ce1ba3 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -12,7 +12,6 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o 14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
15obj-$(CONFIG_USB_SERIAL_ANYDATA) += anydata.o
16obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o 15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
17obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 16obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 17obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
@@ -39,6 +38,7 @@ obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
39obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 38obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
40obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 39obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
41obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 40obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
41obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
42obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 42obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
43obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o 43obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
44obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o 44obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 94b9ba0ff875..62082532a8b3 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 19 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c
deleted file mode 100644
index 343f6f228220..000000000000
--- a/drivers/usb/serial/anydata.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 * AnyData CDMA Serial USB driver
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include "usb-serial.h"
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24/* if overridden by the user, then use their value for the size of the
25 * read and write urbs */
26static int buffer_size;
27static int debug;
28
29static struct usb_driver anydata_driver = {
30 .name = "anydata",
31 .probe = usb_serial_probe,
32 .disconnect = usb_serial_disconnect,
33 .id_table = id_table,
34 .no_dynamic_id = 1,
35};
36
37static int anydata_open(struct usb_serial_port *port, struct file *filp)
38{
39 char *buffer;
40 int result = 0;
41
42 dbg("%s - port %d", __FUNCTION__, port->number);
43
44 if (buffer_size) {
45 /* override the default buffer sizes */
46 buffer = kmalloc(buffer_size, GFP_KERNEL);
47 if (!buffer) {
48 dev_err(&port->dev, "%s - out of memory.\n",
49 __FUNCTION__);
50 return -ENOMEM;
51 }
52 kfree (port->read_urb->transfer_buffer);
53 port->read_urb->transfer_buffer = buffer;
54 port->read_urb->transfer_buffer_length = buffer_size;
55
56 buffer = kmalloc(buffer_size, GFP_KERNEL);
57 if (!buffer) {
58 dev_err(&port->dev, "%s - out of memory.\n",
59 __FUNCTION__);
60 return -ENOMEM;
61 }
62 kfree (port->write_urb->transfer_buffer);
63 port->write_urb->transfer_buffer = buffer;
64 port->write_urb->transfer_buffer_length = buffer_size;
65 port->bulk_out_size = buffer_size;
66 }
67
68 /* Start reading from the device */
69 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
70 usb_rcvbulkpipe(port->serial->dev,
71 port->bulk_in_endpointAddress),
72 port->read_urb->transfer_buffer,
73 port->read_urb->transfer_buffer_length,
74 usb_serial_generic_write_bulk_callback, port);
75 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
76 if (result)
77 dev_err(&port->dev,
78 "%s - failed submitting read urb, error %d\n",
79 __FUNCTION__, result);
80
81 return result;
82}
83
84static struct usb_serial_driver anydata_device = {
85 .driver = {
86 .owner = THIS_MODULE,
87 .name = "anydata",
88 },
89 .id_table = id_table,
90 .num_interrupt_in = NUM_DONT_CARE,
91 .num_bulk_in = NUM_DONT_CARE,
92 .num_bulk_out = NUM_DONT_CARE,
93 .num_ports = 1,
94 .open = anydata_open,
95};
96
97static int __init anydata_init(void)
98{
99 int retval;
100
101 retval = usb_serial_register(&anydata_device);
102 if (retval)
103 return retval;
104 retval = usb_register(&anydata_driver);
105 if (retval)
106 usb_serial_deregister(&anydata_device);
107 return retval;
108}
109
110static void __exit anydata_exit(void)
111{
112 usb_deregister(&anydata_driver);
113 usb_serial_deregister(&anydata_device);
114}
115
116module_init(anydata_init);
117module_exit(anydata_exit);
118MODULE_LICENSE("GPL");
119
120module_param(debug, bool, S_IRUGO | S_IWUSR);
121MODULE_PARM_DESC(debug, "Debug enabled or not");
122module_param(buffer_size, int, 0);
123MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 8dec796222a0..970d9ef0a7a5 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -21,7 +21,7 @@
21#include <linux/tty.h> 21#include <linux/tty.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include "usb-serial.h" 24#include <linux/usb/serial.h>
25 25
26 26
27static int debug; 27static int debug;
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 3faa7aa0111a..70ece9e01ce4 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -74,7 +74,7 @@
74#include <linux/spinlock.h> 74#include <linux/spinlock.h>
75#include <asm/uaccess.h> 75#include <asm/uaccess.h>
76#include <linux/usb.h> 76#include <linux/usb.h>
77#include "usb-serial.h" 77#include <linux/usb/serial.h>
78#include "belkin_sa.h" 78#include "belkin_sa.h"
79 79
80static int debug; 80static int debug;
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index f2d993b70c18..6542f220468f 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static int usb_serial_device_match (struct device *dev, struct device_driver *drv) 18static int usb_serial_device_match (struct device *dev, struct device_driver *drv)
19{ 19{
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 3d456b32c316..3a9073dbfe6a 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -17,11 +17,10 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include <linux/usb/serial.h>
20 21
21static int debug; 22static int debug;
22 23
23#include "usb-serial.h"
24
25struct usbcons_info { 24struct usbcons_info {
26 int magic; 25 int magic;
27 int break_flag; 26 int break_flag;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index df0a4f98b4ae..486c7411b9a7 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -26,7 +26,7 @@
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include "usb-serial.h" 29#include <linux/usb/serial.h>
30 30
31/* 31/*
32 * Version Information 32 * Version Information
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 49b51ab0d4cb..6286aba86fae 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -39,7 +39,7 @@
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include "usb-serial.h" 42#include <linux/usb/serial.h>
43 43
44#define CYBERJACK_LOCAL_BUF_SIZE 32 44#define CYBERJACK_LOCAL_BUF_SIZE 32
45 45
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 4ff2dfb299bd..ee70fddcab60 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -59,11 +59,11 @@
59#include <linux/moduleparam.h> 59#include <linux/moduleparam.h>
60#include <linux/spinlock.h> 60#include <linux/spinlock.h>
61#include <linux/usb.h> 61#include <linux/usb.h>
62#include <linux/usb/serial.h>
62#include <linux/serial.h> 63#include <linux/serial.h>
63#include <linux/delay.h> 64#include <linux/delay.h>
64#include <asm/uaccess.h> 65#include <asm/uaccess.h>
65 66
66#include "usb-serial.h"
67#include "cypress_m8.h" 67#include "cypress_m8.h"
68 68
69 69
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 6953d3ef5738..9b225183fc7a 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -246,7 +246,7 @@
246#include <asm/uaccess.h> 246#include <asm/uaccess.h>
247#include <linux/usb.h> 247#include <linux/usb.h>
248#include <linux/wait.h> 248#include <linux/wait.h>
249#include "usb-serial.h" 249#include <linux/usb/serial.h>
250 250
251/* Defines */ 251/* Defines */
252 252
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 1e2b31eeb497..daafe405d86d 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -62,7 +62,7 @@
62#include <linux/spinlock.h> 62#include <linux/spinlock.h>
63#include <asm/uaccess.h> 63#include <asm/uaccess.h>
64#include <linux/usb.h> 64#include <linux/usb.h>
65#include "usb-serial.h" 65#include <linux/usb/serial.h>
66 66
67static int debug; 67static int debug;
68 68
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index debc3b0f9662..5169c2d154ab 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -15,7 +15,7 @@
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/usb.h> 17#include <linux/usb.h>
18#include "usb-serial.h" 18#include <linux/usb/serial.h>
19 19
20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
21#define CPUCS_REG 0x7F92 21#define CPUCS_REG 0x7F92
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8a74b19f1283..a20da8528a5f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -257,7 +257,7 @@
257#include <asm/uaccess.h> 257#include <asm/uaccess.h>
258#include <linux/usb.h> 258#include <linux/usb.h>
259#include <linux/serial.h> 259#include <linux/serial.h>
260#include "usb-serial.h" 260#include <linux/usb/serial.h>
261#include "ftdi_sio.h" 261#include "ftdi_sio.h"
262 262
263/* 263/*
@@ -313,6 +313,7 @@ static struct usb_device_id id_table_combined [] = {
313 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 314 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
317 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 318 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
318 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 319 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
@@ -336,6 +337,7 @@ static struct usb_device_id id_table_combined [] = {
336 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 337 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
337 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 338 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
338 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 339 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
340 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
339 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) }, 341 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
340 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) }, 342 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
341 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) }, 343 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2103_PID) },
@@ -500,6 +502,8 @@ static struct usb_device_id id_table_combined [] = {
500 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, 502 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
501 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, 503 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
502 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, 504 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
505 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
506 { USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) },
503 { }, /* Optional parameter entry */ 507 { }, /* Optional parameter entry */
504 { } /* Terminating entry */ 508 { } /* Terminating entry */
505}; 509};
@@ -548,11 +552,17 @@ struct ftdi_private {
548 spinlock_t rx_lock; /* spinlock for receive state */ 552 spinlock_t rx_lock; /* spinlock for receive state */
549 struct work_struct rx_work; 553 struct work_struct rx_work;
550 int rx_processed; 554 int rx_processed;
555 unsigned long rx_bytes;
551 556
552 __u16 interface; /* FT2232C port interface (0 for FT232/245) */ 557 __u16 interface; /* FT2232C port interface (0 for FT232/245) */
553 558
554 int force_baud; /* if non-zero, force the baud rate to this value */ 559 int force_baud; /* if non-zero, force the baud rate to this value */
555 int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ 560 int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */
561
562 spinlock_t tx_lock; /* spinlock for transmit state */
563 unsigned long tx_bytes;
564 unsigned long tx_outstanding_bytes;
565 unsigned long tx_outstanding_urbs;
556}; 566};
557 567
558/* Used for TIOCMIWAIT */ 568/* Used for TIOCMIWAIT */
@@ -626,6 +636,9 @@ static struct usb_serial_driver ftdi_sio_device = {
626#define HIGH 1 636#define HIGH 1
627#define LOW 0 637#define LOW 0
628 638
639/* number of outstanding urbs to prevent userspace DoS from happening */
640#define URB_UPPER_LIMIT 42
641
629/* 642/*
630 * *************************************************************************** 643 * ***************************************************************************
631 * Utlity functions 644 * Utlity functions
@@ -1156,6 +1169,7 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1156 } 1169 }
1157 1170
1158 spin_lock_init(&priv->rx_lock); 1171 spin_lock_init(&priv->rx_lock);
1172 spin_lock_init(&priv->tx_lock);
1159 init_waitqueue_head(&priv->delta_msr_wait); 1173 init_waitqueue_head(&priv->delta_msr_wait);
1160 /* This will push the characters through immediately rather 1174 /* This will push the characters through immediately rather
1161 than queue a task to deliver them */ 1175 than queue a task to deliver them */
@@ -1270,6 +1284,13 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1270 1284
1271 dbg("%s", __FUNCTION__); 1285 dbg("%s", __FUNCTION__);
1272 1286
1287 spin_lock_irqsave(&priv->tx_lock, flags);
1288 priv->tx_bytes = 0;
1289 spin_unlock_irqrestore(&priv->tx_lock, flags);
1290 spin_lock_irqsave(&priv->rx_lock, flags);
1291 priv->rx_bytes = 0;
1292 spin_unlock_irqrestore(&priv->rx_lock, flags);
1293
1273 if (port->tty) 1294 if (port->tty)
1274 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1295 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1275 1296
@@ -1372,6 +1393,7 @@ static int ftdi_write (struct usb_serial_port *port,
1372 int data_offset ; /* will be 1 for the SIO and 0 otherwise */ 1393 int data_offset ; /* will be 1 for the SIO and 0 otherwise */
1373 int status; 1394 int status;
1374 int transfer_size; 1395 int transfer_size;
1396 unsigned long flags;
1375 1397
1376 dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count); 1398 dbg("%s port %d, %d bytes", __FUNCTION__, port->number, count);
1377 1399
@@ -1379,6 +1401,13 @@ static int ftdi_write (struct usb_serial_port *port,
1379 dbg("write request of 0 bytes"); 1401 dbg("write request of 0 bytes");
1380 return 0; 1402 return 0;
1381 } 1403 }
1404 spin_lock_irqsave(&priv->tx_lock, flags);
1405 if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
1406 spin_unlock_irqrestore(&priv->tx_lock, flags);
1407 dbg("%s - write limit hit\n", __FUNCTION__);
1408 return 0;
1409 }
1410 spin_unlock_irqrestore(&priv->tx_lock, flags);
1382 1411
1383 data_offset = priv->write_offset; 1412 data_offset = priv->write_offset;
1384 dbg("data_offset set to %d",data_offset); 1413 dbg("data_offset set to %d",data_offset);
@@ -1445,6 +1474,12 @@ static int ftdi_write (struct usb_serial_port *port,
1445 err("%s - failed submitting write urb, error %d", __FUNCTION__, status); 1474 err("%s - failed submitting write urb, error %d", __FUNCTION__, status);
1446 count = status; 1475 count = status;
1447 kfree (buffer); 1476 kfree (buffer);
1477 } else {
1478 spin_lock_irqsave(&priv->tx_lock, flags);
1479 ++priv->tx_outstanding_urbs;
1480 priv->tx_outstanding_bytes += count;
1481 priv->tx_bytes += count;
1482 spin_unlock_irqrestore(&priv->tx_lock, flags);
1448 } 1483 }
1449 1484
1450 /* we are done with this urb, so let the host driver 1485 /* we are done with this urb, so let the host driver
@@ -1460,7 +1495,11 @@ static int ftdi_write (struct usb_serial_port *port,
1460 1495
1461static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 1496static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1462{ 1497{
1498 unsigned long flags;
1463 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1499 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1500 struct ftdi_private *priv;
1501 int data_offset; /* will be 1 for the SIO and 0 otherwise */
1502 unsigned long countback;
1464 1503
1465 /* free up the transfer buffer, as usb_free_urb() does not do this */ 1504 /* free up the transfer buffer, as usb_free_urb() does not do this */
1466 kfree (urb->transfer_buffer); 1505 kfree (urb->transfer_buffer);
@@ -1472,34 +1511,67 @@ static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1472 return; 1511 return;
1473 } 1512 }
1474 1513
1514 priv = usb_get_serial_port_data(port);
1515 if (!priv) {
1516 dbg("%s - bad port private data pointer - exiting", __FUNCTION__);
1517 return;
1518 }
1519 /* account for transferred data */
1520 countback = urb->actual_length;
1521 data_offset = priv->write_offset;
1522 if (data_offset > 0) {
1523 /* Subtract the control bytes */
1524 countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ));
1525 }
1526 spin_lock_irqsave(&priv->tx_lock, flags);
1527 --priv->tx_outstanding_urbs;
1528 priv->tx_outstanding_bytes -= countback;
1529 spin_unlock_irqrestore(&priv->tx_lock, flags);
1530
1475 usb_serial_port_softint(port); 1531 usb_serial_port_softint(port);
1476} /* ftdi_write_bulk_callback */ 1532} /* ftdi_write_bulk_callback */
1477 1533
1478 1534
1479static int ftdi_write_room( struct usb_serial_port *port ) 1535static int ftdi_write_room( struct usb_serial_port *port )
1480{ 1536{
1537 struct ftdi_private *priv = usb_get_serial_port_data(port);
1538 int room;
1539 unsigned long flags;
1540
1481 dbg("%s - port %d", __FUNCTION__, port->number); 1541 dbg("%s - port %d", __FUNCTION__, port->number);
1482 1542
1483 /* 1543 spin_lock_irqsave(&priv->tx_lock, flags);
1484 * We really can take anything the user throws at us 1544 if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) {
1485 * but let's pick a nice big number to tell the tty 1545 /*
1486 * layer that we have lots of free space 1546 * We really can take anything the user throws at us
1487 */ 1547 * but let's pick a nice big number to tell the tty
1488 return 2048; 1548 * layer that we have lots of free space
1549 */
1550 room = 2048;
1551 } else {
1552 room = 0;
1553 }
1554 spin_unlock_irqrestore(&priv->tx_lock, flags);
1555 return room;
1489} /* ftdi_write_room */ 1556} /* ftdi_write_room */
1490 1557
1491 1558
1492static int ftdi_chars_in_buffer (struct usb_serial_port *port) 1559static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1493{ /* ftdi_chars_in_buffer */ 1560{ /* ftdi_chars_in_buffer */
1561 struct ftdi_private *priv = usb_get_serial_port_data(port);
1562 int buffered;
1563 unsigned long flags;
1564
1494 dbg("%s - port %d", __FUNCTION__, port->number); 1565 dbg("%s - port %d", __FUNCTION__, port->number);
1495 1566
1496 /* 1567 spin_lock_irqsave(&priv->tx_lock, flags);
1497 * We can't really account for how much data we 1568 buffered = (int)priv->tx_outstanding_bytes;
1498 * have sent out, but hasn't made it through to the 1569 spin_unlock_irqrestore(&priv->tx_lock, flags);
1499 * device, so just tell the tty layer that everything 1570 if (buffered < 0) {
1500 * is flushed. 1571 err("%s outstanding tx bytes is negative!", __FUNCTION__);
1501 */ 1572 buffered = 0;
1502 return 0; 1573 }
1574 return buffered;
1503} /* ftdi_chars_in_buffer */ 1575} /* ftdi_chars_in_buffer */
1504 1576
1505 1577
@@ -1509,6 +1581,8 @@ static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1509 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1581 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1510 struct tty_struct *tty; 1582 struct tty_struct *tty;
1511 struct ftdi_private *priv; 1583 struct ftdi_private *priv;
1584 unsigned long countread;
1585 unsigned long flags;
1512 1586
1513 if (urb->number_of_packets > 0) { 1587 if (urb->number_of_packets > 0) {
1514 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__, 1588 err("%s transfer_buffer_length %d actual_length %d number of packets %d",__FUNCTION__,
@@ -1543,6 +1617,13 @@ static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1543 return; 1617 return;
1544 } 1618 }
1545 1619
1620 /* count data bytes, but not status bytes */
1621 countread = urb->actual_length;
1622 countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ);
1623 spin_lock_irqsave(&priv->rx_lock, flags);
1624 priv->rx_bytes += countread;
1625 spin_unlock_irqrestore(&priv->rx_lock, flags);
1626
1546 ftdi_process_read(port); 1627 ftdi_process_read(port);
1547 1628
1548} /* ftdi_read_bulk_callback */ 1629} /* ftdi_read_bulk_callback */
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 6ab2ac845bd7..9f7343a45424 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -36,6 +36,9 @@
36#define FTDI_ACTZWAVE_PID 0xF2D0 36#define FTDI_ACTZWAVE_PID 0xF2D0
37 37
38 38
39/* www.starting-point-systems.com µChameleon device */
40#define FTDI_MICRO_CHAMELEON_PID 0xCAA0 /* Product Id */
41
39/* www.irtrans.de device */ 42/* www.irtrans.de device */
40#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ 43#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
41 44
@@ -179,6 +182,10 @@
179/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */ 182/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
180#define FTDI_USB_UIRT_PID 0xF850 /* Product Id */ 183#define FTDI_USB_UIRT_PID 0xF850 /* Product Id */
181 184
185/* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
186
187#define FTDI_TNC_X_PID 0xEBE0
188
182/* 189/*
183 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de). 190 * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
184 * All of these devices use FTDI's vendor ID (0x0403). 191 * All of these devices use FTDI's vendor ID (0x0403).
@@ -442,6 +449,18 @@
442 */ 449 */
443#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */ 450#define FTDI_YEI_SERVOCENTER31_PID 0xE050 /* YEI ServoCenter3.1 USB */
444 451
452/*
453 * ThorLabs USB motor drivers
454 */
455#define FTDI_THORLABS_PID 0xfaf0 /* ThorLabs USB motor drivers */
456
457/*
458 * Testo products (http://www.testo.com/)
459 * Submitted by Colin Leroy
460 */
461#define TESTO_VID 0x128D
462#define TESTO_USB_INTERFACE_PID 0x0001
463
445/* Commands */ 464/* Commands */
446#define FTDI_SIO_RESET 0 /* Reset the port */ 465#define FTDI_SIO_RESET 0 /* Reset the port */
447#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 466#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index 803721b97e2e..77b977206a8c 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -13,7 +13,7 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include "usb-serial.h" 16#include <linux/usb/serial.h>
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x1404, 0xcddc) }, 19 { USB_DEVICE(0x1404, 0xcddc) },
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 1f5d1620baa1..727852634be9 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -35,6 +35,7 @@
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb/serial.h>
38 39
39/* the mode to be set when the port ist opened */ 40/* the mode to be set when the port ist opened */
40static int initial_mode = 1; 41static int initial_mode = 1;
@@ -42,8 +43,6 @@ static int initial_mode = 1;
42/* debug flag */ 43/* debug flag */
43static int debug = 0; 44static int debug = 0;
44 45
45#include "usb-serial.h"
46
47#define GARMIN_VENDOR_ID 0x091E 46#define GARMIN_VENDOR_ID 0x091E
48 47
49/* 48/*
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 945b8bb38c92..172713556393 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -17,8 +17,8 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include <linux/usb/serial.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include "usb-serial.h"
22 22
23static int debug; 23static int debug;
24 24
@@ -285,6 +285,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
285 if (result) 285 if (result)
286 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 286 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
287} 287}
288EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
288 289
289void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 290void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
290{ 291{
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 7e06358b0310..ebcac701b069 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -17,7 +17,7 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/usb.h> 19#include <linux/usb.h>
20#include "usb-serial.h" 20#include <linux/usb/serial.h>
21 21
22/* 22/*
23 * Version Information 23 * Version Information
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index bd2c05dac2a9..c49976c3ad52 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -44,7 +44,7 @@
44#include <linux/wait.h> 44#include <linux/wait.h>
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46#include <linux/usb.h> 46#include <linux/usb.h>
47#include "usb-serial.h" 47#include <linux/usb/serial.h>
48#include "io_edgeport.h" 48#include "io_edgeport.h"
49#include "io_ionsp.h" /* info for the iosp messages */ 49#include "io_ionsp.h" /* info for the iosp messages */
50#include "io_16654.h" /* 16654 UART defines */ 50#include "io_16654.h" /* 16654 UART defines */
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 723a12ae87b5..17c5b1d2311a 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -39,8 +39,8 @@
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#include <asm/semaphore.h> 40#include <asm/semaphore.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include <linux/usb/serial.h>
42 43
43#include "usb-serial.h"
44#include "io_16654.h" 44#include "io_16654.h"
45#include "io_usbvend.h" 45#include "io_usbvend.h"
46#include "io_ti.h" 46#include "io_ti.h"
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index dbcfe172a5cc..7e1bd5d6dfa0 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -55,7 +55,7 @@
55#include <linux/spinlock.h> 55#include <linux/spinlock.h>
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
57#include <linux/usb.h> 57#include <linux/usb.h>
58#include "usb-serial.h" 58#include <linux/usb/serial.h>
59#include "ipaq.h" 59#include "ipaq.h"
60 60
61#define KP_RETRIES 100 61#define KP_RETRIES 100
@@ -70,6 +70,8 @@
70 70
71static __u16 product, vendor; 71static __u16 product, vendor;
72static int debug; 72static int debug;
73static int connect_retries = KP_RETRIES;
74static int initial_wait;
73 75
74/* Function prototypes for an ipaq */ 76/* Function prototypes for an ipaq */
75static int ipaq_open (struct usb_serial_port *port, struct file *filp); 77static int ipaq_open (struct usb_serial_port *port, struct file *filp);
@@ -248,6 +250,7 @@ static struct usb_device_id ipaq_id_table [] = {
248 { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */ 250 { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */
249 { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */ 251 { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */
250 { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */ 252 { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */
253 { USB_DEVICE(0x04DD, 0x9102) }, /* SHARP WS003SH USB Modem */
251 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ 254 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */
252 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ 255 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */
253 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ 256 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */
@@ -582,7 +585,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
582 struct ipaq_private *priv; 585 struct ipaq_private *priv;
583 struct ipaq_packet *pkt; 586 struct ipaq_packet *pkt;
584 int i, result = 0; 587 int i, result = 0;
585 int retries = KP_RETRIES; 588 int retries = connect_retries;
586 589
587 dbg("%s - port %d", __FUNCTION__, port->number); 590 dbg("%s - port %d", __FUNCTION__, port->number);
588 591
@@ -646,16 +649,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
646 port->read_urb->transfer_buffer_length = URBDATA_SIZE; 649 port->read_urb->transfer_buffer_length = URBDATA_SIZE;
647 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE; 650 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;
648 651
652 msleep(1000*initial_wait);
649 /* Start reading from the device */ 653 /* Start reading from the device */
650 usb_fill_bulk_urb(port->read_urb, serial->dev, 654 usb_fill_bulk_urb(port->read_urb, serial->dev,
651 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), 655 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
652 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 656 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
653 ipaq_read_bulk_callback, port); 657 ipaq_read_bulk_callback, port);
654 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
655 if (result) {
656 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
657 goto error;
658 }
659 658
660 /* 659 /*
661 * Send out control message observed in win98 sniffs. Not sure what 660 * Send out control message observed in win98 sniffs. Not sure what
@@ -670,8 +669,14 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
670 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, 669 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
671 0x1, 0, NULL, 0, 100); 670 0x1, 0, NULL, 0, 100);
672 if (result == 0) { 671 if (result == 0) {
672 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
673 if (result) {
674 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
675 goto error;
676 }
673 return 0; 677 return 0;
674 } 678 }
679 msleep(1000);
675 } 680 }
676 err("%s - failed doing control urb, error %d", __FUNCTION__, result); 681 err("%s - failed doing control urb, error %d", __FUNCTION__, result);
677 goto error; 682 goto error;
@@ -854,6 +859,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
854 859
855 if (urb->status) { 860 if (urb->status) {
856 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 861 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
862 return;
857 } 863 }
858 864
859 spin_lock_irqsave(&write_list_lock, flags); 865 spin_lock_irqsave(&write_list_lock, flags);
@@ -966,3 +972,9 @@ MODULE_PARM_DESC(vendor, "User specified USB idVendor");
966 972
967module_param(product, ushort, 0); 973module_param(product, ushort, 0);
968MODULE_PARM_DESC(product, "User specified USB idProduct"); 974MODULE_PARM_DESC(product, "User specified USB idProduct");
975
976module_param(connect_retries, int, S_IRUGO|S_IWUSR);
977MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)");
978
979module_param(initial_wait, int, S_IRUGO|S_IWUSR);
980MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)");
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index a4a0bfeaab00..87306cb6f9f5 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -46,8 +46,8 @@
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/spinlock.h> 47#include <linux/spinlock.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include <linux/usb/serial.h>
49#include <asm/uaccess.h> 50#include <asm/uaccess.h>
50#include "usb-serial.h"
51 51
52/* 52/*
53 * Version Information 53 * Version Information
@@ -373,6 +373,8 @@ static void ipw_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
373 373
374 dbg("%s", __FUNCTION__); 374 dbg("%s", __FUNCTION__);
375 375
376 port->write_urb_busy = 0;
377
376 if (urb->status) 378 if (urb->status)
377 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 379 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
378 380
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 2cf1fed3de43..1738b0b6a376 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -57,7 +57,7 @@
57#include <linux/spinlock.h> 57#include <linux/spinlock.h>
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
59#include <linux/usb.h> 59#include <linux/usb.h>
60#include "usb-serial.h" 60#include <linux/usb/serial.h>
61 61
62/* 62/*
63 * Version Information 63 * Version Information
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index d7c58f1bc960..015ad6cc1bbb 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -107,7 +107,7 @@
107#include <linux/spinlock.h> 107#include <linux/spinlock.h>
108#include <asm/uaccess.h> 108#include <asm/uaccess.h>
109#include <linux/usb.h> 109#include <linux/usb.h>
110#include "usb-serial.h" 110#include <linux/usb/serial.h>
111#include "keyspan.h" 111#include "keyspan.h"
112 112
113static int debug; 113static int debug;
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 03ab3c0f3cce..49b8dc039d1f 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -78,6 +78,7 @@
78#include <linux/workqueue.h> 78#include <linux/workqueue.h>
79#include <asm/uaccess.h> 79#include <asm/uaccess.h>
80#include <linux/usb.h> 80#include <linux/usb.h>
81#include <linux/usb/serial.h>
81 82
82static int debug; 83static int debug;
83 84
@@ -107,8 +108,6 @@ struct ezusb_hex_record {
107#include "xircom_pgs_fw.h" 108#include "xircom_pgs_fw.h"
108#endif 109#endif
109 110
110#include "usb-serial.h"
111
112/* 111/*
113 * Version Information 112 * Version Information
114 */ 113 */
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index b45ff3e7ab40..2a2f3e2da055 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -55,7 +55,7 @@
55#include <linux/module.h> 55#include <linux/module.h>
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
57#include <linux/usb.h> 57#include <linux/usb.h>
58#include "usb-serial.h" 58#include <linux/usb/serial.h>
59#include "kl5kusb105.h" 59#include "kl5kusb105.h"
60 60
61static int debug; 61static int debug;
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 457733374772..d50dce034958 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -46,8 +46,8 @@
46#include <linux/spinlock.h> 46#include <linux/spinlock.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include <linux/usb/serial.h>
49#include <linux/ioctl.h> 50#include <linux/ioctl.h>
50#include "usb-serial.h"
51#include "kobil_sct.h" 51#include "kobil_sct.h"
52 52
53static int debug; 53static int debug;
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index ca05d3275f3e..f4d4305c2c02 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -75,7 +75,7 @@
75#include <linux/spinlock.h> 75#include <linux/spinlock.h>
76#include <asm/uaccess.h> 76#include <asm/uaccess.h>
77#include <linux/usb.h> 77#include <linux/usb.h>
78#include "usb-serial.h" 78#include <linux/usb/serial.h>
79#include "mct_u232.h" 79#include "mct_u232.h"
80 80
81/* 81/*
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 7f544081032e..ac3f8b5d2c49 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -14,7 +14,7 @@
14#include <linux/tty_flip.h> 14#include <linux/tty_flip.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/usb.h> 16#include <linux/usb.h>
17#include "usb-serial.h" 17#include <linux/usb/serial.h>
18 18
19static int debug; 19static int debug;
20 20
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index cfb711a21a45..e49f40913c27 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -46,7 +46,7 @@
46#include <linux/spinlock.h> 46#include <linux/spinlock.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include "usb-serial.h" 49#include <linux/usb/serial.h>
50 50
51static int debug; 51static int debug;
52 52
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 78ad4b3126a6..c856e6f40e22 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -9,39 +9,14 @@
9 9
10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> 10 Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org>
11 11
12 History: 12 History: see the git log.
13
14 2005-05-19 v0.1 Initial version, based on incomplete docs
15 and analysis of misbehavior with the standard driver
16 2005-05-20 v0.2 Extended the input buffer to avoid losing
17 random 64-byte chunks of data
18 2005-05-21 v0.3 implemented chars_in_buffer()
19 turned on low_latency
20 simplified the code somewhat
21 2005-05-24 v0.4 option_write() sometimes deadlocked under heavy load
22 removed some dead code
23 added sponsor notice
24 coding style clean-up
25 2005-06-20 v0.4.1 add missing braces :-/
26 killed end-of-line whitespace
27 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2
28 2005-09-10 v0.4.3 added HUAWEI E600 card and Audiovox AirCard
29 2005-09-20 v0.4.4 increased recv buffer size: the card sometimes
30 wants to send >2000 bytes.
31 2006-04-10 v0.5 fixed two array overrun errors :-/
32 2006-04-21 v0.5.1 added support for Sierra Wireless MC8755
33 2006-05-15 v0.6 re-enable multi-port support
34 2006-06-01 v0.6.1 add COBRA
35 2006-06-01 v0.6.2 add backwards-compatibility stuff
36 2006-06-01 v0.6.3 add Novatel Wireless
37 2006-06-01 v0.7 Option => GSM
38 13
39 Work sponsored by: Sigos GmbH, Germany <info@sigos.de> 14 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
40 15
41 This driver exists because the "normal" serial driver doesn't work too well 16 This driver exists because the "normal" serial driver doesn't work too well
42 with GSM modems. Issues: 17 with GSM modems. Issues:
43 - data loss -- one single Receive URB is not nearly enough 18 - data loss -- one single Receive URB is not nearly enough
44 - nonstandard flow (Option devices) and multiplex (Sierra) control 19 - nonstandard flow (Option devices) control
45 - controlling the baud rate doesn't make sense 20 - controlling the baud rate doesn't make sense
46 21
47 This driver is named "option" because the most common device it's 22 This driver is named "option" because the most common device it's
@@ -53,7 +28,7 @@
53 device features. 28 device features.
54*/ 29*/
55 30
56#define DRIVER_VERSION "v0.7.0" 31#define DRIVER_VERSION "v0.7.1"
57#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 32#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
58#define DRIVER_DESC "USB Driver for GSM modems" 33#define DRIVER_DESC "USB Driver for GSM modems"
59 34
@@ -64,7 +39,7 @@
64#include <linux/tty_flip.h> 39#include <linux/tty_flip.h>
65#include <linux/module.h> 40#include <linux/module.h>
66#include <linux/usb.h> 41#include <linux/usb.h>
67#include "usb-serial.h" 42#include <linux/usb/serial.h>
68 43
69/* Function prototypes */ 44/* Function prototypes */
70static int option_open(struct usb_serial_port *port, struct file *filp); 45static int option_open(struct usb_serial_port *port, struct file *filp);
@@ -95,27 +70,29 @@ static int option_send_setup(struct usb_serial_port *port);
95#define OPTION_VENDOR_ID 0x0AF0 70#define OPTION_VENDOR_ID 0x0AF0
96#define HUAWEI_VENDOR_ID 0x12D1 71#define HUAWEI_VENDOR_ID 0x12D1
97#define AUDIOVOX_VENDOR_ID 0x0F3D 72#define AUDIOVOX_VENDOR_ID 0x0F3D
98#define SIERRAWIRELESS_VENDOR_ID 0x1199
99#define NOVATELWIRELESS_VENDOR_ID 0x1410 73#define NOVATELWIRELESS_VENDOR_ID 0x1410
74#define ANYDATA_VENDOR_ID 0x16d5
100 75
101#define OPTION_PRODUCT_OLD 0x5000 76#define OPTION_PRODUCT_OLD 0x5000
102#define OPTION_PRODUCT_FUSION 0x6000 77#define OPTION_PRODUCT_FUSION 0x6000
103#define OPTION_PRODUCT_FUSION2 0x6300 78#define OPTION_PRODUCT_FUSION2 0x6300
104#define OPTION_PRODUCT_COBRA 0x6500 79#define OPTION_PRODUCT_COBRA 0x6500
80#define OPTION_PRODUCT_COBRA2 0x6600
105#define HUAWEI_PRODUCT_E600 0x1001 81#define HUAWEI_PRODUCT_E600 0x1001
106#define AUDIOVOX_PRODUCT_AIRCARD 0x0112 82#define AUDIOVOX_PRODUCT_AIRCARD 0x0112
107#define SIERRAWIRELESS_PRODUCT_MC8755 0x6802
108#define NOVATELWIRELESS_PRODUCT_U740 0x1400 83#define NOVATELWIRELESS_PRODUCT_U740 0x1400
84#define ANYDATA_PRODUCT_ID 0x6501
109 85
110static struct usb_device_id option_ids[] = { 86static struct usb_device_id option_ids[] = {
111 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, 87 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
112 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 88 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
113 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 89 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
114 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 90 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
91 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
115 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 92 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
116 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 93 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
117 { USB_DEVICE(SIERRAWIRELESS_VENDOR_ID, SIERRAWIRELESS_PRODUCT_MC8755) },
118 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) }, 94 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) },
95 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) },
119 { } /* Terminating entry */ 96 { } /* Terminating entry */
120}; 97};
121 98
@@ -124,13 +101,11 @@ static struct usb_device_id option_ids1[] = {
124 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 101 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
125 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 102 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
126 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 103 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
104 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
127 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 105 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
128 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 106 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
129 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) }, 107 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) },
130 { } /* Terminating entry */ 108 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) },
131};
132static struct usb_device_id option_ids3[] = {
133 { USB_DEVICE(SIERRAWIRELESS_VENDOR_ID, SIERRAWIRELESS_PRODUCT_MC8755) },
134 { } /* Terminating entry */ 109 { } /* Terminating entry */
135}; 110};
136 111
@@ -147,37 +122,11 @@ static struct usb_driver option_driver = {
147/* The card has three separate interfaces, which the serial driver 122/* The card has three separate interfaces, which the serial driver
148 * recognizes separately, thus num_port=1. 123 * recognizes separately, thus num_port=1.
149 */ 124 */
150static struct usb_serial_driver option_3port_device = {
151 .driver = {
152 .owner = THIS_MODULE,
153 .name = "option",
154 },
155 .description = "GSM modem (3-port)",
156 .id_table = option_ids3,
157 .num_interrupt_in = NUM_DONT_CARE,
158 .num_bulk_in = NUM_DONT_CARE,
159 .num_bulk_out = NUM_DONT_CARE,
160 .num_ports = 3,
161 .open = option_open,
162 .close = option_close,
163 .write = option_write,
164 .write_room = option_write_room,
165 .chars_in_buffer = option_chars_in_buffer,
166 .throttle = option_rx_throttle,
167 .unthrottle = option_rx_unthrottle,
168 .set_termios = option_set_termios,
169 .break_ctl = option_break_ctl,
170 .tiocmget = option_tiocmget,
171 .tiocmset = option_tiocmset,
172 .attach = option_startup,
173 .shutdown = option_shutdown,
174 .read_int_callback = option_instat_callback,
175};
176 125
177static struct usb_serial_driver option_1port_device = { 126static struct usb_serial_driver option_1port_device = {
178 .driver = { 127 .driver = {
179 .owner = THIS_MODULE, 128 .owner = THIS_MODULE,
180 .name = "option", 129 .name = "option1",
181 }, 130 },
182 .description = "GSM modem (1-port)", 131 .description = "GSM modem (1-port)",
183 .id_table = option_ids1, 132 .id_table = option_ids1,
@@ -241,9 +190,6 @@ static int __init option_init(void)
241 retval = usb_serial_register(&option_1port_device); 190 retval = usb_serial_register(&option_1port_device);
242 if (retval) 191 if (retval)
243 goto failed_1port_device_register; 192 goto failed_1port_device_register;
244 retval = usb_serial_register(&option_3port_device);
245 if (retval)
246 goto failed_3port_device_register;
247 retval = usb_register(&option_driver); 193 retval = usb_register(&option_driver);
248 if (retval) 194 if (retval)
249 goto failed_driver_register; 195 goto failed_driver_register;
@@ -253,8 +199,6 @@ static int __init option_init(void)
253 return 0; 199 return 0;
254 200
255failed_driver_register: 201failed_driver_register:
256 usb_serial_deregister (&option_3port_device);
257failed_3port_device_register:
258 usb_serial_deregister (&option_1port_device); 202 usb_serial_deregister (&option_1port_device);
259failed_1port_device_register: 203failed_1port_device_register:
260 return retval; 204 return retval;
@@ -263,7 +207,6 @@ failed_1port_device_register:
263static void __exit option_exit(void) 207static void __exit option_exit(void)
264{ 208{
265 usb_deregister (&option_driver); 209 usb_deregister (&option_driver);
266 usb_serial_deregister (&option_3port_device);
267 usb_serial_deregister (&option_1port_device); 210 usb_serial_deregister (&option_1port_device);
268} 211}
269 212
@@ -652,7 +595,6 @@ static void option_setup_urbs(struct usb_serial *serial)
652 595
653 dbg("%s", __FUNCTION__); 596 dbg("%s", __FUNCTION__);
654 597
655
656 for (i = 0; i < serial->num_ports; i++) { 598 for (i = 0; i < serial->num_ports; i++) {
657 port = serial->port[i]; 599 port = serial->port[i];
658 portdata = usb_get_serial_port_data(port); 600 portdata = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index de93a2b909e7..efbbc0adb89a 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -27,7 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include "usb-serial.h" 30#include <linux/usb/serial.h>
31#include "pl2303.h" 31#include "pl2303.h"
32 32
33/* 33/*
@@ -52,6 +52,7 @@ struct pl2303_buf {
52static struct usb_device_id id_table [] = { 52static struct usb_device_id id_table [] = {
53 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 53 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 54 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) },
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, 57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
57 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 58 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
@@ -79,6 +80,8 @@ static struct usb_device_id id_table [] = {
79 { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) }, 80 { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) },
80 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) }, 81 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) },
81 { USB_DEVICE(OTI_VENDOR_ID, OTI_PRODUCT_ID) }, 82 { USB_DEVICE(OTI_VENDOR_ID, OTI_PRODUCT_ID) },
83 { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) },
84 { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) },
82 { } /* Terminating entry */ 85 { } /* Terminating entry */
83}; 86};
84 87
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 7f29e81d3e35..a692ac66ca6c 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -10,6 +10,7 @@
10#define PL2303_VENDOR_ID 0x067b 10#define PL2303_VENDOR_ID 0x067b
11#define PL2303_PRODUCT_ID 0x2303 11#define PL2303_PRODUCT_ID 0x2303
12#define PL2303_PRODUCT_ID_RSAQ2 0x04bb 12#define PL2303_PRODUCT_ID_RSAQ2 0x04bb
13#define PL2303_PRODUCT_ID_DCU11 0x1234
13#define PL2303_PRODUCT_ID_PHAROS 0xaaa0 14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
14#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2
15 16
@@ -84,3 +85,11 @@
84/* Ours Technology Inc DKU-5 clone, chipset: Prolific Technology Inc */ 85/* Ours Technology Inc DKU-5 clone, chipset: Prolific Technology Inc */
85#define OTI_VENDOR_ID 0x0ea0 86#define OTI_VENDOR_ID 0x0ea0
86#define OTI_PRODUCT_ID 0x6858 87#define OTI_PRODUCT_ID 0x6858
88
89/* DATAPILOT Universal-2 Phone Cable */
90#define DATAPILOT_U2_VENDOR_ID 0x0731
91#define DATAPILOT_U2_PRODUCT_ID 0x2003
92
93/* Belkin "F5U257" Serial Adapter */
94#define BELKIN_VENDOR_ID 0x050d
95#define BELKIN_PRODUCT_ID 0x0257
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 897d8447252b..789771ecdb11 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -71,7 +71,7 @@
71#include <linux/spinlock.h> 71#include <linux/spinlock.h>
72#include <asm/uaccess.h> 72#include <asm/uaccess.h>
73#include <linux/usb.h> 73#include <linux/usb.h>
74#include "usb-serial.h" 74#include <linux/usb/serial.h>
75 75
76 76
77#ifndef CONFIG_USB_SAFE_PADDED 77#ifndef CONFIG_USB_SAFE_PADDED
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
new file mode 100644
index 000000000000..d29638daa987
--- /dev/null
+++ b/drivers/usb/serial/sierra.c
@@ -0,0 +1,75 @@
1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver
3 *
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
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 version
9 * 2 as published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/tty.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17#include <linux/usb/serial.h>
18
19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */
31 { }
32};
33MODULE_DEVICE_TABLE(usb, id_table);
34
35static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless",
37 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect,
39 .id_table = id_table,
40};
41
42static struct usb_serial_driver sierra_device = {
43 .driver = {
44 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless",
46 },
47 .id_table = id_table,
48 .num_interrupt_in = NUM_DONT_CARE,
49 .num_bulk_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE,
51 .num_ports = 3,
52};
53
54static int __init sierra_init(void)
55{
56 int retval;
57
58 retval = usb_serial_register(&sierra_device);
59 if (retval)
60 return retval;
61 retval = usb_register(&sierra_driver);
62 if (retval)
63 usb_serial_deregister(&sierra_device);
64 return retval;
65}
66
67static void __exit sierra_exit(void)
68{
69 usb_deregister(&sierra_driver);
70 usb_serial_deregister(&sierra_device);
71}
72
73module_init(sierra_init);
74module_exit(sierra_exit);
75MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index a9afff31a921..ac9b8ee52d44 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -83,8 +83,8 @@
83#include <asm/uaccess.h> 83#include <asm/uaccess.h>
84#include <asm/semaphore.h> 84#include <asm/semaphore.h>
85#include <linux/usb.h> 85#include <linux/usb.h>
86#include <linux/usb/serial.h>
86 87
87#include "usb-serial.h"
88#include "ti_usb_3410_5052.h" 88#include "ti_usb_3410_5052.h"
89#include "ti_fw_3410.h" /* firmware image for 3410 */ 89#include "ti_fw_3410.h" /* firmware image for 3410 */
90#include "ti_fw_5052.h" /* firmware image for 5052 */ 90#include "ti_fw_5052.h" /* firmware image for 5052 */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b59a0536ea5c..12c1694d322e 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include "usb-serial.h" 34#include <linux/usb/serial.h>
35#include "pl2303.h" 35#include "pl2303.h"
36 36
37/* 37/*
@@ -40,6 +40,8 @@
40#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" 40#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
41#define DRIVER_DESC "USB Serial Driver core" 41#define DRIVER_DESC "USB Serial Driver core"
42 42
43static void port_free(struct usb_serial_port *port);
44
43/* Driver structure we register with the USB core */ 45/* Driver structure we register with the USB core */
44static struct usb_driver usb_serial_driver = { 46static struct usb_driver usb_serial_driver = {
45 .name = "usbserial", 47 .name = "usbserial",
@@ -146,23 +148,10 @@ static void destroy_serial(struct kref *kref)
146 port = serial->port[i]; 148 port = serial->port[i];
147 if (!port) 149 if (!port)
148 continue; 150 continue;
149 usb_kill_urb(port->read_urb); 151 port_free(port);
150 usb_free_urb(port->read_urb);
151 usb_kill_urb(port->write_urb);
152 usb_free_urb(port->write_urb);
153 usb_kill_urb(port->interrupt_in_urb);
154 usb_free_urb(port->interrupt_in_urb);
155 usb_kill_urb(port->interrupt_out_urb);
156 usb_free_urb(port->interrupt_out_urb);
157 kfree(port->bulk_in_buffer);
158 kfree(port->bulk_out_buffer);
159 kfree(port->interrupt_in_buffer);
160 kfree(port->interrupt_out_buffer);
161 } 152 }
162 } 153 }
163 154
164 flush_scheduled_work(); /* port->work */
165
166 usb_put_dev(serial->dev); 155 usb_put_dev(serial->dev);
167 156
168 /* free up any memory that we allocated */ 157 /* free up any memory that we allocated */
@@ -564,6 +553,11 @@ static void port_release(struct device *dev)
564 struct usb_serial_port *port = to_usb_serial_port(dev); 553 struct usb_serial_port *port = to_usb_serial_port(dev);
565 554
566 dbg ("%s - %s", __FUNCTION__, dev->bus_id); 555 dbg ("%s - %s", __FUNCTION__, dev->bus_id);
556 port_free(port);
557}
558
559static void port_free(struct usb_serial_port *port)
560{
567 usb_kill_urb(port->read_urb); 561 usb_kill_urb(port->read_urb);
568 usb_free_urb(port->read_urb); 562 usb_free_urb(port->read_urb);
569 usb_kill_urb(port->write_urb); 563 usb_kill_urb(port->write_urb);
@@ -576,6 +570,7 @@ static void port_release(struct device *dev)
576 kfree(port->bulk_out_buffer); 570 kfree(port->bulk_out_buffer);
577 kfree(port->interrupt_in_buffer); 571 kfree(port->interrupt_in_buffer);
578 kfree(port->interrupt_out_buffer); 572 kfree(port->interrupt_out_buffer);
573 flush_scheduled_work(); /* port->work */
579 kfree(port); 574 kfree(port);
580} 575}
581 576
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
deleted file mode 100644
index 0f2802a60194..000000000000
--- a/drivers/usb/serial/usb-serial.h
+++ /dev/null
@@ -1,300 +0,0 @@
1/*
2 * USB Serial Converter driver
3 *
4 * Copyright (C) 1999 - 2005
5 * Greg Kroah-Hartman (greg@kroah.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
10 *
11 */
12
13
14#ifndef __LINUX_USB_SERIAL_H
15#define __LINUX_USB_SERIAL_H
16
17#include <linux/kref.h>
18#include <linux/mutex.h>
19
20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
22
23#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */
24
25/* parity check flag */
26#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
27
28/**
29 * usb_serial_port: structure for the specific ports of a device.
30 * @serial: pointer back to the struct usb_serial owner of this port.
31 * @tty: pointer to the corresponding tty for this port.
32 * @lock: spinlock to grab when updating portions of this structure.
33 * @mutex: mutex used to synchronize serial_open() and serial_close()
34 * access for this port.
35 * @number: the number of the port (the minor number).
36 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port.
37 * @interrupt_in_urb: pointer to the interrupt in struct urb for this port.
38 * @interrupt_in_endpointAddress: endpoint address for the interrupt in pipe
39 * for this port.
40 * @interrupt_out_buffer: pointer to the interrupt out buffer for this port.
41 * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes.
42 * @interrupt_out_urb: pointer to the interrupt out struct urb for this port.
43 * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe
44 * for this port.
45 * @bulk_in_buffer: pointer to the bulk in buffer for this port.
46 * @read_urb: pointer to the bulk in struct urb for this port.
47 * @bulk_in_endpointAddress: endpoint address for the bulk in pipe for this
48 * port.
49 * @bulk_out_buffer: pointer to the bulk out buffer for this port.
50 * @bulk_out_size: the size of the bulk_out_buffer, in bytes.
51 * @write_urb: pointer to the bulk out struct urb for this port.
52 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this
53 * port.
54 * @write_wait: a wait_queue_head_t used by the port.
55 * @work: work queue entry for the line discipline waking up.
56 * @open_count: number of times this port has been opened.
57 *
58 * This structure is used by the usb-serial core and drivers for the specific
59 * ports of a device.
60 */
61struct usb_serial_port {
62 struct usb_serial * serial;
63 struct tty_struct * tty;
64 spinlock_t lock;
65 struct mutex mutex;
66 unsigned char number;
67
68 unsigned char * interrupt_in_buffer;
69 struct urb * interrupt_in_urb;
70 __u8 interrupt_in_endpointAddress;
71
72 unsigned char * interrupt_out_buffer;
73 int interrupt_out_size;
74 struct urb * interrupt_out_urb;
75 __u8 interrupt_out_endpointAddress;
76
77 unsigned char * bulk_in_buffer;
78 int bulk_in_size;
79 struct urb * read_urb;
80 __u8 bulk_in_endpointAddress;
81
82 unsigned char * bulk_out_buffer;
83 int bulk_out_size;
84 struct urb * write_urb;
85 int write_urb_busy;
86 __u8 bulk_out_endpointAddress;
87
88 wait_queue_head_t write_wait;
89 struct work_struct work;
90 int open_count;
91 struct device dev;
92};
93#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
94
95/* get and set the port private data pointer helper functions */
96static inline void *usb_get_serial_port_data (struct usb_serial_port *port)
97{
98 return dev_get_drvdata(&port->dev);
99}
100
101static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data)
102{
103 dev_set_drvdata(&port->dev, data);
104}
105
106/**
107 * usb_serial - structure used by the usb-serial core for a device
108 * @dev: pointer to the struct usb_device for this device
109 * @type: pointer to the struct usb_serial_driver for this device
110 * @interface: pointer to the struct usb_interface for this device
111 * @minor: the starting minor number for this device
112 * @num_ports: the number of ports this device has
113 * @num_interrupt_in: number of interrupt in endpoints we have
114 * @num_interrupt_out: number of interrupt out endpoints we have
115 * @num_bulk_in: number of bulk in endpoints we have
116 * @num_bulk_out: number of bulk out endpoints we have
117 * @port: array of struct usb_serial_port structures for the different ports.
118 * @private: place to put any driver specific information that is needed. The
119 * usb-serial driver is required to manage this data, the usb-serial core
120 * will not touch this. Use usb_get_serial_data() and
121 * usb_set_serial_data() to access this.
122 */
123struct usb_serial {
124 struct usb_device * dev;
125 struct usb_serial_driver * type;
126 struct usb_interface * interface;
127 unsigned char minor;
128 unsigned char num_ports;
129 unsigned char num_port_pointers;
130 char num_interrupt_in;
131 char num_interrupt_out;
132 char num_bulk_in;
133 char num_bulk_out;
134 struct usb_serial_port * port[MAX_NUM_PORTS];
135 struct kref kref;
136 void * private;
137};
138#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
139
140#define NUM_DONT_CARE (-1)
141
142/* get and set the serial private data pointer helper functions */
143static inline void *usb_get_serial_data (struct usb_serial *serial)
144{
145 return serial->private;
146}
147
148static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
149{
150 serial->private = data;
151}
152
153/**
154 * usb_serial_driver - describes a usb serial driver
155 * @description: pointer to a string that describes this driver. This string used
156 * in the syslog messages when a device is inserted or removed.
157 * @id_table: pointer to a list of usb_device_id structures that define all
158 * of the devices this structure can support.
159 * @num_interrupt_in: the number of interrupt in endpoints this device will
160 * have.
161 * @num_interrupt_out: the number of interrupt out endpoints this device will
162 * have.
163 * @num_bulk_in: the number of bulk in endpoints this device will have.
164 * @num_bulk_out: the number of bulk out endpoints this device will have.
165 * @num_ports: the number of different ports this device will have.
166 * @calc_num_ports: pointer to a function to determine how many ports this
167 * device has dynamically. It will be called after the probe()
168 * callback is called, but before attach()
169 * @probe: pointer to the driver's probe function.
170 * This will be called when the device is inserted into the system,
171 * but before the device has been fully initialized by the usb_serial
172 * subsystem. Use this function to download any firmware to the device,
173 * or any other early initialization that might be needed.
174 * Return 0 to continue on with the initialization sequence. Anything
175 * else will abort it.
176 * @attach: pointer to the driver's attach function.
177 * This will be called when the struct usb_serial structure is fully set
178 * set up. Do any local initialization of the device, or any private
179 * memory structure allocation at this point in time.
180 * @shutdown: pointer to the driver's shutdown function. This will be
181 * called when the device is removed from the system.
182 *
183 * This structure is defines a USB Serial driver. It provides all of
184 * the information that the USB serial core code needs. If the function
185 * pointers are defined, then the USB serial core code will call them when
186 * the corresponding tty port functions are called. If they are not
187 * called, the generic serial function will be used instead.
188 *
189 * The driver.owner field should be set to the module owner of this driver.
190 * The driver.name field should be set to the name of this driver (remember
191 * it will show up in sysfs, so it needs to be short and to the point.
192 * Useing the module name is a good idea.)
193 */
194struct usb_serial_driver {
195 const char *description;
196 const struct usb_device_id *id_table;
197 char num_interrupt_in;
198 char num_interrupt_out;
199 char num_bulk_in;
200 char num_bulk_out;
201 char num_ports;
202
203 struct list_head driver_list;
204 struct device_driver driver;
205
206 int (*probe) (struct usb_serial *serial, const struct usb_device_id *id);
207 int (*attach) (struct usb_serial *serial);
208 int (*calc_num_ports) (struct usb_serial *serial);
209
210 void (*shutdown) (struct usb_serial *serial);
211
212 int (*port_probe) (struct usb_serial_port *port);
213 int (*port_remove) (struct usb_serial_port *port);
214
215 /* serial function calls */
216 int (*open) (struct usb_serial_port *port, struct file * filp);
217 void (*close) (struct usb_serial_port *port, struct file * filp);
218 int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count);
219 int (*write_room) (struct usb_serial_port *port);
220 int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
221 void (*set_termios) (struct usb_serial_port *port, struct termios * old);
222 void (*break_ctl) (struct usb_serial_port *port, int break_state);
223 int (*chars_in_buffer) (struct usb_serial_port *port);
224 void (*throttle) (struct usb_serial_port *port);
225 void (*unthrottle) (struct usb_serial_port *port);
226 int (*tiocmget) (struct usb_serial_port *port, struct file *file);
227 int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
228
229 void (*read_int_callback)(struct urb *urb, struct pt_regs *regs);
230 void (*write_int_callback)(struct urb *urb, struct pt_regs *regs);
231 void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs);
232 void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs);
233};
234#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver)
235
236extern int usb_serial_register(struct usb_serial_driver *driver);
237extern void usb_serial_deregister(struct usb_serial_driver *driver);
238extern void usb_serial_port_softint(struct usb_serial_port *port);
239
240extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
241extern void usb_serial_disconnect(struct usb_interface *iface);
242
243extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest);
244extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);
245
246/* USB Serial console functions */
247#ifdef CONFIG_USB_SERIAL_CONSOLE
248extern void usb_serial_console_init (int debug, int minor);
249extern void usb_serial_console_exit (void);
250extern void usb_serial_console_disconnect(struct usb_serial *serial);
251#else
252static inline void usb_serial_console_init (int debug, int minor) { }
253static inline void usb_serial_console_exit (void) { }
254static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
255#endif
256
257/* Functions needed by other parts of the usbserial core */
258extern struct usb_serial *usb_serial_get_by_index (unsigned int minor);
259extern void usb_serial_put(struct usb_serial *serial);
260extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);
261extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);
262extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);
263extern int usb_serial_generic_write_room (struct usb_serial_port *port);
264extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port);
265extern void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
266extern void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
267extern void usb_serial_generic_shutdown (struct usb_serial *serial);
268extern int usb_serial_generic_register (int debug);
269extern void usb_serial_generic_deregister (void);
270
271extern int usb_serial_bus_register (struct usb_serial_driver *device);
272extern void usb_serial_bus_deregister (struct usb_serial_driver *device);
273
274extern struct usb_serial_driver usb_serial_generic_device;
275extern struct bus_type usb_serial_bus_type;
276extern struct tty_driver *usb_serial_tty_driver;
277
278static inline void usb_serial_debug_data(int debug,
279 struct device *dev,
280 const char *function, int size,
281 const unsigned char *data)
282{
283 int i;
284
285 if (debug) {
286 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size);
287 for (i = 0; i < size; ++i)
288 printk ("%.2x ", data[i]);
289 printk ("\n");
290 }
291}
292
293/* Use our own dbg macro */
294#undef dbg
295#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0)
296
297
298
299#endif /* ifdef __LINUX_USB_SERIAL_H */
300
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 95a2936e902e..88949f7884ca 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -25,7 +25,7 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include "usb-serial.h" 28#include <linux/usb/serial.h>
29#include "visor.h" 29#include "visor.h"
30 30
31/* 31/*
@@ -302,7 +302,6 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
302 spin_lock_irqsave(&priv->lock, flags); 302 spin_lock_irqsave(&priv->lock, flags);
303 priv->bytes_in = 0; 303 priv->bytes_in = 0;
304 priv->bytes_out = 0; 304 priv->bytes_out = 0;
305 priv->outstanding_urbs = 0;
306 priv->throttled = 0; 305 priv->throttled = 0;
307 spin_unlock_irqrestore(&priv->lock, flags); 306 spin_unlock_irqrestore(&priv->lock, flags);
308 307
@@ -435,13 +434,25 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
435 434
436static int visor_write_room (struct usb_serial_port *port) 435static int visor_write_room (struct usb_serial_port *port)
437{ 436{
437 struct visor_private *priv = usb_get_serial_port_data(port);
438 unsigned long flags;
439
438 dbg("%s - port %d", __FUNCTION__, port->number); 440 dbg("%s - port %d", __FUNCTION__, port->number);
439 441
440 /* 442 /*
441 * We really can take anything the user throws at us 443 * We really can take anything the user throws at us
442 * but let's pick a nice big number to tell the tty 444 * but let's pick a nice big number to tell the tty
443 * layer that we have lots of free space 445 * layer that we have lots of free space, unless we don't.
444 */ 446 */
447
448 spin_lock_irqsave(&priv->lock, flags);
449 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
450 spin_unlock_irqrestore(&priv->lock, flags);
451 dbg("%s - write limit hit\n", __FUNCTION__);
452 return 0;
453 }
454 spin_unlock_irqrestore(&priv->lock, flags);
455
445 return 2048; 456 return 2048;
446} 457}
447 458
@@ -758,15 +769,22 @@ static int visor_calc_num_ports (struct usb_serial *serial)
758 769
759static int generic_startup(struct usb_serial *serial) 770static int generic_startup(struct usb_serial *serial)
760{ 771{
772 struct usb_serial_port **ports = serial->port;
761 struct visor_private *priv; 773 struct visor_private *priv;
762 int i; 774 int i;
763 775
764 for (i = 0; i < serial->num_ports; ++i) { 776 for (i = 0; i < serial->num_ports; ++i) {
765 priv = kzalloc (sizeof(*priv), GFP_KERNEL); 777 priv = kzalloc (sizeof(*priv), GFP_KERNEL);
766 if (!priv) 778 if (!priv) {
779 while (i-- != 0) {
780 priv = usb_get_serial_port_data(ports[i]);
781 usb_set_serial_port_data(ports[i], NULL);
782 kfree(priv);
783 }
767 return -ENOMEM; 784 return -ENOMEM;
785 }
768 spin_lock_init(&priv->lock); 786 spin_lock_init(&priv->lock);
769 usb_set_serial_port_data(serial->port[i], priv); 787 usb_set_serial_port_data(ports[i], priv);
770 } 788 }
771 return 0; 789 return 0;
772} 790}
@@ -876,7 +894,18 @@ static int clie_5_attach (struct usb_serial *serial)
876 894
877static void visor_shutdown (struct usb_serial *serial) 895static void visor_shutdown (struct usb_serial *serial)
878{ 896{
897 struct visor_private *priv;
898 int i;
899
879 dbg("%s", __FUNCTION__); 900 dbg("%s", __FUNCTION__);
901
902 for (i = 0; i < serial->num_ports; i++) {
903 priv = usb_get_serial_port_data(serial->port[i]);
904 if (priv) {
905 usb_set_serial_port_data(serial->port[i], NULL);
906 kfree(priv);
907 }
908 }
880} 909}
881 910
882static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 911static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 540438c3f381..6e6c7934be32 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -79,7 +79,7 @@
79#include <linux/usb.h> 79#include <linux/usb.h>
80#include <linux/serial_reg.h> 80#include <linux/serial_reg.h>
81#include <linux/serial.h> 81#include <linux/serial.h>
82#include "usb-serial.h" 82#include <linux/usb/serial.h>
83#include "whiteheat_fw.h" /* firmware for the ConnectTech WhiteHEAT device */ 83#include "whiteheat_fw.h" /* firmware for the ConnectTech WhiteHEAT device */
84#include "whiteheat.h" /* WhiteHEAT specific commands */ 84#include "whiteheat.h" /* WhiteHEAT specific commands */
85 85
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 5715291ba540..a4b7df9ff8c1 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -112,13 +112,11 @@ static int slave_configure(struct scsi_device *sdev)
112 if (sdev->scsi_level < SCSI_2) 112 if (sdev->scsi_level < SCSI_2)
113 sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2; 113 sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2;
114 114
115 /* According to the technical support people at Genesys Logic, 115 /* Many devices have trouble transfering more than 32KB at a time,
116 * devices using their chips have problems transferring more than 116 * while others have trouble with more than 64K. At this time we
117 * 32 KB at a time. In practice people have found that 64 KB 117 * are limiting both to 32K (64 sectores).
118 * works okay and that's what Windows does. But we'll be 118 */
119 * conservative; people can always use the sysfs interface to 119 if ((us->flags & US_FL_MAX_SECTORS_64) &&
120 * increase max_sectors. */
121 if (le16_to_cpu(us->pusb_dev->descriptor.idVendor) == USB_VENDOR_ID_GENESYS &&
122 sdev->request_queue->max_sectors > 64) 120 sdev->request_queue->max_sectors > 64)
123 blk_queue_max_sectors(sdev->request_queue, 64); 121 blk_queue_max_sectors(sdev->request_queue, 64);
124 122
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index eb7188b3565c..d6acc92a4ae3 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -180,7 +180,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
180 if (timeleft <= 0) { 180 if (timeleft <= 0) {
181 US_DEBUGP("%s -- cancelling URB\n", 181 US_DEBUGP("%s -- cancelling URB\n",
182 timeleft == 0 ? "Timeout" : "Signal"); 182 timeleft == 0 ? "Timeout" : "Signal");
183 usb_unlink_urb(us->current_urb); 183 usb_kill_urb(us->current_urb);
184 } 184 }
185 185
186 /* return the URB status */ 186 /* return the URB status */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index c7e84e653df9..2793f9a912b4 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -112,6 +112,19 @@ UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113,
112 US_SC_DEVICE, US_PR_DEVICE, NULL, 112 US_SC_DEVICE, US_PR_DEVICE, NULL,
113 US_FL_FIX_INQUIRY ), 113 US_FL_FIX_INQUIRY ),
114 114
115/* Submitted by Ernestas Vaiciukevicius <ernisv@gmail.com> */
116UNUSUAL_DEV( 0x0419, 0x0100, 0x0100, 0x0100,
117 "Samsung Info. Systems America, Inc.",
118 "MP3 Player",
119 US_SC_DEVICE, US_PR_DEVICE, NULL,
120 US_FL_IGNORE_RESIDUE ),
121
122/* Reported by Orgad Shaneh <orgads@gmail.com> */
123UNUSUAL_DEV( 0x0419, 0xaace, 0x0100, 0x0100,
124 "Samsung", "MP3 Player",
125 US_SC_DEVICE, US_PR_DEVICE, NULL,
126 US_FL_IGNORE_RESIDUE ),
127
115/* Reported by Christian Leber <christian@leber.de> */ 128/* Reported by Christian Leber <christian@leber.de> */
116UNUSUAL_DEV( 0x0419, 0xaaf5, 0x0100, 0x0100, 129UNUSUAL_DEV( 0x0419, 0xaaf5, 0x0100, 0x0100,
117 "TrekStor", 130 "TrekStor",
@@ -132,6 +145,21 @@ UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
132 US_SC_DEVICE, US_PR_DEVICE, NULL, 145 US_SC_DEVICE, US_PR_DEVICE, NULL,
133 US_FL_IGNORE_RESIDUE ), 146 US_FL_IGNORE_RESIDUE ),
134 147
148/* Reported by Mario Rettig <mariorettig@web.de> */
149UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
150 "Nokia",
151 "Nokia 3250",
152 US_SC_DEVICE, US_PR_DEVICE, NULL,
153 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
154
155/* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and
156 * Einar Th. Einarsson <einarthered@gmail.com> */
157UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100,
158 "Nokia",
159 "N91",
160 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
162
135/* Reported by Jiri Slaby <jirislaby@gmail.com> and 163/* Reported by Jiri Slaby <jirislaby@gmail.com> and
136 * Rene C. Castberg <Rene@Castberg.org> */ 164 * Rene C. Castberg <Rene@Castberg.org> */
137UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100, 165UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100,
@@ -140,6 +168,13 @@ UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100,
140 US_SC_DEVICE, US_PR_DEVICE, NULL, 168 US_SC_DEVICE, US_PR_DEVICE, NULL,
141 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 169 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
142 170
171/* Reported by Matthew Bloch <matthew@bytemark.co.uk> */
172UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
173 "Nokia",
174 "E61",
175 US_SC_DEVICE, US_PR_DEVICE, NULL,
176 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
177
143/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 178/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
144UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 179UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
145 "SMSC", 180 "SMSC",
@@ -473,10 +508,11 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
473 US_SC_SCSI, US_PR_DEVICE, NULL, 508 US_SC_SCSI, US_PR_DEVICE, NULL,
474 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ), 509 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ),
475 510
476/* This entry is needed because the device reports Sub=ff */ 511/* Submitted by Lars Jacob <jacob.lars@googlemail.com>
477UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0600, 512 * This entry is needed because the device reports Sub=ff */
513UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610,
478 "Sony", 514 "Sony",
479 "DSC-T1/T5", 515 "DSC-T1/T5/H5",
480 US_SC_8070, US_PR_DEVICE, NULL, 516 US_SC_8070, US_PR_DEVICE, NULL,
481 US_FL_SINGLE_LUN ), 517 US_FL_SINGLE_LUN ),
482 518
@@ -598,18 +634,6 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
598 "Digital Camera EX-20 DSC", 634 "Digital Camera EX-20 DSC",
599 US_SC_8070, US_PR_DEVICE, NULL, 0 ), 635 US_SC_8070, US_PR_DEVICE, NULL, 0 ),
600 636
601/* The entry was here before I took over, and had US_SC_RBC. It turns
602 * out that isn't needed. Additionally, Torsten Eriksson
603 * <Torsten.Eriksson@bergianska.se> is able to use his device fine
604 * without this entry at all - but I don't suspect that will be true
605 * for all users (the protocol is likely needed), so is staying at
606 * this time. - Phil Dibowitz <phil@ipom.com>
607 */
608UNUSUAL_DEV( 0x059f, 0xa601, 0x0200, 0x0200,
609 "LaCie",
610 "USB Hard Disk",
611 US_SC_DEVICE, US_PR_CB, NULL, 0 ),
612
613/* Submitted by Joel Bourquard <numlock@freesurf.ch> 637/* Submitted by Joel Bourquard <numlock@freesurf.ch>
614 * Some versions of this device need the SubClass and Protocol overrides 638 * Some versions of this device need the SubClass and Protocol overrides
615 * while others don't. 639 * while others don't.
@@ -708,18 +732,22 @@ UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
708 * They were originally reported by Alexander Oltu 732 * They were originally reported by Alexander Oltu
709 * <alexander@all-2.com> and Peter Marks <peter.marks@turner.com> 733 * <alexander@all-2.com> and Peter Marks <peter.marks@turner.com>
710 * respectively. 734 * respectively.
735 *
736 * US_FL_GO_SLOW and US_FL_MAX_SECTORS_64 added by Phil Dibowitz
737 * <phil@ipom.com> as these flags were made and hard-coded
738 * special-cases were pulled from scsiglue.c.
711 */ 739 */
712UNUSUAL_DEV( 0x05e3, 0x0701, 0x0000, 0xffff, 740UNUSUAL_DEV( 0x05e3, 0x0701, 0x0000, 0xffff,
713 "Genesys Logic", 741 "Genesys Logic",
714 "USB to IDE Optical", 742 "USB to IDE Optical",
715 US_SC_DEVICE, US_PR_DEVICE, NULL, 743 US_SC_DEVICE, US_PR_DEVICE, NULL,
716 US_FL_GO_SLOW ), 744 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ),
717 745
718UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff, 746UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff,
719 "Genesys Logic", 747 "Genesys Logic",
720 "USB to IDE Disk", 748 "USB to IDE Disk",
721 US_SC_DEVICE, US_PR_DEVICE, NULL, 749 US_SC_DEVICE, US_PR_DEVICE, NULL,
722 US_FL_GO_SLOW ), 750 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ),
723 751
724/* Reported by Hanno Boeck <hanno@gmx.de> 752/* Reported by Hanno Boeck <hanno@gmx.de>
725 * Taken from the Lycoris Kernel */ 753 * Taken from the Lycoris Kernel */
@@ -1073,7 +1101,15 @@ UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1073 "Optio S/S4", 1101 "Optio S/S4",
1074 US_SC_DEVICE, US_PR_DEVICE, NULL, 1102 US_SC_DEVICE, US_PR_DEVICE, NULL,
1075 US_FL_FIX_INQUIRY ), 1103 US_FL_FIX_INQUIRY ),
1076 1104
1105/* This is a virtual windows driver CD, which the zd1211rw driver automatically
1106 * converts into a WLAN device. */
1107UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
1108 "ZyXEL",
1109 "G-220F USB-WLAN Install",
1110 US_SC_DEVICE, US_PR_DEVICE, NULL,
1111 US_FL_IGNORE_DEVICE ),
1112
1077#ifdef CONFIG_USB_STORAGE_ISD200 1113#ifdef CONFIG_USB_STORAGE_ISD200
1078UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1114UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1079 "ATI", 1115 "ATI",
@@ -1196,6 +1232,14 @@ UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110,
1196 US_SC_DEVICE, US_PR_DEVICE, NULL, 1232 US_SC_DEVICE, US_PR_DEVICE, NULL,
1197 US_FL_IGNORE_RESIDUE ), 1233 US_FL_IGNORE_RESIDUE ),
1198 1234
1235/* Reported by Benjamin Schiller <sbenni@gmx.de>
1236 * It is also sold by Easylite as DJ 20 */
1237UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103,
1238 "Typhoon",
1239 "My DJ 1820",
1240 US_SC_DEVICE, US_PR_DEVICE, NULL,
1241 US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64),
1242
1199/* Reported by Michael Stattmann <michael@stattmann.com> */ 1243/* Reported by Michael Stattmann <michael@stattmann.com> */
1200UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, 1244UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1201 "Sony Ericsson", 1245 "Sony Ericsson",
@@ -1227,6 +1271,15 @@ UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
1227 US_SC_DEVICE, US_PR_DEVICE, NULL, 1271 US_SC_DEVICE, US_PR_DEVICE, NULL,
1228 US_FL_IGNORE_RESIDUE ), 1272 US_FL_IGNORE_RESIDUE ),
1229 1273
1274/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
1275 * and Renato Perini <rperini@email.it>
1276 */
1277UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
1278 "Motorola",
1279 "RAZR V3x",
1280 US_SC_DEVICE, US_PR_DEVICE, NULL,
1281 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
1282
1230/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */ 1283/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */
1231UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, 1284UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1232 "MPIO", 1285 "MPIO",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 1185acac4b21..8d7bdcb5924d 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -55,6 +55,7 @@
55#include <linux/slab.h> 55#include <linux/slab.h>
56#include <linux/kthread.h> 56#include <linux/kthread.h>
57#include <linux/mutex.h> 57#include <linux/mutex.h>
58#include <linux/utsrelease.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -373,8 +374,12 @@ static int usb_stor_control_thread(void * __us)
373 /* lock access to the state */ 374 /* lock access to the state */
374 scsi_lock(host); 375 scsi_lock(host);
375 376
377 /* did the command already complete because of a disconnect? */
378 if (!us->srb)
379 ; /* nothing to do */
380
376 /* indicate that the command is done */ 381 /* indicate that the command is done */
377 if (us->srb->result != DID_ABORT << 16) { 382 else if (us->srb->result != DID_ABORT << 16) {
378 US_DEBUGP("scsi cmd done, result=0x%x\n", 383 US_DEBUGP("scsi cmd done, result=0x%x\n",
379 us->srb->result); 384 us->srb->result);
380 us->srb->scsi_done(us->srb); 385 us->srb->scsi_done(us->srb);
@@ -478,7 +483,7 @@ static struct us_unusual_dev *find_unusual(const struct usb_device_id *id)
478} 483}
479 484
480/* Get the unusual_devs entries and the string descriptors */ 485/* Get the unusual_devs entries and the string descriptors */
481static void get_device_info(struct us_data *us, const struct usb_device_id *id) 486static int get_device_info(struct us_data *us, const struct usb_device_id *id)
482{ 487{
483 struct usb_device *dev = us->pusb_dev; 488 struct usb_device *dev = us->pusb_dev;
484 struct usb_interface_descriptor *idesc = 489 struct usb_interface_descriptor *idesc =
@@ -495,6 +500,11 @@ static void get_device_info(struct us_data *us, const struct usb_device_id *id)
495 unusual_dev->useTransport; 500 unusual_dev->useTransport;
496 us->flags = USB_US_ORIG_FLAGS(id->driver_info); 501 us->flags = USB_US_ORIG_FLAGS(id->driver_info);
497 502
503 if (us->flags & US_FL_IGNORE_DEVICE) {
504 printk(KERN_INFO USB_STORAGE "device ignored\n");
505 return -ENODEV;
506 }
507
498 /* 508 /*
499 * This flag is only needed when we're in high-speed, so let's 509 * This flag is only needed when we're in high-speed, so let's
500 * disable it if we're in full-speed 510 * disable it if we're in full-speed
@@ -524,7 +534,8 @@ static void get_device_info(struct us_data *us, const struct usb_device_id *id)
524 if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE)) 534 if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE))
525 printk(KERN_NOTICE USB_STORAGE "This device " 535 printk(KERN_NOTICE USB_STORAGE "This device "
526 "(%04x,%04x,%04x S %02x P %02x)" 536 "(%04x,%04x,%04x S %02x P %02x)"
527 " has %s in unusual_devs.h\n" 537 " has %s in unusual_devs.h (kernel"
538 " %s)\n"
528 " Please send a copy of this message to " 539 " Please send a copy of this message to "
529 "<linux-usb-devel@lists.sourceforge.net>\n", 540 "<linux-usb-devel@lists.sourceforge.net>\n",
530 le16_to_cpu(ddesc->idVendor), 541 le16_to_cpu(ddesc->idVendor),
@@ -532,8 +543,11 @@ static void get_device_info(struct us_data *us, const struct usb_device_id *id)
532 le16_to_cpu(ddesc->bcdDevice), 543 le16_to_cpu(ddesc->bcdDevice),
533 idesc->bInterfaceSubClass, 544 idesc->bInterfaceSubClass,
534 idesc->bInterfaceProtocol, 545 idesc->bInterfaceProtocol,
535 msgs[msg]); 546 msgs[msg],
547 UTS_RELEASE);
536 } 548 }
549
550 return 0;
537} 551}
538 552
539/* Get the transport settings */ 553/* Get the transport settings */
@@ -836,32 +850,34 @@ static void dissociate_dev(struct us_data *us)
836 * the host */ 850 * the host */
837static void quiesce_and_remove_host(struct us_data *us) 851static void quiesce_and_remove_host(struct us_data *us)
838{ 852{
853 struct Scsi_Host *host = us_to_host(us);
854
839 /* Prevent new USB transfers, stop the current command, and 855 /* Prevent new USB transfers, stop the current command, and
840 * interrupt a SCSI-scan or device-reset delay */ 856 * interrupt a SCSI-scan or device-reset delay */
857 scsi_lock(host);
841 set_bit(US_FLIDX_DISCONNECTING, &us->flags); 858 set_bit(US_FLIDX_DISCONNECTING, &us->flags);
859 scsi_unlock(host);
842 usb_stor_stop_transport(us); 860 usb_stor_stop_transport(us);
843 wake_up(&us->delay_wait); 861 wake_up(&us->delay_wait);
844 862
845 /* It doesn't matter if the SCSI-scanning thread is still running. 863 /* It doesn't matter if the SCSI-scanning thread is still running.
846 * The thread will exit when it sees the DISCONNECTING flag. */ 864 * The thread will exit when it sees the DISCONNECTING flag. */
847 865
848 /* Wait for the current command to finish, then remove the host */
849 mutex_lock(&us->dev_mutex);
850 mutex_unlock(&us->dev_mutex);
851
852 /* queuecommand won't accept any new commands and the control 866 /* queuecommand won't accept any new commands and the control
853 * thread won't execute a previously-queued command. If there 867 * thread won't execute a previously-queued command. If there
854 * is such a command pending, complete it with an error. */ 868 * is such a command pending, complete it with an error. */
869 mutex_lock(&us->dev_mutex);
855 if (us->srb) { 870 if (us->srb) {
856 us->srb->result = DID_NO_CONNECT << 16; 871 us->srb->result = DID_NO_CONNECT << 16;
857 scsi_lock(us_to_host(us)); 872 scsi_lock(host);
858 us->srb->scsi_done(us->srb); 873 us->srb->scsi_done(us->srb);
859 us->srb = NULL; 874 us->srb = NULL;
860 scsi_unlock(us_to_host(us)); 875 scsi_unlock(host);
861 } 876 }
877 mutex_unlock(&us->dev_mutex);
862 878
863 /* Now we own no commands so it's safe to remove the SCSI host */ 879 /* Now we own no commands so it's safe to remove the SCSI host */
864 scsi_remove_host(us_to_host(us)); 880 scsi_remove_host(host);
865} 881}
866 882
867/* Second stage of disconnect processing: deallocate all resources */ 883/* Second stage of disconnect processing: deallocate all resources */
@@ -960,7 +976,9 @@ static int storage_probe(struct usb_interface *intf,
960 * of the match from the usb_device_id table, so we can find the 976 * of the match from the usb_device_id table, so we can find the
961 * corresponding entry in the private table. 977 * corresponding entry in the private table.
962 */ 978 */
963 get_device_info(us, id); 979 result = get_device_info(us, id);
980 if (result)
981 goto BadDevice;
964 982
965 /* Get the transport, protocol, and pipe settings */ 983 /* Get the transport, protocol, and pipe settings */
966 result = get_transport(us); 984 result = get_transport(us);
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 5284abe1b5eb..21f3ddbc9080 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -176,8 +176,4 @@ extern void fill_inquiry_response(struct us_data *us,
176#define scsi_unlock(host) spin_unlock_irq(host->host_lock) 176#define scsi_unlock(host) spin_unlock_irq(host->host_lock)
177#define scsi_lock(host) spin_lock_irq(host->host_lock) 177#define scsi_lock(host) spin_lock_irq(host->host_lock)
178 178
179
180/* Vendor ID list for devices that require special handling */
181#define USB_VENDOR_ID_GENESYS 0x05e3 /* Genesys Logic */
182
183#endif 179#endif