aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
commitbef986502fa398b1785a3979b1aa17cd902d3527 (patch)
treeb59c1afe7b1dfcc001b86e54863f550d7ddc8c34 /drivers/usb
parent4bdbd2807deeccc0793d57fb5120d7a53f2c0b3c (diff)
parentc99767974ebd2a719d849fdeaaa1674456f5283f (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/usb/input/hid.h
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/atm/cxacru.c12
-rw-r--r--drivers/usb/atm/speedtch.c19
-rw-r--r--drivers/usb/atm/ueagle-atm.c18
-rw-r--r--drivers/usb/class/cdc-acm.c8
-rw-r--r--drivers/usb/core/Kconfig15
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/devices.c9
-rw-r--r--drivers/usb/core/devio.c4
-rw-r--r--drivers/usb/core/driver.c304
-rw-r--r--drivers/usb/core/endpoint.c98
-rw-r--r--drivers/usb/core/hcd.c4
-rw-r--r--drivers/usb/core/hub.c259
-rw-r--r--drivers/usb/core/hub.h41
-rw-r--r--drivers/usb/core/message.c22
-rw-r--r--drivers/usb/core/usb.c169
-rw-r--r--drivers/usb/core/usb.h9
-rw-r--r--drivers/usb/gadget/Kconfig2
-rw-r--r--drivers/usb/gadget/ether.c10
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c1
-rw-r--r--drivers/usb/gadget/net2280.c10
-rw-r--r--drivers/usb/gadget/net2280.h3
-rw-r--r--drivers/usb/gadget/omap_udc.c2
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c16
-rw-r--r--drivers/usb/host/ehci-hub.c104
-rw-r--r--drivers/usb/host/ehci-pci.c40
-rw-r--r--drivers/usb/host/ehci.h1
-rw-r--r--drivers/usb/host/hc_crisv10.c16
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c40
-rw-r--r--drivers/usb/host/ohci-hub.c172
-rw-r--r--drivers/usb/host/ohci-pnx4008.c2
-rw-r--r--drivers/usb/host/sl811_cs.c15
-rw-r--r--drivers/usb/host/u132-hcd.c76
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/image/microtek.c8
-rw-r--r--drivers/usb/input/Kconfig6
-rw-r--r--drivers/usb/input/acecad.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c23
-rw-r--r--drivers/usb/input/ati_remote2.c3
-rw-r--r--drivers/usb/input/hid-core.c107
-rw-r--r--drivers/usb/input/hid-input.c17
-rw-r--r--drivers/usb/input/hid.h4
-rw-r--r--drivers/usb/input/keyspan_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/powermate.c4
-rw-r--r--drivers/usb/input/touchkitusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c18
-rw-r--r--drivers/usb/input/usbmouse.c8
-rw-r--r--drivers/usb/input/usbtouchscreen.c98
-rw-r--r--drivers/usb/input/wacom.h1
-rw-r--r--drivers/usb/input/wacom_sys.c2
-rw-r--r--drivers/usb/input/xpad.c2
-rw-r--r--drivers/usb/input/yealink.c12
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/appledisplay.c16
-rw-r--r--drivers/usb/misc/auerswald.c9
-rw-r--r--drivers/usb/misc/emi26.c3
-rw-r--r--drivers/usb/misc/emi62.c3
-rw-r--r--drivers/usb/misc/ftdi-elan.c106
-rw-r--r--drivers/usb/misc/idmouse.c22
-rw-r--r--drivers/usb/misc/legousbtower.c31
-rw-r--r--drivers/usb/misc/phidgetkit.c30
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c20
-rw-r--r--drivers/usb/misc/usb_u132.h6
-rw-r--r--drivers/usb/misc/usbtest.c40
-rw-r--r--drivers/usb/mon/mon_text.c10
-rw-r--r--drivers/usb/net/asix.c6
-rw-r--r--drivers/usb/net/catc.c14
-rw-r--r--drivers/usb/net/cdc_ether.c3
-rw-r--r--drivers/usb/net/kaweth.c9
-rw-r--r--drivers/usb/net/net1080.c6
-rw-r--r--drivers/usb/net/pegasus.c9
-rw-r--r--drivers/usb/net/pegasus.h2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/usbnet.c15
-rw-r--r--drivers/usb/serial/Kconfig11
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/aircable.c22
-rw-r--r--drivers/usb/serial/airprime.c1
-rw-r--r--drivers/usb/serial/ark3116.c3
-rw-r--r--drivers/usb/serial/console.c6
-rw-r--r--drivers/usb/serial/cypress_m8.c9
-rw-r--r--drivers/usb/serial/digi_acceleport.c16
-rw-r--r--drivers/usb/serial/ezusb.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c24
-rw-r--r--drivers/usb/serial/ftdi_sio.h11
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c4
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/keyspan.c18
-rw-r--r--drivers/usb/serial/keyspan_pda.c22
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c6
-rw-r--r--drivers/usb/serial/mos7720.c2
-rw-r--r--drivers/usb/serial/mos7840.c7
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c5
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h1
-rw-r--r--drivers/usb/serial/usb-serial.c19
-rw-r--r--drivers/usb/serial/usb_debug.c65
-rw-r--r--drivers/usb/serial/visor.c3
-rw-r--r--drivers/usb/serial/whiteheat.c15
-rw-r--r--drivers/usb/storage/onetouch.c9
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h28
-rw-r--r--drivers/usb/storage/usb.c10
119 files changed, 1427 insertions, 1134 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index f9b1719b9a37..9980a4ddfed9 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -24,7 +24,7 @@ config USB_ARCH_HAS_OHCI
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_EP93XX 26 default y if ARCH_EP93XX
27 default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261) 27 default y if ARCH_AT91
28 default y if ARCH_PNX4008 28 default y if ARCH_PNX4008
29 # PPC: 29 # PPC:
30 default y if STB03xxx 30 default y if STB03xxx
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index e6565633ba0f..3dfa3e40e148 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -158,7 +158,7 @@ struct cxacru_data {
158 const struct cxacru_modem_type *modem_type; 158 const struct cxacru_modem_type *modem_type;
159 159
160 int line_status; 160 int line_status;
161 struct work_struct poll_work; 161 struct delayed_work poll_work;
162 162
163 /* contol handles */ 163 /* contol handles */
164 struct mutex cm_serialize; 164 struct mutex cm_serialize;
@@ -347,7 +347,7 @@ static int cxacru_card_status(struct cxacru_data *instance)
347 return 0; 347 return 0;
348} 348}
349 349
350static void cxacru_poll_status(struct cxacru_data *instance); 350static void cxacru_poll_status(struct work_struct *work);
351 351
352static int cxacru_atm_start(struct usbatm_data *usbatm_instance, 352static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
353 struct atm_dev *atm_dev) 353 struct atm_dev *atm_dev)
@@ -376,12 +376,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
376 } 376 }
377 377
378 /* Start status polling */ 378 /* Start status polling */
379 cxacru_poll_status(instance); 379 cxacru_poll_status(&instance->poll_work.work);
380 return 0; 380 return 0;
381} 381}
382 382
383static void cxacru_poll_status(struct cxacru_data *instance) 383static void cxacru_poll_status(struct work_struct *work)
384{ 384{
385 struct cxacru_data *instance =
386 container_of(work, struct cxacru_data, poll_work.work);
385 u32 buf[CXINF_MAX] = {}; 387 u32 buf[CXINF_MAX] = {};
386 struct usbatm_data *usbatm = instance->usbatm; 388 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = usbatm->atm_dev; 389 struct atm_dev *atm_dev = usbatm->atm_dev;
@@ -720,7 +722,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
720 722
721 mutex_init(&instance->cm_serialize); 723 mutex_init(&instance->cm_serialize);
722 724
723 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); 725 INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
724 726
725 usbatm_instance->driver_data = instance; 727 usbatm_instance->driver_data = instance;
726 728
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index c870c804470f..8ed6c75adf0f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -142,7 +142,7 @@ struct speedtch_instance_data {
142 142
143 struct speedtch_params params; /* set in probe, constant afterwards */ 143 struct speedtch_params params; /* set in probe, constant afterwards */
144 144
145 struct work_struct status_checker; 145 struct delayed_work status_checker;
146 146
147 unsigned char last_status; 147 unsigned char last_status;
148 148
@@ -498,8 +498,11 @@ static int speedtch_start_synchro(struct speedtch_instance_data *instance)
498 return ret; 498 return ret;
499} 499}
500 500
501static void speedtch_check_status(struct speedtch_instance_data *instance) 501static void speedtch_check_status(struct work_struct *work)
502{ 502{
503 struct speedtch_instance_data *instance =
504 container_of(work, struct speedtch_instance_data,
505 status_checker.work);
503 struct usbatm_data *usbatm = instance->usbatm; 506 struct usbatm_data *usbatm = instance->usbatm;
504 struct atm_dev *atm_dev = usbatm->atm_dev; 507 struct atm_dev *atm_dev = usbatm->atm_dev;
505 unsigned char *buf = instance->scratch_buffer; 508 unsigned char *buf = instance->scratch_buffer;
@@ -576,7 +579,7 @@ static void speedtch_status_poll(unsigned long data)
576{ 579{
577 struct speedtch_instance_data *instance = (void *)data; 580 struct speedtch_instance_data *instance = (void *)data;
578 581
579 schedule_work(&instance->status_checker); 582 schedule_delayed_work(&instance->status_checker, 0);
580 583
581 /* The following check is racy, but the race is harmless */ 584 /* The following check is racy, but the race is harmless */
582 if (instance->poll_delay < MAX_POLL_DELAY) 585 if (instance->poll_delay < MAX_POLL_DELAY)
@@ -596,7 +599,7 @@ static void speedtch_resubmit_int(unsigned long data)
596 if (int_urb) { 599 if (int_urb) {
597 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 600 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
598 if (!ret) 601 if (!ret)
599 schedule_work(&instance->status_checker); 602 schedule_delayed_work(&instance->status_checker, 0);
600 else { 603 else {
601 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 604 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
602 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); 605 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
@@ -640,7 +643,7 @@ static void speedtch_handle_int(struct urb *int_urb)
640 643
641 if ((int_urb = instance->int_urb)) { 644 if ((int_urb = instance->int_urb)) {
642 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 645 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
643 schedule_work(&instance->status_checker); 646 schedule_delayed_work(&instance->status_checker, 0);
644 if (ret < 0) { 647 if (ret < 0) {
645 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 648 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
646 goto fail; 649 goto fail;
@@ -834,8 +837,8 @@ static int speedtch_bind(struct usbatm_data *usbatm,
834 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; 837 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc;
835 838
836 if ((endpoint_desc->bEndpointAddress == target_address)) { 839 if ((endpoint_desc->bEndpointAddress == target_address)) {
837 use_isoc = (endpoint_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 840 use_isoc =
838 USB_ENDPOINT_XFER_ISOC; 841 usb_endpoint_xfer_isoc(endpoint_desc);
839 break; 842 break;
840 } 843 }
841 } 844 }
@@ -855,7 +858,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
855 858
856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 859 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
857 860
858 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 861 INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status);
859 862
860 instance->status_checker.timer.function = speedtch_status_poll; 863 instance->status_checker.timer.function = speedtch_status_poll;
861 instance->status_checker.timer.data = (unsigned long)instance; 864 instance->status_checker.timer.data = (unsigned long)instance;
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f6b9f7e1f716..dae4ef1e8fe5 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -64,6 +64,8 @@
64#include <linux/kthread.h> 64#include <linux/kthread.h>
65#include <linux/version.h> 65#include <linux/version.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/freezer.h>
68
67#include <asm/unaligned.h> 69#include <asm/unaligned.h>
68 70
69#include "usbatm.h" 71#include "usbatm.h"
@@ -401,9 +403,8 @@ static int uea_send_modem_cmd(struct usb_device *usb,
401 int ret = -ENOMEM; 403 int ret = -ENOMEM;
402 u8 *xfer_buff; 404 u8 *xfer_buff;
403 405
404 xfer_buff = kmalloc(size, GFP_KERNEL); 406 xfer_buff = kmemdup(buff, size, GFP_KERNEL);
405 if (xfer_buff) { 407 if (xfer_buff) {
406 memcpy(xfer_buff, buff, size);
407 ret = usb_control_msg(usb, 408 ret = usb_control_msg(usb,
408 usb_sndctrlpipe(usb, 0), 409 usb_sndctrlpipe(usb, 0),
409 LOAD_INTERNAL, 410 LOAD_INTERNAL,
@@ -595,14 +596,12 @@ static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
595 u8 *xfer_buff; 596 u8 *xfer_buff;
596 int bytes_read; 597 int bytes_read;
597 598
598 xfer_buff = kmalloc(size, GFP_KERNEL); 599 xfer_buff = kmemdup(data, size, GFP_KERNEL);
599 if (!xfer_buff) { 600 if (!xfer_buff) {
600 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 601 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
601 return ret; 602 return ret;
602 } 603 }
603 604
604 memcpy(xfer_buff, data, size);
605
606 ret = usb_bulk_msg(sc->usb_dev, 605 ret = usb_bulk_msg(sc->usb_dev,
607 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), 606 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
608 xfer_buff, size, &bytes_read, BULK_TIMEOUT); 607 xfer_buff, size, &bytes_read, BULK_TIMEOUT);
@@ -658,9 +657,9 @@ static int request_dsp(struct uea_softc *sc)
658/* 657/*
659 * The uea_load_page() function must be called within a process context 658 * The uea_load_page() function must be called within a process context
660 */ 659 */
661static void uea_load_page(void *xsc) 660static void uea_load_page(struct work_struct *work)
662{ 661{
663 struct uea_softc *sc = xsc; 662 struct uea_softc *sc = container_of(work, struct uea_softc, task);
664 u16 pageno = sc->pageno; 663 u16 pageno = sc->pageno;
665 u16 ovl = sc->ovl; 664 u16 ovl = sc->ovl;
666 struct block_info bi; 665 struct block_info bi;
@@ -765,12 +764,11 @@ static int uea_request(struct uea_softc *sc,
765 u8 *xfer_buff; 764 u8 *xfer_buff;
766 int ret = -ENOMEM; 765 int ret = -ENOMEM;
767 766
768 xfer_buff = kmalloc(size, GFP_KERNEL); 767 xfer_buff = kmemdup(data, size, GFP_KERNEL);
769 if (!xfer_buff) { 768 if (!xfer_buff) {
770 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 769 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
771 return ret; 770 return ret;
772 } 771 }
773 memcpy(xfer_buff, data, size);
774 772
775 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), 773 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
776 UCDC_SEND_ENCAPSULATED_COMMAND, 774 UCDC_SEND_ENCAPSULATED_COMMAND,
@@ -1352,7 +1350,7 @@ static int uea_boot(struct uea_softc *sc)
1352 1350
1353 uea_enters(INS_TO_USBDEV(sc)); 1351 uea_enters(INS_TO_USBDEV(sc));
1354 1352
1355 INIT_WORK(&sc->task, uea_load_page, sc); 1353 INIT_WORK(&sc->task, uea_load_page);
1356 init_waitqueue_head(&sc->sync_q); 1354 init_waitqueue_head(&sc->sync_q);
1357 init_waitqueue_head(&sc->cmv_ack_wait); 1355 init_waitqueue_head(&sc->cmv_ack_wait);
1358 1356
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 9a9012fd284b..7f1fa956dcdb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -421,9 +421,9 @@ static void acm_write_bulk(struct urb *urb)
421 schedule_work(&acm->work); 421 schedule_work(&acm->work);
422} 422}
423 423
424static void acm_softint(void *private) 424static void acm_softint(struct work_struct *work)
425{ 425{
426 struct acm *acm = private; 426 struct acm *acm = container_of(work, struct acm, work);
427 dbg("Entering acm_softint."); 427 dbg("Entering acm_softint.");
428 428
429 if (!ACM_READY(acm)) 429 if (!ACM_READY(acm))
@@ -892,7 +892,7 @@ skip_normal_probe:
892 892
893 893
894 /* workaround for switched endpoints */ 894 /* workaround for switched endpoints */
895 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) { 895 if (!usb_endpoint_dir_in(epread)) {
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"); 898 dev_dbg(&intf->dev,"The data interface has switched endpoints");
@@ -927,7 +927,7 @@ skip_normal_probe:
927 acm->rx_buflimit = num_rx_buf; 927 acm->rx_buflimit = num_rx_buf;
928 acm->urb_task.func = acm_rx_tasklet; 928 acm->urb_task.func = acm_rx_tasklet;
929 acm->urb_task.data = (unsigned long) acm; 929 acm->urb_task.data = (unsigned long) acm;
930 INIT_WORK(&acm->work, acm_softint, acm); 930 INIT_WORK(&acm->work, acm_softint);
931 spin_lock_init(&acm->throttle_lock); 931 spin_lock_init(&acm->throttle_lock);
932 spin_lock_init(&acm->write_lock); 932 spin_lock_init(&acm->write_lock);
933 spin_lock_init(&acm->read_lock); 933 spin_lock_init(&acm->read_lock);
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 6e3b5358a760..f8324d8d06ac 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -72,6 +72,21 @@ config USB_SUSPEND
72 72
73 If you are unsure about this, say N here. 73 If you are unsure about this, say N here.
74 74
75config USB_MULTITHREAD_PROBE
76 bool "USB Multi-threaded probe (EXPERIMENTAL)"
77 depends on USB && EXPERIMENTAL
78 default n
79 help
80 Say Y here if you want the USB core to spawn a new thread for
81 every USB device that is probed. This can cause a small speedup
82 in boot times on systems with a lot of different USB devices.
83
84 This option should be safe to enable, but if any odd probing
85 problems are found, please disable it, or dynamically turn it
86 off in the /sys/module/usbcore/parameters/multithread_probe
87 file
88
89 When in doubt, say N.
75 90
76config USB_OTG 91config USB_OTG
77 bool 92 bool
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 840442a25b61..c3915dc28608 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -93,7 +93,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
93} 93}
94 94
95 95
96/* sometimes alloc/free could use kmalloc with SLAB_DMA, for 96/* sometimes alloc/free could use kmalloc with GFP_DMA, for
97 * better sharing and to leverage mm/slab.c intelligence. 97 * better sharing and to leverage mm/slab.c intelligence.
98 */ 98 */
99 99
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 3538c2fdadfe..ea398e5d50af 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -175,12 +175,13 @@ static char *usb_dump_endpoint_descriptor (
175) 175)
176{ 176{
177 char dir, unit, *type; 177 char dir, unit, *type;
178 unsigned interval, in, bandwidth = 1; 178 unsigned interval, bandwidth = 1;
179 179
180 if (start > end) 180 if (start > end)
181 return start; 181 return start;
182 in = (desc->bEndpointAddress & USB_DIR_IN); 182
183 dir = in ? 'I' : 'O'; 183 dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
184
184 if (speed == USB_SPEED_HIGH) { 185 if (speed == USB_SPEED_HIGH) {
185 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { 186 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) {
186 case 1 << 11: bandwidth = 2; break; 187 case 1 << 11: bandwidth = 2; break;
@@ -204,7 +205,7 @@ static char *usb_dump_endpoint_descriptor (
204 break; 205 break;
205 case USB_ENDPOINT_XFER_BULK: 206 case USB_ENDPOINT_XFER_BULK:
206 type = "Bulk"; 207 type = "Bulk";
207 if (speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ 208 if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */
208 interval = desc->bInterval; 209 interval = desc->bInterval;
209 else 210 else
210 interval = 0; 211 interval = 0;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index fed92be63b5e..3ed4cb2d56d9 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -561,7 +561,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
561 dev = inode->i_private; 561 dev = inode->i_private;
562 if (!dev) 562 if (!dev)
563 goto out; 563 goto out;
564 ret = usb_autoresume_device(dev, 1); 564 ret = usb_autoresume_device(dev);
565 if (ret) 565 if (ret)
566 goto out; 566 goto out;
567 567
@@ -609,7 +609,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
609 releaseintf(ps, ifnum); 609 releaseintf(ps, ifnum);
610 } 610 }
611 destroy_all_async(ps); 611 destroy_all_async(ps);
612 usb_autosuspend_device(dev, 1); 612 usb_autosuspend_device(dev);
613 usb_unlock_device(dev); 613 usb_unlock_device(dev);
614 usb_put_dev(dev); 614 usb_put_dev(dev);
615 put_pid(ps->disc_pid); 615 put_pid(ps->disc_pid);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 113e484c763e..d6eb5ce1dd1d 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -205,7 +205,7 @@ static int usb_probe_interface(struct device *dev)
205 if (id) { 205 if (id) {
206 dev_dbg(dev, "%s - got id\n", __FUNCTION__); 206 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
207 207
208 error = usb_autoresume_device(udev, 1); 208 error = usb_autoresume_device(udev);
209 if (error) 209 if (error)
210 return error; 210 return error;
211 211
@@ -229,7 +229,7 @@ static int usb_probe_interface(struct device *dev)
229 } else 229 } else
230 intf->condition = USB_INTERFACE_BOUND; 230 intf->condition = USB_INTERFACE_BOUND;
231 231
232 usb_autosuspend_device(udev, 1); 232 usb_autosuspend_device(udev);
233 } 233 }
234 234
235 return error; 235 return error;
@@ -247,7 +247,7 @@ static int usb_unbind_interface(struct device *dev)
247 247
248 /* Autoresume for set_interface call below */ 248 /* Autoresume for set_interface call below */
249 udev = interface_to_usbdev(intf); 249 udev = interface_to_usbdev(intf);
250 error = usb_autoresume_device(udev, 1); 250 error = usb_autoresume_device(udev);
251 251
252 /* release all urbs for this interface */ 252 /* release all urbs for this interface */
253 usb_disable_interface(interface_to_usbdev(intf), intf); 253 usb_disable_interface(interface_to_usbdev(intf), intf);
@@ -265,7 +265,7 @@ static int usb_unbind_interface(struct device *dev)
265 intf->needs_remote_wakeup = 0; 265 intf->needs_remote_wakeup = 0;
266 266
267 if (!error) 267 if (!error)
268 usb_autosuspend_device(udev, 1); 268 usb_autosuspend_device(udev);
269 269
270 return 0; 270 return 0;
271} 271}
@@ -408,6 +408,16 @@ static int usb_match_one_id(struct usb_interface *interface,
408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) 408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
409 return 0; 409 return 0;
410 410
411 /* The interface class, subclass, and protocol should never be
412 * checked for a match if the device class is Vendor Specific,
413 * unless the match record specifies the Vendor ID. */
414 if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC &&
415 !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
416 (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
417 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
418 USB_DEVICE_ID_MATCH_INT_PROTOCOL)))
419 return 0;
420
411 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && 421 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
412 (id->bInterfaceClass != intf->desc.bInterfaceClass)) 422 (id->bInterfaceClass != intf->desc.bInterfaceClass))
413 return 0; 423 return 0;
@@ -476,7 +486,17 @@ static int usb_match_one_id(struct usb_interface *interface,
476 * most general; they let drivers bind to any interface on a 486 * most general; they let drivers bind to any interface on a
477 * multiple-function device. Use the USB_INTERFACE_INFO 487 * multiple-function device. Use the USB_INTERFACE_INFO
478 * macro, or its siblings, to match class-per-interface style 488 * macro, or its siblings, to match class-per-interface style
479 * devices (as recorded in bDeviceClass). 489 * devices (as recorded in bInterfaceClass).
490 *
491 * Note that an entry created by USB_INTERFACE_INFO won't match
492 * any interface if the device class is set to Vendor-Specific.
493 * This is deliberate; according to the USB spec the meanings of
494 * the interface class/subclass/protocol for these devices are also
495 * vendor-specific, and hence matching against a standard product
496 * class wouldn't work anyway. If you really want to use an
497 * interface-based match for such a device, create a match record
498 * that also specifies the vendor ID. (Unforunately there isn't a
499 * standard macro for creating records like this.)
480 * 500 *
481 * Within those groups, remember that not all combinations are 501 * Within those groups, remember that not all combinations are
482 * meaningful. For example, don't give a product version range 502 * meaningful. For example, don't give a product version range
@@ -505,7 +525,7 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
505} 525}
506EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); 526EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
507 527
508int usb_device_match(struct device *dev, struct device_driver *drv) 528static int usb_device_match(struct device *dev, struct device_driver *drv)
509{ 529{
510 /* devices and interfaces are handled separately */ 530 /* devices and interfaces are handled separately */
511 if (is_usb_device(dev)) { 531 if (is_usb_device(dev)) {
@@ -790,7 +810,7 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
790#ifdef CONFIG_PM 810#ifdef CONFIG_PM
791 811
792/* Caller has locked udev's pm_mutex */ 812/* Caller has locked udev's pm_mutex */
793static int suspend_device(struct usb_device *udev, pm_message_t msg) 813static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
794{ 814{
795 struct usb_device_driver *udriver; 815 struct usb_device_driver *udriver;
796 int status = 0; 816 int status = 0;
@@ -817,7 +837,7 @@ done:
817} 837}
818 838
819/* Caller has locked udev's pm_mutex */ 839/* Caller has locked udev's pm_mutex */
820static int resume_device(struct usb_device *udev) 840static int usb_resume_device(struct usb_device *udev)
821{ 841{
822 struct usb_device_driver *udriver; 842 struct usb_device_driver *udriver;
823 int status = 0; 843 int status = 0;
@@ -843,7 +863,7 @@ done:
843} 863}
844 864
845/* Caller has locked intf's usb_device's pm mutex */ 865/* Caller has locked intf's usb_device's pm mutex */
846static int suspend_interface(struct usb_interface *intf, pm_message_t msg) 866static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg)
847{ 867{
848 struct usb_driver *driver; 868 struct usb_driver *driver;
849 int status = 0; 869 int status = 0;
@@ -880,7 +900,7 @@ done:
880} 900}
881 901
882/* Caller has locked intf's usb_device's pm_mutex */ 902/* Caller has locked intf's usb_device's pm_mutex */
883static int resume_interface(struct usb_interface *intf) 903static int usb_resume_interface(struct usb_interface *intf)
884{ 904{
885 struct usb_driver *driver; 905 struct usb_driver *driver;
886 int status = 0; 906 int status = 0;
@@ -920,6 +940,44 @@ done:
920 return status; 940 return status;
921} 941}
922 942
943#ifdef CONFIG_USB_SUSPEND
944
945/* Internal routine to check whether we may autosuspend a device. */
946static int autosuspend_check(struct usb_device *udev)
947{
948 int i;
949 struct usb_interface *intf;
950
951 /* For autosuspend, fail fast if anything is in use.
952 * Also fail if any interfaces require remote wakeup but it
953 * isn't available. */
954 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
955 if (udev->pm_usage_cnt > 0)
956 return -EBUSY;
957 if (udev->actconfig) {
958 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
959 intf = udev->actconfig->interface[i];
960 if (!is_active(intf))
961 continue;
962 if (intf->pm_usage_cnt > 0)
963 return -EBUSY;
964 if (intf->needs_remote_wakeup &&
965 !udev->do_remote_wakeup) {
966 dev_dbg(&udev->dev, "remote wakeup needed "
967 "for autosuspend\n");
968 return -EOPNOTSUPP;
969 }
970 }
971 }
972 return 0;
973}
974
975#else
976
977#define autosuspend_check(udev) 0
978
979#endif
980
923/** 981/**
924 * usb_suspend_both - suspend a USB device and its interfaces 982 * usb_suspend_both - suspend a USB device and its interfaces
925 * @udev: the usb_device to suspend 983 * @udev: the usb_device to suspend
@@ -971,52 +1029,34 @@ int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
971 1029
972 udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1030 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
973 1031
974 /* For autosuspend, fail fast if anything is in use.
975 * Also fail if any interfaces require remote wakeup but it
976 * isn't available. */
977 if (udev->auto_pm) { 1032 if (udev->auto_pm) {
978 if (udev->pm_usage_cnt > 0) 1033 status = autosuspend_check(udev);
979 return -EBUSY; 1034 if (status < 0)
980 if (udev->actconfig) { 1035 return status;
981 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
982 intf = udev->actconfig->interface[i];
983 if (!is_active(intf))
984 continue;
985 if (intf->pm_usage_cnt > 0)
986 return -EBUSY;
987 if (intf->needs_remote_wakeup &&
988 !udev->do_remote_wakeup) {
989 dev_dbg(&udev->dev,
990 "remote wakeup needed for autosuspend\n");
991 return -EOPNOTSUPP;
992 }
993 }
994 i = 0;
995 }
996 } 1036 }
997 1037
998 /* Suspend all the interfaces and then udev itself */ 1038 /* Suspend all the interfaces and then udev itself */
999 if (udev->actconfig) { 1039 if (udev->actconfig) {
1000 for (; i < udev->actconfig->desc.bNumInterfaces; i++) { 1040 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
1001 intf = udev->actconfig->interface[i]; 1041 intf = udev->actconfig->interface[i];
1002 status = suspend_interface(intf, msg); 1042 status = usb_suspend_interface(intf, msg);
1003 if (status != 0) 1043 if (status != 0)
1004 break; 1044 break;
1005 } 1045 }
1006 } 1046 }
1007 if (status == 0) 1047 if (status == 0)
1008 status = suspend_device(udev, msg); 1048 status = usb_suspend_device(udev, msg);
1009 1049
1010 /* If the suspend failed, resume interfaces that did get suspended */ 1050 /* If the suspend failed, resume interfaces that did get suspended */
1011 if (status != 0) { 1051 if (status != 0) {
1012 while (--i >= 0) { 1052 while (--i >= 0) {
1013 intf = udev->actconfig->interface[i]; 1053 intf = udev->actconfig->interface[i];
1014 resume_interface(intf); 1054 usb_resume_interface(intf);
1015 } 1055 }
1016 1056
1017 /* If the suspend succeeded, propagate it up the tree */ 1057 /* If the suspend succeeded, propagate it up the tree */
1018 } else if (parent) 1058 } else if (parent)
1019 usb_autosuspend_device(parent, 0); 1059 usb_autosuspend_device(parent);
1020 1060
1021 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1061 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
1022 return status; 1062 return status;
@@ -1064,9 +1104,25 @@ int usb_resume_both(struct usb_device *udev)
1064 /* Propagate the resume up the tree, if necessary */ 1104 /* Propagate the resume up the tree, if necessary */
1065 if (udev->state == USB_STATE_SUSPENDED) { 1105 if (udev->state == USB_STATE_SUSPENDED) {
1066 if (parent) { 1106 if (parent) {
1067 usb_pm_lock(parent); 1107 status = usb_autoresume_device(parent);
1068 parent->auto_pm = 1; 1108 if (status == 0) {
1069 status = usb_resume_both(parent); 1109 status = usb_resume_device(udev);
1110 if (status) {
1111 usb_autosuspend_device(parent);
1112
1113 /* It's possible usb_resume_device()
1114 * failed after the port was
1115 * unsuspended, causing udev to be
1116 * logically disconnected. We don't
1117 * want usb_disconnect() to autosuspend
1118 * the parent again, so tell it that
1119 * udev disconnected while still
1120 * suspended. */
1121 if (udev->state ==
1122 USB_STATE_NOTATTACHED)
1123 udev->discon_suspended = 1;
1124 }
1125 }
1070 } else { 1126 } else {
1071 1127
1072 /* We can't progagate beyond the USB subsystem, 1128 /* We can't progagate beyond the USB subsystem,
@@ -1075,24 +1131,20 @@ int usb_resume_both(struct usb_device *udev)
1075 if (udev->dev.parent->power.power_state.event != 1131 if (udev->dev.parent->power.power_state.event !=
1076 PM_EVENT_ON) 1132 PM_EVENT_ON)
1077 status = -EHOSTUNREACH; 1133 status = -EHOSTUNREACH;
1078 } 1134 else
1079 if (status == 0) 1135 status = usb_resume_device(udev);
1080 status = resume_device(udev); 1136 }
1081 if (parent)
1082 usb_pm_unlock(parent);
1083 } else { 1137 } else {
1084 1138
1085 /* Needed only for setting udev->dev.power.power_state.event 1139 /* Needed only for setting udev->dev.power.power_state.event
1086 * and for possible debugging message. */ 1140 * and for possible debugging message. */
1087 status = resume_device(udev); 1141 status = usb_resume_device(udev);
1088 } 1142 }
1089 1143
1090 /* Now the parent won't suspend until we are finished */
1091
1092 if (status == 0 && udev->actconfig) { 1144 if (status == 0 && udev->actconfig) {
1093 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1145 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1094 intf = udev->actconfig->interface[i]; 1146 intf = udev->actconfig->interface[i];
1095 resume_interface(intf); 1147 usb_resume_interface(intf);
1096 } 1148 }
1097 } 1149 }
1098 1150
@@ -1102,39 +1154,53 @@ int usb_resume_both(struct usb_device *udev)
1102 1154
1103#ifdef CONFIG_USB_SUSPEND 1155#ifdef CONFIG_USB_SUSPEND
1104 1156
1157/* Internal routine to adjust a device's usage counter and change
1158 * its autosuspend state.
1159 */
1160static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1161{
1162 int status = 0;
1163
1164 usb_pm_lock(udev);
1165 udev->pm_usage_cnt += inc_usage_cnt;
1166 WARN_ON(udev->pm_usage_cnt < 0);
1167 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
1168 udev->auto_pm = 1;
1169 status = usb_resume_both(udev);
1170 if (status != 0)
1171 udev->pm_usage_cnt -= inc_usage_cnt;
1172 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1173 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1174 USB_AUTOSUSPEND_DELAY);
1175 usb_pm_unlock(udev);
1176 return status;
1177}
1178
1105/** 1179/**
1106 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces 1180 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1107 * @udev: the usb_device to autosuspend 1181 * @udev: the usb_device to autosuspend
1108 * @dec_usage_cnt: flag to decrement @udev's PM-usage counter
1109 * 1182 *
1110 * This routine should be called when a core subsystem is finished using 1183 * This routine should be called when a core subsystem is finished using
1111 * @udev and wants to allow it to autosuspend. Examples would be when 1184 * @udev and wants to allow it to autosuspend. Examples would be when
1112 * @udev's device file in usbfs is closed or after a configuration change. 1185 * @udev's device file in usbfs is closed or after a configuration change.
1113 * 1186 *
1114 * @dec_usage_cnt should be 1 if the subsystem previously incremented 1187 * @udev's usage counter is decremented. If it or any of the usage counters
1115 * @udev's usage counter (such as by passing 1 to usb_autoresume_device); 1188 * for an active interface is greater than 0, no autosuspend request will be
1116 * otherwise it should be 0. 1189 * queued. (If an interface driver does not support autosuspend then its
1117 * 1190 * usage counter is permanently positive.) Furthermore, if an interface
1118 * If the usage counter for @udev or any of its active interfaces is greater 1191 * driver requires remote-wakeup capability during autosuspend but remote
1119 * than 0, the autosuspend request will not be queued. (If an interface 1192 * wakeup is disabled, the autosuspend will fail.
1120 * driver does not support autosuspend then its usage counter is permanently
1121 * positive.) Likewise, if an interface driver requires remote-wakeup
1122 * capability during autosuspend but remote wakeup is disabled, the
1123 * autosuspend will fail.
1124 * 1193 *
1125 * Often the caller will hold @udev's device lock, but this is not 1194 * Often the caller will hold @udev's device lock, but this is not
1126 * necessary. 1195 * necessary.
1127 * 1196 *
1128 * This routine can run only in process context. 1197 * This routine can run only in process context.
1129 */ 1198 */
1130void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt) 1199void usb_autosuspend_device(struct usb_device *udev)
1131{ 1200{
1132 usb_pm_lock(udev); 1201 int status;
1133 udev->pm_usage_cnt -= dec_usage_cnt; 1202
1134 if (udev->pm_usage_cnt <= 0) 1203 status = usb_autopm_do_device(udev, -1);
1135 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1136 USB_AUTOSUSPEND_DELAY);
1137 usb_pm_unlock(udev);
1138 // dev_dbg(&udev->dev, "%s: cnt %d\n", 1204 // dev_dbg(&udev->dev, "%s: cnt %d\n",
1139 // __FUNCTION__, udev->pm_usage_cnt); 1205 // __FUNCTION__, udev->pm_usage_cnt);
1140} 1206}
@@ -1142,44 +1208,59 @@ void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
1142/** 1208/**
1143 * usb_autoresume_device - immediately autoresume a USB device and its interfaces 1209 * usb_autoresume_device - immediately autoresume a USB device and its interfaces
1144 * @udev: the usb_device to autoresume 1210 * @udev: the usb_device to autoresume
1145 * @inc_usage_cnt: flag to increment @udev's PM-usage counter
1146 * 1211 *
1147 * This routine should be called when a core subsystem wants to use @udev 1212 * This routine should be called when a core subsystem wants to use @udev
1148 * and needs to guarantee that it is not suspended. In addition, the 1213 * and needs to guarantee that it is not suspended. No autosuspend will
1149 * caller can prevent @udev from being autosuspended subsequently. (Note 1214 * occur until usb_autosuspend_device is called. (Note that this will not
1150 * that this will not prevent suspend events originating in the PM core.) 1215 * prevent suspend events originating in the PM core.) Examples would be
1151 * Examples would be when @udev's device file in usbfs is opened (autosuspend 1216 * when @udev's device file in usbfs is opened or when a remote-wakeup
1152 * should be prevented until the file is closed) or when a remote-wakeup 1217 * request is received.
1153 * request is received (later autosuspends should not be prevented).
1154 * 1218 *
1155 * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent 1219 * @udev's usage counter is incremented to prevent subsequent autosuspends.
1156 * autosuspends. This prevention will persist until the usage counter is 1220 * However if the autoresume fails then the usage counter is re-decremented.
1157 * decremented again (such as by passing 1 to usb_autosuspend_device).
1158 * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged.
1159 * Regardless, if the autoresume fails then the usage counter is not
1160 * incremented.
1161 * 1221 *
1162 * Often the caller will hold @udev's device lock, but this is not 1222 * Often the caller will hold @udev's device lock, but this is not
1163 * necessary (and attempting it might cause deadlock). 1223 * necessary (and attempting it might cause deadlock).
1164 * 1224 *
1165 * This routine can run only in process context. 1225 * This routine can run only in process context.
1166 */ 1226 */
1167int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt) 1227int usb_autoresume_device(struct usb_device *udev)
1168{ 1228{
1169 int status; 1229 int status;
1170 1230
1171 usb_pm_lock(udev); 1231 status = usb_autopm_do_device(udev, 1);
1172 udev->pm_usage_cnt += inc_usage_cnt;
1173 udev->auto_pm = 1;
1174 status = usb_resume_both(udev);
1175 if (status != 0)
1176 udev->pm_usage_cnt -= inc_usage_cnt;
1177 usb_pm_unlock(udev);
1178 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n", 1232 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
1179 // __FUNCTION__, status, udev->pm_usage_cnt); 1233 // __FUNCTION__, status, udev->pm_usage_cnt);
1180 return status; 1234 return status;
1181} 1235}
1182 1236
1237/* Internal routine to adjust an interface's usage counter and change
1238 * its device's autosuspend state.
1239 */
1240static int usb_autopm_do_interface(struct usb_interface *intf,
1241 int inc_usage_cnt)
1242{
1243 struct usb_device *udev = interface_to_usbdev(intf);
1244 int status = 0;
1245
1246 usb_pm_lock(udev);
1247 if (intf->condition == USB_INTERFACE_UNBOUND)
1248 status = -ENODEV;
1249 else {
1250 intf->pm_usage_cnt += inc_usage_cnt;
1251 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
1252 udev->auto_pm = 1;
1253 status = usb_resume_both(udev);
1254 if (status != 0)
1255 intf->pm_usage_cnt -= inc_usage_cnt;
1256 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1257 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1258 USB_AUTOSUSPEND_DELAY);
1259 }
1260 usb_pm_unlock(udev);
1261 return status;
1262}
1263
1183/** 1264/**
1184 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter 1265 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
1185 * @intf: the usb_interface whose counter should be decremented 1266 * @intf: the usb_interface whose counter should be decremented
@@ -1213,17 +1294,11 @@ int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt)
1213 */ 1294 */
1214void usb_autopm_put_interface(struct usb_interface *intf) 1295void usb_autopm_put_interface(struct usb_interface *intf)
1215{ 1296{
1216 struct usb_device *udev = interface_to_usbdev(intf); 1297 int status;
1217 1298
1218 usb_pm_lock(udev); 1299 status = usb_autopm_do_interface(intf, -1);
1219 if (intf->condition != USB_INTERFACE_UNBOUND && 1300 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1220 --intf->pm_usage_cnt <= 0) { 1301 // __FUNCTION__, status, intf->pm_usage_cnt);
1221 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1222 USB_AUTOSUSPEND_DELAY);
1223 }
1224 usb_pm_unlock(udev);
1225 // dev_dbg(&intf->dev, "%s: cnt %d\n",
1226 // __FUNCTION__, intf->pm_usage_cnt);
1227} 1302}
1228EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1303EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1229 1304
@@ -1260,26 +1335,37 @@ EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1260 */ 1335 */
1261int usb_autopm_get_interface(struct usb_interface *intf) 1336int usb_autopm_get_interface(struct usb_interface *intf)
1262{ 1337{
1263 struct usb_device *udev = interface_to_usbdev(intf); 1338 int status;
1264 int status;
1265 1339
1266 usb_pm_lock(udev); 1340 status = usb_autopm_do_interface(intf, 1);
1267 if (intf->condition == USB_INTERFACE_UNBOUND)
1268 status = -ENODEV;
1269 else {
1270 ++intf->pm_usage_cnt;
1271 udev->auto_pm = 1;
1272 status = usb_resume_both(udev);
1273 if (status != 0)
1274 --intf->pm_usage_cnt;
1275 }
1276 usb_pm_unlock(udev);
1277 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", 1341 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1278 // __FUNCTION__, status, intf->pm_usage_cnt); 1342 // __FUNCTION__, status, intf->pm_usage_cnt);
1279 return status; 1343 return status;
1280} 1344}
1281EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1345EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1282 1346
1347/**
1348 * usb_autopm_set_interface - set a USB interface's autosuspend state
1349 * @intf: the usb_interface whose state should be set
1350 *
1351 * This routine sets the autosuspend state of @intf's device according
1352 * to @intf's usage counter, which the caller must have set previously.
1353 * If the counter is <= 0, the device is autosuspended (if it isn't
1354 * already suspended and if nothing else prevents the autosuspend). If
1355 * the counter is > 0, the device is autoresumed (if it isn't already
1356 * awake).
1357 */
1358int usb_autopm_set_interface(struct usb_interface *intf)
1359{
1360 int status;
1361
1362 status = usb_autopm_do_interface(intf, 0);
1363 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1364 // __FUNCTION__, status, intf->pm_usage_cnt);
1365 return status;
1366}
1367EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
1368
1283#endif /* CONFIG_USB_SUSPEND */ 1369#endif /* CONFIG_USB_SUSPEND */
1284 1370
1285static int usb_suspend(struct device *dev, pm_message_t message) 1371static int usb_suspend(struct device *dev, pm_message_t message)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3b2d137912be..c505b767cee1 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -10,15 +10,20 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/spinlock.h>
14#include <linux/idr.h>
13#include <linux/usb.h> 15#include <linux/usb.h>
14#include "usb.h" 16#include "usb.h"
15 17
16/* endpoint stuff */ 18#define MAX_ENDPOINT_MINORS (64*128*32)
19static int usb_endpoint_major;
20static DEFINE_IDR(endpoint_idr);
17 21
18struct ep_device { 22struct ep_device {
19 struct usb_endpoint_descriptor *desc; 23 struct usb_endpoint_descriptor *desc;
20 struct usb_device *udev; 24 struct usb_device *udev;
21 struct device dev; 25 struct device dev;
26 int minor;
22}; 27};
23#define to_ep_device(_dev) \ 28#define to_ep_device(_dev) \
24 container_of(_dev, struct ep_device, dev) 29 container_of(_dev, struct ep_device, dev)
@@ -152,6 +157,55 @@ static struct attribute_group ep_dev_attr_grp = {
152 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
153}; 158};
154 159
160static int usb_endpoint_major_init(void)
161{
162 dev_t dev;
163 int error;
164
165 error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS,
166 "usb_endpoint");
167 if (error) {
168 err("unable to get a dynamic major for usb endpoints");
169 return error;
170 }
171 usb_endpoint_major = MAJOR(dev);
172
173 return error;
174}
175
176static void usb_endpoint_major_cleanup(void)
177{
178 unregister_chrdev_region(MKDEV(usb_endpoint_major, 0),
179 MAX_ENDPOINT_MINORS);
180}
181
182static int endpoint_get_minor(struct ep_device *ep_dev)
183{
184 static DEFINE_MUTEX(minor_lock);
185 int retval = -ENOMEM;
186 int id;
187
188 mutex_lock(&minor_lock);
189 if (idr_pre_get(&endpoint_idr, GFP_KERNEL) == 0)
190 goto exit;
191
192 retval = idr_get_new(&endpoint_idr, ep_dev, &id);
193 if (retval < 0) {
194 if (retval == -EAGAIN)
195 retval = -ENOMEM;
196 goto exit;
197 }
198 ep_dev->minor = id & MAX_ID_MASK;
199exit:
200 mutex_unlock(&minor_lock);
201 return retval;
202}
203
204static void endpoint_free_minor(struct ep_device *ep_dev)
205{
206 idr_remove(&endpoint_idr, ep_dev->minor);
207}
208
155static struct endpoint_class { 209static struct endpoint_class {
156 struct kref kref; 210 struct kref kref;
157 struct class *class; 211 struct class *class;
@@ -176,11 +230,20 @@ static int init_endpoint_class(void)
176 ep_class->class = class_create(THIS_MODULE, "usb_endpoint"); 230 ep_class->class = class_create(THIS_MODULE, "usb_endpoint");
177 if (IS_ERR(ep_class->class)) { 231 if (IS_ERR(ep_class->class)) {
178 result = IS_ERR(ep_class->class); 232 result = IS_ERR(ep_class->class);
179 kfree(ep_class); 233 goto class_create_error;
180 ep_class = NULL;
181 goto exit;
182 } 234 }
183 235
236 result = usb_endpoint_major_init();
237 if (result)
238 goto endpoint_major_error;
239
240 goto exit;
241
242endpoint_major_error:
243 class_destroy(ep_class->class);
244class_create_error:
245 kfree(ep_class);
246 ep_class = NULL;
184exit: 247exit:
185 return result; 248 return result;
186} 249}
@@ -191,6 +254,7 @@ static void release_endpoint_class(struct kref *kref)
191 class_destroy(ep_class->class); 254 class_destroy(ep_class->class);
192 kfree(ep_class); 255 kfree(ep_class);
193 ep_class = NULL; 256 ep_class = NULL;
257 usb_endpoint_major_cleanup();
194} 258}
195 259
196static void destroy_endpoint_class(void) 260static void destroy_endpoint_class(void)
@@ -213,7 +277,6 @@ int usb_create_ep_files(struct device *parent,
213{ 277{
214 char name[8]; 278 char name[8];
215 struct ep_device *ep_dev; 279 struct ep_device *ep_dev;
216 int minor;
217 int retval; 280 int retval;
218 281
219 retval = init_endpoint_class(); 282 retval = init_endpoint_class();
@@ -226,12 +289,16 @@ int usb_create_ep_files(struct device *parent,
226 goto error_alloc; 289 goto error_alloc;
227 } 290 }
228 291
229 /* fun calculation to determine the minor of this endpoint */ 292 retval = endpoint_get_minor(ep_dev);
230 minor = (((udev->bus->busnum - 1) * 128) * 16) + (udev->devnum - 1); 293 if (retval) {
294 dev_err(parent, "can not allocate minor number for %s",
295 ep_dev->dev.bus_id);
296 goto error_register;
297 }
231 298
232 ep_dev->desc = &endpoint->desc; 299 ep_dev->desc = &endpoint->desc;
233 ep_dev->udev = udev; 300 ep_dev->udev = udev;
234 ep_dev->dev.devt = MKDEV(442, minor); // FIXME fake number... 301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
235 ep_dev->dev.class = ep_class->class; 302 ep_dev->dev.class = ep_class->class;
236 ep_dev->dev.parent = parent; 303 ep_dev->dev.parent = parent;
237 ep_dev->dev.release = ep_device_release; 304 ep_dev->dev.release = ep_device_release;
@@ -241,7 +308,7 @@ int usb_create_ep_files(struct device *parent,
241 308
242 retval = device_register(&ep_dev->dev); 309 retval = device_register(&ep_dev->dev);
243 if (retval) 310 if (retval)
244 goto error_register; 311 goto error_chrdev;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 313 if (retval)
247 goto error_group; 314 goto error_group;
@@ -261,6 +328,9 @@ error_group:
261 destroy_endpoint_class(); 328 destroy_endpoint_class();
262 return retval; 329 return retval;
263 330
331error_chrdev:
332 endpoint_free_minor(ep_dev);
333
264error_register: 334error_register:
265 kfree(ep_dev); 335 kfree(ep_dev);
266error_alloc: 336error_alloc:
@@ -271,14 +341,16 @@ exit:
271 341
272void usb_remove_ep_files(struct usb_host_endpoint *endpoint) 342void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
273{ 343{
344 struct ep_device *ep_dev = endpoint->ep_dev;
274 345
275 if (endpoint->ep_dev) { 346 if (ep_dev) {
276 char name[8]; 347 char name[8];
277 348
278 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
279 sysfs_remove_link(&endpoint->ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
281 device_unregister(&endpoint->ep_dev->dev); 352 endpoint_free_minor(ep_dev);
353 device_unregister(&ep_dev->dev);
282 endpoint->ep_dev = NULL; 354 endpoint->ep_dev = NULL;
283 destroy_endpoint_class(); 355 destroy_endpoint_class();
284 } 356 }
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index afa2dd203329..10064af65d17 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -256,7 +256,9 @@ static const u8 hs_rh_config_descriptor [] = {
256 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 256 0x05, /* __u8 ep_bDescriptorType; Endpoint */
257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
258 0x03, /* __u8 ep_bmAttributes; Interrupt */ 258 0x03, /* __u8 ep_bmAttributes; Interrupt */
259 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 259 /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8)
260 * see hub.c:hub_configure() for details. */
261 (USB_MAXCHILDREN + 1 + 7) / 8, 0x00,
260 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ 262 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */
261}; 263};
262 264
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index ba165aff9ea4..2651c2e2a89f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -22,6 +22,7 @@
22#include <linux/usbdevice_fs.h> 22#include <linux/usbdevice_fs.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/freezer.h>
25 26
26#include <asm/semaphore.h> 27#include <asm/semaphore.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -31,6 +32,47 @@
31#include "hcd.h" 32#include "hcd.h"
32#include "hub.h" 33#include "hub.h"
33 34
35struct usb_hub {
36 struct device *intfdev; /* the "interface" device */
37 struct usb_device *hdev;
38 struct urb *urb; /* for interrupt polling pipe */
39
40 /* buffer for urb ... with extra space in case of babble */
41 char (*buffer)[8];
42 dma_addr_t buffer_dma; /* DMA address for buffer */
43 union {
44 struct usb_hub_status hub;
45 struct usb_port_status port;
46 } *status; /* buffer for status reports */
47
48 int error; /* last reported error */
49 int nerrors; /* track consecutive errors */
50
51 struct list_head event_list; /* hubs w/data or errs ready */
52 unsigned long event_bits[1]; /* status change bitmask */
53 unsigned long change_bits[1]; /* ports with logical connect
54 status change */
55 unsigned long busy_bits[1]; /* ports being reset or
56 resumed */
57#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
58#error event_bits[] is too short!
59#endif
60
61 struct usb_hub_descriptor *descriptor; /* class descriptor */
62 struct usb_tt tt; /* Transaction Translator */
63
64 unsigned mA_per_port; /* current for each child */
65
66 unsigned limited_power:1;
67 unsigned quiescing:1;
68 unsigned activating:1;
69
70 unsigned has_indicators:1;
71 u8 indicator[USB_MAXCHILDREN];
72 struct delayed_work leds;
73};
74
75
34/* Protect struct usb_device->state and ->children members 76/* Protect struct usb_device->state and ->children members
35 * Note: Both are also protected by ->dev.sem, except that ->state can 77 * Note: Both are also protected by ->dev.sem, except that ->state can
36 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ 78 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
@@ -45,6 +87,16 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
45 87
46static struct task_struct *khubd_task; 88static struct task_struct *khubd_task;
47 89
90/* multithreaded probe logic */
91static int multithread_probe =
92#ifdef CONFIG_USB_MULTITHREAD_PROBE
93 1;
94#else
95 0;
96#endif
97module_param(multithread_probe, bool, S_IRUGO);
98MODULE_PARM_DESC(multithread_probe, "Run each USB device probe in a new thread");
99
48/* cycle leds on hubs that aren't blinking for attention */ 100/* cycle leds on hubs that aren't blinking for attention */
49static int blinkenlights = 0; 101static int blinkenlights = 0;
50module_param (blinkenlights, bool, S_IRUGO); 102module_param (blinkenlights, bool, S_IRUGO);
@@ -167,9 +219,10 @@ static void set_port_led(
167 219
168#define LED_CYCLE_PERIOD ((2*HZ)/3) 220#define LED_CYCLE_PERIOD ((2*HZ)/3)
169 221
170static void led_work (void *__hub) 222static void led_work (struct work_struct *work)
171{ 223{
172 struct usb_hub *hub = __hub; 224 struct usb_hub *hub =
225 container_of(work, struct usb_hub, leds.work);
173 struct usb_device *hdev = hub->hdev; 226 struct usb_device *hdev = hub->hdev;
174 unsigned i; 227 unsigned i;
175 unsigned changed = 0; 228 unsigned changed = 0;
@@ -276,6 +329,9 @@ static void kick_khubd(struct usb_hub *hub)
276{ 329{
277 unsigned long flags; 330 unsigned long flags;
278 331
332 /* Suppress autosuspend until khubd runs */
333 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
334
279 spin_lock_irqsave(&hub_event_lock, flags); 335 spin_lock_irqsave(&hub_event_lock, flags);
280 if (list_empty(&hub->event_list)) { 336 if (list_empty(&hub->event_list)) {
281 list_add_tail(&hub->event_list, &hub_event_list); 337 list_add_tail(&hub->event_list, &hub_event_list);
@@ -351,9 +407,10 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
351 * talking to TTs must queue control transfers (not just bulk and iso), so 407 * talking to TTs must queue control transfers (not just bulk and iso), so
352 * both can talk to the same hub concurrently. 408 * both can talk to the same hub concurrently.
353 */ 409 */
354static void hub_tt_kevent (void *arg) 410static void hub_tt_kevent (struct work_struct *work)
355{ 411{
356 struct usb_hub *hub = arg; 412 struct usb_hub *hub =
413 container_of(work, struct usb_hub, tt.kevent);
357 unsigned long flags; 414 unsigned long flags;
358 415
359 spin_lock_irqsave (&hub->tt.lock, flags); 416 spin_lock_irqsave (&hub->tt.lock, flags);
@@ -404,7 +461,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
404 * since each TT has "at least two" buffers that can need it (and 461 * since each TT has "at least two" buffers that can need it (and
405 * there can be many TTs per hub). even if they're uncommon. 462 * there can be many TTs per hub). even if they're uncommon.
406 */ 463 */
407 if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) { 464 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
408 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 465 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
409 /* FIXME recover somehow ... RESET_TT? */ 466 /* FIXME recover somehow ... RESET_TT? */
410 return; 467 return;
@@ -457,7 +514,6 @@ static void hub_quiesce(struct usb_hub *hub)
457 /* (nonblocking) khubd and related activity won't re-trigger */ 514 /* (nonblocking) khubd and related activity won't re-trigger */
458 hub->quiescing = 1; 515 hub->quiescing = 1;
459 hub->activating = 0; 516 hub->activating = 0;
460 hub->resume_root_hub = 0;
461 517
462 /* (blocking) stop khubd and related activity */ 518 /* (blocking) stop khubd and related activity */
463 usb_kill_urb(hub->urb); 519 usb_kill_urb(hub->urb);
@@ -473,7 +529,7 @@ static void hub_activate(struct usb_hub *hub)
473 529
474 hub->quiescing = 0; 530 hub->quiescing = 0;
475 hub->activating = 1; 531 hub->activating = 1;
476 hub->resume_root_hub = 0; 532
477 status = usb_submit_urb(hub->urb, GFP_NOIO); 533 status = usb_submit_urb(hub->urb, GFP_NOIO);
478 if (status < 0) 534 if (status < 0)
479 dev_err(hub->intfdev, "activate --> %d\n", status); 535 dev_err(hub->intfdev, "activate --> %d\n", status);
@@ -641,7 +697,7 @@ static int hub_configure(struct usb_hub *hub,
641 697
642 spin_lock_init (&hub->tt.lock); 698 spin_lock_init (&hub->tt.lock);
643 INIT_LIST_HEAD (&hub->tt.clear_list); 699 INIT_LIST_HEAD (&hub->tt.clear_list);
644 INIT_WORK (&hub->tt.kevent, hub_tt_kevent, hub); 700 INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
645 switch (hdev->descriptor.bDeviceProtocol) { 701 switch (hdev->descriptor.bDeviceProtocol) {
646 case 0: 702 case 0:
647 break; 703 break;
@@ -759,7 +815,12 @@ static int hub_configure(struct usb_hub *hub,
759 dev_dbg(hub_dev, "%sover-current condition exists\n", 815 dev_dbg(hub_dev, "%sover-current condition exists\n",
760 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); 816 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
761 817
762 /* set up the interrupt endpoint */ 818 /* set up the interrupt endpoint
819 * We use the EP's maxpacket size instead of (PORTS+1+7)/8
820 * bytes as USB2.0[11.12.3] says because some hubs are known
821 * to send more data (and thus cause overflow). For root hubs,
822 * maxpktsize is defined in hcd.c's fake endpoint descriptors
823 * to be big enough for at least USB_MAXCHILDREN ports. */
763 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 824 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
764 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 825 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
765 826
@@ -880,9 +941,10 @@ descriptor_error:
880 INIT_LIST_HEAD(&hub->event_list); 941 INIT_LIST_HEAD(&hub->event_list);
881 hub->intfdev = &intf->dev; 942 hub->intfdev = &intf->dev;
882 hub->hdev = hdev; 943 hub->hdev = hdev;
883 INIT_WORK(&hub->leds, led_work, hub); 944 INIT_DELAYED_WORK(&hub->leds, led_work);
884 945
885 usb_set_intfdata (intf, hub); 946 usb_set_intfdata (intf, hub);
947 intf->needs_remote_wakeup = 1;
886 948
887 if (hdev->speed == USB_SPEED_HIGH) 949 if (hdev->speed == USB_SPEED_HIGH)
888 highspeed_hubs++; 950 highspeed_hubs++;
@@ -980,6 +1042,8 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev)
980 if (udev->children[i]) 1042 if (udev->children[i])
981 recursively_mark_NOTATTACHED(udev->children[i]); 1043 recursively_mark_NOTATTACHED(udev->children[i]);
982 } 1044 }
1045 if (udev->state == USB_STATE_SUSPENDED)
1046 udev->discon_suspended = 1;
983 udev->state = USB_STATE_NOTATTACHED; 1047 udev->state = USB_STATE_NOTATTACHED;
984} 1048}
985 1049
@@ -1169,6 +1233,14 @@ void usb_disconnect(struct usb_device **pdev)
1169 *pdev = NULL; 1233 *pdev = NULL;
1170 spin_unlock_irq(&device_state_lock); 1234 spin_unlock_irq(&device_state_lock);
1171 1235
1236 /* Decrement the parent's count of unsuspended children */
1237 if (udev->parent) {
1238 usb_pm_lock(udev);
1239 if (!udev->discon_suspended)
1240 usb_autosuspend_device(udev->parent);
1241 usb_pm_unlock(udev);
1242 }
1243
1172 put_device(&udev->dev); 1244 put_device(&udev->dev);
1173} 1245}
1174 1246
@@ -1191,29 +1263,17 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1191static int __usb_port_suspend(struct usb_device *, int port1); 1263static int __usb_port_suspend(struct usb_device *, int port1);
1192#endif 1264#endif
1193 1265
1194/** 1266static int __usb_new_device(void *void_data)
1195 * usb_new_device - perform initial device setup (usbcore-internal)
1196 * @udev: newly addressed device (in ADDRESS state)
1197 *
1198 * This is called with devices which have been enumerated, but not yet
1199 * configured. The device descriptor is available, but not descriptors
1200 * for any device configuration. The caller must have locked either
1201 * the parent hub (if udev is a normal device) or else the
1202 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1203 * udev has already been installed, but udev is not yet visible through
1204 * sysfs or other filesystem code.
1205 *
1206 * Returns 0 for success (device is configured and listed, with its
1207 * interfaces, in sysfs); else a negative errno value.
1208 *
1209 * This call is synchronous, and may not be used in an interrupt context.
1210 *
1211 * Only the hub driver or root-hub registrar should ever call this.
1212 */
1213int usb_new_device(struct usb_device *udev)
1214{ 1267{
1268 struct usb_device *udev = void_data;
1215 int err; 1269 int err;
1216 1270
1271 /* Lock ourself into memory in order to keep a probe sequence
1272 * sleeping in a new thread from allowing us to be unloaded.
1273 */
1274 if (!try_module_get(THIS_MODULE))
1275 return -EINVAL;
1276
1217 err = usb_get_configuration(udev); 1277 err = usb_get_configuration(udev);
1218 if (err < 0) { 1278 if (err < 0) {
1219 dev_err(&udev->dev, "can't read configurations, error %d\n", 1279 dev_err(&udev->dev, "can't read configurations, error %d\n",
@@ -1309,13 +1369,56 @@ int usb_new_device(struct usb_device *udev)
1309 goto fail; 1369 goto fail;
1310 } 1370 }
1311 1371
1312 return 0; 1372 /* Increment the parent's count of unsuspended children */
1373 if (udev->parent)
1374 usb_autoresume_device(udev->parent);
1375
1376exit:
1377 module_put(THIS_MODULE);
1378 return err;
1313 1379
1314fail: 1380fail:
1315 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1381 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1316 return err; 1382 goto exit;
1317} 1383}
1318 1384
1385/**
1386 * usb_new_device - perform initial device setup (usbcore-internal)
1387 * @udev: newly addressed device (in ADDRESS state)
1388 *
1389 * This is called with devices which have been enumerated, but not yet
1390 * configured. The device descriptor is available, but not descriptors
1391 * for any device configuration. The caller must have locked either
1392 * the parent hub (if udev is a normal device) or else the
1393 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1394 * udev has already been installed, but udev is not yet visible through
1395 * sysfs or other filesystem code.
1396 *
1397 * The return value for this function depends on if the
1398 * multithread_probe variable is set or not. If it's set, it will
1399 * return a if the probe thread was successfully created or not. If the
1400 * variable is not set, it will return if the device is configured
1401 * properly or not. interfaces, in sysfs); else a negative errno value.
1402 *
1403 * This call is synchronous, and may not be used in an interrupt context.
1404 *
1405 * Only the hub driver or root-hub registrar should ever call this.
1406 */
1407int usb_new_device(struct usb_device *udev)
1408{
1409 struct task_struct *probe_task;
1410 int ret = 0;
1411
1412 if (multithread_probe) {
1413 probe_task = kthread_run(__usb_new_device, udev,
1414 "usb-probe-%s", udev->devnum);
1415 if (IS_ERR(probe_task))
1416 ret = PTR_ERR(probe_task);
1417 } else
1418 ret = __usb_new_device(udev);
1419
1420 return ret;
1421}
1319 1422
1320static int hub_port_status(struct usb_hub *hub, int port1, 1423static int hub_port_status(struct usb_hub *hub, int port1,
1321 u16 *status, u16 *change) 1424 u16 *status, u16 *change)
@@ -1323,10 +1426,12 @@ static int hub_port_status(struct usb_hub *hub, int port1,
1323 int ret; 1426 int ret;
1324 1427
1325 ret = get_port_status(hub->hdev, port1, &hub->status->port); 1428 ret = get_port_status(hub->hdev, port1, &hub->status->port);
1326 if (ret < 0) 1429 if (ret < 4) {
1327 dev_err (hub->intfdev, 1430 dev_err (hub->intfdev,
1328 "%s failed (err = %d)\n", __FUNCTION__, ret); 1431 "%s failed (err = %d)\n", __FUNCTION__, ret);
1329 else { 1432 if (ret >= 0)
1433 ret = -EIO;
1434 } else {
1330 *status = le16_to_cpu(hub->status->port.wPortStatus); 1435 *status = le16_to_cpu(hub->status->port.wPortStatus);
1331 *change = le16_to_cpu(hub->status->port.wPortChange); 1436 *change = le16_to_cpu(hub->status->port.wPortChange);
1332 ret = 0; 1437 ret = 0;
@@ -1674,6 +1779,12 @@ static int
1674hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) 1779hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1675{ 1780{
1676 int status; 1781 int status;
1782 u16 portchange, portstatus;
1783
1784 /* Skip the initial Clear-Suspend step for a remote wakeup */
1785 status = hub_port_status(hub, port1, &portstatus, &portchange);
1786 if (status == 0 && !(portstatus & USB_PORT_STAT_SUSPEND))
1787 goto SuspendCleared;
1677 1788
1678 // dev_dbg(hub->intfdev, "resume port %d\n", port1); 1789 // dev_dbg(hub->intfdev, "resume port %d\n", port1);
1679 1790
@@ -1687,9 +1798,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1687 "can't resume port %d, status %d\n", 1798 "can't resume port %d, status %d\n",
1688 port1, status); 1799 port1, status);
1689 } else { 1800 } else {
1690 u16 devstatus;
1691 u16 portchange;
1692
1693 /* drive resume for at least 20 msec */ 1801 /* drive resume for at least 20 msec */
1694 if (udev) 1802 if (udev)
1695 dev_dbg(&udev->dev, "usb %sresume\n", 1803 dev_dbg(&udev->dev, "usb %sresume\n",
@@ -1704,16 +1812,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1704 * stop resume signaling. Then finish the resume 1812 * stop resume signaling. Then finish the resume
1705 * sequence. 1813 * sequence.
1706 */ 1814 */
1707 devstatus = portchange = 0; 1815 status = hub_port_status(hub, port1, &portstatus, &portchange);
1708 status = hub_port_status(hub, port1, 1816SuspendCleared:
1709 &devstatus, &portchange);
1710 if (status < 0 1817 if (status < 0
1711 || (devstatus & LIVE_FLAGS) != LIVE_FLAGS 1818 || (portstatus & LIVE_FLAGS) != LIVE_FLAGS
1712 || (devstatus & USB_PORT_STAT_SUSPEND) != 0 1819 || (portstatus & USB_PORT_STAT_SUSPEND) != 0
1713 ) { 1820 ) {
1714 dev_dbg(hub->intfdev, 1821 dev_dbg(hub->intfdev,
1715 "port %d status %04x.%04x after resume, %d\n", 1822 "port %d status %04x.%04x after resume, %d\n",
1716 port1, portchange, devstatus, status); 1823 port1, portchange, portstatus, status);
1717 if (status >= 0) 1824 if (status >= 0)
1718 status = -ENODEV; 1825 status = -ENODEV;
1719 } else { 1826 } else {
@@ -1774,23 +1881,16 @@ static int remote_wakeup(struct usb_device *udev)
1774{ 1881{
1775 int status = 0; 1882 int status = 0;
1776 1883
1777 /* All this just to avoid sending a port-resume message
1778 * to the parent hub! */
1779
1780 usb_lock_device(udev); 1884 usb_lock_device(udev);
1781 usb_pm_lock(udev);
1782 if (udev->state == USB_STATE_SUSPENDED) { 1885 if (udev->state == USB_STATE_SUSPENDED) {
1783 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 1886 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
1784 /* TRSMRCY = 10 msec */ 1887 status = usb_autoresume_device(udev);
1785 msleep(10); 1888
1786 status = finish_port_resume(udev); 1889 /* Give the interface drivers a chance to do something,
1890 * then autosuspend the device again. */
1787 if (status == 0) 1891 if (status == 0)
1788 udev->dev.power.power_state.event = PM_EVENT_ON; 1892 usb_autosuspend_device(udev);
1789 } 1893 }
1790 usb_pm_unlock(udev);
1791
1792 if (status == 0)
1793 usb_autoresume_device(udev, 0);
1794 usb_unlock_device(udev); 1894 usb_unlock_device(udev);
1795 return status; 1895 return status;
1796} 1896}
@@ -1854,6 +1954,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1854 } 1954 }
1855 } 1955 }
1856 1956
1957 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1958
1857 /* "global suspend" of the downstream HC-to-USB interface */ 1959 /* "global suspend" of the downstream HC-to-USB interface */
1858 if (!hdev->parent) { 1960 if (!hdev->parent) {
1859 struct usb_bus *bus = hdev->bus; 1961 struct usb_bus *bus = hdev->bus;
@@ -1876,10 +1978,12 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1876 1978
1877static int hub_resume(struct usb_interface *intf) 1979static int hub_resume(struct usb_interface *intf)
1878{ 1980{
1879 struct usb_device *hdev = interface_to_usbdev(intf);
1880 struct usb_hub *hub = usb_get_intfdata (intf); 1981 struct usb_hub *hub = usb_get_intfdata (intf);
1982 struct usb_device *hdev = hub->hdev;
1881 int status; 1983 int status;
1882 1984
1985 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1986
1883 /* "global resume" of the downstream HC-to-USB interface */ 1987 /* "global resume" of the downstream HC-to-USB interface */
1884 if (!hdev->parent) { 1988 if (!hdev->parent) {
1885 struct usb_bus *bus = hdev->bus; 1989 struct usb_bus *bus = hdev->bus;
@@ -1918,7 +2022,6 @@ void usb_resume_root_hub(struct usb_device *hdev)
1918{ 2022{
1919 struct usb_hub *hub = hdev_to_hub(hdev); 2023 struct usb_hub *hub = hdev_to_hub(hdev);
1920 2024
1921 hub->resume_root_hub = 1;
1922 kick_khubd(hub); 2025 kick_khubd(hub);
1923} 2026}
1924 2027
@@ -2269,7 +2372,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2269 struct usb_qualifier_descriptor *qual; 2372 struct usb_qualifier_descriptor *qual;
2270 int status; 2373 int status;
2271 2374
2272 qual = kmalloc (sizeof *qual, SLAB_KERNEL); 2375 qual = kmalloc (sizeof *qual, GFP_KERNEL);
2273 if (qual == NULL) 2376 if (qual == NULL)
2274 return; 2377 return;
2275 2378
@@ -2281,7 +2384,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2281 /* hub LEDs are probably harder to miss than syslog */ 2384 /* hub LEDs are probably harder to miss than syslog */
2282 if (hub->has_indicators) { 2385 if (hub->has_indicators) {
2283 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; 2386 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
2284 schedule_work (&hub->leds); 2387 schedule_delayed_work (&hub->leds, 0);
2285 } 2388 }
2286 } 2389 }
2287 kfree(qual); 2390 kfree(qual);
@@ -2455,7 +2558,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2455 if (hub->has_indicators) { 2558 if (hub->has_indicators) {
2456 hub->indicator[port1-1] = 2559 hub->indicator[port1-1] =
2457 INDICATOR_AMBER_BLINK; 2560 INDICATOR_AMBER_BLINK;
2458 schedule_work (&hub->leds); 2561 schedule_delayed_work (&hub->leds, 0);
2459 } 2562 }
2460 status = -ENOTCONN; /* Don't retry */ 2563 status = -ENOTCONN; /* Don't retry */
2461 goto loop_disable; 2564 goto loop_disable;
@@ -2555,16 +2658,13 @@ static void hub_events(void)
2555 intf = to_usb_interface(hub->intfdev); 2658 intf = to_usb_interface(hub->intfdev);
2556 hub_dev = &intf->dev; 2659 hub_dev = &intf->dev;
2557 2660
2558 i = hub->resume_root_hub; 2661 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
2559
2560 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n",
2561 hdev->state, hub->descriptor 2662 hdev->state, hub->descriptor
2562 ? hub->descriptor->bNbrPorts 2663 ? hub->descriptor->bNbrPorts
2563 : 0, 2664 : 0,
2564 /* NOTE: expects max 15 ports... */ 2665 /* NOTE: expects max 15 ports... */
2565 (u16) hub->change_bits[0], 2666 (u16) hub->change_bits[0],
2566 (u16) hub->event_bits[0], 2667 (u16) hub->event_bits[0]);
2567 i ? ", resume root" : "");
2568 2668
2569 usb_get_intf(intf); 2669 usb_get_intf(intf);
2570 spin_unlock_irq(&hub_event_lock); 2670 spin_unlock_irq(&hub_event_lock);
@@ -2585,16 +2685,16 @@ static void hub_events(void)
2585 goto loop; 2685 goto loop;
2586 } 2686 }
2587 2687
2588 /* Is this is a root hub wanting to reactivate the downstream 2688 /* Autoresume */
2589 * ports? If so, be sure the interface resumes even if its 2689 ret = usb_autopm_get_interface(intf);
2590 * stub "device" node was never suspended. 2690 if (ret) {
2591 */ 2691 dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
2592 if (i) 2692 goto loop;
2593 usb_autoresume_device(hdev, 0); 2693 }
2594 2694
2595 /* If this is an inactive or suspended hub, do nothing */ 2695 /* If this is an inactive hub, do nothing */
2596 if (hub->quiescing) 2696 if (hub->quiescing)
2597 goto loop; 2697 goto loop_autopm;
2598 2698
2599 if (hub->error) { 2699 if (hub->error) {
2600 dev_dbg (hub_dev, "resetting for error %d\n", 2700 dev_dbg (hub_dev, "resetting for error %d\n",
@@ -2604,7 +2704,7 @@ static void hub_events(void)
2604 if (ret) { 2704 if (ret) {
2605 dev_dbg (hub_dev, 2705 dev_dbg (hub_dev,
2606 "error resetting hub: %d\n", ret); 2706 "error resetting hub: %d\n", ret);
2607 goto loop; 2707 goto loop_autopm;
2608 } 2708 }
2609 2709
2610 hub->nerrors = 0; 2710 hub->nerrors = 0;
@@ -2732,6 +2832,10 @@ static void hub_events(void)
2732 if (!hdev->parent && !hub->busy_bits[0]) 2832 if (!hdev->parent && !hub->busy_bits[0])
2733 usb_enable_root_hub_irq(hdev->bus); 2833 usb_enable_root_hub_irq(hdev->bus);
2734 2834
2835loop_autopm:
2836 /* Allow autosuspend if we're not going to run again */
2837 if (list_empty(&hub->event_list))
2838 usb_autopm_enable(intf);
2735loop: 2839loop:
2736 usb_unlock_device(hdev); 2840 usb_unlock_device(hdev);
2737 usb_put_intf(intf); 2841 usb_put_intf(intf);
@@ -2773,6 +2877,7 @@ static struct usb_driver hub_driver = {
2773 .post_reset = hub_post_reset, 2877 .post_reset = hub_post_reset,
2774 .ioctl = hub_ioctl, 2878 .ioctl = hub_ioctl,
2775 .id_table = hub_id_table, 2879 .id_table = hub_id_table,
2880 .supports_autosuspend = 1,
2776}; 2881};
2777 2882
2778int usb_hub_init(void) 2883int usb_hub_init(void)
@@ -2818,7 +2923,7 @@ static int config_descriptors_changed(struct usb_device *udev)
2818 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 2923 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength))
2819 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 2924 len = le16_to_cpu(udev->config[index].desc.wTotalLength);
2820 } 2925 }
2821 buf = kmalloc (len, SLAB_KERNEL); 2926 buf = kmalloc (len, GFP_KERNEL);
2822 if (buf == NULL) { 2927 if (buf == NULL) {
2823 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 2928 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
2824 /* assume the worst */ 2929 /* assume the worst */
@@ -2997,7 +3102,7 @@ int usb_reset_composite_device(struct usb_device *udev,
2997 } 3102 }
2998 3103
2999 /* Prevent autosuspend during the reset */ 3104 /* Prevent autosuspend during the reset */
3000 usb_autoresume_device(udev, 1); 3105 usb_autoresume_device(udev);
3001 3106
3002 if (iface && iface->condition != USB_INTERFACE_BINDING) 3107 if (iface && iface->condition != USB_INTERFACE_BINDING)
3003 iface = NULL; 3108 iface = NULL;
@@ -3040,7 +3145,7 @@ int usb_reset_composite_device(struct usb_device *udev,
3040 } 3145 }
3041 } 3146 }
3042 3147
3043 usb_autosuspend_device(udev, 1); 3148 usb_autosuspend_device(udev);
3044 return ret; 3149 return ret;
3045} 3150}
3046EXPORT_SYMBOL(usb_reset_composite_device); 3151EXPORT_SYMBOL(usb_reset_composite_device);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 0f8e82a4d480..cf9559c6c9b6 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -192,45 +192,4 @@ struct usb_tt_clear {
192 192
193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); 193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe);
194 194
195struct usb_hub {
196 struct device *intfdev; /* the "interface" device */
197 struct usb_device *hdev;
198 struct urb *urb; /* for interrupt polling pipe */
199
200 /* buffer for urb ... with extra space in case of babble */
201 char (*buffer)[8];
202 dma_addr_t buffer_dma; /* DMA address for buffer */
203 union {
204 struct usb_hub_status hub;
205 struct usb_port_status port;
206 } *status; /* buffer for status reports */
207
208 int error; /* last reported error */
209 int nerrors; /* track consecutive errors */
210
211 struct list_head event_list; /* hubs w/data or errs ready */
212 unsigned long event_bits[1]; /* status change bitmask */
213 unsigned long change_bits[1]; /* ports with logical connect
214 status change */
215 unsigned long busy_bits[1]; /* ports being reset or
216 resumed */
217#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
218#error event_bits[] is too short!
219#endif
220
221 struct usb_hub_descriptor *descriptor; /* class descriptor */
222 struct usb_tt tt; /* Transaction Translator */
223
224 unsigned mA_per_port; /* current for each child */
225
226 unsigned limited_power:1;
227 unsigned quiescing:1;
228 unsigned activating:1;
229 unsigned resume_root_hub:1;
230
231 unsigned has_indicators:1;
232 enum hub_led_mode indicator[USB_MAXCHILDREN];
233 struct work_struct leds;
234};
235
236#endif /* __LINUX_HUB_H */ 195#endif /* __LINUX_HUB_H */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fccd1952bad3..149aa8bfb1fe 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -488,7 +488,7 @@ void usb_sg_wait (struct usb_sg_request *io)
488 int retval; 488 int retval;
489 489
490 io->urbs [i]->dev = io->dev; 490 io->urbs [i]->dev = io->dev;
491 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC); 491 retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC);
492 492
493 /* after we submit, let completions or cancelations fire; 493 /* after we submit, let completions or cancelations fire;
494 * we handshake using io->status. 494 * we handshake using io->status.
@@ -764,7 +764,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
764 err = -EINVAL; 764 err = -EINVAL;
765 goto errout; 765 goto errout;
766 } else { 766 } else {
767 dev->have_langid = -1; 767 dev->have_langid = 1;
768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8); 768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8);
769 /* always use the first langid listed */ 769 /* always use the first langid listed */
770 dev_dbg (&dev->dev, "default language 0x%04x\n", 770 dev_dbg (&dev->dev, "default language 0x%04x\n",
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
828 * Context: !in_interrupt () 828 * Context: !in_interrupt ()
829 * 829 *
830 * Updates the copy of the device descriptor stored in the device structure, 830 * Updates the copy of the device descriptor stored in the device structure,
831 * which dedicates space for this purpose. Note that several fields are 831 * which dedicates space for this purpose.
832 * converted to the host CPU's byte order: the USB version (bcdUSB), and
833 * vendors product and version fields (idVendor, idProduct, and bcdDevice).
834 * That lets device drivers compare against non-byteswapped constants.
835 * 832 *
836 * Not exported, only for use by the core. If drivers really want to read 833 * Not exported, only for use by the core. If drivers really want to read
837 * the device descriptor directly, they can call usb_get_descriptor() with 834 * the device descriptor directly, they can call usb_get_descriptor() with
@@ -1401,7 +1398,7 @@ free_interfaces:
1401 } 1398 }
1402 1399
1403 /* Wake up the device so we can send it the Set-Config request */ 1400 /* Wake up the device so we can send it the Set-Config request */
1404 ret = usb_autoresume_device(dev, 1); 1401 ret = usb_autoresume_device(dev);
1405 if (ret) 1402 if (ret)
1406 goto free_interfaces; 1403 goto free_interfaces;
1407 1404
@@ -1424,7 +1421,7 @@ free_interfaces:
1424 dev->actconfig = cp; 1421 dev->actconfig = cp;
1425 if (!cp) { 1422 if (!cp) {
1426 usb_set_device_state(dev, USB_STATE_ADDRESS); 1423 usb_set_device_state(dev, USB_STATE_ADDRESS);
1427 usb_autosuspend_device(dev, 1); 1424 usb_autosuspend_device(dev);
1428 goto free_interfaces; 1425 goto free_interfaces;
1429 } 1426 }
1430 usb_set_device_state(dev, USB_STATE_CONFIGURED); 1427 usb_set_device_state(dev, USB_STATE_CONFIGURED);
@@ -1493,7 +1490,7 @@ free_interfaces:
1493 usb_create_sysfs_intf_files (intf); 1490 usb_create_sysfs_intf_files (intf);
1494 } 1491 }
1495 1492
1496 usb_autosuspend_device(dev, 1); 1493 usb_autosuspend_device(dev);
1497 return 0; 1494 return 0;
1498} 1495}
1499 1496
@@ -1504,9 +1501,10 @@ struct set_config_request {
1504}; 1501};
1505 1502
1506/* Worker routine for usb_driver_set_configuration() */ 1503/* Worker routine for usb_driver_set_configuration() */
1507static void driver_set_config_work(void *_req) 1504static void driver_set_config_work(struct work_struct *work)
1508{ 1505{
1509 struct set_config_request *req = _req; 1506 struct set_config_request *req =
1507 container_of(work, struct set_config_request, work);
1510 1508
1511 usb_lock_device(req->udev); 1509 usb_lock_device(req->udev);
1512 usb_set_configuration(req->udev, req->config); 1510 usb_set_configuration(req->udev, req->config);
@@ -1544,7 +1542,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
1544 return -ENOMEM; 1542 return -ENOMEM;
1545 req->udev = udev; 1543 req->udev = udev;
1546 req->config = config; 1544 req->config = config;
1547 INIT_WORK(&req->work, driver_set_config_work, req); 1545 INIT_WORK(&req->work, driver_set_config_work);
1548 1546
1549 usb_get_dev(udev); 1547 usb_get_dev(udev);
1550 if (!schedule_work(&req->work)) { 1548 if (!schedule_work(&req->work)) {
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 467cb02832f3..02426d0b9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -200,19 +200,13 @@ static void ksuspend_usb_cleanup(void)
200 destroy_workqueue(ksuspend_usb_wq); 200 destroy_workqueue(ksuspend_usb_wq);
201} 201}
202 202
203#else
204
205#define ksuspend_usb_init() 0
206#define ksuspend_usb_cleanup() do {} while (0)
207
208#endif
209
210#ifdef CONFIG_USB_SUSPEND 203#ifdef CONFIG_USB_SUSPEND
211 204
212/* usb_autosuspend_work - callback routine to autosuspend a USB device */ 205/* usb_autosuspend_work - callback routine to autosuspend a USB device */
213static void usb_autosuspend_work(void *_udev) 206static void usb_autosuspend_work(struct work_struct *work)
214{ 207{
215 struct usb_device *udev = _udev; 208 struct usb_device *udev =
209 container_of(work, struct usb_device, autosuspend.work);
216 210
217 usb_pm_lock(udev); 211 usb_pm_lock(udev);
218 udev->auto_pm = 1; 212 udev->auto_pm = 1;
@@ -222,10 +216,17 @@ static void usb_autosuspend_work(void *_udev)
222 216
223#else 217#else
224 218
225static void usb_autosuspend_work(void *_udev) 219static void usb_autosuspend_work(struct work_struct *work)
226{} 220{}
227 221
228#endif 222#endif /* CONFIG_USB_SUSPEND */
223
224#else
225
226#define ksuspend_usb_init() 0
227#define ksuspend_usb_cleanup() do {} while (0)
228
229#endif /* CONFIG_PM */
229 230
230/** 231/**
231 * usb_alloc_dev - usb device constructor (usbcore-internal) 232 * usb_alloc_dev - usb device constructor (usbcore-internal)
@@ -304,7 +305,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
304 305
305#ifdef CONFIG_PM 306#ifdef CONFIG_PM
306 mutex_init(&dev->pm_mutex); 307 mutex_init(&dev->pm_mutex);
307 INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev); 308 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
308#endif 309#endif
309 return dev; 310 return dev;
310} 311}
@@ -537,138 +538,6 @@ int usb_get_current_frame_number(struct usb_device *dev)
537 return usb_hcd_get_frame_number (dev); 538 return usb_hcd_get_frame_number (dev);
538} 539}
539 540
540/**
541 * usb_endpoint_dir_in - check if the endpoint has IN direction
542 * @epd: endpoint to be checked
543 *
544 * Returns true if the endpoint is of type IN, otherwise it returns false.
545 */
546int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
547{
548 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
549}
550
551/**
552 * usb_endpoint_dir_out - check if the endpoint has OUT direction
553 * @epd: endpoint to be checked
554 *
555 * Returns true if the endpoint is of type OUT, otherwise it returns false.
556 */
557int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
558{
559 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
560}
561
562/**
563 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
564 * @epd: endpoint to be checked
565 *
566 * Returns true if the endpoint is of type bulk, otherwise it returns false.
567 */
568int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
569{
570 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
571 USB_ENDPOINT_XFER_BULK);
572}
573
574/**
575 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
576 * @epd: endpoint to be checked
577 *
578 * Returns true if the endpoint is of type interrupt, otherwise it returns
579 * false.
580 */
581int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
582{
583 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
584 USB_ENDPOINT_XFER_INT);
585}
586
587/**
588 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
589 * @epd: endpoint to be checked
590 *
591 * Returns true if the endpoint is of type isochronous, otherwise it returns
592 * false.
593 */
594int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
595{
596 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
597 USB_ENDPOINT_XFER_ISOC);
598}
599
600/**
601 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
602 * @epd: endpoint to be checked
603 *
604 * Returns true if the endpoint has bulk transfer type and IN direction,
605 * otherwise it returns false.
606 */
607int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
608{
609 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
610}
611
612/**
613 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
614 * @epd: endpoint to be checked
615 *
616 * Returns true if the endpoint has bulk transfer type and OUT direction,
617 * otherwise it returns false.
618 */
619int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
620{
621 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
622}
623
624/**
625 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
626 * @epd: endpoint to be checked
627 *
628 * Returns true if the endpoint has interrupt transfer type and IN direction,
629 * otherwise it returns false.
630 */
631int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
632{
633 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
634}
635
636/**
637 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
638 * @epd: endpoint to be checked
639 *
640 * Returns true if the endpoint has interrupt transfer type and OUT direction,
641 * otherwise it returns false.
642 */
643int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
644{
645 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
646}
647
648/**
649 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
650 * @epd: endpoint to be checked
651 *
652 * Returns true if the endpoint has isochronous transfer type and IN direction,
653 * otherwise it returns false.
654 */
655int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
656{
657 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
658}
659
660/**
661 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
662 * @epd: endpoint to be checked
663 *
664 * Returns true if the endpoint has isochronous transfer type and OUT direction,
665 * otherwise it returns false.
666 */
667int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
668{
669 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
670}
671
672/*-------------------------------------------------------------------*/ 541/*-------------------------------------------------------------------*/
673/* 542/*
674 * __usb_get_extra_descriptor() finds a descriptor of specific type in the 543 * __usb_get_extra_descriptor() finds a descriptor of specific type in the
@@ -1102,18 +971,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor);
1102EXPORT_SYMBOL(usb_find_device); 971EXPORT_SYMBOL(usb_find_device);
1103EXPORT_SYMBOL(usb_get_current_frame_number); 972EXPORT_SYMBOL(usb_get_current_frame_number);
1104 973
1105EXPORT_SYMBOL_GPL(usb_endpoint_dir_in);
1106EXPORT_SYMBOL_GPL(usb_endpoint_dir_out);
1107EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk);
1108EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int);
1109EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc);
1110EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in);
1111EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out);
1112EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in);
1113EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out);
1114EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in);
1115EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out);
1116
1117EXPORT_SYMBOL (usb_buffer_alloc); 974EXPORT_SYMBOL (usb_buffer_alloc);
1118EXPORT_SYMBOL (usb_buffer_free); 975EXPORT_SYMBOL (usb_buffer_free);
1119 976
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 13322e33f912..17830a81be14 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -64,14 +64,13 @@ static inline void usb_pm_unlock(struct usb_device *udev) {}
64 64
65#define USB_AUTOSUSPEND_DELAY (HZ*2) 65#define USB_AUTOSUSPEND_DELAY (HZ*2)
66 66
67extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt); 67extern void usb_autosuspend_device(struct usb_device *udev);
68extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt); 68extern int usb_autoresume_device(struct usb_device *udev);
69 69
70#else 70#else
71 71
72#define usb_autosuspend_device(udev, dec_busy_cnt) do {} while (0) 72#define usb_autosuspend_device(udev) do {} while (0)
73static inline int usb_autoresume_device(struct usb_device *udev, 73static inline int usb_autoresume_device(struct usb_device *udev)
74 int inc_busy_cnt)
75{ 74{
76 return 0; 75 return 0;
77} 76}
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index bbbc82a8336a..4097a86c4b5e 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -189,7 +189,7 @@ config USB_OTG
189 189
190config USB_GADGET_AT91 190config USB_GADGET_AT91
191 boolean "AT91 USB Device Port" 191 boolean "AT91 USB Device Port"
192 depends on ARCH_AT91RM9200 192 depends on ARCH_AT91
193 select USB_GADGET_SELECTED 193 select USB_GADGET_SELECTED
194 help 194 help
195 Many Atmel AT91 processors (such as the AT91RM2000) have a 195 Many Atmel AT91 processors (such as the AT91RM2000) have a
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 1c17d26d03b8..d15bf22b9a03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1833,9 +1833,9 @@ static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags)
1833 spin_unlock_irqrestore(&dev->req_lock, flags); 1833 spin_unlock_irqrestore(&dev->req_lock, flags);
1834} 1834}
1835 1835
1836static void eth_work (void *_dev) 1836static void eth_work (struct work_struct *work)
1837{ 1837{
1838 struct eth_dev *dev = _dev; 1838 struct eth_dev *dev = container_of(work, struct eth_dev, work);
1839 1839
1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) { 1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) {
1841 if (netif_running (dev->net)) 1841 if (netif_running (dev->net))
@@ -1894,13 +1894,13 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
1894 if (!eth_is_promisc (dev)) { 1894 if (!eth_is_promisc (dev)) {
1895 u8 *dest = skb->data; 1895 u8 *dest = skb->data;
1896 1896
1897 if (dest [0] & 0x01) { 1897 if (is_multicast_ether_addr(dest)) {
1898 u16 type; 1898 u16 type;
1899 1899
1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host 1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
1901 * SET_ETHERNET_MULTICAST_FILTERS requests 1901 * SET_ETHERNET_MULTICAST_FILTERS requests
1902 */ 1902 */
1903 if (memcmp (dest, net->broadcast, ETH_ALEN) == 0) 1903 if (is_broadcast_ether_addr(dest))
1904 type = USB_CDC_PACKET_TYPE_BROADCAST; 1904 type = USB_CDC_PACKET_TYPE_BROADCAST;
1905 else 1905 else
1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST; 1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
@@ -2398,7 +2398,7 @@ autoconf_fail:
2398 dev = netdev_priv(net); 2398 dev = netdev_priv(net);
2399 spin_lock_init (&dev->lock); 2399 spin_lock_init (&dev->lock);
2400 spin_lock_init (&dev->req_lock); 2400 spin_lock_init (&dev->req_lock);
2401 INIT_WORK (&dev->work, eth_work, dev); 2401 INIT_WORK (&dev->work, eth_work);
2402 INIT_LIST_HEAD (&dev->tx_reqs); 2402 INIT_LIST_HEAD (&dev->tx_reqs);
2403 INIT_LIST_HEAD (&dev->rx_reqs); 2403 INIT_LIST_HEAD (&dev->rx_reqs);
2404 2404
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 8b975d15538d..c98316ce8384 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -250,7 +250,7 @@
250#include <linux/slab.h> 250#include <linux/slab.h>
251#include <linux/spinlock.h> 251#include <linux/spinlock.h>
252#include <linux/string.h> 252#include <linux/string.h>
253#include <linux/suspend.h> 253#include <linux/freezer.h>
254#include <linux/utsname.h> 254#include <linux/utsname.h>
255 255
256#include <linux/usb_ch9.h> 256#include <linux/usb_ch9.h>
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 64554acad63f..31351826f2ba 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1236,7 +1236,7 @@ autoconf_fail:
1236 1236
1237 1237
1238 /* ok, we made sense of the hardware ... */ 1238 /* ok, we made sense of the hardware ... */
1239 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1239 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1240 if (!dev) { 1240 if (!dev) {
1241 return -ENOMEM; 1241 return -ENOMEM;
1242 } 1242 }
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index a3076da3f4eb..805a9826842d 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1864,7 +1864,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1864 } 1864 }
1865 1865
1866 /* alloc, and start init */ 1866 /* alloc, and start init */
1867 dev = kmalloc (sizeof *dev, SLAB_KERNEL); 1867 dev = kmalloc (sizeof *dev, GFP_KERNEL);
1868 if (dev == NULL){ 1868 if (dev == NULL){
1869 pr_debug("enomem %s\n", pci_name(pdev)); 1869 pr_debug("enomem %s\n", pci_name(pdev));
1870 retval = -ENOMEM; 1870 retval = -ENOMEM;
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 86924f9cdd7e..3fb1044a4db0 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -412,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */ 412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */
413 413
414 value = -ENOMEM; 414 value = -ENOMEM;
415 kbuf = kmalloc (len, SLAB_KERNEL); 415 kbuf = kmalloc (len, GFP_KERNEL);
416 if (unlikely (!kbuf)) 416 if (unlikely (!kbuf))
417 goto free1; 417 goto free1;
418 418
@@ -456,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ 456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
457 457
458 value = -ENOMEM; 458 value = -ENOMEM;
459 kbuf = kmalloc (len, SLAB_KERNEL); 459 kbuf = kmalloc (len, GFP_KERNEL);
460 if (!kbuf) 460 if (!kbuf)
461 goto free1; 461 goto free1;
462 if (copy_from_user (kbuf, buf, len)) { 462 if (copy_from_user (kbuf, buf, len)) {
@@ -1898,7 +1898,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1898 buf += 4; 1898 buf += 4;
1899 length -= 4; 1899 length -= 4;
1900 1900
1901 kbuf = kmalloc (length, SLAB_KERNEL); 1901 kbuf = kmalloc (length, GFP_KERNEL);
1902 if (!kbuf) 1902 if (!kbuf)
1903 return -ENOMEM; 1903 return -ENOMEM;
1904 if (copy_from_user (kbuf, buf, length)) { 1904 if (copy_from_user (kbuf, buf, length)) {
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 179259664c18..4a991564a03e 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -83,7 +83,6 @@ static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t);
83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); 83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *);
84static int lh7a40x_set_halt(struct usb_ep *ep, int); 84static int lh7a40x_set_halt(struct usb_ep *ep, int);
85static int lh7a40x_fifo_status(struct usb_ep *ep); 85static int lh7a40x_fifo_status(struct usb_ep *ep);
86static int lh7a40x_fifo_status(struct usb_ep *ep);
87static void lh7a40x_fifo_flush(struct usb_ep *ep); 86static void lh7a40x_fifo_flush(struct usb_ep *ep);
88static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep); 87static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep);
89static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr); 88static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3acc896a5d4c..3024c679e38e 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1040,6 +1040,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1040 1040
1041 } /* else the irq handler advances the queue. */ 1041 } /* else the irq handler advances the queue. */
1042 1042
1043 ep->responded = 1;
1043 if (req) 1044 if (req)
1044 list_add_tail (&req->queue, &ep->queue); 1045 list_add_tail (&req->queue, &ep->queue);
1045done: 1046done:
@@ -2188,7 +2189,8 @@ static void handle_ep_small (struct net2280_ep *ep)
2188 ep->stopped = 1; 2189 ep->stopped = 1;
2189 set_halt (ep); 2190 set_halt (ep);
2190 mode = 2; 2191 mode = 2;
2191 } else if (!req && !ep->stopped) 2192 } else if (ep->responded &&
2193 !req && !ep->stopped)
2192 write_fifo (ep, NULL); 2194 write_fifo (ep, NULL);
2193 } 2195 }
2194 } else { 2196 } else {
@@ -2203,7 +2205,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2203 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) 2205 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT))
2204 && req 2206 && req
2205 && req->req.actual == req->req.length) 2207 && req->req.actual == req->req.length)
2206 || !req) { 2208 || (ep->responded && !req)) {
2207 ep->dev->protocol_stall = 1; 2209 ep->dev->protocol_stall = 1;
2208 set_halt (ep); 2210 set_halt (ep);
2209 ep->stopped = 1; 2211 ep->stopped = 1;
@@ -2469,6 +2471,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2469 /* we made the hardware handle most lowlevel requests; 2471 /* we made the hardware handle most lowlevel requests;
2470 * everything else goes uplevel to the gadget code. 2472 * everything else goes uplevel to the gadget code.
2471 */ 2473 */
2474 ep->responded = 1;
2472 switch (u.r.bRequest) { 2475 switch (u.r.bRequest) {
2473 case USB_REQ_GET_STATUS: { 2476 case USB_REQ_GET_STATUS: {
2474 struct net2280_ep *e; 2477 struct net2280_ep *e;
@@ -2537,6 +2540,7 @@ delegate:
2537 u.r.bRequestType, u.r.bRequest, 2540 u.r.bRequestType, u.r.bRequest,
2538 w_value, w_index, w_length, 2541 w_value, w_index, w_length,
2539 readl (&ep->regs->ep_cfg)); 2542 readl (&ep->regs->ep_cfg));
2543 ep->responded = 0;
2540 spin_unlock (&dev->lock); 2544 spin_unlock (&dev->lock);
2541 tmp = dev->driver->setup (&dev->gadget, &u.r); 2545 tmp = dev->driver->setup (&dev->gadget, &u.r);
2542 spin_lock (&dev->lock); 2546 spin_lock (&dev->lock);
@@ -2857,7 +2861,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2857 } 2861 }
2858 2862
2859 /* alloc, and start init */ 2863 /* alloc, and start init */
2860 dev = kzalloc (sizeof *dev, SLAB_KERNEL); 2864 dev = kzalloc (sizeof *dev, GFP_KERNEL);
2861 if (dev == NULL){ 2865 if (dev == NULL){
2862 retval = -ENOMEM; 2866 retval = -ENOMEM;
2863 goto done; 2867 goto done;
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 957d6df34015..44ca139983d8 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -110,7 +110,8 @@ struct net2280_ep {
110 out_overflow : 1, 110 out_overflow : 1,
111 stopped : 1, 111 stopped : 1,
112 is_in : 1, 112 is_in : 1,
113 is_iso : 1; 113 is_iso : 1,
114 responded : 1;
114}; 115};
115 116
116static inline void allow_status (struct net2280_ep *ep) 117static inline void allow_status (struct net2280_ep *ep)
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 48a09fd89d18..030d87c28c2f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2581,7 +2581,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2581 /* UDC_PULLUP_EN gates the chip clock */ 2581 /* UDC_PULLUP_EN gates the chip clock */
2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN; 2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
2583 2583
2584 udc = kzalloc(sizeof(*udc), SLAB_KERNEL); 2584 udc = kzalloc(sizeof(*udc), GFP_KERNEL);
2585 if (!udc) 2585 if (!udc)
2586 return -ENOMEM; 2586 return -ENOMEM;
2587 2587
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 671c24bc6d75..1ed506e95985 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2472,6 +2472,7 @@ static struct pxa2xx_udc memory = {
2472#define PXA210_B1 0x00000123 2472#define PXA210_B1 0x00000123
2473#define PXA210_B0 0x00000122 2473#define PXA210_B0 0x00000122
2474#define IXP425_A0 0x000001c1 2474#define IXP425_A0 0x000001c1
2475#define IXP425_B0 0x000001f1
2475#define IXP465_AD 0x00000200 2476#define IXP465_AD 0x00000200
2476 2477
2477/* 2478/*
@@ -2509,6 +2510,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2509 break; 2510 break;
2510#elif defined(CONFIG_ARCH_IXP4XX) 2511#elif defined(CONFIG_ARCH_IXP4XX)
2511 case IXP425_A0: 2512 case IXP425_A0:
2513 case IXP425_B0:
2512 case IXP465_AD: 2514 case IXP465_AD:
2513 dev->has_cfr = 1; 2515 dev->has_cfr = 1;
2514 out_dma = 0; 2516 out_dma = 0;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0f809dd68492..40710ea1b490 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1190,7 +1190,7 @@ autoconf_fail:
1190 1190
1191 1191
1192 /* ok, we made sense of the hardware ... */ 1192 /* ok, we made sense of the hardware ... */
1193 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1193 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1194 if (!dev) 1194 if (!dev)
1195 return -ENOMEM; 1195 return -ENOMEM;
1196 spin_lock_init (&dev->lock); 1196 spin_lock_init (&dev->lock);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index cf10cbc98f80..cc60759083bf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -153,7 +153,7 @@ config USB_U132_HCD
153 adapter will *NOT* work with PC cards that do not contain an OHCI 153 adapter will *NOT* work with PC cards that do not contain an OHCI
154 controller. 154 controller.
155 155
156 For those PC cards that contain multiple OHCI controllers only ther 156 For those PC cards that contain multiple OHCI controllers only the
157 first one is used. 157 first one is used.
158 158
159 The driver consists of two modules, the "ftdi-elan" module is a 159 The driver consists of two modules, the "ftdi-elan" module is a
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 34b7a31cd85b..56349d21e6ea 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -492,7 +492,7 @@ show_periodic (struct class_device *class_dev, char *buf)
492 unsigned i; 492 unsigned i;
493 __le32 tag; 493 __le32 tag;
494 494
495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
496 return 0; 496 return 0;
497 seen_count = 0; 497 seen_count = 0;
498 498
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 9030994aba98..025d33313681 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -126,6 +126,11 @@ static unsigned park = 0;
126module_param (park, uint, S_IRUGO); 126module_param (park, uint, S_IRUGO);
127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); 127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
128 128
129/* for flakey hardware, ignore overcurrent indicators */
130static int ignore_oc = 0;
131module_param (ignore_oc, bool, S_IRUGO);
132MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
133
129#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 134#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
130 135
131/*-------------------------------------------------------------------------*/ 136/*-------------------------------------------------------------------------*/
@@ -541,9 +546,10 @@ static int ehci_run (struct usb_hcd *hcd)
541 546
542 temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); 547 temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
543 ehci_info (ehci, 548 ehci_info (ehci,
544 "USB %x.%x started, EHCI %x.%02x, driver %s\n", 549 "USB %x.%x started, EHCI %x.%02x, driver %s%s\n",
545 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 550 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
546 temp >> 8, temp & 0xff, DRIVER_VERSION); 551 temp >> 8, temp & 0xff, DRIVER_VERSION,
552 ignore_oc ? ", overcurrent ignored" : "");
547 553
548 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ 554 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
549 555
@@ -613,9 +619,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
613 unsigned i = HCS_N_PORTS (ehci->hcs_params); 619 unsigned i = HCS_N_PORTS (ehci->hcs_params);
614 620
615 /* resume root hub? */ 621 /* resume root hub? */
616 status = readl (&ehci->regs->command); 622 if (!(readl(&ehci->regs->command) & CMD_RUN))
617 if (!(status & CMD_RUN)) 623 usb_hcd_resume_root_hub(hcd);
618 writel (status | CMD_RUN, &ehci->regs->command);
619 624
620 while (i--) { 625 while (i--) {
621 int pstatus = readl (&ehci->regs->port_status [i]); 626 int pstatus = readl (&ehci->regs->port_status [i]);
@@ -632,7 +637,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
632 */ 637 */
633 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 638 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
634 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 639 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
635 usb_hcd_resume_root_hub(hcd);
636 } 640 }
637 } 641 }
638 642
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 1b20722c102b..bfe5f307cba6 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -34,6 +34,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
34{ 34{
35 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 35 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
36 int port; 36 int port;
37 int mask;
37 38
38 if (time_before (jiffies, ehci->next_statechange)) 39 if (time_before (jiffies, ehci->next_statechange))
39 msleep(5); 40 msleep(5);
@@ -51,14 +52,25 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
51 ehci->reclaim_ready = 1; 52 ehci->reclaim_ready = 1;
52 ehci_work(ehci); 53 ehci_work(ehci);
53 54
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 55 /* Unlike other USB host controller types, EHCI doesn't have
56 * any notion of "global" or bus-wide suspend. The driver has
57 * to manually suspend all the active unsuspended ports, and
58 * then manually resume them in the bus_resume() routine.
59 */
60 ehci->bus_suspended = 0;
55 while (port--) { 61 while (port--) {
56 u32 __iomem *reg = &ehci->regs->port_status [port]; 62 u32 __iomem *reg = &ehci->regs->port_status [port];
57 u32 t1 = readl (reg) & ~PORT_RWC_BITS; 63 u32 t1 = readl (reg) & ~PORT_RWC_BITS;
58 u32 t2 = t1; 64 u32 t2 = t1;
59 65
60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) 66 /* keep track of which ports we suspend */
67 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) &&
68 !(t1 & PORT_SUSPEND)) {
61 t2 |= PORT_SUSPEND; 69 t2 |= PORT_SUSPEND;
70 set_bit(port, &ehci->bus_suspended);
71 }
72
73 /* enable remote wakeup on all ports */
62 if (device_may_wakeup(&hcd->self.root_hub->dev)) 74 if (device_may_wakeup(&hcd->self.root_hub->dev))
63 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; 75 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
64 else 76 else
@@ -76,6 +88,13 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
76 ehci_halt (ehci); 88 ehci_halt (ehci);
77 hcd->state = HC_STATE_SUSPENDED; 89 hcd->state = HC_STATE_SUSPENDED;
78 90
91 /* allow remote wakeup */
92 mask = INTR_MASK;
93 if (!device_may_wakeup(&hcd->self.root_hub->dev))
94 mask &= ~STS_PCD;
95 writel(mask, &ehci->regs->intr_enable);
96 readl(&ehci->regs->intr_enable);
97
79 ehci->next_statechange = jiffies + msecs_to_jiffies(10); 98 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
80 spin_unlock_irq (&ehci->lock); 99 spin_unlock_irq (&ehci->lock);
81 return 0; 100 return 0;
@@ -88,7 +107,6 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
88 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 107 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
89 u32 temp; 108 u32 temp;
90 int i; 109 int i;
91 int intr_enable;
92 110
93 if (time_before (jiffies, ehci->next_statechange)) 111 if (time_before (jiffies, ehci->next_statechange))
94 msleep(5); 112 msleep(5);
@@ -100,31 +118,30 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
100 * the last user of the controller, not reset/pm hardware keeping 118 * the last user of the controller, not reset/pm hardware keeping
101 * state we gave to it. 119 * state we gave to it.
102 */ 120 */
121 temp = readl(&ehci->regs->intr_enable);
122 ehci_dbg(ehci, "resume root hub%s\n", temp ? "" : " after power loss");
103 123
104 /* re-init operational registers in case we lost power */ 124 /* at least some APM implementations will try to deliver
105 if (readl (&ehci->regs->intr_enable) == 0) { 125 * IRQs right away, so delay them until we're ready.
106 /* at least some APM implementations will try to deliver 126 */
107 * IRQs right away, so delay them until we're ready. 127 writel(0, &ehci->regs->intr_enable);
108 */ 128
109 intr_enable = 1; 129 /* re-init operational registers */
110 writel (0, &ehci->regs->segment); 130 writel(0, &ehci->regs->segment);
111 writel (ehci->periodic_dma, &ehci->regs->frame_list); 131 writel(ehci->periodic_dma, &ehci->regs->frame_list);
112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); 132 writel((u32) ehci->async->qh_dma, &ehci->regs->async_next);
113 } else
114 intr_enable = 0;
115 ehci_dbg(ehci, "resume root hub%s\n",
116 intr_enable ? " after power loss" : "");
117 133
118 /* restore CMD_RUN, framelist size, and irq threshold */ 134 /* restore CMD_RUN, framelist size, and irq threshold */
119 writel (ehci->command, &ehci->regs->command); 135 writel (ehci->command, &ehci->regs->command);
120 136
121 /* take ports out of suspend */ 137 /* manually resume the ports we suspended during bus_suspend() */
122 i = HCS_N_PORTS (ehci->hcs_params); 138 i = HCS_N_PORTS (ehci->hcs_params);
123 while (i--) { 139 while (i--) {
124 temp = readl (&ehci->regs->port_status [i]); 140 temp = readl (&ehci->regs->port_status [i]);
125 temp &= ~(PORT_RWC_BITS 141 temp &= ~(PORT_RWC_BITS
126 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); 142 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
127 if (temp & PORT_SUSPEND) { 143 if (test_bit(i, &ehci->bus_suspended) &&
144 (temp & PORT_SUSPEND)) {
128 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 145 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
129 temp |= PORT_RESUME; 146 temp |= PORT_RESUME;
130 } 147 }
@@ -134,11 +151,12 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
134 mdelay (20); 151 mdelay (20);
135 while (i--) { 152 while (i--) {
136 temp = readl (&ehci->regs->port_status [i]); 153 temp = readl (&ehci->regs->port_status [i]);
137 if ((temp & PORT_SUSPEND) == 0) 154 if (test_bit(i, &ehci->bus_suspended) &&
138 continue; 155 (temp & PORT_SUSPEND)) {
139 temp &= ~(PORT_RWC_BITS | PORT_RESUME); 156 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
140 writel (temp, &ehci->regs->port_status [i]); 157 writel (temp, &ehci->regs->port_status [i]);
141 ehci_vdbg (ehci, "resumed port %d\n", i + 1); 158 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
159 }
142 } 160 }
143 (void) readl (&ehci->regs->command); 161 (void) readl (&ehci->regs->command);
144 162
@@ -157,8 +175,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
157 hcd->state = HC_STATE_RUNNING; 175 hcd->state = HC_STATE_RUNNING;
158 176
159 /* Now we can safely re-enable irqs */ 177 /* Now we can safely re-enable irqs */
160 if (intr_enable) 178 writel(INTR_MASK, &ehci->regs->intr_enable);
161 writel (INTR_MASK, &ehci->regs->intr_enable);
162 179
163 spin_unlock_irq (&ehci->lock); 180 spin_unlock_irq (&ehci->lock);
164 return 0; 181 return 0;
@@ -218,6 +235,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
218{ 235{
219 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 236 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
220 u32 temp, status = 0; 237 u32 temp, status = 0;
238 u32 mask;
221 int ports, i, retval = 1; 239 int ports, i, retval = 1;
222 unsigned long flags; 240 unsigned long flags;
223 241
@@ -233,6 +251,18 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
233 retval++; 251 retval++;
234 } 252 }
235 253
254 /* Some boards (mostly VIA?) report bogus overcurrent indications,
255 * causing massive log spam unless we completely ignore them. It
256 * may be relevant that VIA VT8235 controlers, where PORT_POWER is
257 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
258 * PORT_POWER; that's surprising, but maybe within-spec.
259 */
260 if (!ignore_oc)
261 mask = PORT_CSC | PORT_PEC | PORT_OCC;
262 else
263 mask = PORT_CSC | PORT_PEC;
264 // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
265
236 /* no hub change reports (bit 0) for now (power, ...) */ 266 /* no hub change reports (bit 0) for now (power, ...) */
237 267
238 /* port N changes (bit N)? */ 268 /* port N changes (bit N)? */
@@ -250,8 +280,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
250 } 280 }
251 if (!(temp & PORT_CONNECT)) 281 if (!(temp & PORT_CONNECT))
252 ehci->reset_done [i] = 0; 282 ehci->reset_done [i] = 0;
253 if ((temp & (PORT_CSC | PORT_PEC | PORT_OCC)) != 0 283 if ((temp & mask) != 0
254 // PORT_STAT_C_SUSPEND?
255 || ((temp & PORT_RESUME) != 0 284 || ((temp & PORT_RESUME) != 0
256 && time_after (jiffies, 285 && time_after (jiffies,
257 ehci->reset_done [i]))) { 286 ehci->reset_done [i]))) {
@@ -319,6 +348,7 @@ static int ehci_hub_control (
319 u32 temp, status; 348 u32 temp, status;
320 unsigned long flags; 349 unsigned long flags;
321 int retval = 0; 350 int retval = 0;
351 unsigned selector;
322 352
323 /* 353 /*
324 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. 354 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
@@ -417,7 +447,7 @@ static int ehci_hub_control (
417 status |= 1 << USB_PORT_FEAT_C_CONNECTION; 447 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
418 if (temp & PORT_PEC) 448 if (temp & PORT_PEC)
419 status |= 1 << USB_PORT_FEAT_C_ENABLE; 449 status |= 1 << USB_PORT_FEAT_C_ENABLE;
420 if (temp & PORT_OCC) 450 if ((temp & PORT_OCC) && !ignore_oc)
421 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; 451 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
422 452
423 /* whoever resumes must GetPortStatus to complete it!! */ 453 /* whoever resumes must GetPortStatus to complete it!! */
@@ -506,6 +536,8 @@ static int ehci_hub_control (
506 } 536 }
507 break; 537 break;
508 case SetPortFeature: 538 case SetPortFeature:
539 selector = wIndex >> 8;
540 wIndex &= 0xff;
509 if (!wIndex || wIndex > ports) 541 if (!wIndex || wIndex > ports)
510 goto error; 542 goto error;
511 wIndex--; 543 wIndex--;
@@ -559,6 +591,22 @@ static int ehci_hub_control (
559 } 591 }
560 writel (temp, &ehci->regs->port_status [wIndex]); 592 writel (temp, &ehci->regs->port_status [wIndex]);
561 break; 593 break;
594
595 /* For downstream facing ports (these): one hub port is put
596 * into test mode according to USB2 11.24.2.13, then the hub
597 * must be reset (which for root hub now means rmmod+modprobe,
598 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
599 * about the EHCI-specific stuff.
600 */
601 case USB_PORT_FEAT_TEST:
602 if (!selector || selector > 5)
603 goto error;
604 ehci_quiesce(ehci);
605 ehci_halt(ehci);
606 temp |= selector << 16;
607 writel (temp, &ehci->regs->port_status [wIndex]);
608 break;
609
562 default: 610 default:
563 goto error; 611 goto error;
564 } 612 }
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index e51c1ed81ac4..4bc7970ba3ef 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -257,9 +257,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
257static int ehci_pci_resume(struct usb_hcd *hcd) 257static int ehci_pci_resume(struct usb_hcd *hcd)
258{ 258{
259 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 259 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
260 unsigned port;
261 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 260 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
262 int retval = -EINVAL;
263 261
264 // maybe restore FLADJ 262 // maybe restore FLADJ
265 263
@@ -269,27 +267,19 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
269 /* Mark hardware accessible again as we are out of D3 state by now */ 267 /* Mark hardware accessible again as we are out of D3 state by now */
270 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 268 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
271 269
272 /* If CF is clear, we lost PCI Vaux power and need to restart. */ 270 /* If CF is still set, we maintained PCI Vaux power.
273 if (readl(&ehci->regs->configured_flag) != FLAG_CF) 271 * Just undo the effect of ehci_pci_suspend().
274 goto restart;
275
276 /* If any port is suspended (or owned by the companion),
277 * we know we can/must resume the HC (and mustn't reset it).
278 * We just defer that to the root hub code.
279 */ 272 */
280 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 273 if (readl(&ehci->regs->configured_flag) == FLAG_CF) {
281 u32 status; 274 int mask = INTR_MASK;
282 port--; 275
283 status = readl(&ehci->regs->port_status [port]); 276 if (!device_may_wakeup(&hcd->self.root_hub->dev))
284 if (!(status & PORT_POWER)) 277 mask &= ~STS_PCD;
285 continue; 278 writel(mask, &ehci->regs->intr_enable);
286 if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { 279 readl(&ehci->regs->intr_enable);
287 usb_hcd_resume_root_hub(hcd); 280 return 0;
288 return 0;
289 }
290 } 281 }
291 282
292restart:
293 ehci_dbg(ehci, "lost power, restarting\n"); 283 ehci_dbg(ehci, "lost power, restarting\n");
294 usb_root_hub_lost_power(hcd->self.root_hub); 284 usb_root_hub_lost_power(hcd->self.root_hub);
295 285
@@ -307,13 +297,15 @@ restart:
307 ehci_work(ehci); 297 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 298 spin_unlock_irq(&ehci->lock);
309 299
310 /* restart; khubd will disconnect devices */
311 retval = ehci_run(hcd);
312
313 /* here we "know" root ports should always stay powered */ 300 /* here we "know" root ports should always stay powered */
314 ehci_port_power(ehci, 1); 301 ehci_port_power(ehci, 1);
315 302
316 return retval; 303 writel(ehci->command, &ehci->regs->command);
304 writel(FLAG_CF, &ehci->regs->configured_flag);
305 readl(&ehci->regs->command); /* unblock posted writes */
306
307 hcd->state = HC_STATE_SUSPENDED;
308 return 0;
317} 309}
318#endif 310#endif
319 311
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bbc3082a73d7..74dbc6c8228f 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -74,6 +74,7 @@ struct ehci_hcd { /* one per controller */
74 74
75 /* per root hub port */ 75 /* per root hub port */
76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; 76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS];
77 unsigned long bus_suspended;
77 78
78 /* per-HC memory pools (could be per-bus, but ...) */ 79 /* per-HC memory pools (could be per-bus, but ...) */
79 struct dma_pool *qh_pool; /* qh per active urb */ 80 struct dma_pool *qh_pool; /* qh per active urb */
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 87eca6aeacf2..9325e46a68c0 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -188,7 +188,7 @@ static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0);
188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \ 188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);} 189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
190 190
191#define SLAB_FLAG (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL) 191#define SLAB_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) 192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
193 193
194/* Most helpful debugging aid */ 194/* Most helpful debugging aid */
@@ -275,13 +275,13 @@ static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
275static int zout_buffer[4] __attribute__ ((aligned (4))); 275static int zout_buffer[4] __attribute__ ((aligned (4)));
276 276
277/* Cache for allocating new EP and SB descriptors. */ 277/* Cache for allocating new EP and SB descriptors. */
278static kmem_cache_t *usb_desc_cache; 278static struct kmem_cache *usb_desc_cache;
279 279
280/* Cache for the registers allocated in the top half. */ 280/* Cache for the registers allocated in the top half. */
281static kmem_cache_t *top_half_reg_cache; 281static struct kmem_cache *top_half_reg_cache;
282 282
283/* Cache for the data allocated in the isoc descr top half. */ 283/* Cache for the data allocated in the isoc descr top half. */
284static kmem_cache_t *isoc_compl_cache; 284static struct kmem_cache *isoc_compl_cache;
285 285
286static struct usb_bus *etrax_usb_bus; 286static struct usb_bus *etrax_usb_bus;
287 287
@@ -1743,7 +1743,7 @@ static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
1743 1743
1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do); 1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
1745 1745
1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC); 1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, GFP_ATOMIC);
1747 assert(comp_data != NULL); 1747 assert(comp_data != NULL);
1748 1748
1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data); 1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
@@ -3010,7 +3010,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3010 if (!urb->iso_frame_desc[i].length) 3010 if (!urb->iso_frame_desc[i].length)
3011 continue; 3011 continue;
3012 3012
3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3014 assert(next_sb_desc != NULL); 3014 assert(next_sb_desc != NULL);
3015 3015
3016 if (urb->iso_frame_desc[i].length > 0) { 3016 if (urb->iso_frame_desc[i].length > 0) {
@@ -3063,7 +3063,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3063 if (TxIsocEPList[epid].sub == 0) { 3063 if (TxIsocEPList[epid].sub == 0) {
3064 dbg_isoc("Isoc traffic not already running, allocating SB"); 3064 dbg_isoc("Isoc traffic not already running, allocating SB");
3065 3065
3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3067 assert(next_sb_desc != NULL); 3067 assert(next_sb_desc != NULL);
3068 3068
3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) | 3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
@@ -3317,7 +3317,7 @@ static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
3317 3317
3318 restore_flags(flags); 3318 restore_flags(flags);
3319 3319
3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC); 3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, GFP_ATOMIC);
3321 3321
3322 assert(reg != NULL); 3322 assert(reg != NULL);
3323 3323
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 8293c1d4be3f..0f47a57dac28 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -505,7 +505,7 @@ show_periodic (struct class_device *class_dev, char *buf)
505 char *next; 505 char *next;
506 unsigned i; 506 unsigned i;
507 507
508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
509 return 0; 509 return 0;
510 seen_count = 0; 510 seen_count = 0;
511 511
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9be6b303e784..b28a9b602066 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -715,13 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
715 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
716 } 716 }
717 717
718 if (ints & OHCI_INTR_RHSC) {
719 ohci_vdbg (ohci, "rhsc\n");
720 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
721 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
722 usb_hcd_poll_rh_status(hcd);
723 }
724
725 if (ints & OHCI_INTR_UE) { 718 if (ints & OHCI_INTR_UE) {
726 disable (ohci); 719 disable (ohci);
727 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); 720 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -731,9 +724,31 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
731 ohci_usb_reset (ohci); 724 ohci_usb_reset (ohci);
732 } 725 }
733 726
734 if (ints & OHCI_INTR_RD) { 727 if (ints & OHCI_INTR_RHSC) {
735 ohci_vdbg (ohci, "resume detect\n"); 728 ohci_vdbg(ohci, "rhsc\n");
736 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus);
732
733 /* NOTE: Vendors didn't always make the same implementation
734 * choices for RHSC. Many followed the spec; RHSC triggers
735 * on an edge, like setting and maybe clearing a port status
736 * change bit. With others it's level-triggered, active
737 * until khubd clears all the port status change bits. We'll
738 * always disable it here and rely on polling until khubd
739 * re-enables it.
740 */
741 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
742 usb_hcd_poll_rh_status(hcd);
743 }
744
745 /* For connect and disconnect events, we expect the controller
746 * to turn on RHSC along with RD. But for remote wakeup events
747 * this might not happen.
748 */
749 else if (ints & OHCI_INTR_RD) {
750 ohci_vdbg(ohci, "resume detect\n");
751 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
737 hcd->poll_rh = 1; 752 hcd->poll_rh = 1;
738 if (ohci->autostop) { 753 if (ohci->autostop) {
739 spin_lock (&ohci->lock); 754 spin_lock (&ohci->lock);
@@ -930,7 +945,7 @@ MODULE_LICENSE ("GPL");
930#include "ohci-ppc-soc.c" 945#include "ohci-ppc-soc.c"
931#endif 946#endif
932 947
933#if defined(CONFIG_ARCH_AT91RM9200) || defined(CONFIG_ARCH_AT91SAM9261) 948#ifdef CONFIG_ARCH_AT91
934#include "ohci-at91.c" 949#include "ohci-at91.c"
935#endif 950#endif
936 951
@@ -947,8 +962,7 @@ MODULE_LICENSE ("GPL");
947 || defined (CONFIG_ARCH_EP93XX) \ 962 || defined (CONFIG_ARCH_EP93XX) \
948 || defined (CONFIG_SOC_AU1X00) \ 963 || defined (CONFIG_SOC_AU1X00) \
949 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ 964 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
950 || defined (CONFIG_ARCH_AT91RM9200) \ 965 || defined (CONFIG_ARCH_AT91) \
951 || defined (CONFIG_ARCH_AT91SAM9261) \
952 || defined (CONFIG_ARCH_PNX4008) \ 966 || defined (CONFIG_ARCH_PNX4008) \
953 ) 967 )
954#error "missing bus glue for ohci-hcd" 968#error "missing bus glue for ohci-hcd"
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 6f113596af66..2441642cb7b4 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -41,7 +41,11 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
41{ 41{
42 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 42 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
43 43
44 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 44 spin_lock_irq(&ohci->lock);
45 if (!ohci->autostop)
46 del_timer(&hcd->rh_timer); /* Prevent next poll */
47 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
48 spin_unlock_irq(&ohci->lock);
45} 49}
46 50
47#define OHCI_SCHED_ENABLES \ 51#define OHCI_SCHED_ENABLES \
@@ -50,6 +54,9 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
50static void dl_done_list (struct ohci_hcd *); 54static void dl_done_list (struct ohci_hcd *);
51static void finish_unlinks (struct ohci_hcd *, u16); 55static void finish_unlinks (struct ohci_hcd *, u16);
52 56
57#ifdef CONFIG_PM
58static int ohci_restart(struct ohci_hcd *ohci);
59
53static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) 60static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop)
54__releases(ohci->lock) 61__releases(ohci->lock)
55__acquires(ohci->lock) 62__acquires(ohci->lock)
@@ -132,8 +139,6 @@ static inline struct ed *find_head (struct ed *ed)
132 return ed; 139 return ed;
133} 140}
134 141
135static int ohci_restart (struct ohci_hcd *ohci);
136
137/* caller has locked the root hub */ 142/* caller has locked the root hub */
138static int ohci_rh_resume (struct ohci_hcd *ohci) 143static int ohci_rh_resume (struct ohci_hcd *ohci)
139__releases(ohci->lock) 144__releases(ohci->lock)
@@ -169,7 +174,8 @@ __acquires(ohci->lock)
169 break; 174 break;
170 case OHCI_USB_RESUME: 175 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 176 /* HCFS changes sometime after INTR_RD */
172 ohci_info (ohci, "wakeup\n"); 177 ohci_dbg(ohci, "%swakeup root hub\n",
178 autostopped ? "auto-" : "");
173 break; 179 break;
174 case OHCI_USB_OPER: 180 case OHCI_USB_OPER:
175 /* this can happen after resuming a swsusp snapshot */ 181 /* this can happen after resuming a swsusp snapshot */
@@ -180,7 +186,6 @@ __acquires(ohci->lock)
180 ohci_dbg (ohci, "lost power\n"); 186 ohci_dbg (ohci, "lost power\n");
181 status = -EBUSY; 187 status = -EBUSY;
182 } 188 }
183#ifdef CONFIG_PM
184 if (status == -EBUSY) { 189 if (status == -EBUSY) {
185 if (!autostopped) { 190 if (!autostopped) {
186 spin_unlock_irq (&ohci->lock); 191 spin_unlock_irq (&ohci->lock);
@@ -190,25 +195,12 @@ __acquires(ohci->lock)
190 } 195 }
191 return status; 196 return status;
192 } 197 }
193#endif
194 if (status != -EINPROGRESS) 198 if (status != -EINPROGRESS)
195 return status; 199 return status;
196 if (autostopped) 200 if (autostopped)
197 goto skip_resume; 201 goto skip_resume;
198 spin_unlock_irq (&ohci->lock); 202 spin_unlock_irq (&ohci->lock);
199 203
200 temp = ohci->num_ports;
201 while (temp--) {
202 u32 stat = ohci_readl (ohci,
203 &ohci->regs->roothub.portstatus [temp]);
204
205 /* force global, not selective, resume */
206 if (!(stat & RH_PS_PSS))
207 continue;
208 ohci_writel (ohci, RH_PS_POCI,
209 &ohci->regs->roothub.portstatus [temp]);
210 }
211
212 /* Some controllers (lucent erratum) need extra-long delays */ 204 /* Some controllers (lucent erratum) need extra-long delays */
213 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); 205 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1);
214 206
@@ -216,6 +208,7 @@ __acquires(ohci->lock)
216 temp &= OHCI_CTRL_HCFS; 208 temp &= OHCI_CTRL_HCFS;
217 if (temp != OHCI_USB_RESUME) { 209 if (temp != OHCI_USB_RESUME) {
218 ohci_err (ohci, "controller won't resume\n"); 210 ohci_err (ohci, "controller won't resume\n");
211 spin_lock_irq(&ohci->lock);
219 return -EBUSY; 212 return -EBUSY;
220 } 213 }
221 214
@@ -295,8 +288,6 @@ skip_resume:
295 return 0; 288 return 0;
296} 289}
297 290
298#ifdef CONFIG_PM
299
300static int ohci_bus_suspend (struct usb_hcd *hcd) 291static int ohci_bus_suspend (struct usb_hcd *hcd)
301{ 292{
302 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 293 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
@@ -334,6 +325,83 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
334 return rc; 325 return rc;
335} 326}
336 327
328/* Carry out polling-, autostop-, and autoresume-related state changes */
329static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
330 int any_connected)
331{
332 int poll_rh = 1;
333
334 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
335
336 case OHCI_USB_OPER:
337 /* keep on polling until we know a device is connected
338 * and RHSC is enabled */
339 if (!ohci->autostop) {
340 if (any_connected ||
341 !device_may_wakeup(&ohci_to_hcd(ohci)
342 ->self.root_hub->dev)) {
343 if (ohci_readl(ohci, &ohci->regs->intrenable) &
344 OHCI_INTR_RHSC)
345 poll_rh = 0;
346 } else {
347 ohci->autostop = 1;
348 ohci->next_statechange = jiffies + HZ;
349 }
350
351 /* if no devices have been attached for one second, autostop */
352 } else {
353 if (changed || any_connected) {
354 ohci->autostop = 0;
355 ohci->next_statechange = jiffies +
356 STATECHANGE_DELAY;
357 } else if (time_after_eq(jiffies,
358 ohci->next_statechange)
359 && !ohci->ed_rm_list
360 && !(ohci->hc_control &
361 OHCI_SCHED_ENABLES)) {
362 ohci_rh_suspend(ohci, 1);
363 }
364 }
365 break;
366
367 /* if there is a port change, autostart or ask to be resumed */
368 case OHCI_USB_SUSPEND:
369 case OHCI_USB_RESUME:
370 if (changed) {
371 if (ohci->autostop)
372 ohci_rh_resume(ohci);
373 else
374 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
375 } else {
376 /* everything is idle, no need for polling */
377 poll_rh = 0;
378 }
379 break;
380 }
381 return poll_rh;
382}
383
384#else /* CONFIG_PM */
385
386static inline int ohci_rh_resume(struct ohci_hcd *ohci)
387{
388 return 0;
389}
390
391/* Carry out polling-related state changes.
392 * autostop isn't used when CONFIG_PM is turned off.
393 */
394static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
395 int any_connected)
396{
397 int poll_rh = 1;
398
399 /* keep on polling until RHSC is enabled */
400 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
401 poll_rh = 0;
402 return poll_rh;
403}
404
337#endif /* CONFIG_PM */ 405#endif /* CONFIG_PM */
338 406
339/*-------------------------------------------------------------------------*/ 407/*-------------------------------------------------------------------------*/
@@ -345,7 +413,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
345{ 413{
346 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 414 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
347 int i, changed = 0, length = 1; 415 int i, changed = 0, length = 1;
348 int any_connected = 0, rhsc_enabled = 1; 416 int any_connected = 0;
349 unsigned long flags; 417 unsigned long flags;
350 418
351 spin_lock_irqsave (&ohci->lock, flags); 419 spin_lock_irqsave (&ohci->lock, flags);
@@ -386,66 +454,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
386 } 454 }
387 } 455 }
388 456
389 /* NOTE: vendors didn't always make the same implementation 457 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed,
390 * choices for RHSC. Sometimes it triggers on an edge (like 458 any_connected);
391 * setting and maybe clearing a port status change bit); and
392 * it's level-triggered on other silicon, active until khubd
393 * clears all active port status change bits. If it's still
394 * set (level-triggered) we must disable it and rely on
395 * polling until khubd re-enables it.
396 */
397 if (ohci_readl (ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) {
398 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable);
399 (void) ohci_readl (ohci, &ohci->regs->intrdisable);
400 rhsc_enabled = 0;
401 }
402 hcd->poll_rh = 1;
403
404 /* carry out appropriate state changes */
405 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
406
407 case OHCI_USB_OPER:
408 /* keep on polling until we know a device is connected
409 * and RHSC is enabled */
410 if (!ohci->autostop) {
411 if (any_connected) {
412 if (rhsc_enabled)
413 hcd->poll_rh = 0;
414 } else {
415 ohci->autostop = 1;
416 ohci->next_statechange = jiffies + HZ;
417 }
418
419 /* if no devices have been attached for one second, autostop */
420 } else {
421 if (changed || any_connected) {
422 ohci->autostop = 0;
423 ohci->next_statechange = jiffies +
424 STATECHANGE_DELAY;
425 } else if (time_after_eq (jiffies,
426 ohci->next_statechange)
427 && !ohci->ed_rm_list
428 && !(ohci->hc_control &
429 OHCI_SCHED_ENABLES)) {
430 ohci_rh_suspend (ohci, 1);
431 }
432 }
433 break;
434
435 /* if there is a port change, autostart or ask to be resumed */
436 case OHCI_USB_SUSPEND:
437 case OHCI_USB_RESUME:
438 if (changed) {
439 if (ohci->autostop)
440 ohci_rh_resume (ohci);
441 else
442 usb_hcd_resume_root_hub (hcd);
443 } else {
444 /* everything is idle, no need for polling */
445 hcd->poll_rh = 0;
446 }
447 break;
448 }
449 459
450done: 460done:
451 spin_unlock_irqrestore (&ohci->lock, flags); 461 spin_unlock_irqrestore (&ohci->lock, flags);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 2dbb77414905..7f26f9bdbaf1 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -134,7 +134,7 @@ static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
134{ 134{
135 struct i2c_client *c; 135 struct i2c_client *c;
136 136
137 c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL); 137 c = (struct i2c_client *)kzalloc(sizeof(*c), GFP_KERNEL);
138 138
139 if (!c) 139 if (!c)
140 return -ENOMEM; 140 return -ENOMEM;
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 54f554e0f0ad..ac9f11d19817 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -169,21 +169,14 @@ static int sl811_cs_config(struct pcmcia_device *link)
169 169
170 DBG(0, "sl811_cs_config(0x%p)\n", link); 170 DBG(0, "sl811_cs_config(0x%p)\n", link);
171 171
172 tuple.DesiredTuple = CISTPL_CONFIG;
173 tuple.Attributes = 0;
174 tuple.TupleData = buf;
175 tuple.TupleDataMax = sizeof(buf);
176 tuple.TupleOffset = 0;
177 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
178 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
179 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
180 link->conf.ConfigBase = parse.config.base;
181 link->conf.Present = parse.config.rmask[0];
182
183 /* Look up the current Vcc */ 172 /* Look up the current Vcc */
184 CS_CHECK(GetConfigurationInfo, 173 CS_CHECK(GetConfigurationInfo,
185 pcmcia_get_configuration_info(link, &conf)); 174 pcmcia_get_configuration_info(link, &conf));
186 175
176 tuple.Attributes = 0;
177 tuple.TupleData = buf;
178 tuple.TupleDataMax = sizeof(buf);
179 tuple.TupleOffset = 0;
187 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 180 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
188 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 181 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
189 while (1) { 182 while (1) {
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 32c635ecbf31..a9d7119e3176 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -71,7 +71,7 @@ static int distrust_firmware = 1;
71module_param(distrust_firmware, bool, 0); 71module_param(distrust_firmware, bool, 0);
72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" 72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
73 "t setup"); 73 "t setup");
74DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); 74static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
75/* 75/*
76* u132_module_lock exists to protect access to global variables 76* u132_module_lock exists to protect access to global variables
77* 77*
@@ -163,7 +163,7 @@ struct u132_endp {
163 u16 queue_next; 163 u16 queue_next;
164 struct urb *urb_list[ENDP_QUEUE_SIZE]; 164 struct urb *urb_list[ENDP_QUEUE_SIZE];
165 struct list_head urb_more; 165 struct list_head urb_more;
166 struct work_struct scheduler; 166 struct delayed_work scheduler;
167}; 167};
168struct u132_ring { 168struct u132_ring {
169 unsigned in_use:1; 169 unsigned in_use:1;
@@ -171,7 +171,7 @@ struct u132_ring {
171 u8 number; 171 u8 number;
172 struct u132 *u132; 172 struct u132 *u132;
173 struct u132_endp *curr_endp; 173 struct u132_endp *curr_endp;
174 struct work_struct scheduler; 174 struct delayed_work scheduler;
175}; 175};
176#define OHCI_QUIRK_AMD756 0x01 176#define OHCI_QUIRK_AMD756 0x01
177#define OHCI_QUIRK_SUPERIO 0x02 177#define OHCI_QUIRK_SUPERIO 0x02
@@ -198,20 +198,16 @@ struct u132 {
198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
199 int flags; 199 int flags;
200 unsigned long next_statechange; 200 unsigned long next_statechange;
201 struct work_struct monitor; 201 struct delayed_work monitor;
202 int num_endpoints; 202 int num_endpoints;
203 struct u132_addr addr[MAX_U132_ADDRS]; 203 struct u132_addr addr[MAX_U132_ADDRS];
204 struct u132_udev udev[MAX_U132_UDEVS]; 204 struct u132_udev udev[MAX_U132_UDEVS];
205 struct u132_port port[MAX_U132_PORTS]; 205 struct u132_port port[MAX_U132_PORTS];
206 struct u132_endp *endp[MAX_U132_ENDPS]; 206 struct u132_endp *endp[MAX_U132_ENDPS];
207}; 207};
208int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data); 208
209int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs,
210 u8 width, u32 *data);
211int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs,
212 u8 width, u32 data);
213/* 209/*
214* these can not be inlines because we need the structure offset!! 210* these cannot be inlines because we need the structure offset!!
215* Does anyone have a better way????? 211* Does anyone have a better way?????
216*/ 212*/
217#define u132_read_pcimem(u132, member, data) \ 213#define u132_read_pcimem(u132, member, data) \
@@ -314,7 +310,7 @@ static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
314 if (delta > 0) { 310 if (delta > 0) {
315 if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 311 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
316 return; 312 return;
317 } else if (queue_work(workqueue, &ring->scheduler)) 313 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
318 return; 314 return;
319 kref_put(&u132->kref, u132_hcd_delete); 315 kref_put(&u132->kref, u132_hcd_delete);
320 return; 316 return;
@@ -393,12 +389,8 @@ static inline void u132_endp_init_kref(struct u132 *u132,
393static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
394 unsigned int delta) 390 unsigned int delta)
395{ 391{
396 if (delta > 0) { 392 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
397 if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 393 kref_get(&endp->kref);
398 kref_get(&endp->kref);
399 } else if (queue_work(workqueue, &endp->scheduler))
400 kref_get(&endp->kref);
401 return;
402} 394}
403 395
404static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 396static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
@@ -414,24 +406,14 @@ static inline void u132_monitor_put_kref(struct u132 *u132)
414 406
415static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 407static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
416{ 408{
417 if (delta > 0) { 409 if (queue_delayed_work(workqueue, &u132->monitor, delta))
418 if (queue_delayed_work(workqueue, &u132->monitor, delta)) { 410 kref_get(&u132->kref);
419 kref_get(&u132->kref);
420 }
421 } else if (queue_work(workqueue, &u132->monitor))
422 kref_get(&u132->kref);
423 return;
424} 411}
425 412
426static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) 413static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
427{ 414{
428 if (delta > 0) { 415 if (!queue_delayed_work(workqueue, &u132->monitor, delta))
429 if (queue_delayed_work(workqueue, &u132->monitor, delta)) 416 kref_put(&u132->kref, u132_hcd_delete);
430 return;
431 } else if (queue_work(workqueue, &u132->monitor))
432 return;
433 kref_put(&u132->kref, u132_hcd_delete);
434 return;
435} 417}
436 418
437static void u132_monitor_cancel_work(struct u132 *u132) 419static void u132_monitor_cancel_work(struct u132 *u132)
@@ -493,9 +475,9 @@ static int read_roothub_info(struct u132 *u132)
493 return 0; 475 return 0;
494} 476}
495 477
496static void u132_hcd_monitor_work(void *data) 478static void u132_hcd_monitor_work(struct work_struct *work)
497{ 479{
498 struct u132 *u132 = data; 480 struct u132 *u132 = container_of(work, struct u132, monitor.work);
499 if (u132->going > 1) { 481 if (u132->going > 1) {
500 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 482 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
501 , u132->going); 483 , u132->going);
@@ -1319,15 +1301,14 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1319 } 1301 }
1320} 1302}
1321 1303
1322static void u132_hcd_ring_work_scheduler(void *data);
1323static void u132_hcd_endp_work_scheduler(void *data);
1324/* 1304/*
1325* this work function is only executed from the work queue 1305* this work function is only executed from the work queue
1326* 1306*
1327*/ 1307*/
1328static void u132_hcd_ring_work_scheduler(void *data) 1308static void u132_hcd_ring_work_scheduler(struct work_struct *work)
1329{ 1309{
1330 struct u132_ring *ring = data; 1310 struct u132_ring *ring =
1311 container_of(work, struct u132_ring, scheduler.work);
1331 struct u132 *u132 = ring->u132; 1312 struct u132 *u132 = ring->u132;
1332 down(&u132->scheduler_lock); 1313 down(&u132->scheduler_lock);
1333 if (ring->in_use) { 1314 if (ring->in_use) {
@@ -1386,10 +1367,11 @@ static void u132_hcd_ring_work_scheduler(void *data)
1386 } 1367 }
1387} 1368}
1388 1369
1389static void u132_hcd_endp_work_scheduler(void *data) 1370static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1390{ 1371{
1391 struct u132_ring *ring; 1372 struct u132_ring *ring;
1392 struct u132_endp *endp = data; 1373 struct u132_endp *endp =
1374 container_of(work, struct u132_endp, scheduler.work);
1393 struct u132 *u132 = endp->u132; 1375 struct u132 *u132 = endp->u132;
1394 down(&u132->scheduler_lock); 1376 down(&u132->scheduler_lock);
1395 ring = endp->ring; 1377 ring = endp->ring;
@@ -1947,7 +1929,7 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
1947 if (!endp) { 1929 if (!endp) {
1948 return -ENOMEM; 1930 return -ENOMEM;
1949 } 1931 }
1950 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 1932 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
1951 spin_lock_init(&endp->queue_lock.slock); 1933 spin_lock_init(&endp->queue_lock.slock);
1952 INIT_LIST_HEAD(&endp->urb_more); 1934 INIT_LIST_HEAD(&endp->urb_more);
1953 ring = endp->ring = &u132->ring[0]; 1935 ring = endp->ring = &u132->ring[0];
@@ -2036,7 +2018,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
2036 if (!endp) { 2018 if (!endp) {
2037 return -ENOMEM; 2019 return -ENOMEM;
2038 } 2020 }
2039 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2021 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2040 spin_lock_init(&endp->queue_lock.slock); 2022 spin_lock_init(&endp->queue_lock.slock);
2041 INIT_LIST_HEAD(&endp->urb_more); 2023 INIT_LIST_HEAD(&endp->urb_more);
2042 endp->dequeueing = 0; 2024 endp->dequeueing = 0;
@@ -2121,7 +2103,7 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
2121 if (!endp) { 2103 if (!endp) {
2122 return -ENOMEM; 2104 return -ENOMEM;
2123 } 2105 }
2124 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2106 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2125 spin_lock_init(&endp->queue_lock.slock); 2107 spin_lock_init(&endp->queue_lock.slock);
2126 INIT_LIST_HEAD(&endp->urb_more); 2108 INIT_LIST_HEAD(&endp->urb_more);
2127 ring = endp->ring = &u132->ring[0]; 2109 ring = endp->ring = &u132->ring[0];
@@ -3045,7 +3027,7 @@ static struct hc_driver u132_hc_driver = {
3045* This function may be called by the USB core whilst the "usb_all_devices_rwsem" 3027* This function may be called by the USB core whilst the "usb_all_devices_rwsem"
3046* is held for writing, thus this module must not call usb_remove_hcd() 3028* is held for writing, thus this module must not call usb_remove_hcd()
3047* synchronously - but instead should immediately stop activity to the 3029* synchronously - but instead should immediately stop activity to the
3048* device and ansynchronously call usb_remove_hcd() 3030* device and asynchronously call usb_remove_hcd()
3049*/ 3031*/
3050static int __devexit u132_remove(struct platform_device *pdev) 3032static int __devexit u132_remove(struct platform_device *pdev)
3051{ 3033{
@@ -3100,10 +3082,10 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3100 ring->number = rings + 1; 3082 ring->number = rings + 1;
3101 ring->length = 0; 3083 ring->length = 0;
3102 ring->curr_endp = NULL; 3084 ring->curr_endp = NULL;
3103 INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler, 3085 INIT_DELAYED_WORK(&ring->scheduler,
3104 (void *)ring); 3086 u132_hcd_ring_work_scheduler);
3105 } down(&u132->sw_lock); 3087 } down(&u132->sw_lock);
3106 INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132); 3088 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
3107 while (ports-- > 0) { 3089 while (ports-- > 0) {
3108 struct u132_port *port = &u132->port[ports]; 3090 struct u132_port *port = &u132->port[ports];
3109 port->u132 = u132; 3091 port->u132 = u132;
@@ -3241,7 +3223,7 @@ static int u132_resume(struct platform_device *pdev)
3241#define u132_resume NULL 3223#define u132_resume NULL
3242#endif 3224#endif
3243/* 3225/*
3244* this driver is loaded explicitely by ftdi_u132 3226* this driver is loaded explicitly by ftdi_u132
3245* 3227*
3246* the platform_driver struct is static because it is per type of module 3228* the platform_driver struct is static because it is per type of module
3247*/ 3229*/
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 226bf3de8edd..e87692c31be4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debug level");
81static char *errbuf; 81static char *errbuf;
82#define ERRBUF_LEN (32 * 1024) 82#define ERRBUF_LEN (32 * 1024)
83 83
84static kmem_cache_t *uhci_up_cachep; /* urb_priv */ 84static struct kmem_cache *uhci_up_cachep; /* urb_priv */
85 85
86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state); 86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
87static void wakeup_rh(struct uhci_hcd *uhci); 87static void wakeup_rh(struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 06115f22a4fa..30b88459ac7d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -498,7 +498,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
498{ 498{
499 struct urb_priv *urbp; 499 struct urb_priv *urbp;
500 500
501 urbp = kmem_cache_alloc(uhci_up_cachep, SLAB_ATOMIC); 501 urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
502 if (!urbp) 502 if (!urbp)
503 return NULL; 503 return NULL;
504 504
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 3038ed0700d3..8ccddf74534a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -796,7 +796,7 @@ static int mts_usb_probe(struct usb_interface *intf,
796 796
797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL); 797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL);
798 if (!new_desc->context.scsi_status) 798 if (!new_desc->context.scsi_status)
799 goto out_kfree2; 799 goto out_free_urb;
800 800
801 new_desc->usb_dev = dev; 801 new_desc->usb_dev = dev;
802 new_desc->usb_intf = intf; 802 new_desc->usb_intf = intf;
@@ -822,18 +822,20 @@ static int mts_usb_probe(struct usb_interface *intf,
822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template, 822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template,
823 sizeof(new_desc)); 823 sizeof(new_desc));
824 if (!new_desc->host) 824 if (!new_desc->host)
825 goto out_free_urb; 825 goto out_kfree2;
826 826
827 new_desc->host->hostdata[0] = (unsigned long)new_desc; 827 new_desc->host->hostdata[0] = (unsigned long)new_desc;
828 if (scsi_add_host(new_desc->host, NULL)) { 828 if (scsi_add_host(new_desc->host, NULL)) {
829 err_retval = -EIO; 829 err_retval = -EIO;
830 goto out_free_urb; 830 goto out_host_put;
831 } 831 }
832 scsi_scan_host(new_desc->host); 832 scsi_scan_host(new_desc->host);
833 833
834 usb_set_intfdata(intf, new_desc); 834 usb_set_intfdata(intf, new_desc);
835 return 0; 835 return 0;
836 836
837 out_host_put:
838 scsi_host_put(new_desc->host);
837 out_kfree2: 839 out_kfree2:
838 kfree(new_desc->context.scsi_status); 840 kfree(new_desc->context.scsi_status);
839 out_free_urb: 841 out_free_urb:
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 20db36448ab3..661af7aa6236 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -221,6 +221,7 @@ config USB_TOUCHSCREEN
221 - ITM 221 - ITM
222 - some other eTurboTouch 222 - some other eTurboTouch
223 - Gunze AHL61 223 - Gunze AHL61
224 - DMC TSC-10/25
224 225
225 Have a look at <http://linux.chapter7.ch/touchkit/> for 226 Have a look at <http://linux.chapter7.ch/touchkit/> for
226 a usage description and the required user-space stuff. 227 a usage description and the required user-space stuff.
@@ -258,6 +259,11 @@ config USB_TOUCHSCREEN_GUNZE
258 bool "Gunze AHL61 device support" if EMBEDDED 259 bool "Gunze AHL61 device support" if EMBEDDED
259 depends on USB_TOUCHSCREEN 260 depends on USB_TOUCHSCREEN
260 261
262config USB_TOUCHSCREEN_DMC_TSC10
263 default y
264 bool "DMC TSC-10/25 device support" if EMBEDDED
265 depends on USB_TOUCHSCREEN
266
261config USB_YEALINK 267config USB_YEALINK
262 tristate "Yealink usb-p1k voip phone" 268 tristate "Yealink usb-p1k voip phone"
263 depends on USB && INPUT && EXPERIMENTAL 269 depends on USB && INPUT && EXPERIMENTAL
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 0096373b5f98..909138e5aa04 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -152,7 +152,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
152 if (!acecad || !input_dev) 152 if (!acecad || !input_dev)
153 goto fail1; 153 goto fail1;
154 154
155 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 155 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
156 if (!acecad->data) 156 if (!acecad->data)
157 goto fail1; 157 goto fail1;
158 158
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index bf428184608f..9f52429ce654 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -1988,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1988 goto fail1; 1988 goto fail1;
1989 1989
1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
1991 SLAB_ATOMIC, &aiptek->data_dma); 1991 GFP_ATOMIC, &aiptek->data_dma);
1992 if (!aiptek->data) 1992 if (!aiptek->data)
1993 goto fail1; 1993 goto fail1;
1994 1994
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index f659f3028ad2..b724e36f7b92 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -592,7 +592,7 @@ static void ati_remote_irq_in(struct urb *urb)
592 __FUNCTION__, urb->status); 592 __FUNCTION__, urb->status);
593 } 593 }
594 594
595 retval = usb_submit_urb(urb, SLAB_ATOMIC); 595 retval = usb_submit_urb(urb, GFP_ATOMIC);
596 if (retval) 596 if (retval)
597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", 597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
598 __FUNCTION__, retval); 598 __FUNCTION__, retval);
@@ -604,12 +604,12 @@ static void ati_remote_irq_in(struct urb *urb)
604static int ati_remote_alloc_buffers(struct usb_device *udev, 604static int ati_remote_alloc_buffers(struct usb_device *udev,
605 struct ati_remote *ati_remote) 605 struct ati_remote *ati_remote)
606{ 606{
607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
608 &ati_remote->inbuf_dma); 608 &ati_remote->inbuf_dma);
609 if (!ati_remote->inbuf) 609 if (!ati_remote->inbuf)
610 return -1; 610 return -1;
611 611
612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
613 &ati_remote->outbuf_dma); 613 &ati_remote->outbuf_dma);
614 if (!ati_remote->outbuf) 614 if (!ati_remote->outbuf)
615 return -1; 615 return -1;
@@ -630,19 +630,14 @@ static int ati_remote_alloc_buffers(struct usb_device *udev,
630 */ 630 */
631static void ati_remote_free_buffers(struct ati_remote *ati_remote) 631static void ati_remote_free_buffers(struct ati_remote *ati_remote)
632{ 632{
633 if (ati_remote->irq_urb) 633 usb_free_urb(ati_remote->irq_urb);
634 usb_free_urb(ati_remote->irq_urb); 634 usb_free_urb(ati_remote->out_urb);
635 635
636 if (ati_remote->out_urb) 636 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
637 usb_free_urb(ati_remote->out_urb); 637 ati_remote->inbuf, ati_remote->inbuf_dma);
638 638
639 if (ati_remote->inbuf) 639 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
640 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 640 ati_remote->outbuf, ati_remote->outbuf_dma);
641 ati_remote->inbuf, ati_remote->inbuf_dma);
642
643 if (ati_remote->outbuf)
644 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
645 ati_remote->inbuf, ati_remote->outbuf_dma);
646} 641}
647 642
648static void ati_remote_input_init(struct ati_remote *ati_remote) 643static void ati_remote_input_init(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index f982a2b4a7f9..83f1f79db7c7 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -372,8 +372,7 @@ static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
372 int i; 372 int i;
373 373
374 for (i = 0; i < 2; i++) { 374 for (i = 0; i < 2; i++) {
375 if (ar2->urb[i]) 375 usb_free_urb(ar2->urb[i]);
376 usb_free_urb(ar2->urb[i]);
377 376
378 if (ar2->buf[i]) 377 if (ar2->buf[i])
379 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]); 378 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 6095d9cedb7e..0811c39bd14f 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -968,20 +968,30 @@ static void hid_retry_timeout(unsigned long _hid)
968 hid_io_error(hid); 968 hid_io_error(hid);
969} 969}
970 970
971/* Workqueue routine to reset the device */ 971/* Workqueue routine to reset the device or clear a halt */
972static void hid_reset(void *_hid) 972static void hid_reset(struct work_struct *work)
973{ 973{
974 struct hid_device *hid = (struct hid_device *) _hid; 974 struct hid_device *hid =
975 int rc_lock, rc; 975 container_of(work, struct hid_device, reset_work);
976 976 int rc_lock, rc = 0;
977 dev_dbg(&hid->intf->dev, "resetting device\n"); 977
978 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf); 978 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
979 if (rc_lock >= 0) { 979 dev_dbg(&hid->intf->dev, "clear halt\n");
980 rc = usb_reset_composite_device(hid->dev, hid->intf); 980 rc = usb_clear_halt(hid->dev, hid->urbin->pipe);
981 if (rc_lock) 981 clear_bit(HID_CLEAR_HALT, &hid->iofl);
982 usb_unlock_device(hid->dev); 982 hid_start_in(hid);
983 }
984
985 else if (test_bit(HID_RESET_PENDING, &hid->iofl)) {
986 dev_dbg(&hid->intf->dev, "resetting device\n");
987 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
988 if (rc_lock >= 0) {
989 rc = usb_reset_composite_device(hid->dev, hid->intf);
990 if (rc_lock)
991 usb_unlock_device(hid->dev);
992 }
993 clear_bit(HID_RESET_PENDING, &hid->iofl);
983 } 994 }
984 clear_bit(HID_RESET_PENDING, &hid->iofl);
985 995
986 switch (rc) { 996 switch (rc) {
987 case 0: 997 case 0:
@@ -1023,9 +1033,8 @@ static void hid_io_error(struct hid_device *hid)
1023 1033
1024 /* Retries failed, so do a port reset */ 1034 /* Retries failed, so do a port reset */
1025 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) { 1035 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) {
1026 if (schedule_work(&hid->reset_work)) 1036 schedule_work(&hid->reset_work);
1027 goto done; 1037 goto done;
1028 clear_bit(HID_RESET_PENDING, &hid->iofl);
1029 } 1038 }
1030 } 1039 }
1031 1040
@@ -1049,6 +1058,11 @@ static void hid_irq_in(struct urb *urb)
1049 hid->retry_delay = 0; 1058 hid->retry_delay = 0;
1050 hid_input_report(HID_INPUT_REPORT, urb, 1); 1059 hid_input_report(HID_INPUT_REPORT, urb, 1);
1051 break; 1060 break;
1061 case -EPIPE: /* stall */
1062 clear_bit(HID_IN_RUNNING, &hid->iofl);
1063 set_bit(HID_CLEAR_HALT, &hid->iofl);
1064 schedule_work(&hid->reset_work);
1065 return;
1052 case -ECONNRESET: /* unlink */ 1066 case -ECONNRESET: /* unlink */
1053 case -ENOENT: 1067 case -ENOENT:
1054 case -ESHUTDOWN: /* unplug */ 1068 case -ESHUTDOWN: /* unplug */
@@ -1065,7 +1079,7 @@ static void hid_irq_in(struct urb *urb)
1065 warn("input irq status %d received", urb->status); 1079 warn("input irq status %d received", urb->status);
1066 } 1080 }
1067 1081
1068 status = usb_submit_urb(urb, SLAB_ATOMIC); 1082 status = usb_submit_urb(urb, GFP_ATOMIC);
1069 if (status) { 1083 if (status) {
1070 clear_bit(HID_IN_RUNNING, &hid->iofl); 1084 clear_bit(HID_IN_RUNNING, &hid->iofl);
1071 if (status != -EPERM) { 1085 if (status != -EPERM) {
@@ -1627,6 +1641,19 @@ void hid_init_reports(struct hid_device *hid)
1627 1641
1628#define USB_VENDOR_ID_APPLE 0x05ac 1642#define USB_VENDOR_ID_APPLE 0x05ac
1629#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 1643#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
1644#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
1645#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
1646#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
1647#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
1648#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
1649#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
1650#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
1651#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
1652#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
1653#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
1654#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
1655#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
1656#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
1630 1657
1631#define USB_VENDOR_ID_CHERRY 0x046a 1658#define USB_VENDOR_ID_CHERRY 0x046a
1632#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 1659#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
@@ -1797,16 +1824,19 @@ static const struct hid_blacklist {
1797 1824
1798 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, 1825 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION },
1799 1826
1800 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1827 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1801 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1828 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1802 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1829 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1803 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN }, 1830 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1804 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1831 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1805 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1832 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1806 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN }, 1833 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1807 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1834 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1808 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1835 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1809 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1836 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1837 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1838 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1839 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1810 1840
1811 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, 1841 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
1812 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, 1842 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
@@ -1839,13 +1869,13 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *
1839 1869
1840static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) 1870static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1841{ 1871{
1842 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) 1872 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->inbuf_dma)))
1843 return -1; 1873 return -1;
1844 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) 1874 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->outbuf_dma)))
1845 return -1; 1875 return -1;
1846 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) 1876 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), GFP_ATOMIC, &hid->cr_dma)))
1847 return -1; 1877 return -1;
1848 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) 1878 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->ctrlbuf_dma)))
1849 return -1; 1879 return -1;
1850 1880
1851 return 0; 1881 return 0;
@@ -1989,7 +2019,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1989 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 2019 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
1990 interval = hid_mousepoll_interval; 2020 interval = hid_mousepoll_interval;
1991 2021
1992 if (endpoint->bEndpointAddress & USB_DIR_IN) { 2022 if (usb_endpoint_dir_in(endpoint)) {
1993 if (hid->urbin) 2023 if (hid->urbin)
1994 continue; 2024 continue;
1995 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) 2025 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
@@ -2019,7 +2049,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2019 2049
2020 init_waitqueue_head(&hid->wait); 2050 init_waitqueue_head(&hid->wait);
2021 2051
2022 INIT_WORK(&hid->reset_work, hid_reset, hid); 2052 INIT_WORK(&hid->reset_work, hid_reset);
2023 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); 2053 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid);
2024 2054
2025 spin_lock_init(&hid->inlock); 2055 spin_lock_init(&hid->inlock);
@@ -2071,13 +2101,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2071 return hid; 2101 return hid;
2072 2102
2073fail: 2103fail:
2074 2104 usb_free_urb(hid->urbin);
2075 if (hid->urbin) 2105 usb_free_urb(hid->urbout);
2076 usb_free_urb(hid->urbin); 2106 usb_free_urb(hid->urbctrl);
2077 if (hid->urbout)
2078 usb_free_urb(hid->urbout);
2079 if (hid->urbctrl)
2080 usb_free_urb(hid->urbctrl);
2081 hid_free_buffers(dev, hid); 2107 hid_free_buffers(dev, hid);
2082 hid_free_device(hid); 2108 hid_free_device(hid);
2083 2109
@@ -2108,8 +2134,7 @@ static void hid_disconnect(struct usb_interface *intf)
2108 2134
2109 usb_free_urb(hid->urbin); 2135 usb_free_urb(hid->urbin);
2110 usb_free_urb(hid->urbctrl); 2136 usb_free_urb(hid->urbctrl);
2111 if (hid->urbout) 2137 usb_free_urb(hid->urbout);
2112 usb_free_urb(hid->urbout);
2113 2138
2114 hid_free_buffers(hid->dev, hid); 2139 hid_free_buffers(hid->dev, hid);
2115 hid_free_device(hid); 2140 hid_free_device(hid);
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index c8ce65c70a42..3a7e5fbff025 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -121,6 +121,12 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
121 { } 121 { }
122}; 122};
123 123
124static struct hidinput_key_translation powerbook_iso_keyboard[] = {
125 { KEY_GRAVE, KEY_102ND },
126 { KEY_102ND, KEY_GRAVE },
127 { }
128};
129
124static int usbhid_pb_fnmode = 1; 130static int usbhid_pb_fnmode = 1;
125module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644); 131module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
126MODULE_PARM_DESC(pb_fnmode, 132MODULE_PARM_DESC(pb_fnmode,
@@ -195,6 +201,14 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
195 } 201 }
196 } 202 }
197 203
204 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
205 trans = find_translation(powerbook_iso_keyboard, usage->code);
206 if (trans) {
207 input_event(input, usage->type, trans->to, value);
208 return 1;
209 }
210 }
211
198 return 0; 212 return 0;
199} 213}
200 214
@@ -210,6 +224,9 @@ static void hidinput_pb_setup(struct input_dev *input)
210 224
211 for (trans = powerbook_numlock_keys; trans->from; trans++) 225 for (trans = powerbook_numlock_keys; trans->from; trans++)
212 set_bit(trans->to, input->keybit); 226 set_bit(trans->to, input->keybit);
227
228 for (trans = powerbook_iso_keyboard; trans->from; trans++)
229 set_bit(trans->to, input->keybit);
213} 230}
214#else 231#else
215static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 232static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 8aa9ec08e8ab..76ad68d9edfd 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,7 +260,8 @@ struct hid_item {
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
262#define HID_QUIRK_INVERT_HWHEEL 0x00004000 262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
263#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000 263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
264#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00010000
264 265
265/* 266/*
266 * This is the global environment of the parser. This information is 267 * This is the global environment of the parser. This information is
@@ -385,6 +386,7 @@ struct hid_control_fifo {
385#define HID_IN_RUNNING 3 386#define HID_IN_RUNNING 3
386#define HID_RESET_PENDING 4 387#define HID_RESET_PENDING 4
387#define HID_SUSPENDED 5 388#define HID_SUSPENDED 5
389#define HID_CLEAR_HALT 6
388 390
389struct hid_input { 391struct hid_input {
390 struct list_head list; 392 struct list_head list;
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 50aa8108a50b..98bd323369c7 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -456,7 +456,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
456 remote->in_endpoint = endpoint; 456 remote->in_endpoint = endpoint;
457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
458 458
459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); 459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
460 if (!remote->in_buffer) { 460 if (!remote->in_buffer) {
461 retval = -ENOMEM; 461 retval = -ENOMEM;
462 goto fail1; 462 goto fail1;
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 79a85d46cb13..92c4e07da4c8 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -164,7 +164,7 @@ static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *m
164 dbg("%s - called", __FUNCTION__); 164 dbg("%s - called", __FUNCTION__);
165 165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 SLAB_ATOMIC, &mtouch->data_dma); 167 GFP_ATOMIC, &mtouch->data_dma);
168 168
169 if (!mtouch->data) 169 if (!mtouch->data)
170 return -1; 170 return -1;
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 0bf91778c40d..fea97e5437f8 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -277,12 +277,12 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) 277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
278{ 278{
279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX, 279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX,
280 SLAB_ATOMIC, &pm->data_dma); 280 GFP_ATOMIC, &pm->data_dma);
281 if (!pm->data) 281 if (!pm->data)
282 return -1; 282 return -1;
283 283
284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), 284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
285 SLAB_ATOMIC, &pm->configcr_dma); 285 GFP_ATOMIC, &pm->configcr_dma);
286 if (!pm->configcr) 286 if (!pm->configcr)
287 return -1; 287 return -1;
288 288
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 05c0d1ca39ab..2a314b065922 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -248,7 +248,7 @@ static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit) 248 struct touchkit_usb *touchkit)
249{ 249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE, 250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 SLAB_ATOMIC, &touchkit->data_dma); 251 GFP_ATOMIC, &touchkit->data_dma);
252 252
253 if (!touchkit->data) 253 if (!touchkit->data)
254 return -1; 254 return -1;
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index c73285cf8558..8505824848f6 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -122,7 +122,7 @@ static void usb_kbd_irq(struct urb *urb)
122 memcpy(kbd->old, kbd->new, 8); 122 memcpy(kbd->old, kbd->new, 8);
123 123
124resubmit: 124resubmit:
125 i = usb_submit_urb (urb, SLAB_ATOMIC); 125 i = usb_submit_urb (urb, GFP_ATOMIC);
126 if (i) 126 if (i)
127 err ("can't resubmit intr, %s-%s/input0, status %d", 127 err ("can't resubmit intr, %s-%s/input0, status %d",
128 kbd->usbdev->bus->bus_name, 128 kbd->usbdev->bus->bus_name,
@@ -196,11 +196,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
196 return -1; 196 return -1;
197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) 197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
198 return -1; 198 return -1;
199 if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma))) 199 if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
200 return -1; 200 return -1;
201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma))) 201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
202 return -1; 202 return -1;
203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma))) 203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
204 return -1; 204 return -1;
205 205
206 return 0; 206 return 0;
@@ -208,10 +208,8 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
208 208
209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) 209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
210{ 210{
211 if (kbd->irq) 211 usb_free_urb(kbd->irq);
212 usb_free_urb(kbd->irq); 212 usb_free_urb(kbd->led);
213 if (kbd->led)
214 usb_free_urb(kbd->led);
215 if (kbd->new) 213 if (kbd->new)
216 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); 214 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
217 if (kbd->cr) 215 if (kbd->cr)
@@ -236,9 +234,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
236 return -ENODEV; 234 return -ENODEV;
237 235
238 endpoint = &interface->endpoint[0].desc; 236 endpoint = &interface->endpoint[0].desc;
239 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 237 if (!usb_endpoint_is_int_in(endpoint))
240 return -ENODEV;
241 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
242 return -ENODEV; 238 return -ENODEV;
243 239
244 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 240 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index cbbbea332ed7..64a33e420cfb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -86,7 +86,7 @@ static void usb_mouse_irq(struct urb *urb)
86 86
87 input_sync(dev); 87 input_sync(dev);
88resubmit: 88resubmit:
89 status = usb_submit_urb (urb, SLAB_ATOMIC); 89 status = usb_submit_urb (urb, GFP_ATOMIC);
90 if (status) 90 if (status)
91 err ("can't resubmit intr, %s-%s/input0, status %d", 91 err ("can't resubmit intr, %s-%s/input0, status %d",
92 mouse->usbdev->bus->bus_name, 92 mouse->usbdev->bus->bus_name,
@@ -126,9 +126,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
126 return -ENODEV; 126 return -ENODEV;
127 127
128 endpoint = &interface->endpoint[0].desc; 128 endpoint = &interface->endpoint[0].desc;
129 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 129 if (!usb_endpoint_is_int_in(endpoint))
130 return -ENODEV;
131 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
132 return -ENODEV; 130 return -ENODEV;
133 131
134 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 132 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
@@ -139,7 +137,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
139 if (!mouse || !input_dev) 137 if (!mouse || !input_dev)
140 goto fail1; 138 goto fail1;
141 139
142 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); 140 mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma);
143 if (!mouse->data) 141 if (!mouse->data)
144 goto fail1; 142 goto fail1;
145 143
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 933ceddf3dee..7f3c57da9bc0 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -8,6 +8,7 @@
8 * - PanJit TouchSet 8 * - PanJit TouchSet
9 * - eTurboTouch 9 * - eTurboTouch
10 * - Gunze AHL61 10 * - Gunze AHL61
11 * - DMC TSC-10/25
11 * 12 *
12 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch> 13 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
13 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 14 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -30,6 +31,8 @@
30 * - ITM parts are from itmtouch.c 31 * - ITM parts are from itmtouch.c
31 * - 3M parts are from mtouchusb.c 32 * - 3M parts are from mtouchusb.c
32 * - PanJit parts are from an unmerged driver by Lanslott Gish 33 * - PanJit parts are from an unmerged driver by Lanslott Gish
34 * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
35 * driver from Marius Vollmer
33 * 36 *
34 *****************************************************************************/ 37 *****************************************************************************/
35 38
@@ -44,7 +47,7 @@
44#include <linux/usb/input.h> 47#include <linux/usb/input.h>
45 48
46 49
47#define DRIVER_VERSION "v0.4" 50#define DRIVER_VERSION "v0.5"
48#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" 51#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
49#define DRIVER_DESC "USB Touchscreen Driver" 52#define DRIVER_DESC "USB Touchscreen Driver"
50 53
@@ -103,6 +106,7 @@ enum {
103 DEVTYPE_ITM, 106 DEVTYPE_ITM,
104 DEVTYPE_ETURBO, 107 DEVTYPE_ETURBO,
105 DEVTYPE_GUNZE, 108 DEVTYPE_GUNZE,
109 DEVTYPE_DMC_TSC10,
106}; 110};
107 111
108static struct usb_device_id usbtouch_devices[] = { 112static struct usb_device_id usbtouch_devices[] = {
@@ -139,6 +143,10 @@ static struct usb_device_id usbtouch_devices[] = {
139 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE}, 143 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
140#endif 144#endif
141 145
146#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
147 {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
148#endif
149
142 {} 150 {}
143}; 151};
144 152
@@ -313,6 +321,80 @@ static int gunze_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *
313#endif 321#endif
314 322
315/***************************************************************************** 323/*****************************************************************************
324 * DMC TSC-10/25 Part
325 *
326 * Documentation about the controller and it's protocol can be found at
327 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
328 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
329 */
330#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
331
332/* supported data rates. currently using 130 */
333#define TSC10_RATE_POINT 0x50
334#define TSC10_RATE_30 0x40
335#define TSC10_RATE_50 0x41
336#define TSC10_RATE_80 0x42
337#define TSC10_RATE_100 0x43
338#define TSC10_RATE_130 0x44
339#define TSC10_RATE_150 0x45
340
341/* commands */
342#define TSC10_CMD_RESET 0x55
343#define TSC10_CMD_RATE 0x05
344#define TSC10_CMD_DATA1 0x01
345
346static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
347{
348 struct usb_device *dev = usbtouch->udev;
349 int ret;
350 unsigned char buf[2];
351
352 /* reset */
353 buf[0] = buf[1] = 0xFF;
354 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
355 TSC10_CMD_RESET,
356 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
357 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
358 if (ret < 0)
359 return ret;
360 if (buf[0] != 0x06 || buf[1] != 0x00)
361 return -ENODEV;
362
363 /* set coordinate output rate */
364 buf[0] = buf[1] = 0xFF;
365 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
366 TSC10_CMD_RATE,
367 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
368 TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
369 if (ret < 0)
370 return ret;
371 if (buf[0] != 0x06 || buf[1] != 0x00)
372 return -ENODEV;
373
374 /* start sending data */
375 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
376 TSC10_CMD_DATA1,
377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
378 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
379 if (ret < 0)
380 return ret;
381
382 return 0;
383}
384
385
386static int dmc_tsc10_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
387{
388 *x = ((pkt[2] & 0x03) << 8) | pkt[1];
389 *y = ((pkt[4] & 0x03) << 8) | pkt[3];
390 *touch = pkt[0] & 0x01;
391
392 return 1;
393}
394#endif
395
396
397/*****************************************************************************
316 * the different device descriptors 398 * the different device descriptors
317 */ 399 */
318static struct usbtouch_device_info usbtouch_dev_info[] = { 400static struct usbtouch_device_info usbtouch_dev_info[] = {
@@ -389,6 +471,18 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
389 .read_data = gunze_read_data, 471 .read_data = gunze_read_data,
390 }, 472 },
391#endif 473#endif
474
475#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
476 [DEVTYPE_DMC_TSC10] = {
477 .min_xc = 0x0,
478 .max_xc = 0x03ff,
479 .min_yc = 0x0,
480 .max_yc = 0x03ff,
481 .rept_size = 5,
482 .init = dmc_tsc10_init,
483 .read_data = dmc_tsc10_read_data,
484 },
485#endif
392}; 486};
393 487
394 488
@@ -586,7 +680,7 @@ static int usbtouch_probe(struct usb_interface *intf,
586 type->process_pkt = usbtouch_process_pkt; 680 type->process_pkt = usbtouch_process_pkt;
587 681
588 usbtouch->data = usb_buffer_alloc(udev, type->rept_size, 682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
589 SLAB_KERNEL, &usbtouch->data_dma); 683 GFP_KERNEL, &usbtouch->data_dma);
590 if (!usbtouch->data) 684 if (!usbtouch->data)
591 goto out_free; 685 goto out_free;
592 686
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 1cf08f02c50e..d85abfc5ab58 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -110,7 +110,6 @@ struct wacom_combo {
110}; 110};
111 111
112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
113extern void wacom_sys_irq(struct urb *urb);
114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 113extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 114extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data); 115extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index 3498b893b53b..e7cc20ab8155 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -42,7 +42,7 @@ static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
42 return wcombo->wacom->dev; 42 return wcombo->wacom->dev;
43} 43}
44 44
45void wacom_sys_irq(struct urb *urb) 45static void wacom_sys_irq(struct urb *urb)
46{ 46{
47 struct wacom *wacom = urb->context; 47 struct wacom *wacom = urb->context;
48 struct wacom_combo wcombo; 48 struct wacom_combo wcombo;
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index df97e5c803f9..e4bc76ebc835 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -325,7 +325,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
325 goto fail1; 325 goto fail1;
326 326
327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
328 SLAB_ATOMIC, &xpad->idata_dma); 328 GFP_ATOMIC, &xpad->idata_dma);
329 if (!xpad->idata) 329 if (!xpad->idata)
330 goto fail1; 330 goto fail1;
331 331
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 905bf6398257..caff8e6d7448 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -859,10 +859,8 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
859 859
860 interface = intf->cur_altsetting; 860 interface = intf->cur_altsetting;
861 endpoint = &interface->endpoint[0].desc; 861 endpoint = &interface->endpoint[0].desc;
862 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 862 if (!usb_endpoint_is_int_in(endpoint))
863 return -EIO; 863 return -ENODEV;
864 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
865 return -EIO;
866 864
867 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); 865 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL);
868 if (!yld) 866 if (!yld)
@@ -876,17 +874,17 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
876 874
877 /* allocate usb buffers */ 875 /* allocate usb buffers */
878 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
879 SLAB_ATOMIC, &yld->irq_dma); 877 GFP_ATOMIC, &yld->irq_dma);
880 if (yld->irq_data == NULL) 878 if (yld->irq_data == NULL)
881 return usb_cleanup(yld, -ENOMEM); 879 return usb_cleanup(yld, -ENOMEM);
882 880
883 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, 881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
884 SLAB_ATOMIC, &yld->ctl_dma); 882 GFP_ATOMIC, &yld->ctl_dma);
885 if (!yld->ctl_data) 883 if (!yld->ctl_data)
886 return usb_cleanup(yld, -ENOMEM); 884 return usb_cleanup(yld, -ENOMEM);
887 885
888 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), 886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
889 SLAB_ATOMIC, &yld->ctl_req_dma); 887 GFP_ATOMIC, &yld->ctl_req_dma);
890 if (yld->ctl_req == NULL) 888 if (yld->ctl_req == NULL)
891 return usb_cleanup(yld, -ENOMEM); 889 return usb_cleanup(yld, -ENOMEM);
892 890
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 11dc59540cda..2cba07d31971 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -4,6 +4,7 @@
4# 4#
5 5
6obj-$(CONFIG_USB_ADUTUX) += adutux.o 6obj-$(CONFIG_USB_ADUTUX) += adutux.o
7obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
7obj-$(CONFIG_USB_AUERSWALD) += auerswald.o 8obj-$(CONFIG_USB_AUERSWALD) += auerswald.o
8obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 9obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
9obj-$(CONFIG_USB_CYTHERM) += cytherm.o 10obj-$(CONFIG_USB_CYTHERM) += cytherm.o
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 6b23a1def9fe..02cbb7fff24f 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -76,7 +76,7 @@ struct appledisplay {
76 char *urbdata; /* interrupt URB data buffer */ 76 char *urbdata; /* interrupt URB data buffer */
77 char *msgdata; /* control message data buffer */ 77 char *msgdata; /* control message data buffer */
78 78
79 struct work_struct work; 79 struct delayed_work work;
80 int button_pressed; 80 int button_pressed;
81 spinlock_t lock; 81 spinlock_t lock;
82}; 82};
@@ -117,7 +117,7 @@ static void appledisplay_complete(struct urb *urb)
117 case ACD_BTN_BRIGHT_UP: 117 case ACD_BTN_BRIGHT_UP:
118 case ACD_BTN_BRIGHT_DOWN: 118 case ACD_BTN_BRIGHT_DOWN:
119 pdata->button_pressed = 1; 119 pdata->button_pressed = 1;
120 queue_work(wq, &pdata->work); 120 queue_delayed_work(wq, &pdata->work, 0);
121 break; 121 break;
122 case ACD_BTN_NONE: 122 case ACD_BTN_NONE:
123 default: 123 default:
@@ -184,9 +184,10 @@ static struct backlight_properties appledisplay_bl_data = {
184 .max_brightness = 0xFF 184 .max_brightness = 0xFF
185}; 185};
186 186
187static void appledisplay_work(void *private) 187static void appledisplay_work(struct work_struct *work)
188{ 188{
189 struct appledisplay *pdata = private; 189 struct appledisplay *pdata =
190 container_of(work, struct appledisplay, work.work);
190 int retval; 191 int retval;
191 192
192 up(&pdata->bd->sem); 193 up(&pdata->bd->sem);
@@ -216,10 +217,7 @@ static int appledisplay_probe(struct usb_interface *iface,
216 iface_desc = iface->cur_altsetting; 217 iface_desc = iface->cur_altsetting;
217 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 218 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
218 endpoint = &iface_desc->endpoint[i].desc; 219 endpoint = &iface_desc->endpoint[i].desc;
219 if (!int_in_endpointAddr && 220 if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
220 (endpoint->bEndpointAddress & USB_DIR_IN) &&
221 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
222 USB_ENDPOINT_XFER_INT)) {
223 /* we found an interrupt in endpoint */ 221 /* we found an interrupt in endpoint */
224 int_in_endpointAddr = endpoint->bEndpointAddress; 222 int_in_endpointAddr = endpoint->bEndpointAddress;
225 break; 223 break;
@@ -241,7 +239,7 @@ static int appledisplay_probe(struct usb_interface *iface,
241 pdata->udev = udev; 239 pdata->udev = udev;
242 240
243 spin_lock_init(&pdata->lock); 241 spin_lock_init(&pdata->lock);
244 INIT_WORK(&pdata->work, appledisplay_work, pdata); 242 INIT_DELAYED_WORK(&pdata->work, appledisplay_work);
245 243
246 /* Allocate buffer for control messages */ 244 /* Allocate buffer for control messages */
247 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); 245 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 0be9d62d62ae..c703f73e1655 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -704,9 +704,7 @@ static void auerbuf_free (pauerbuf_t bp)
704{ 704{
705 kfree(bp->bufp); 705 kfree(bp->bufp);
706 kfree(bp->dr); 706 kfree(bp->dr);
707 if (bp->urbp) { 707 usb_free_urb(bp->urbp);
708 usb_free_urb(bp->urbp);
709 }
710 kfree(bp); 708 kfree(bp);
711} 709}
712 710
@@ -780,7 +778,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
780 778
781bl_fail:/* not enough memory. Free allocated elements */ 779bl_fail:/* not enough memory. Free allocated elements */
782 dbg ("auerbuf_setup: no more memory"); 780 dbg ("auerbuf_setup: no more memory");
783 kfree(bep); 781 auerbuf_free(bep);
784 auerbuf_free_buffers (bcp); 782 auerbuf_free_buffers (bcp);
785 return -ENOMEM; 783 return -ENOMEM;
786} 784}
@@ -1155,8 +1153,7 @@ static void auerswald_int_release (pauerswald_t cp)
1155 dbg ("auerswald_int_release"); 1153 dbg ("auerswald_int_release");
1156 1154
1157 /* stop the int endpoint */ 1155 /* stop the int endpoint */
1158 if (cp->inturbp) 1156 usb_kill_urb (cp->inturbp);
1159 usb_kill_urb (cp->inturbp);
1160 1157
1161 /* deallocate memory */ 1158 /* deallocate memory */
1162 auerswald_int_free (cp); 1159 auerswald_int_free (cp);
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index 1fd9cb85f4ca..5c0a26cbd128 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -53,13 +53,12 @@ static void __exit emi26_exit (void);
53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
54{ 54{
55 int result; 55 int result;
56 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 56 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
57 57
58 if (!buffer) { 58 if (!buffer) {
59 err("emi26: kmalloc(%d) failed.", length); 59 err("emi26: kmalloc(%d) failed.", length);
60 return -ENOMEM; 60 return -ENOMEM;
61 } 61 }
62 memcpy (buffer, data, length);
63 /* Note: usb_control_msg returns negative value on error or length of the 62 /* Note: usb_control_msg returns negative value on error or length of the
64 * data that was written! */ 63 * data that was written! */
65 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 64 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index fe351371f274..23153eac0dfa 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -61,13 +61,12 @@ static void __exit emi62_exit (void);
61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
62{ 62{
63 int result; 63 int result;
64 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 64 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
65 65
66 if (!buffer) { 66 if (!buffer) {
67 err("emi62: kmalloc(%d) failed.", length); 67 err("emi62: kmalloc(%d) failed.", length);
68 return -ENOMEM; 68 return -ENOMEM;
69 } 69 }
70 memcpy (buffer, data, length);
71 /* Note: usb_control_msg returns negative value on error or length of the 70 /* Note: usb_control_msg returns negative value on error or length of the
72 * data that was written! */ 71 * data that was written! */
73 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 72 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 9b591b8b9369..18b1925032a8 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -156,9 +156,9 @@ struct usb_ftdi {
156 struct usb_device *udev; 156 struct usb_device *udev;
157 struct usb_interface *interface; 157 struct usb_interface *interface;
158 struct usb_class_driver *class; 158 struct usb_class_driver *class;
159 struct work_struct status_work; 159 struct delayed_work status_work;
160 struct work_struct command_work; 160 struct delayed_work command_work;
161 struct work_struct respond_work; 161 struct delayed_work respond_work;
162 struct u132_platform_data platform_data; 162 struct u132_platform_data platform_data;
163 struct resource resources[0]; 163 struct resource resources[0];
164 struct platform_device platform_dev; 164 struct platform_device platform_dev;
@@ -210,23 +210,14 @@ static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
210 210
211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
212{ 212{
213 if (delta > 0) { 213 if (!queue_delayed_work(status_queue, &ftdi->status_work, delta))
214 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 214 kref_put(&ftdi->kref, ftdi_elan_delete);
215 return;
216 } else if (queue_work(status_queue, &ftdi->status_work))
217 return;
218 kref_put(&ftdi->kref, ftdi_elan_delete);
219 return;
220} 215}
221 216
222static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 217static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
223{ 218{
224 if (delta > 0) { 219 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
225 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 220 kref_get(&ftdi->kref);
226 kref_get(&ftdi->kref);
227 } else if (queue_work(status_queue, &ftdi->status_work))
228 kref_get(&ftdi->kref);
229 return;
230} 221}
231 222
232static void ftdi_status_cancel_work(struct usb_ftdi *ftdi) 223static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
@@ -237,25 +228,14 @@ static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
237 228
238static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 229static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
239{ 230{
240 if (delta > 0) { 231 if (!queue_delayed_work(command_queue, &ftdi->command_work, delta))
241 if (queue_delayed_work(command_queue, &ftdi->command_work, 232 kref_put(&ftdi->kref, ftdi_elan_delete);
242 delta))
243 return;
244 } else if (queue_work(command_queue, &ftdi->command_work))
245 return;
246 kref_put(&ftdi->kref, ftdi_elan_delete);
247 return;
248} 233}
249 234
250static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 235static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
251{ 236{
252 if (delta > 0) { 237 if (queue_delayed_work(command_queue, &ftdi->command_work, delta))
253 if (queue_delayed_work(command_queue, &ftdi->command_work, 238 kref_get(&ftdi->kref);
254 delta))
255 kref_get(&ftdi->kref);
256 } else if (queue_work(command_queue, &ftdi->command_work))
257 kref_get(&ftdi->kref);
258 return;
259} 239}
260 240
261static void ftdi_command_cancel_work(struct usb_ftdi *ftdi) 241static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
@@ -267,25 +247,14 @@ static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
267static void ftdi_response_requeue_work(struct usb_ftdi *ftdi, 247static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
268 unsigned int delta) 248 unsigned int delta)
269{ 249{
270 if (delta > 0) { 250 if (!queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
271 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 251 kref_put(&ftdi->kref, ftdi_elan_delete);
272 delta))
273 return;
274 } else if (queue_work(respond_queue, &ftdi->respond_work))
275 return;
276 kref_put(&ftdi->kref, ftdi_elan_delete);
277 return;
278} 252}
279 253
280static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 254static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
281{ 255{
282 if (delta > 0) { 256 if (queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
283 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 257 kref_get(&ftdi->kref);
284 delta))
285 kref_get(&ftdi->kref);
286 } else if (queue_work(respond_queue, &ftdi->respond_work))
287 kref_get(&ftdi->kref);
288 return;
289} 258}
290 259
291static void ftdi_response_cancel_work(struct usb_ftdi *ftdi) 260static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
@@ -303,7 +272,7 @@ void ftdi_elan_gone_away(struct platform_device *pdev)
303 272
304 273
305EXPORT_SYMBOL_GPL(ftdi_elan_gone_away); 274EXPORT_SYMBOL_GPL(ftdi_elan_gone_away);
306void ftdi_release_platform_dev(struct device *dev) 275static void ftdi_release_platform_dev(struct device *dev)
307{ 276{
308 dev->parent = NULL; 277 dev->parent = NULL;
309} 278}
@@ -475,9 +444,11 @@ static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi)
475 return; 444 return;
476} 445}
477 446
478static void ftdi_elan_command_work(void *data) 447static void ftdi_elan_command_work(struct work_struct *work)
479{ 448{
480 struct usb_ftdi *ftdi = data; 449 struct usb_ftdi *ftdi =
450 container_of(work, struct usb_ftdi, command_work.work);
451
481 if (ftdi->disconnected > 0) { 452 if (ftdi->disconnected > 0) {
482 ftdi_elan_put_kref(ftdi); 453 ftdi_elan_put_kref(ftdi);
483 return; 454 return;
@@ -500,9 +471,10 @@ static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi)
500 return; 471 return;
501} 472}
502 473
503static void ftdi_elan_respond_work(void *data) 474static void ftdi_elan_respond_work(struct work_struct *work)
504{ 475{
505 struct usb_ftdi *ftdi = data; 476 struct usb_ftdi *ftdi =
477 container_of(work, struct usb_ftdi, respond_work.work);
506 if (ftdi->disconnected > 0) { 478 if (ftdi->disconnected > 0) {
507 ftdi_elan_put_kref(ftdi); 479 ftdi_elan_put_kref(ftdi);
508 return; 480 return;
@@ -534,9 +506,10 @@ static void ftdi_elan_respond_work(void *data)
534* after the FTDI has been synchronized 506* after the FTDI has been synchronized
535* 507*
536*/ 508*/
537static void ftdi_elan_status_work(void *data) 509static void ftdi_elan_status_work(struct work_struct *work)
538{ 510{
539 struct usb_ftdi *ftdi = data; 511 struct usb_ftdi *ftdi =
512 container_of(work, struct usb_ftdi, status_work.work);
540 int work_delay_in_msec = 0; 513 int work_delay_in_msec = 0;
541 if (ftdi->disconnected > 0) { 514 if (ftdi->disconnected > 0) {
542 ftdi_elan_put_kref(ftdi); 515 ftdi_elan_put_kref(ftdi);
@@ -1426,14 +1399,6 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data)
1426 } 1399 }
1427} 1400}
1428 1401
1429int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data)
1430{
1431 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1432 return ftdi_elan_read_reg(ftdi, data);
1433}
1434
1435
1436EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_reg);
1437static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, 1402static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset,
1438 u8 width, u32 *data) 1403 u8 width, u32 *data)
1439{ 1404{
@@ -2633,10 +2598,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2633 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 2598 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2634 endpoint = &iface_desc->endpoint[i].desc; 2599 endpoint = &iface_desc->endpoint[i].desc;
2635 if (!ftdi->bulk_in_endpointAddr && 2600 if (!ftdi->bulk_in_endpointAddr &&
2636 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2601 usb_endpoint_is_bulk_in(endpoint)) {
2637 == USB_DIR_IN) && ((endpoint->bmAttributes &
2638 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2639 {
2640 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 2602 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
2641 ftdi->bulk_in_size = buffer_size; 2603 ftdi->bulk_in_size = buffer_size;
2642 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; 2604 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
@@ -2649,10 +2611,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2649 } 2611 }
2650 } 2612 }
2651 if (!ftdi->bulk_out_endpointAddr && 2613 if (!ftdi->bulk_out_endpointAddr &&
2652 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2614 usb_endpoint_is_bulk_out(endpoint)) {
2653 == USB_DIR_OUT) && ((endpoint->bmAttributes &
2654 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2655 {
2656 ftdi->bulk_out_endpointAddr = 2615 ftdi->bulk_out_endpointAddr =
2657 endpoint->bEndpointAddress; 2616 endpoint->bEndpointAddress;
2658 } 2617 }
@@ -2691,12 +2650,9 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2691 ftdi->class = NULL; 2650 ftdi->class = NULL;
2692 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a" 2651 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a"
2693 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber); 2652 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber);
2694 INIT_WORK(&ftdi->status_work, ftdi_elan_status_work, 2653 INIT_DELAYED_WORK(&ftdi->status_work, ftdi_elan_status_work);
2695 (void *)ftdi); 2654 INIT_DELAYED_WORK(&ftdi->command_work, ftdi_elan_command_work);
2696 INIT_WORK(&ftdi->command_work, ftdi_elan_command_work, 2655 INIT_DELAYED_WORK(&ftdi->respond_work, ftdi_elan_respond_work);
2697 (void *)ftdi);
2698 INIT_WORK(&ftdi->respond_work, ftdi_elan_respond_work,
2699 (void *)ftdi);
2700 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000)); 2656 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000));
2701 return 0; 2657 return 0;
2702 } else { 2658 } else {
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 8e6e195a22ba..c9418535bef8 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -125,12 +125,12 @@ static DEFINE_MUTEX(disconnect_mutex);
125 125
126static int idmouse_create_image(struct usb_idmouse *dev) 126static int idmouse_create_image(struct usb_idmouse *dev)
127{ 127{
128 int bytes_read = 0; 128 int bytes_read;
129 int bulk_read = 0; 129 int bulk_read;
130 int result = 0; 130 int result;
131 131
132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1); 132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1);
133 bytes_read += sizeof(HEADER)-1; 133 bytes_read = sizeof(HEADER)-1;
134 134
135 /* reset the device and set a fast blink rate */ 135 /* reset the device and set a fast blink rate */
136 result = ftip_command(dev, FTIP_RELEASE, 0, 0); 136 result = ftip_command(dev, FTIP_RELEASE, 0, 0);
@@ -208,9 +208,9 @@ static inline void idmouse_delete(struct usb_idmouse *dev)
208 208
209static int idmouse_open(struct inode *inode, struct file *file) 209static int idmouse_open(struct inode *inode, struct file *file)
210{ 210{
211 struct usb_idmouse *dev = NULL; 211 struct usb_idmouse *dev;
212 struct usb_interface *interface; 212 struct usb_interface *interface;
213 int result = 0; 213 int result;
214 214
215 /* prevent disconnects */ 215 /* prevent disconnects */
216 mutex_lock(&disconnect_mutex); 216 mutex_lock(&disconnect_mutex);
@@ -305,7 +305,7 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count
305 loff_t * ppos) 305 loff_t * ppos)
306{ 306{
307 struct usb_idmouse *dev; 307 struct usb_idmouse *dev;
308 int result = 0; 308 int result;
309 309
310 dev = (struct usb_idmouse *) file->private_data; 310 dev = (struct usb_idmouse *) file->private_data;
311 311
@@ -329,7 +329,7 @@ static int idmouse_probe(struct usb_interface *interface,
329 const struct usb_device_id *id) 329 const struct usb_device_id *id)
330{ 330{
331 struct usb_device *udev = interface_to_usbdev(interface); 331 struct usb_device *udev = interface_to_usbdev(interface);
332 struct usb_idmouse *dev = NULL; 332 struct usb_idmouse *dev;
333 struct usb_host_interface *iface_desc; 333 struct usb_host_interface *iface_desc;
334 struct usb_endpoint_descriptor *endpoint; 334 struct usb_endpoint_descriptor *endpoint;
335 int result; 335 int result;
@@ -350,11 +350,7 @@ static int idmouse_probe(struct usb_interface *interface,
350 350
351 /* set up the endpoint information - use only the first bulk-in endpoint */ 351 /* set up the endpoint information - use only the first bulk-in endpoint */
352 endpoint = &iface_desc->endpoint[0].desc; 352 endpoint = &iface_desc->endpoint[0].desc;
353 if (!dev->bulk_in_endpointAddr 353 if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
354 && (endpoint->bEndpointAddress & USB_DIR_IN)
355 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
356 USB_ENDPOINT_XFER_BULK)) {
357
358 /* we found a bulk in endpoint */ 354 /* we found a bulk in endpoint */
359 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize); 355 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize);
360 dev->bulk_in_size = 0x200; /* works _much_ faster */ 356 dev->bulk_in_size = 0x200; /* works _much_ faster */
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 27089497e717..5dce797bddb7 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -317,12 +317,8 @@ static inline void tower_delete (struct lego_usb_tower *dev)
317 tower_abort_transfers (dev); 317 tower_abort_transfers (dev);
318 318
319 /* free data structures */ 319 /* free data structures */
320 if (dev->interrupt_in_urb != NULL) { 320 usb_free_urb(dev->interrupt_in_urb);
321 usb_free_urb (dev->interrupt_in_urb); 321 usb_free_urb(dev->interrupt_out_urb);
322 }
323 if (dev->interrupt_out_urb != NULL) {
324 usb_free_urb (dev->interrupt_out_urb);
325 }
326 kfree (dev->read_buffer); 322 kfree (dev->read_buffer);
327 kfree (dev->interrupt_in_buffer); 323 kfree (dev->interrupt_in_buffer);
328 kfree (dev->interrupt_out_buffer); 324 kfree (dev->interrupt_out_buffer);
@@ -502,15 +498,11 @@ static void tower_abort_transfers (struct lego_usb_tower *dev)
502 if (dev->interrupt_in_running) { 498 if (dev->interrupt_in_running) {
503 dev->interrupt_in_running = 0; 499 dev->interrupt_in_running = 0;
504 mb(); 500 mb();
505 if (dev->interrupt_in_urb != NULL && dev->udev) { 501 if (dev->udev)
506 usb_kill_urb (dev->interrupt_in_urb); 502 usb_kill_urb (dev->interrupt_in_urb);
507 }
508 }
509 if (dev->interrupt_out_busy) {
510 if (dev->interrupt_out_urb != NULL && dev->udev) {
511 usb_kill_urb (dev->interrupt_out_urb);
512 }
513 } 503 }
504 if (dev->interrupt_out_busy && dev->udev)
505 usb_kill_urb(dev->interrupt_out_urb);
514 506
515exit: 507exit:
516 dbg(2, "%s: leave", __FUNCTION__); 508 dbg(2, "%s: leave", __FUNCTION__);
@@ -898,14 +890,11 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
898 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 890 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
899 endpoint = &iface_desc->endpoint[i].desc; 891 endpoint = &iface_desc->endpoint[i].desc;
900 892
901 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 893 if (usb_endpoint_xfer_int(endpoint)) {
902 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { 894 if (usb_endpoint_dir_in(endpoint))
903 dev->interrupt_in_endpoint = endpoint; 895 dev->interrupt_in_endpoint = endpoint;
904 } 896 else
905 897 dev->interrupt_out_endpoint = endpoint;
906 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
907 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
908 dev->interrupt_out_endpoint = endpoint;
909 } 898 }
910 } 899 }
911 if(dev->interrupt_in_endpoint == NULL) { 900 if(dev->interrupt_in_endpoint == NULL) {
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index abb4dcd811ac..371bf2b1197d 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -81,8 +81,8 @@ struct interfacekit {
81 unsigned char *data; 81 unsigned char *data;
82 dma_addr_t data_dma; 82 dma_addr_t data_dma;
83 83
84 struct work_struct do_notify; 84 struct delayed_work do_notify;
85 struct work_struct do_resubmit; 85 struct delayed_work do_resubmit;
86 unsigned long input_events; 86 unsigned long input_events;
87 unsigned long sensor_events; 87 unsigned long sensor_events;
88}; 88};
@@ -374,19 +374,20 @@ static void interfacekit_irq(struct urb *urb)
374 } 374 }
375 375
376 if (kit->input_events || kit->sensor_events) 376 if (kit->input_events || kit->sensor_events)
377 schedule_work(&kit->do_notify); 377 schedule_delayed_work(&kit->do_notify, 0);
378 378
379resubmit: 379resubmit:
380 status = usb_submit_urb(urb, SLAB_ATOMIC); 380 status = usb_submit_urb(urb, GFP_ATOMIC);
381 if (status) 381 if (status)
382 err("can't resubmit intr, %s-%s/interfacekit0, status %d", 382 err("can't resubmit intr, %s-%s/interfacekit0, status %d",
383 kit->udev->bus->bus_name, 383 kit->udev->bus->bus_name,
384 kit->udev->devpath, status); 384 kit->udev->devpath, status);
385} 385}
386 386
387static void do_notify(void *data) 387static void do_notify(struct work_struct *work)
388{ 388{
389 struct interfacekit *kit = data; 389 struct interfacekit *kit =
390 container_of(work, struct interfacekit, do_notify.work);
390 int i; 391 int i;
391 char sysfs_file[8]; 392 char sysfs_file[8];
392 393
@@ -405,9 +406,11 @@ static void do_notify(void *data)
405 } 406 }
406} 407}
407 408
408static void do_resubmit(void *data) 409static void do_resubmit(struct work_struct *work)
409{ 410{
410 set_outputs(data); 411 struct interfacekit *kit =
412 container_of(work, struct interfacekit, do_resubmit.work);
413 set_outputs(kit);
411} 414}
412 415
413#define show_set_output(value) \ 416#define show_set_output(value) \
@@ -551,7 +554,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
551 return -ENODEV; 554 return -ENODEV;
552 555
553 endpoint = &interface->endpoint[0].desc; 556 endpoint = &interface->endpoint[0].desc;
554 if (!(endpoint->bEndpointAddress & 0x80)) 557 if (!usb_endpoint_dir_in(endpoint))
555 return -ENODEV; 558 return -ENODEV;
556 /* 559 /*
557 * bmAttributes 560 * bmAttributes
@@ -565,7 +568,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
565 568
566 kit->dev_no = -1; 569 kit->dev_no = -1;
567 kit->ifkit = ifkit; 570 kit->ifkit = ifkit;
568 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); 571 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
569 if (!kit->data) 572 if (!kit->data)
570 goto out; 573 goto out;
571 574
@@ -575,8 +578,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
575 578
576 kit->udev = usb_get_dev(dev); 579 kit->udev = usb_get_dev(dev);
577 kit->intf = intf; 580 kit->intf = intf;
578 INIT_WORK(&kit->do_notify, do_notify, kit); 581 INIT_DELAYED_WORK(&kit->do_notify, do_notify);
579 INIT_WORK(&kit->do_resubmit, do_resubmit, kit); 582 INIT_DELAYED_WORK(&kit->do_resubmit, do_resubmit);
580 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, 583 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
581 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 584 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
582 interfacekit_irq, kit, endpoint->bInterval); 585 interfacekit_irq, kit, endpoint->bInterval);
@@ -650,8 +653,7 @@ out2:
650 device_remove_file(kit->dev, &dev_output_attrs[i]); 653 device_remove_file(kit->dev, &dev_output_attrs[i]);
651out: 654out:
652 if (kit) { 655 if (kit) {
653 if (kit->irq) 656 usb_free_urb(kit->irq);
654 usb_free_urb(kit->irq);
655 if (kit->data) 657 if (kit->data)
656 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma); 658 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma);
657 if (kit->dev) 659 if (kit->dev)
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 5c780cab92e0..5727e1ea2f91 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -41,7 +41,7 @@ struct motorcontrol {
41 unsigned char *data; 41 unsigned char *data;
42 dma_addr_t data_dma; 42 dma_addr_t data_dma;
43 43
44 struct work_struct do_notify; 44 struct delayed_work do_notify;
45 unsigned long input_events; 45 unsigned long input_events;
46 unsigned long speed_events; 46 unsigned long speed_events;
47 unsigned long exceed_events; 47 unsigned long exceed_events;
@@ -148,10 +148,10 @@ static void motorcontrol_irq(struct urb *urb)
148 set_bit(1, &mc->exceed_events); 148 set_bit(1, &mc->exceed_events);
149 149
150 if (mc->input_events || mc->exceed_events || mc->speed_events) 150 if (mc->input_events || mc->exceed_events || mc->speed_events)
151 schedule_work(&mc->do_notify); 151 schedule_delayed_work(&mc->do_notify, 0);
152 152
153resubmit: 153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC); 154 status = usb_submit_urb(urb, GFP_ATOMIC);
155 if (status) 155 if (status)
156 dev_err(&mc->intf->dev, 156 dev_err(&mc->intf->dev,
157 "can't resubmit intr, %s-%s/motorcontrol0, status %d", 157 "can't resubmit intr, %s-%s/motorcontrol0, status %d",
@@ -159,9 +159,10 @@ resubmit:
159 mc->udev->devpath, status); 159 mc->udev->devpath, status);
160} 160}
161 161
162static void do_notify(void *data) 162static void do_notify(struct work_struct *work)
163{ 163{
164 struct motorcontrol *mc = data; 164 struct motorcontrol *mc =
165 container_of(work, struct motorcontrol, do_notify.work);
165 int i; 166 int i;
166 char sysfs_file[8]; 167 char sysfs_file[8];
167 168
@@ -323,7 +324,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
323 return -ENODEV; 324 return -ENODEV;
324 325
325 endpoint = &interface->endpoint[0].desc; 326 endpoint = &interface->endpoint[0].desc;
326 if (!(endpoint->bEndpointAddress & 0x80)) 327 if (!usb_endpoint_dir_in(endpoint))
327 return -ENODEV; 328 return -ENODEV;
328 329
329 /* 330 /*
@@ -337,7 +338,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
337 goto out; 338 goto out;
338 339
339 mc->dev_no = -1; 340 mc->dev_no = -1;
340 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma); 341 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
341 if (!mc->data) 342 if (!mc->data)
342 goto out; 343 goto out;
343 344
@@ -348,7 +349,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
348 mc->udev = usb_get_dev(dev); 349 mc->udev = usb_get_dev(dev);
349 mc->intf = intf; 350 mc->intf = intf;
350 mc->acceleration[0] = mc->acceleration[1] = 10; 351 mc->acceleration[0] = mc->acceleration[1] = 10;
351 INIT_WORK(&mc->do_notify, do_notify, mc); 352 INIT_DELAYED_WORK(&mc->do_notify, do_notify);
352 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data, 353 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
353 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 354 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
354 motorcontrol_irq, mc, endpoint->bInterval); 355 motorcontrol_irq, mc, endpoint->bInterval);
@@ -392,8 +393,7 @@ out2:
392 device_remove_file(mc->dev, &dev_attrs[i]); 393 device_remove_file(mc->dev, &dev_attrs[i]);
393out: 394out:
394 if (mc) { 395 if (mc) {
395 if (mc->irq) 396 usb_free_urb(mc->irq);
396 usb_free_urb(mc->irq);
397 if (mc->data) 397 if (mc->data)
398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma); 398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma);
399 if (mc->dev) 399 if (mc->dev)
diff --git a/drivers/usb/misc/usb_u132.h b/drivers/usb/misc/usb_u132.h
index 551ba8906d62..dc2e5a31caec 100644
--- a/drivers/usb/misc/usb_u132.h
+++ b/drivers/usb/misc/usb_u132.h
@@ -52,7 +52,7 @@
52* the kernel to load the "u132-hcd" module. 52* the kernel to load the "u132-hcd" module.
53* 53*
54* The "ftdi-u132" module provides the interface to the inserted 54* The "ftdi-u132" module provides the interface to the inserted
55* PC card and the "u132-hcd" module uses the API to send and recieve 55* PC card and the "u132-hcd" module uses the API to send and receive
56* data. The API features call-backs, so that part of the "u132-hcd" 56* data. The API features call-backs, so that part of the "u132-hcd"
57* module code will run in the context of one of the kernel threads 57* module code will run in the context of one of the kernel threads
58* of the "ftdi-u132" module. 58* of the "ftdi-u132" module.
@@ -95,3 +95,7 @@ int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number,
95 int halted, int skipped, int actual, int non_null)); 95 int halted, int skipped, int actual, int non_null));
96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number, 96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number,
97 void *endp); 97 void *endp);
98int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset,
99 u8 width, u32 *data);
100int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset,
101 u8 width, u32 data);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 7c2cbdf81d20..fb321864a92d 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -138,7 +138,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
138 default: 138 default:
139 continue; 139 continue;
140 } 140 }
141 if (e->desc.bEndpointAddress & USB_DIR_IN) { 141 if (usb_endpoint_dir_in(&e->desc)) {
142 if (!in) 142 if (!in)
143 in = e; 143 in = e;
144 } else { 144 } else {
@@ -147,7 +147,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
147 } 147 }
148 continue; 148 continue;
149try_iso: 149try_iso:
150 if (e->desc.bEndpointAddress & USB_DIR_IN) { 150 if (usb_endpoint_dir_in(&e->desc)) {
151 if (!iso_in) 151 if (!iso_in)
152 iso_in = e; 152 iso_in = e;
153 } else { 153 } else {
@@ -213,7 +213,7 @@ static struct urb *simple_alloc_urb (
213 213
214 if (bytes < 0) 214 if (bytes < 0)
215 return NULL; 215 return NULL;
216 urb = usb_alloc_urb (0, SLAB_KERNEL); 216 urb = usb_alloc_urb (0, GFP_KERNEL);
217 if (!urb) 217 if (!urb)
218 return urb; 218 return urb;
219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); 219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
@@ -223,7 +223,7 @@ static struct urb *simple_alloc_urb (
223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
224 if (usb_pipein (pipe)) 224 if (usb_pipein (pipe))
225 urb->transfer_flags |= URB_SHORT_NOT_OK; 225 urb->transfer_flags |= URB_SHORT_NOT_OK;
226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
227 &urb->transfer_dma); 227 &urb->transfer_dma);
228 if (!urb->transfer_buffer) { 228 if (!urb->transfer_buffer) {
229 usb_free_urb (urb); 229 usb_free_urb (urb);
@@ -315,7 +315,7 @@ static int simple_io (
315 init_completion (&completion); 315 init_completion (&completion);
316 if (usb_pipeout (urb->pipe)) 316 if (usb_pipeout (urb->pipe))
317 simple_fill_buf (urb); 317 simple_fill_buf (urb);
318 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) 318 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
319 break; 319 break;
320 320
321 /* NOTE: no timeouts; can't be broken out of by interrupt */ 321 /* NOTE: no timeouts; can't be broken out of by interrupt */
@@ -374,7 +374,7 @@ alloc_sglist (int nents, int max, int vary)
374 unsigned i; 374 unsigned i;
375 unsigned size = max; 375 unsigned size = max;
376 376
377 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); 377 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
378 if (!sg) 378 if (!sg)
379 return NULL; 379 return NULL;
380 380
@@ -382,7 +382,7 @@ alloc_sglist (int nents, int max, int vary)
382 char *buf; 382 char *buf;
383 unsigned j; 383 unsigned j;
384 384
385 buf = kzalloc (size, SLAB_KERNEL); 385 buf = kzalloc (size, GFP_KERNEL);
386 if (!buf) { 386 if (!buf) {
387 free_sglist (sg, i); 387 free_sglist (sg, i);
388 return NULL; 388 return NULL;
@@ -428,7 +428,7 @@ static int perform_sglist (
428 (udev->speed == USB_SPEED_HIGH) 428 (udev->speed == USB_SPEED_HIGH)
429 ? (INTERRUPT_RATE << 3) 429 ? (INTERRUPT_RATE << 3)
430 : INTERRUPT_RATE, 430 : INTERRUPT_RATE,
431 sg, nents, 0, SLAB_KERNEL); 431 sg, nents, 0, GFP_KERNEL);
432 432
433 if (retval) 433 if (retval)
434 break; 434 break;
@@ -819,7 +819,7 @@ error:
819 819
820 /* resubmit if we need to, else mark this as done */ 820 /* resubmit if we need to, else mark this as done */
821 if ((status == 0) && (ctx->pending < ctx->count)) { 821 if ((status == 0) && (ctx->pending < ctx->count)) {
822 if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) { 822 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
823 dbg ("can't resubmit ctrl %02x.%02x, err %d", 823 dbg ("can't resubmit ctrl %02x.%02x, err %d",
824 reqp->bRequestType, reqp->bRequest, status); 824 reqp->bRequestType, reqp->bRequest, status);
825 urb->dev = NULL; 825 urb->dev = NULL;
@@ -855,7 +855,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
855 * as with bulk/intr sglists, sglen is the queue depth; it also 855 * as with bulk/intr sglists, sglen is the queue depth; it also
856 * controls which subtests run (more tests than sglen) or rerun. 856 * controls which subtests run (more tests than sglen) or rerun.
857 */ 857 */
858 urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL); 858 urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);
859 if (!urb) 859 if (!urb)
860 return -ENOMEM; 860 return -ENOMEM;
861 for (i = 0; i < param->sglen; i++) { 861 for (i = 0; i < param->sglen; i++) {
@@ -981,7 +981,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
981 if (!u) 981 if (!u)
982 goto cleanup; 982 goto cleanup;
983 983
984 reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL, 984 reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
985 &u->setup_dma); 985 &u->setup_dma);
986 if (!reqp) 986 if (!reqp)
987 goto cleanup; 987 goto cleanup;
@@ -999,7 +999,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
999 context.urb = urb; 999 context.urb = urb;
1000 spin_lock_irq (&context.lock); 1000 spin_lock_irq (&context.lock);
1001 for (i = 0; i < param->sglen; i++) { 1001 for (i = 0; i < param->sglen; i++) {
1002 context.status = usb_submit_urb (urb [i], SLAB_ATOMIC); 1002 context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
1003 if (context.status != 0) { 1003 if (context.status != 0) {
1004 dbg ("can't submit urb[%d], status %d", 1004 dbg ("can't submit urb[%d], status %d",
1005 i, context.status); 1005 i, context.status);
@@ -1041,7 +1041,7 @@ static void unlink1_callback (struct urb *urb)
1041 1041
1042 // we "know" -EPIPE (stall) never happens 1042 // we "know" -EPIPE (stall) never happens
1043 if (!status) 1043 if (!status)
1044 status = usb_submit_urb (urb, SLAB_ATOMIC); 1044 status = usb_submit_urb (urb, GFP_ATOMIC);
1045 if (status) { 1045 if (status) {
1046 urb->status = status; 1046 urb->status = status;
1047 complete ((struct completion *) urb->context); 1047 complete ((struct completion *) urb->context);
@@ -1067,7 +1067,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1067 * FIXME want additional tests for when endpoint is STALLing 1067 * FIXME want additional tests for when endpoint is STALLing
1068 * due to errors, or is just NAKing requests. 1068 * due to errors, or is just NAKing requests.
1069 */ 1069 */
1070 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) { 1070 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); 1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval);
1072 return retval; 1072 return retval;
1073 } 1073 }
@@ -1251,7 +1251,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1251 if (length < 1 || length > 0xffff || vary >= length) 1251 if (length < 1 || length > 0xffff || vary >= length)
1252 return -EINVAL; 1252 return -EINVAL;
1253 1253
1254 buf = kmalloc(length, SLAB_KERNEL); 1254 buf = kmalloc(length, GFP_KERNEL);
1255 if (!buf) 1255 if (!buf)
1256 return -ENOMEM; 1256 return -ENOMEM;
1257 1257
@@ -1403,7 +1403,7 @@ static struct urb *iso_alloc_urb (
1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1404 packets = (bytes + maxp - 1) / maxp; 1404 packets = (bytes + maxp - 1) / maxp;
1405 1405
1406 urb = usb_alloc_urb (packets, SLAB_KERNEL); 1406 urb = usb_alloc_urb (packets, GFP_KERNEL);
1407 if (!urb) 1407 if (!urb)
1408 return urb; 1408 return urb;
1409 urb->dev = udev; 1409 urb->dev = udev;
@@ -1411,7 +1411,7 @@ static struct urb *iso_alloc_urb (
1411 1411
1412 urb->number_of_packets = packets; 1412 urb->number_of_packets = packets;
1413 urb->transfer_buffer_length = bytes; 1413 urb->transfer_buffer_length = bytes;
1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
1415 &urb->transfer_dma); 1415 &urb->transfer_dma);
1416 if (!urb->transfer_buffer) { 1416 if (!urb->transfer_buffer) {
1417 usb_free_urb (urb); 1417 usb_free_urb (urb);
@@ -1481,7 +1481,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1481 spin_lock_irq (&context.lock); 1481 spin_lock_irq (&context.lock);
1482 for (i = 0; i < param->sglen; i++) { 1482 for (i = 0; i < param->sglen; i++) {
1483 ++context.pending; 1483 ++context.pending;
1484 status = usb_submit_urb (urbs [i], SLAB_ATOMIC); 1484 status = usb_submit_urb (urbs [i], GFP_ATOMIC);
1485 if (status < 0) { 1485 if (status < 0) {
1486 ERROR (dev, "submit iso[%d], error %d\n", i, status); 1486 ERROR (dev, "submit iso[%d], error %d\n", i, status);
1487 if (i == 0) { 1487 if (i == 0) {
@@ -1900,7 +1900,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1900 } 1900 }
1901#endif 1901#endif
1902 1902
1903 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1903 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1904 if (!dev) 1904 if (!dev)
1905 return -ENOMEM; 1905 return -ENOMEM;
1906 info = (struct usbtest_info *) id->driver_info; 1906 info = (struct usbtest_info *) id->driver_info;
@@ -1910,7 +1910,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1910 dev->intf = intf; 1910 dev->intf = intf;
1911 1911
1912 /* cacheline-aligned scratch for i/o */ 1912 /* cacheline-aligned scratch for i/o */
1913 if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) { 1913 if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
1914 kfree (dev); 1914 kfree (dev);
1915 return -ENOMEM; 1915 return -ENOMEM;
1916 } 1916 }
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 7a2346c53284..05cf2c9a8f84 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -50,7 +50,7 @@ struct mon_event_text {
50 50
51#define SLAB_NAME_SZ 30 51#define SLAB_NAME_SZ 30
52struct mon_reader_text { 52struct mon_reader_text {
53 kmem_cache_t *e_slab; 53 struct kmem_cache *e_slab;
54 int nevents; 54 int nevents;
55 struct list_head e_list; 55 struct list_head e_list;
56 struct mon_reader r; /* In C, parent class can be placed anywhere */ 56 struct mon_reader r; /* In C, parent class can be placed anywhere */
@@ -63,7 +63,7 @@ struct mon_reader_text {
63 char slab_name[SLAB_NAME_SZ]; 63 char slab_name[SLAB_NAME_SZ];
64}; 64};
65 65
66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long); 66static void mon_text_ctor(void *, struct kmem_cache *, unsigned long);
67 67
68/* 68/*
69 * mon_text_submit 69 * mon_text_submit
@@ -147,7 +147,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
147 stamp = mon_get_timestamp(); 147 stamp = mon_get_timestamp();
148 148
149 if (rp->nevents >= EVENT_MAX || 149 if (rp->nevents >= EVENT_MAX ||
150 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 150 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
151 rp->r.m_bus->cnt_text_lost++; 151 rp->r.m_bus->cnt_text_lost++;
152 return; 152 return;
153 } 153 }
@@ -188,7 +188,7 @@ static void mon_text_error(void *data, struct urb *urb, int error)
188 struct mon_event_text *ep; 188 struct mon_event_text *ep;
189 189
190 if (rp->nevents >= EVENT_MAX || 190 if (rp->nevents >= EVENT_MAX ||
191 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 191 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
192 rp->r.m_bus->cnt_text_lost++; 192 rp->r.m_bus->cnt_text_lost++;
193 return; 193 return;
194 } 194 }
@@ -450,7 +450,7 @@ const struct file_operations mon_fops_text = {
450/* 450/*
451 * Slab interface: constructor. 451 * Slab interface: constructor.
452 */ 452 */
453static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags) 453static void mon_text_ctor(void *mem, struct kmem_cache *slab, unsigned long sflags)
454{ 454{
455 /* 455 /*
456 * Nothing to initialize. No, really! 456 * Nothing to initialize. No, really!
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 881841e600de..95e682e2c9d6 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -249,9 +249,9 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
249 249
250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; 250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
251 req->bRequest = cmd; 251 req->bRequest = cmd;
252 req->wValue = value; 252 req->wValue = cpu_to_le16(value);
253 req->wIndex = index; 253 req->wIndex = cpu_to_le16(index);
254 req->wLength = size; 254 req->wLength = cpu_to_le16(size);
255 255
256 usb_fill_control_urb(urb, dev->udev, 256 usb_fill_control_urb(urb, dev->udev,
257 usb_sndctrlpipe(dev->udev, 0), 257 usb_sndctrlpipe(dev->udev, 0),
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index f740325abac4..4852012735f6 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -345,7 +345,7 @@ static void catc_irq_done(struct urb *urb)
345 } 345 }
346 } 346 }
347resubmit: 347resubmit:
348 status = usb_submit_urb (urb, SLAB_ATOMIC); 348 status = usb_submit_urb (urb, GFP_ATOMIC);
349 if (status) 349 if (status)
350 err ("can't resubmit intr, %s-%s, status %d", 350 err ("can't resubmit intr, %s-%s, status %d",
351 catc->usbdev->bus->bus_name, 351 catc->usbdev->bus->bus_name,
@@ -786,14 +786,10 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
786 if ((!catc->ctrl_urb) || (!catc->tx_urb) || 786 if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
787 (!catc->rx_urb) || (!catc->irq_urb)) { 787 (!catc->rx_urb) || (!catc->irq_urb)) {
788 err("No free urbs available."); 788 err("No free urbs available.");
789 if (catc->ctrl_urb) 789 usb_free_urb(catc->ctrl_urb);
790 usb_free_urb(catc->ctrl_urb); 790 usb_free_urb(catc->tx_urb);
791 if (catc->tx_urb) 791 usb_free_urb(catc->rx_urb);
792 usb_free_urb(catc->tx_urb); 792 usb_free_urb(catc->irq_urb);
793 if (catc->rx_urb)
794 usb_free_urb(catc->rx_urb);
795 if (catc->irq_urb)
796 usb_free_urb(catc->irq_urb);
797 free_netdev(netdev); 793 free_netdev(netdev);
798 return -ENOMEM; 794 return -ENOMEM;
799 } 795 }
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index f6971b88349d..44a91547146e 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -200,8 +200,7 @@ next_desc:
200 200
201 dev->status = &info->control->cur_altsetting->endpoint [0]; 201 dev->status = &info->control->cur_altsetting->endpoint [0];
202 desc = &dev->status->desc; 202 desc = &dev->status->desc;
203 if (desc->bmAttributes != USB_ENDPOINT_XFER_INT 203 if (!usb_endpoint_is_int_in(desc)
204 || !(desc->bEndpointAddress & USB_DIR_IN)
205 || (le16_to_cpu(desc->wMaxPacketSize) 204 || (le16_to_cpu(desc->wMaxPacketSize)
206 < sizeof(struct usb_cdc_notification)) 205 < sizeof(struct usb_cdc_notification))
207 || !desc->bInterval) { 206 || !desc->bInterval) {
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 7c906a43e497..fa78326d0bf0 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -222,7 +222,7 @@ struct kaweth_device
222 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
223 int linkstate; 223 int linkstate;
224 int opened; 224 int opened;
225 struct work_struct lowmem_work; 225 struct delayed_work lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
228 struct net_device *net; 228 struct net_device *net;
@@ -530,9 +530,10 @@ resubmit:
530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); 530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC);
531} 531}
532 532
533static void kaweth_resubmit_tl(void *d) 533static void kaweth_resubmit_tl(struct work_struct *work)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth =
536 container_of(work, struct kaweth_device, lowmem_work.work);
536 537
537 if (IS_BLOCKED(kaweth->status)) 538 if (IS_BLOCKED(kaweth->status))
538 return; 539 return;
@@ -1126,7 +1127,7 @@ err_fw:
1126 1127
1127 /* kaweth is zeroed as part of alloc_netdev */ 1128 /* kaweth is zeroed as part of alloc_netdev */
1128 1129
1129 INIT_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl, (void *)kaweth); 1130 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl);
1130 1131
1131 SET_MODULE_OWNER(netdev); 1132 SET_MODULE_OWNER(netdev);
1132 1133
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index ce00de8f13a1..493635954513 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -237,12 +237,12 @@ static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl)
237#define STATUS_CONN_OTHER (1 << 14) 237#define STATUS_CONN_OTHER (1 << 14)
238#define STATUS_SUSPEND_OTHER (1 << 13) 238#define STATUS_SUSPEND_OTHER (1 << 13)
239#define STATUS_MAILBOX_OTHER (1 << 12) 239#define STATUS_MAILBOX_OTHER (1 << 12)
240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) 240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03)
241 241
242#define STATUS_CONN_THIS (1 << 6) 242#define STATUS_CONN_THIS (1 << 6)
243#define STATUS_SUSPEND_THIS (1 << 5) 243#define STATUS_SUSPEND_THIS (1 << 5)
244#define STATUS_MAILBOX_THIS (1 << 4) 244#define STATUS_MAILBOX_THIS (1 << 4)
245#define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) 245#define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03)
246 246
247#define STATUS_UNSPEC_MASK 0x0c8c 247#define STATUS_UNSPEC_MASK 0x0c8c
248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) 248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK))
@@ -383,7 +383,7 @@ static void nc_ensure_sync(struct usbnet *dev)
383 int status; 383 int status;
384 384
385 /* Send a flush */ 385 /* Send a flush */
386 urb = usb_alloc_urb(0, SLAB_ATOMIC); 386 urb = usb_alloc_urb(0, GFP_ATOMIC);
387 if (!urb) 387 if (!urb)
388 return; 388 return;
389 389
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 33abbd2176b6..d48c024cff59 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -163,6 +163,7 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size,
163 163
164 /* using ATOMIC, we'd never wake up if we slept */ 164 /* using ATOMIC, we'd never wake up if we slept */
165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { 165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
166 set_current_state(TASK_RUNNING);
166 if (ret == -ENODEV) 167 if (ret == -ENODEV)
167 netif_device_detach(pegasus->net); 168 netif_device_detach(pegasus->net);
168 if (netif_msg_drv(pegasus)) 169 if (netif_msg_drv(pegasus))
@@ -855,7 +856,7 @@ static void intr_callback(struct urb *urb)
855 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; 856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
856 } 857 }
857 858
858 status = usb_submit_urb(urb, SLAB_ATOMIC); 859 status = usb_submit_urb(urb, GFP_ATOMIC);
859 if (status == -ENODEV) 860 if (status == -ENODEV)
860 netif_device_detach(pegasus->net); 861 netif_device_detach(pegasus->net);
861 if (status && netif_msg_timer(pegasus)) 862 if (status && netif_msg_timer(pegasus))
@@ -1280,9 +1281,9 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1280static struct workqueue_struct *pegasus_workqueue = NULL; 1281static struct workqueue_struct *pegasus_workqueue = NULL;
1281#define CARRIER_CHECK_DELAY (2 * HZ) 1282#define CARRIER_CHECK_DELAY (2 * HZ)
1282 1283
1283static void check_carrier(void *data) 1284static void check_carrier(struct work_struct *work)
1284{ 1285{
1285 pegasus_t *pegasus = data; 1286 pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
1286 set_carrier(pegasus->net); 1287 set_carrier(pegasus->net);
1287 if (!(pegasus->flags & PEGASUS_UNPLUG)) { 1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) {
1288 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
@@ -1318,7 +1319,7 @@ static int pegasus_probe(struct usb_interface *intf,
1318 1319
1319 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); 1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
1320 1321
1321 INIT_WORK(&pegasus->carrier_check, check_carrier, pegasus); 1322 INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
1322 1323
1323 pegasus->intf = intf; 1324 pegasus->intf = intf;
1324 pegasus->usb = dev; 1325 pegasus->usb = dev;
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index 006438069b66..98f6898cae1f 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -95,7 +95,7 @@ typedef struct pegasus {
95 int dev_index; 95 int dev_index;
96 int intr_interval; 96 int intr_interval;
97 struct tasklet_struct rx_tl; 97 struct tasklet_struct rx_tl;
98 struct work_struct carrier_check; 98 struct delayed_work carrier_check;
99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb; 99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
100 struct sk_buff *rx_pool[RX_SKBS]; 100 struct sk_buff *rx_pool[RX_SKBS];
101 struct sk_buff *rx_skb; 101 struct sk_buff *rx_skb;
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index c2a28d88ef3c..99f26b3e502f 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
469 struct rndis_halt *halt; 469 struct rndis_halt *halt;
470 470
471 /* try to clear any rndis state/activity (no i/o from stack!) */ 471 /* try to clear any rndis state/activity (no i/o from stack!) */
472 halt = kcalloc(1, sizeof *halt, SLAB_KERNEL); 472 halt = kcalloc(1, sizeof *halt, GFP_KERNEL);
473 if (halt) { 473 if (halt) {
474 halt->msg_type = RNDIS_MSG_HALT; 474 halt->msg_type = RNDIS_MSG_HALT;
475 halt->msg_len = ccpu2(sizeof *halt); 475 halt->msg_len = ccpu2(sizeof *halt);
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 72171f94ded4..c54235f73cb6 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -587,7 +587,7 @@ static void intr_callback(struct urb *urb)
587 } 587 }
588 588
589resubmit: 589resubmit:
590 status = usb_submit_urb (urb, SLAB_ATOMIC); 590 status = usb_submit_urb (urb, GFP_ATOMIC);
591 if (status == -ENODEV) 591 if (status == -ENODEV)
592 netif_device_detach(dev->netdev); 592 netif_device_detach(dev->netdev);
593 else if (status) 593 else if (status)
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 760b5327b81b..6e39e9988259 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -116,7 +116,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
116 e = alt->endpoint + ep; 116 e = alt->endpoint + ep;
117 switch (e->desc.bmAttributes) { 117 switch (e->desc.bmAttributes) {
118 case USB_ENDPOINT_XFER_INT: 118 case USB_ENDPOINT_XFER_INT:
119 if (!(e->desc.bEndpointAddress & USB_DIR_IN)) 119 if (!usb_endpoint_dir_in(&e->desc))
120 continue; 120 continue;
121 intr = 1; 121 intr = 1;
122 /* FALLTHROUGH */ 122 /* FALLTHROUGH */
@@ -125,7 +125,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
125 default: 125 default:
126 continue; 126 continue;
127 } 127 }
128 if (e->desc.bEndpointAddress & USB_DIR_IN) { 128 if (usb_endpoint_dir_in(&e->desc)) {
129 if (!intr && !in) 129 if (!intr && !in)
130 in = e; 130 in = e;
131 else if (intr && !status) 131 else if (intr && !status)
@@ -179,9 +179,9 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
179 period = max ((int) dev->status->desc.bInterval, 179 period = max ((int) dev->status->desc.bInterval,
180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); 180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
181 181
182 buf = kmalloc (maxp, SLAB_KERNEL); 182 buf = kmalloc (maxp, GFP_KERNEL);
183 if (buf) { 183 if (buf) {
184 dev->interrupt = usb_alloc_urb (0, SLAB_KERNEL); 184 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
185 if (!dev->interrupt) { 185 if (!dev->interrupt) {
186 kfree (buf); 186 kfree (buf);
187 return -ENOMEM; 187 return -ENOMEM;
@@ -782,9 +782,10 @@ static struct ethtool_ops usbnet_ethtool_ops = {
782 * especially now that control transfers can be queued. 782 * especially now that control transfers can be queued.
783 */ 783 */
784static void 784static void
785kevent (void *data) 785kevent (struct work_struct *work)
786{ 786{
787 struct usbnet *dev = data; 787 struct usbnet *dev =
788 container_of(work, struct usbnet, kevent);
788 int status; 789 int status;
789 790
790 /* usb_clear_halt() needs a thread context */ 791 /* usb_clear_halt() needs a thread context */
@@ -1146,7 +1147,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1146 skb_queue_head_init (&dev->done); 1147 skb_queue_head_init (&dev->done);
1147 dev->bh.func = usbnet_bh; 1148 dev->bh.func = usbnet_bh;
1148 dev->bh.data = (unsigned long) dev; 1149 dev->bh.data = (unsigned long) dev;
1149 INIT_WORK (&dev->kevent, kevent, dev); 1150 INIT_WORK (&dev->kevent, kevent);
1150 dev->delay.function = usbnet_bh; 1151 dev->delay.function = usbnet_bh;
1151 dev->delay.data = (unsigned long) dev; 1152 dev->delay.data = (unsigned long) dev;
1152 init_timer (&dev->delay); 1153 init_timer (&dev->delay);
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2a8dd4cc943d..2f4d303ee36f 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -554,6 +554,17 @@ config USB_SERIAL_OMNINET
554 To compile this driver as a module, choose M here: the 554 To compile this driver as a module, choose M here: the
555 module will be called omninet. 555 module will be called omninet.
556 556
557config USB_SERIAL_DEBUG
558 tristate "USB Debugging Device"
559 depends on USB_SERIAL
560 help
561 Say Y here if you have a USB debugging device used to recieve
562 debugging data from another machine. The most common of these
563 devices is the NetChip TurboCONNECT device.
564
565 To compile this driver as a module, choose M here: the
566 module will be called usb-debug.
567
557config USB_EZUSB 568config USB_EZUSB
558 bool 569 bool
559 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT 570 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index a5047dc599bb..61166ad450e6 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o 20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o
21obj-$(CONFIG_USB_SERIAL_DEBUG) += usb_debug.o
21obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o 22obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o
22obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o 23obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o
23obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o 24obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 812275509137..86bcf63b6ba5 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -92,6 +92,7 @@ struct aircable_private {
92 struct circ_buf *rx_buf; /* read buffer */ 92 struct circ_buf *rx_buf; /* read buffer */
93 int rx_flags; /* for throttilng */ 93 int rx_flags; /* for throttilng */
94 struct work_struct rx_work; /* work cue for the receiving line */ 94 struct work_struct rx_work; /* work cue for the receiving line */
95 struct usb_serial_port *port; /* USB port with which associated */
95}; 96};
96 97
97/* Private methods */ 98/* Private methods */
@@ -251,10 +252,11 @@ static void aircable_send(struct usb_serial_port *port)
251 schedule_work(&port->work); 252 schedule_work(&port->work);
252} 253}
253 254
254static void aircable_read(void *params) 255static void aircable_read(struct work_struct *work)
255{ 256{
256 struct usb_serial_port *port = params; 257 struct aircable_private *priv =
257 struct aircable_private *priv = usb_get_serial_port_data(port); 258 container_of(work, struct aircable_private, rx_work);
259 struct usb_serial_port *port = priv->port;
258 struct tty_struct *tty; 260 struct tty_struct *tty;
259 unsigned char *data; 261 unsigned char *data;
260 int count; 262 int count;
@@ -270,8 +272,11 @@ static void aircable_read(void *params)
270 */ 272 */
271 tty = port->tty; 273 tty = port->tty;
272 274
273 if (!tty) 275 if (!tty) {
274 schedule_work(&priv->rx_work); 276 schedule_work(&priv->rx_work);
277 err("%s - No tty available", __FUNCTION__);
278 return ;
279 }
275 280
276 count = min(64, serial_buf_data_avail(priv->rx_buf)); 281 count = min(64, serial_buf_data_avail(priv->rx_buf));
277 282
@@ -305,9 +310,7 @@ static int aircable_probe(struct usb_serial *serial,
305 310
306 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 311 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
307 endpoint = &iface_desc->endpoint[i].desc; 312 endpoint = &iface_desc->endpoint[i].desc;
308 if (((endpoint->bEndpointAddress & 0x80) == 0x00) && 313 if (usb_endpoint_is_bulk_out(endpoint)) {
309 ((endpoint->bmAttributes & 3) == 0x02)) {
310 /* we found our bulk out endpoint */
311 dbg("found bulk out on endpoint %d", i); 314 dbg("found bulk out on endpoint %d", i);
312 ++num_bulk_out; 315 ++num_bulk_out;
313 } 316 }
@@ -348,7 +351,8 @@ static int aircable_attach (struct usb_serial *serial)
348 } 351 }
349 352
350 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 353 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
351 INIT_WORK(&priv->rx_work, aircable_read, port); 354 priv->port = port;
355 INIT_WORK(&priv->rx_work, aircable_read);
352 356
353 usb_set_serial_port_data(serial->port[0], priv); 357 usb_set_serial_port_data(serial->port[0], priv);
354 358
@@ -515,7 +519,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
515 package_length - shift); 519 package_length - shift);
516 } 520 }
517 } 521 }
518 aircable_read(port); 522 aircable_read(&priv->rx_work);
519 } 523 }
520 524
521 /* Schedule the next read _if_ we are still open */ 525 /* Schedule the next read _if_ we are still open */
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 7f5d546da39a..96c73726d74a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -19,6 +19,7 @@
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */ 23 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
23 { }, 24 { },
24}; 25};
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index ca52f12f0e24..863966c1c5ac 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -85,10 +85,9 @@ static int ark3116_attach(struct usb_serial *serial)
85 int i; 85 int i;
86 86
87 for (i = 0; i < serial->num_ports; ++i) { 87 for (i = 0; i < serial->num_ports; ++i) {
88 priv = kmalloc(sizeof (struct ark3116_private), GFP_KERNEL); 88 priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
89 if (!priv) 89 if (!priv)
90 goto cleanup; 90 goto cleanup;
91 memset(priv, 0x00, sizeof (struct ark3116_private));
92 spin_lock_init(&priv->lock); 91 spin_lock_init(&priv->lock);
93 92
94 usb_set_serial_port_data(serial->port[i], priv); 93 usb_set_serial_port_data(serial->port[i], priv);
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 3a9073dbfe6a..7167728d764c 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -166,19 +166,17 @@ static int usb_console_setup(struct console *co, char *options)
166 if (serial->type->set_termios) { 166 if (serial->type->set_termios) {
167 /* build up a fake tty structure so that the open call has something 167 /* build up a fake tty structure so that the open call has something
168 * to look at to get the cflag value */ 168 * to look at to get the cflag value */
169 tty = kmalloc (sizeof (*tty), GFP_KERNEL); 169 tty = kzalloc(sizeof(*tty), GFP_KERNEL);
170 if (!tty) { 170 if (!tty) {
171 err ("no more memory"); 171 err ("no more memory");
172 return -ENOMEM; 172 return -ENOMEM;
173 } 173 }
174 termios = kmalloc (sizeof (*termios), GFP_KERNEL); 174 termios = kzalloc(sizeof(*termios), GFP_KERNEL);
175 if (!termios) { 175 if (!termios) {
176 err ("no more memory"); 176 err ("no more memory");
177 kfree (tty); 177 kfree (tty);
178 return -ENOMEM; 178 return -ENOMEM;
179 } 179 }
180 memset (tty, 0x00, sizeof(*tty));
181 memset (termios, 0x00, sizeof(*termios));
182 termios->c_cflag = cflag; 180 termios->c_cflag = cflag;
183 tty->termios = termios; 181 tty->termios = termios;
184 port->tty = tty; 182 port->tty = tty;
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index f2e89a083659..093f303b3189 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1684,15 +1684,14 @@ static int __init cypress_init(void)
1684 1684
1685 info(DRIVER_DESC " " DRIVER_VERSION); 1685 info(DRIVER_DESC " " DRIVER_VERSION);
1686 return 0; 1686 return 0;
1687
1687failed_usb_register: 1688failed_usb_register:
1688 usb_deregister(&cypress_driver);
1689failed_ca42v2_register:
1690 usb_serial_deregister(&cypress_ca42v2_device); 1689 usb_serial_deregister(&cypress_ca42v2_device);
1691failed_hidcom_register: 1690failed_ca42v2_register:
1692 usb_serial_deregister(&cypress_hidcom_device); 1691 usb_serial_deregister(&cypress_hidcom_device);
1693failed_em_register: 1692failed_hidcom_register:
1694 usb_serial_deregister(&cypress_earthmate_device); 1693 usb_serial_deregister(&cypress_earthmate_device);
1695 1694failed_em_register:
1696 return retval; 1695 return retval;
1697} 1696}
1698 1697
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index bdb58100fc1d..83d0e21145b0 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -157,7 +157,7 @@
157* to TASK_RUNNING will be lost and write_chan's subsequent call to 157* to TASK_RUNNING will be lost and write_chan's subsequent call to
158* schedule() will never return (unless it catches a signal). 158* schedule() will never return (unless it catches a signal).
159* This race condition occurs because write_bulk_callback() (and thus 159* This race condition occurs because write_bulk_callback() (and thus
160* the wakeup) are called asynchonously from an interrupt, rather than 160* the wakeup) are called asynchronously from an interrupt, rather than
161* from the scheduler. We can avoid the race by calling the wakeup 161* from the scheduler. We can avoid the race by calling the wakeup
162* from the scheduler queue and that's our fix: Now, at the end of 162* from the scheduler queue and that's our fix: Now, at the end of
163* write_bulk_callback() we queue up a wakeup call on the scheduler 163* write_bulk_callback() we queue up a wakeup call on the scheduler
@@ -430,13 +430,14 @@ struct digi_port {
430 int dp_in_close; /* close in progress */ 430 int dp_in_close; /* close in progress */
431 wait_queue_head_t dp_close_wait; /* wait queue for close */ 431 wait_queue_head_t dp_close_wait; /* wait queue for close */
432 struct work_struct dp_wakeup_work; 432 struct work_struct dp_wakeup_work;
433 struct usb_serial_port *dp_port;
433}; 434};
434 435
435 436
436/* Local Function Declarations */ 437/* Local Function Declarations */
437 438
438static void digi_wakeup_write( struct usb_serial_port *port ); 439static void digi_wakeup_write( struct usb_serial_port *port );
439static void digi_wakeup_write_lock(void *); 440static void digi_wakeup_write_lock(struct work_struct *work);
440static int digi_write_oob_command( struct usb_serial_port *port, 441static int digi_write_oob_command( struct usb_serial_port *port,
441 unsigned char *buf, int count, int interruptible ); 442 unsigned char *buf, int count, int interruptible );
442static int digi_write_inb_command( struct usb_serial_port *port, 443static int digi_write_inb_command( struct usb_serial_port *port,
@@ -598,11 +599,12 @@ static inline long cond_wait_interruptible_timeout_irqrestore(
598* on writes. 599* on writes.
599*/ 600*/
600 601
601static void digi_wakeup_write_lock(void *arg) 602static void digi_wakeup_write_lock(struct work_struct *work)
602{ 603{
603 struct usb_serial_port *port = arg; 604 struct digi_port *priv =
605 container_of(work, struct digi_port, dp_wakeup_work);
606 struct usb_serial_port *port = priv->dp_port;
604 unsigned long flags; 607 unsigned long flags;
605 struct digi_port *priv = usb_get_serial_port_data(port);
606 608
607 609
608 spin_lock_irqsave( &priv->dp_port_lock, flags ); 610 spin_lock_irqsave( &priv->dp_port_lock, flags );
@@ -1702,8 +1704,8 @@ dbg( "digi_startup: TOP" );
1702 init_waitqueue_head( &priv->dp_flush_wait ); 1704 init_waitqueue_head( &priv->dp_flush_wait );
1703 priv->dp_in_close = 0; 1705 priv->dp_in_close = 0;
1704 init_waitqueue_head( &priv->dp_close_wait ); 1706 init_waitqueue_head( &priv->dp_close_wait );
1705 INIT_WORK(&priv->dp_wakeup_work, 1707 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1706 digi_wakeup_write_lock, serial->port[i]); 1708 priv->dp_port = serial->port[i];
1707 1709
1708 /* initialize write wait queue for this port */ 1710 /* initialize write wait queue for this port */
1709 init_waitqueue_head( &serial->port[i]->write_wait ); 1711 init_waitqueue_head( &serial->port[i]->write_wait );
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 5169c2d154ab..97ee718b1da2 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -31,12 +31,11 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
31 return -ENODEV; 31 return -ENODEV;
32 } 32 }
33 33
34 transfer_buffer = kmalloc (length, GFP_KERNEL); 34 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
35 if (!transfer_buffer) { 35 if (!transfer_buffer) {
36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length); 36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
37 return -ENOMEM; 37 return -ENOMEM;
38 } 38 }
39 memcpy (transfer_buffer, data, length);
40 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); 39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
41 kfree (transfer_buffer); 40 kfree (transfer_buffer);
42 return result; 41 return result;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index bd76b4c11fcc..72e4d48f51e9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
@@ -557,7 +559,8 @@ struct ftdi_private {
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 562 struct delayed_work rx_work;
563 struct usb_serial_port *port;
561 int rx_processed; 564 int rx_processed;
562 unsigned long rx_bytes; 565 unsigned long rx_bytes;
563 566
@@ -591,7 +594,7 @@ static int ftdi_write_room (struct usb_serial_port *port);
591static int ftdi_chars_in_buffer (struct usb_serial_port *port); 594static int ftdi_chars_in_buffer (struct usb_serial_port *port);
592static void ftdi_write_bulk_callback (struct urb *urb); 595static void ftdi_write_bulk_callback (struct urb *urb);
593static void ftdi_read_bulk_callback (struct urb *urb); 596static void ftdi_read_bulk_callback (struct urb *urb);
594static void ftdi_process_read (void *param); 597static void ftdi_process_read (struct work_struct *work);
595static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old); 598static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old);
596static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 599static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file);
597static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); 600static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
@@ -1199,7 +1202,8 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1199 port->read_urb->transfer_buffer_length = BUFSZ; 1202 port->read_urb->transfer_buffer_length = BUFSZ;
1200 } 1203 }
1201 1204
1202 INIT_WORK(&priv->rx_work, ftdi_process_read, port); 1205 INIT_DELAYED_WORK(&priv->rx_work, ftdi_process_read);
1206 priv->port = port;
1203 1207
1204 /* Free port's existing write urb and transfer buffer. */ 1208 /* Free port's existing write urb and transfer buffer. */
1205 if (port->write_urb) { 1209 if (port->write_urb) {
@@ -1386,8 +1390,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1386 flush_scheduled_work(); 1390 flush_scheduled_work();
1387 1391
1388 /* shutdown our bulk read */ 1392 /* shutdown our bulk read */
1389 if (port->read_urb) 1393 usb_kill_urb(port->read_urb);
1390 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1394} /* ftdi_close */
1392 1395
1393 1396
@@ -1639,17 +1642,18 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1639 priv->rx_bytes += countread; 1642 priv->rx_bytes += countread;
1640 spin_unlock_irqrestore(&priv->rx_lock, flags); 1643 spin_unlock_irqrestore(&priv->rx_lock, flags);
1641 1644
1642 ftdi_process_read(port); 1645 ftdi_process_read(&priv->rx_work.work);
1643 1646
1644} /* ftdi_read_bulk_callback */ 1647} /* ftdi_read_bulk_callback */
1645 1648
1646 1649
1647static void ftdi_process_read (void *param) 1650static void ftdi_process_read (struct work_struct *work)
1648{ /* ftdi_process_read */ 1651{ /* ftdi_process_read */
1649 struct usb_serial_port *port = (struct usb_serial_port*)param; 1652 struct ftdi_private *priv =
1653 container_of(work, struct ftdi_private, rx_work.work);
1654 struct usb_serial_port *port = priv->port;
1650 struct urb *urb; 1655 struct urb *urb;
1651 struct tty_struct *tty; 1656 struct tty_struct *tty;
1652 struct ftdi_private *priv;
1653 char error_flag; 1657 char error_flag;
1654 unsigned char *data; 1658 unsigned char *data;
1655 1659
@@ -2178,7 +2182,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
2178 spin_unlock_irqrestore(&priv->rx_lock, flags); 2182 spin_unlock_irqrestore(&priv->rx_lock, flags);
2179 2183
2180 if (actually_throttled) 2184 if (actually_throttled)
2181 schedule_work(&priv->rx_work); 2185 schedule_delayed_work(&priv->rx_work, 0);
2182} 2186}
2183 2187
2184static int __init ftdi_init (void) 2188static int __init ftdi_init (void)
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f0edb87d2dd5..bae117d359af 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -55,6 +55,9 @@
55/* iPlus device */ 55/* iPlus device */
56#define FTDI_IPLUS_PID 0xD070 /* Product Id */ 56#define FTDI_IPLUS_PID 0xD070 /* Product Id */
57 57
58/* DMX4ALL DMX Interfaces */
59#define FTDI_DMX4ALL 0xC850
60
58/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 61/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
59/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 62/* they use the ftdi chipset for the USB interface and the vendor id is the same */
60#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 63#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -175,9 +178,15 @@
175#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 178#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
176 179
177/* 180/*
181 * FTDI USB UART chips used in construction projects from the
182 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
183 */
184#define ELEKTOR_VID 0x0C7D
185#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
186
187/*
178 * DSS-20 Sync Station for Sony Ericsson P800 188 * DSS-20 Sync Station for Sony Ericsson P800
179 */ 189 */
180
181#define FTDI_DSS20_PID 0xFC82 190#define FTDI_DSS20_PID 0xFC82
182 191
183/* 192/*
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 4543152a9966..6530d391ebed 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1523,12 +1523,11 @@ static int garmin_attach (struct usb_serial *serial)
1523 1523
1524 dbg("%s", __FUNCTION__); 1524 dbg("%s", __FUNCTION__);
1525 1525
1526 garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL); 1526 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
1527 if (garmin_data_p == NULL) { 1527 if (garmin_data_p == NULL) {
1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); 1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
1529 return -ENOMEM; 1529 return -ENOMEM;
1530 } 1530 }
1531 memset (garmin_data_p, 0, sizeof(struct garmin_data));
1532 init_timer(&garmin_data_p->timer); 1531 init_timer(&garmin_data_p->timer);
1533 spin_lock_init(&garmin_data_p->lock); 1532 spin_lock_init(&garmin_data_p->lock);
1534 INIT_LIST_HEAD(&garmin_data_p->pktlist); 1533 INIT_LIST_HEAD(&garmin_data_p->pktlist);
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 91bd3014ef1e..d06547a13f28 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1038,9 +1038,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1038 edge_port->open = FALSE; 1038 edge_port->open = FALSE;
1039 edge_port->openPending = FALSE; 1039 edge_port->openPending = FALSE;
1040 1040
1041 if (edge_port->write_urb) { 1041 usb_kill_urb(edge_port->write_urb);
1042 usb_kill_urb(edge_port->write_urb);
1043 }
1044 1042
1045 if (edge_port->write_urb) { 1043 if (edge_port->write_urb) {
1046 /* if this urb had a transfer buffer already (old transfer) free it */ 1044 /* if this urb had a transfer buffer already (old transfer) free it */
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 6238aff1e772..d72cf8bc7f76 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -320,6 +320,7 @@ static struct usb_device_id ipaq_id_table [] = {
320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ 320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ 321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
323 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC USB Modem */
323 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 324 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
324 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 325 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
325 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */ 326 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 2a4bb66691ad..d3b9a351cef8 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -206,10 +206,9 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
206 206
207 dbg("%s", __FUNCTION__); 207 dbg("%s", __FUNCTION__);
208 208
209 buf_flow_init = kmalloc(16, GFP_KERNEL); 209 buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL);
210 if (!buf_flow_init) 210 if (!buf_flow_init)
211 return -ENOMEM; 211 return -ENOMEM;
212 memcpy(buf_flow_init, buf_flow_static, 16);
213 212
214 if (port->tty) 213 if (port->tty)
215 port->tty->low_latency = 1; 214 port->tty->low_latency = 1;
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 53be824eb1bf..7639652cec42 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2306,22 +2306,16 @@ static void keyspan_shutdown (struct usb_serial *serial)
2306 } 2306 }
2307 2307
2308 /* Now free them */ 2308 /* Now free them */
2309 if (s_priv->instat_urb) 2309 usb_free_urb(s_priv->instat_urb);
2310 usb_free_urb(s_priv->instat_urb); 2310 usb_free_urb(s_priv->glocont_urb);
2311 if (s_priv->glocont_urb)
2312 usb_free_urb(s_priv->glocont_urb);
2313 for (i = 0; i < serial->num_ports; ++i) { 2311 for (i = 0; i < serial->num_ports; ++i) {
2314 port = serial->port[i]; 2312 port = serial->port[i];
2315 p_priv = usb_get_serial_port_data(port); 2313 p_priv = usb_get_serial_port_data(port);
2316 if (p_priv->inack_urb) 2314 usb_free_urb(p_priv->inack_urb);
2317 usb_free_urb(p_priv->inack_urb); 2315 usb_free_urb(p_priv->outcont_urb);
2318 if (p_priv->outcont_urb)
2319 usb_free_urb(p_priv->outcont_urb);
2320 for (j = 0; j < 2; j++) { 2316 for (j = 0; j < 2; j++) {
2321 if (p_priv->in_urbs[j]) 2317 usb_free_urb(p_priv->in_urbs[j]);
2322 usb_free_urb(p_priv->in_urbs[j]); 2318 usb_free_urb(p_priv->out_urbs[j]);
2323 if (p_priv->out_urbs[j])
2324 usb_free_urb(p_priv->out_urbs[j]);
2325 } 2319 }
2326 } 2320 }
2327 2321
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 909005107ea2..e09a0bfe6231 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -120,6 +120,8 @@ struct keyspan_pda_private {
120 int tx_throttled; 120 int tx_throttled;
121 struct work_struct wakeup_work; 121 struct work_struct wakeup_work;
122 struct work_struct unthrottle_work; 122 struct work_struct unthrottle_work;
123 struct usb_serial *serial;
124 struct usb_serial_port *port;
123}; 125};
124 126
125 127
@@ -175,9 +177,11 @@ static struct usb_device_id id_table_fake_xircom [] = {
175}; 177};
176#endif 178#endif
177 179
178static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) 180static void keyspan_pda_wakeup_write(struct work_struct *work)
179{ 181{
180 182 struct keyspan_pda_private *priv =
183 container_of(work, struct keyspan_pda_private, wakeup_work);
184 struct usb_serial_port *port = priv->port;
181 struct tty_struct *tty = port->tty; 185 struct tty_struct *tty = port->tty;
182 186
183 /* wake up port processes */ 187 /* wake up port processes */
@@ -187,8 +191,11 @@ static void keyspan_pda_wakeup_write( struct usb_serial_port *port )
187 tty_wakeup(tty); 191 tty_wakeup(tty);
188} 192}
189 193
190static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) 194static void keyspan_pda_request_unthrottle(struct work_struct *work)
191{ 195{
196 struct keyspan_pda_private *priv =
197 container_of(work, struct keyspan_pda_private, unthrottle_work);
198 struct usb_serial *serial = priv->serial;
192 int result; 199 int result;
193 200
194 dbg(" request_unthrottle"); 201 dbg(" request_unthrottle");
@@ -765,11 +772,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
765 return (1); /* error */ 772 return (1); /* error */
766 usb_set_serial_port_data(serial->port[0], priv); 773 usb_set_serial_port_data(serial->port[0], priv);
767 init_waitqueue_head(&serial->port[0]->write_wait); 774 init_waitqueue_head(&serial->port[0]->write_wait);
768 INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, 775 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
769 (void *)(serial->port[0])); 776 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
770 INIT_WORK(&priv->unthrottle_work, 777 priv->serial = serial;
771 (void *)keyspan_pda_request_unthrottle, 778 priv->port = serial->port[0];
772 (void *)(serial));
773 return (0); 779 return (0);
774} 780}
775 781
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index ff03331e0bcf..237289920f03 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -185,13 +185,11 @@ static int kobil_startup (struct usb_serial *serial)
185 185
186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { 186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
187 endpoint = &altsetting->endpoint[i]; 187 endpoint = &altsetting->endpoint[i];
188 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) && 188 if (usb_endpoint_is_int_out(&endpoint->desc)) {
189 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
190 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 189 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
191 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; 190 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
192 } 191 }
193 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 192 if (usb_endpoint_is_int_in(&endpoint->desc)) {
194 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
195 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 193 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
196 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; 194 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
197 } 195 }
@@ -355,8 +353,7 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp)
355 usb_free_urb( port->write_urb ); 353 usb_free_urb( port->write_urb );
356 port->write_urb = NULL; 354 port->write_urb = NULL;
357 } 355 }
358 if (port->interrupt_in_urb) 356 usb_kill_urb(port->interrupt_in_urb);
359 usb_kill_urb(port->interrupt_in_urb);
360} 357}
361 358
362 359
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index b7582cc496dc..a906e500a02b 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -358,10 +358,8 @@ static int mct_u232_startup (struct usb_serial *serial)
358 /* Puh, that's dirty */ 358 /* Puh, that's dirty */
359 port = serial->port[0]; 359 port = serial->port[0];
360 rport = serial->port[1]; 360 rport = serial->port[1];
361 if (port->read_urb) { 361 /* No unlinking, it wasn't submitted yet. */
362 /* No unlinking, it wasn't submitted yet. */ 362 usb_free_urb(port->read_urb);
363 usb_free_urb(port->read_urb);
364 }
365 port->read_urb = rport->interrupt_in_urb; 363 port->read_urb = rport->interrupt_in_urb;
366 rport->interrupt_in_urb = NULL; 364 rport->interrupt_in_urb = NULL;
367 port->read_urb->context = port; 365 port->read_urb->context = port;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 82cd15b894b0..70f93b18292f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -363,7 +363,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
363 363
364 /* Initialising the write urb pool */ 364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) { 365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC); 366 urb = usb_alloc_urb(0,GFP_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb; 367 mos7720_port->write_urb_pool[j] = urb;
368 368
369 if (urb == NULL) { 369 if (urb == NULL) {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 5b71962d0351..5432c6340086 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -826,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
826 826
827 /* Initialising the write urb pool */ 827 /* Initialising the write urb pool */
828 for (j = 0; j < NUM_URBS; ++j) { 828 for (j = 0; j < NUM_URBS; ++j) {
829 urb = usb_alloc_urb(0, SLAB_ATOMIC); 829 urb = usb_alloc_urb(0, GFP_ATOMIC);
830 mos7840_port->write_urb_pool[j] = urb; 830 mos7840_port->write_urb_pool[j] = urb;
831 831
832 if (urb == NULL) { 832 if (urb == NULL) {
@@ -2596,12 +2596,11 @@ static int mos7840_startup(struct usb_serial *serial)
2596 2596
2597 /* set up port private structures */ 2597 /* set up port private structures */
2598 for (i = 0; i < serial->num_ports; ++i) { 2598 for (i = 0; i < serial->num_ports; ++i) {
2599 mos7840_port = kmalloc(sizeof(struct moschip_port), GFP_KERNEL); 2599 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2600 if (mos7840_port == NULL) { 2600 if (mos7840_port == NULL) {
2601 err("%s - Out of memory", __FUNCTION__); 2601 err("%s - Out of memory", __FUNCTION__);
2602 return -ENOMEM; 2602 return -ENOMEM;
2603 } 2603 }
2604 memset(mos7840_port, 0, sizeof(struct moschip_port));
2605 2604
2606 /* Initialize all port interrupt end point to port 0 int endpoint * 2605 /* Initialize all port interrupt end point to port 0 int endpoint *
2607 * Our device has only one interrupt end point comman to all port */ 2606 * Our device has only one interrupt end point comman to all port */
@@ -2787,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
2787 i + 1, status); 2786 i + 1, status);
2788 2787
2789 } 2788 }
2790 mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC); 2789 mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
2791 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2792 2791
2793 } 2792 }
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 0610409a6568..054abee81652 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -95,8 +95,7 @@ static void navman_close(struct usb_serial_port *port, struct file *filp)
95{ 95{
96 dbg("%s - port %d", __FUNCTION__, port->number); 96 dbg("%s - port %d", __FUNCTION__, port->number);
97 97
98 if (port->interrupt_in_urb) 98 usb_kill_urb(port->interrupt_in_urb);
99 usb_kill_urb(port->interrupt_in_urb);
100} 99}
101 100
102static int navman_write(struct usb_serial_port *port, 101static int navman_write(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 07400c0c8a8c..ae98d8cbdbb8 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -228,6 +228,7 @@ static int product_5052_count;
228/* null entry */ 228/* null entry */
229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = {
230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
231 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
231}; 232};
232 233
233static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 234static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -239,6 +240,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
239 240
240static struct usb_device_id ti_id_table_combined[] = { 241static struct usb_device_id ti_id_table_combined[] = {
241 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 242 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
242 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 245 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 246 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -459,13 +461,12 @@ static int ti_startup(struct usb_serial *serial)
459 461
460 /* set up port structures */ 462 /* set up port structures */
461 for (i = 0; i < serial->num_ports; ++i) { 463 for (i = 0; i < serial->num_ports; ++i) {
462 tport = kmalloc(sizeof(struct ti_port), GFP_KERNEL); 464 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
463 if (tport == NULL) { 465 if (tport == NULL) {
464 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 466 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
465 status = -ENOMEM; 467 status = -ENOMEM;
466 goto free_tports; 468 goto free_tports;
467 } 469 }
468 memset(tport, 0, sizeof(struct ti_port));
469 spin_lock_init(&tport->tp_lock); 470 spin_lock_init(&tport->tp_lock);
470 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); 471 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
471 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; 472 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index 02c1aeb9e1b8..b5541bf991ba 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -28,6 +28,7 @@
28/* Vendor and product ids */ 28/* Vendor and product ids */
29#define TI_VENDOR_ID 0x0451 29#define TI_VENDOR_ID 0x0451
30#define TI_3410_PRODUCT_ID 0x3410 30#define TI_3410_PRODUCT_ID 0x3410
31#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
31#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 32#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
32#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 33#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
33#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 8006e51c34bb..3d5072f14b8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -533,9 +533,10 @@ void usb_serial_port_softint(struct usb_serial_port *port)
533 schedule_work(&port->work); 533 schedule_work(&port->work);
534} 534}
535 535
536static void usb_serial_port_work(void *private) 536static void usb_serial_port_work(struct work_struct *work)
537{ 537{
538 struct usb_serial_port *port = private; 538 struct usb_serial_port *port =
539 container_of(work, struct usb_serial_port, work);
539 struct tty_struct *tty; 540 struct tty_struct *tty;
540 541
541 dbg("%s - port %d", __FUNCTION__, port->number); 542 dbg("%s - port %d", __FUNCTION__, port->number);
@@ -799,7 +800,7 @@ int usb_serial_probe(struct usb_interface *interface,
799 port->serial = serial; 800 port->serial = serial;
800 spin_lock_init(&port->lock); 801 spin_lock_init(&port->lock);
801 mutex_init(&port->mutex); 802 mutex_init(&port->mutex);
802 INIT_WORK(&port->work, usb_serial_port_work, port); 803 INIT_WORK(&port->work, usb_serial_port_work);
803 serial->port[i] = port; 804 serial->port[i] = port;
804 } 805 }
805 806
@@ -952,32 +953,28 @@ probe_error:
952 port = serial->port[i]; 953 port = serial->port[i];
953 if (!port) 954 if (!port)
954 continue; 955 continue;
955 if (port->read_urb) 956 usb_free_urb(port->read_urb);
956 usb_free_urb (port->read_urb);
957 kfree(port->bulk_in_buffer); 957 kfree(port->bulk_in_buffer);
958 } 958 }
959 for (i = 0; i < num_bulk_out; ++i) { 959 for (i = 0; i < num_bulk_out; ++i) {
960 port = serial->port[i]; 960 port = serial->port[i];
961 if (!port) 961 if (!port)
962 continue; 962 continue;
963 if (port->write_urb) 963 usb_free_urb(port->write_urb);
964 usb_free_urb (port->write_urb);
965 kfree(port->bulk_out_buffer); 964 kfree(port->bulk_out_buffer);
966 } 965 }
967 for (i = 0; i < num_interrupt_in; ++i) { 966 for (i = 0; i < num_interrupt_in; ++i) {
968 port = serial->port[i]; 967 port = serial->port[i];
969 if (!port) 968 if (!port)
970 continue; 969 continue;
971 if (port->interrupt_in_urb) 970 usb_free_urb(port->interrupt_in_urb);
972 usb_free_urb (port->interrupt_in_urb);
973 kfree(port->interrupt_in_buffer); 971 kfree(port->interrupt_in_buffer);
974 } 972 }
975 for (i = 0; i < num_interrupt_out; ++i) { 973 for (i = 0; i < num_interrupt_out; ++i) {
976 port = serial->port[i]; 974 port = serial->port[i];
977 if (!port) 975 if (!port)
978 continue; 976 continue;
979 if (port->interrupt_out_urb) 977 usb_free_urb(port->interrupt_out_urb);
980 usb_free_urb (port->interrupt_out_urb);
981 kfree(port->interrupt_out_buffer); 978 kfree(port->interrupt_out_buffer);
982 } 979 }
983 980
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
new file mode 100644
index 000000000000..257a5e436873
--- /dev/null
+++ b/drivers/usb/serial/usb_debug.c
@@ -0,0 +1,65 @@
1/*
2 * USB Debug cable driver
3 *
4 * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
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 <linux/usb/serial.h>
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0525, 0x127a) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver debug_driver = {
25 .name = "debug",
26 .probe = usb_serial_probe,
27 .disconnect = usb_serial_disconnect,
28 .id_table = id_table,
29 .no_dynamic_id = 1,
30};
31
32static struct usb_serial_driver debug_device = {
33 .driver = {
34 .owner = THIS_MODULE,
35 .name = "debug",
36 },
37 .id_table = id_table,
38 .num_interrupt_in = NUM_DONT_CARE,
39 .num_bulk_in = NUM_DONT_CARE,
40 .num_bulk_out = NUM_DONT_CARE,
41 .num_ports = 1,
42};
43
44static int __init debug_init(void)
45{
46 int retval;
47
48 retval = usb_serial_register(&debug_device);
49 if (retval)
50 return retval;
51 retval = usb_register(&debug_driver);
52 if (retval)
53 usb_serial_deregister(&debug_device);
54 return retval;
55}
56
57static void __exit debug_exit(void)
58{
59 usb_deregister(&debug_driver);
60 usb_serial_deregister(&debug_device);
61}
62
63module_init(debug_init);
64module_exit(debug_exit);
65MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index befe2e11a041..eef5eaa5fa0b 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -348,8 +348,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
348 348
349 /* shutdown our urbs */ 349 /* shutdown our urbs */
350 usb_kill_urb(port->read_urb); 350 usb_kill_urb(port->read_urb);
351 if (port->interrupt_in_urb) 351 usb_kill_urb(port->interrupt_in_urb);
352 usb_kill_urb(port->interrupt_in_urb);
353 352
354 /* Try to send shutdown message, if the device is gone, this will just fail. */ 353 /* Try to send shutdown message, if the device is gone, this will just fail. */
355 transfer_buffer = kmalloc (0x12, GFP_KERNEL); 354 transfer_buffer = kmalloc (0x12, GFP_KERNEL);
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 4d1cd7aeccd3..154c7d290597 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -227,6 +227,7 @@ struct whiteheat_private {
227 struct list_head rx_urbs_submitted; 227 struct list_head rx_urbs_submitted;
228 struct list_head rx_urb_q; 228 struct list_head rx_urb_q;
229 struct work_struct rx_work; 229 struct work_struct rx_work;
230 struct usb_serial_port *port;
230 struct list_head tx_urbs_free; 231 struct list_head tx_urbs_free;
231 struct list_head tx_urbs_submitted; 232 struct list_head tx_urbs_submitted;
232}; 233};
@@ -241,7 +242,7 @@ static void command_port_read_callback(struct urb *urb);
241static int start_port_read(struct usb_serial_port *port); 242static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 243static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
243static struct list_head *list_first(struct list_head *head); 244static struct list_head *list_first(struct list_head *head);
244static void rx_data_softint(void *private); 245static void rx_data_softint(struct work_struct *work);
245 246
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 247static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 248static int firm_open(struct usb_serial_port *port);
@@ -424,7 +425,8 @@ static int whiteheat_attach (struct usb_serial *serial)
424 spin_lock_init(&info->lock); 425 spin_lock_init(&info->lock);
425 info->flags = 0; 426 info->flags = 0;
426 info->mcr = 0; 427 info->mcr = 0;
427 INIT_WORK(&info->rx_work, rx_data_softint, port); 428 INIT_WORK(&info->rx_work, rx_data_softint);
429 info->port = port;
428 430
429 INIT_LIST_HEAD(&info->rx_urbs_free); 431 INIT_LIST_HEAD(&info->rx_urbs_free);
430 INIT_LIST_HEAD(&info->rx_urbs_submitted); 432 INIT_LIST_HEAD(&info->rx_urbs_submitted);
@@ -949,7 +951,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
949 spin_unlock_irqrestore(&info->lock, flags); 951 spin_unlock_irqrestore(&info->lock, flags);
950 952
951 if (actually_throttled) 953 if (actually_throttled)
952 rx_data_softint(port); 954 rx_data_softint(&info->rx_work);
953 955
954 return; 956 return;
955} 957}
@@ -1400,10 +1402,11 @@ static struct list_head *list_first(struct list_head *head)
1400} 1402}
1401 1403
1402 1404
1403static void rx_data_softint(void *private) 1405static void rx_data_softint(struct work_struct *work)
1404{ 1406{
1405 struct usb_serial_port *port = (struct usb_serial_port *)private; 1407 struct whiteheat_private *info =
1406 struct whiteheat_private *info = usb_get_serial_port_data(port); 1408 container_of(work, struct whiteheat_private, rx_work);
1409 struct usb_serial_port *port = info->port;
1407 struct tty_struct *tty = port->tty; 1410 struct tty_struct *tty = port->tty;
1408 struct whiteheat_urb_wrap *wrap; 1411 struct whiteheat_urb_wrap *wrap;
1409 struct urb *urb; 1412 struct urb *urb;
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 3baf448e300d..e565d3d2ab29 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -76,7 +76,7 @@ static void usb_onetouch_irq(struct urb *urb)
76 input_sync(dev); 76 input_sync(dev);
77 77
78resubmit: 78resubmit:
79 status = usb_submit_urb (urb, SLAB_ATOMIC); 79 status = usb_submit_urb (urb, GFP_ATOMIC);
80 if (status) 80 if (status)
81 err ("can't resubmit intr, %s-%s/input0, status %d", 81 err ("can't resubmit intr, %s-%s/input0, status %d",
82 onetouch->udev->bus->bus_name, 82 onetouch->udev->bus->bus_name,
@@ -142,10 +142,7 @@ int onetouch_connect_input(struct us_data *ss)
142 return -ENODEV; 142 return -ENODEV;
143 143
144 endpoint = &interface->endpoint[2].desc; 144 endpoint = &interface->endpoint[2].desc;
145 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 145 if (!usb_endpoint_is_int_in(endpoint))
146 return -ENODEV;
147 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
148 != USB_ENDPOINT_XFER_INT)
149 return -ENODEV; 146 return -ENODEV;
150 147
151 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 148 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
@@ -157,7 +154,7 @@ int onetouch_connect_input(struct us_data *ss)
157 goto fail1; 154 goto fail1;
158 155
159 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
160 SLAB_ATOMIC, &onetouch->data_dma); 157 GFP_ATOMIC, &onetouch->data_dma);
161 if (!onetouch->data) 158 if (!onetouch->data)
162 goto fail1; 159 goto fail1;
163 160
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 47644b5b6155..323293a3e61f 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -427,7 +427,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, SLAB_NOIO); 430 sg, num_sg, length, GFP_NOIO);
431 if (result) { 431 if (result) {
432 US_DEBUGP("usb_sg_init returned %d\n", result); 432 US_DEBUGP("usb_sg_init returned %d\n", result);
433 return USB_STOR_XFER_ERROR; 433 return USB_STOR_XFER_ERROR;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index bc1ac07bf6ce..db8b26012c75 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1306,30 +1306,28 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1306 US_SC_DEVICE, US_PR_DEVICE, NULL, 1306 US_SC_DEVICE, US_PR_DEVICE, NULL,
1307 US_FL_FIX_CAPACITY ), 1307 US_FL_FIX_CAPACITY ),
1308 1308
1309/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1310UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1311 "Sony Ericsson",
1312 "P990i",
1313 US_SC_DEVICE, US_PR_DEVICE, NULL,
1314 US_FL_FIX_CAPACITY ),
1315
1316/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1317UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1318 "Sony Ericsson",
1319 "P990i",
1320 US_SC_DEVICE, US_PR_DEVICE, NULL,
1321 US_FL_FIX_CAPACITY ),
1322
1323/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1309/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1324 * Tested on hardware version 1.10. 1310 * Tested on hardware version 1.10.
1325 * Entry is needed only for the initializer function override. 1311 * Entry is needed only for the initializer function override.
1312 * Devices with bcd > 110 seem to not need it while those
1313 * with bcd < 110 appear to need it.
1326 */ 1314 */
1327UNUSUAL_DEV( 0x1019, 0x0c55, 0x0110, 0x0110, 1315UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1328 "Desknote", 1316 "Desknote",
1329 "UCR-61S2B", 1317 "UCR-61S2B",
1330 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
1331 0 ), 1319 0 ),
1332 1320
1321/* Reported by Jaco Kroon <jaco@kroon.co.za>
1322 * The usb-storage module found on the Digitech GNX4 (and supposedly other
1323 * devices) misbehaves and causes a bunch of invalid I/O errors.
1324 */
1325UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1326 "Digitech HMG",
1327 "DigiTech Mass Storage",
1328 US_SC_DEVICE, US_PR_DEVICE, NULL,
1329 US_FL_IGNORE_RESIDUE ),
1330
1333/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */ 1331/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1334UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001, 1332UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1335 "Minolta", 1333 "Minolta",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b8d6031b0975..70644506651f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -49,7 +49,7 @@
49 49
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/suspend.h> 52#include <linux/freezer.h>
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
@@ -740,18 +740,16 @@ static int get_pipes(struct us_data *us)
740 ep = &altsetting->endpoint[i].desc; 740 ep = &altsetting->endpoint[i].desc;
741 741
742 /* Is it a BULK endpoint? */ 742 /* Is it a BULK endpoint? */
743 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 743 if (usb_endpoint_xfer_bulk(ep)) {
744 == USB_ENDPOINT_XFER_BULK) {
745 /* BULK in or out? */ 744 /* BULK in or out? */
746 if (ep->bEndpointAddress & USB_DIR_IN) 745 if (usb_endpoint_dir_in(ep))
747 ep_in = ep; 746 ep_in = ep;
748 else 747 else
749 ep_out = ep; 748 ep_out = ep;
750 } 749 }
751 750
752 /* Is it an interrupt endpoint? */ 751 /* Is it an interrupt endpoint? */
753 else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 752 else if (usb_endpoint_xfer_int(ep)) {
754 == USB_ENDPOINT_XFER_INT) {
755 ep_int = ep; 753 ep_int = ep;
756 } 754 }
757 } 755 }