aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-07-30 18:14:15 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-07-30 18:14:15 -0400
commita670fcb43f01a67ef56176afc76e5d43d128b25c (patch)
tree09c9411c78a33ff980e9ea871bc7686e7589abbf /drivers/usb
parent327309e899662b482c58cf25f574513d38b5788c (diff)
parentb0825488a642cadcf39709961dde61440cb0731c (diff)
/spare/repo/netdev-2.6 branch 'master'
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/devio.c18
-rw-r--r--drivers/usb/core/hcd.c4
-rw-r--r--drivers/usb/core/hcd.h8
-rw-r--r--drivers/usb/core/message.c6
-rw-r--r--drivers/usb/host/ehci-q.c4
-rw-r--r--drivers/usb/host/ohci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-s3c2410.c496
-rw-r--r--drivers/usb/image/microtek.c3
-rw-r--r--drivers/usb/input/acecad.c14
-rw-r--r--drivers/usb/input/aiptek.c6
-rw-r--r--drivers/usb/input/ati_remote.c8
-rw-r--r--drivers/usb/input/hid-core.c24
-rw-r--r--drivers/usb/input/hid-input.c11
-rw-r--r--drivers/usb/input/itmtouch.c6
-rw-r--r--drivers/usb/input/kbtab.c6
-rw-r--r--drivers/usb/input/mtouchusb.c6
-rw-r--r--drivers/usb/input/powermate.c6
-rw-r--r--drivers/usb/input/touchkitusb.c7
-rw-r--r--drivers/usb/input/usbkbd.c6
-rw-r--r--drivers/usb/input/usbmouse.c6
-rw-r--r--drivers/usb/input/wacom.c6
-rw-r--r--drivers/usb/input/xpad.c6
-rw-r--r--drivers/usb/media/konicawc.c6
-rw-r--r--drivers/usb/misc/ldusb.c7
-rw-r--r--drivers/usb/net/pegasus.c1
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/zd1201.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c146
-rw-r--r--drivers/usb/serial/ftdi_sio.h14
-rw-r--r--drivers/usb/serial/option.c228
-rw-r--r--drivers/usb/usb-skeleton.c6
33 files changed, 767 insertions, 310 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index cd329dd7fb86..85dacc92545a 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -20,6 +20,7 @@ config USB_ARCH_HAS_OHCI
20 default y if SA1111 20 default y if SA1111
21 default y if ARCH_OMAP 21 default y if ARCH_OMAP
22 default y if ARCH_LH7A404 22 default y if ARCH_LH7A404
23 default y if ARCH_S3C2410
23 default y if PXA27x 24 default y if PXA27x
24 # PPC: 25 # PPC:
25 default y if STB03xxx 26 default y if STB03xxx
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index adff5a77e31f..16ecad30e29c 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -980,6 +980,9 @@ static struct usb_device_id acm_ids[] = {
980 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 980 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
981 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 981 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
982 }, 982 },
983 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
984 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
985 },
983 /* control interfaces with various AT-command sets */ 986 /* control interfaces with various AT-command sets */
984 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 987 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
985 USB_CDC_ACM_PROTO_AT_V25TER) }, 988 USB_CDC_ACM_PROTO_AT_V25TER) },
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 787c27a63c51..f86bf1454e21 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -569,8 +569,11 @@ static int proc_control(struct dev_state *ps, void __user *arg)
569 free_page((unsigned long)tbuf); 569 free_page((unsigned long)tbuf);
570 return -EINVAL; 570 return -EINVAL;
571 } 571 }
572 snoop(&dev->dev, "control read: bRequest=%02x bRrequestType=%02x wValue=%04x wIndex=%04x\n", 572 snoop(&dev->dev, "control read: bRequest=%02x "
573 ctrl.bRequest, ctrl.bRequestType, ctrl.wValue, ctrl.wIndex); 573 "bRrequestType=%02x wValue=%04x "
574 "wIndex=%04x wLength=%04x\n",
575 ctrl.bRequest, ctrl.bRequestType, ctrl.wValue,
576 ctrl.wIndex, ctrl.wLength);
574 577
575 usb_unlock_device(dev); 578 usb_unlock_device(dev);
576 i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, 579 i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType,
@@ -579,11 +582,11 @@ static int proc_control(struct dev_state *ps, void __user *arg)
579 if ((i > 0) && ctrl.wLength) { 582 if ((i > 0) && ctrl.wLength) {
580 if (usbfs_snoop) { 583 if (usbfs_snoop) {
581 dev_info(&dev->dev, "control read: data "); 584 dev_info(&dev->dev, "control read: data ");
582 for (j = 0; j < ctrl.wLength; ++j) 585 for (j = 0; j < i; ++j)
583 printk ("%02x ", (unsigned char)(tbuf)[j]); 586 printk ("%02x ", (unsigned char)(tbuf)[j]);
584 printk("\n"); 587 printk("\n");
585 } 588 }
586 if (copy_to_user(ctrl.data, tbuf, ctrl.wLength)) { 589 if (copy_to_user(ctrl.data, tbuf, i)) {
587 free_page((unsigned long)tbuf); 590 free_page((unsigned long)tbuf);
588 return -EFAULT; 591 return -EFAULT;
589 } 592 }
@@ -595,8 +598,11 @@ static int proc_control(struct dev_state *ps, void __user *arg)
595 return -EFAULT; 598 return -EFAULT;
596 } 599 }
597 } 600 }
598 snoop(&dev->dev, "control write: bRequest=%02x bRrequestType=%02x wValue=%04x wIndex=%04x\n", 601 snoop(&dev->dev, "control write: bRequest=%02x "
599 ctrl.bRequest, ctrl.bRequestType, ctrl.wValue, ctrl.wIndex); 602 "bRrequestType=%02x wValue=%04x "
603 "wIndex=%04x wLength=%04x\n",
604 ctrl.bRequest, ctrl.bRequestType, ctrl.wValue,
605 ctrl.wIndex, ctrl.wLength);
600 if (usbfs_snoop) { 606 if (usbfs_snoop) {
601 dev_info(&dev->dev, "control write: data: "); 607 dev_info(&dev->dev, "control write: data: ");
602 for (j = 0; j < ctrl.wLength; ++j) 608 for (j = 0; j < ctrl.wLength; ++j)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8616356f55e8..79422a3b07bc 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -939,9 +939,9 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount)
939 case USB_SPEED_HIGH: /* ISOC or INTR */ 939 case USB_SPEED_HIGH: /* ISOC or INTR */
940 // FIXME adjust for input vs output 940 // FIXME adjust for input vs output
941 if (isoc) 941 if (isoc)
942 tmp = HS_USECS (bytecount); 942 tmp = HS_NSECS_ISO (bytecount);
943 else 943 else
944 tmp = HS_USECS_ISO (bytecount); 944 tmp = HS_NSECS (bytecount);
945 return tmp; 945 return tmp;
946 default: 946 default:
947 pr_debug ("%s: bogus device speed!\n", usbcore_name); 947 pr_debug ("%s: bogus device speed!\n", usbcore_name);
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 67db4a999b93..28055f95645b 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -334,17 +334,19 @@ extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
334extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb); 334extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
335 335
336/* 336/*
337 * Ceiling microseconds (typical) for that many bytes at high speed 337 * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed
338 * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed 338 * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed
339 * to preallocate bandwidth) 339 * to preallocate bandwidth)
340 */ 340 */
341#define USB2_HOST_DELAY 5 /* nsec, guess */ 341#define USB2_HOST_DELAY 5 /* nsec, guess */
342#define HS_USECS(bytes) NS_TO_US ( ((55 * 8 * 2083)/1000) \ 342#define HS_NSECS(bytes) ( ((55 * 8 * 2083)/1000) \
343 + ((2083UL * (3167 + BitTime (bytes)))/1000) \ 343 + ((2083UL * (3167 + BitTime (bytes)))/1000) \
344 + USB2_HOST_DELAY) 344 + USB2_HOST_DELAY)
345#define HS_USECS_ISO(bytes) NS_TO_US ( ((38 * 8 * 2083)/1000) \ 345#define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083)/1000) \
346 + ((2083UL * (3167 + BitTime (bytes)))/1000) \ 346 + ((2083UL * (3167 + BitTime (bytes)))/1000) \
347 + USB2_HOST_DELAY) 347 + USB2_HOST_DELAY)
348#define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes))
349#define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes))
348 350
349extern long usb_calc_bus_time (int speed, int is_input, 351extern long usb_calc_bus_time (int speed, int is_input,
350 int isoc, int bytecount); 352 int isoc, int bytecount);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index a428ef479bd7..88d1b376f67c 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -985,8 +985,10 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
985 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { 985 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
986 struct usb_interface *interface; 986 struct usb_interface *interface;
987 987
988 /* remove this interface */ 988 /* remove this interface if it has been registered */
989 interface = dev->actconfig->interface[i]; 989 interface = dev->actconfig->interface[i];
990 if (!klist_node_attached(&interface->dev.knode_bus))
991 continue;
990 dev_dbg (&dev->dev, "unregistering interface %s\n", 992 dev_dbg (&dev->dev, "unregistering interface %s\n",
991 interface->dev.bus_id); 993 interface->dev.bus_id);
992 usb_remove_sysfs_intf_files(interface); 994 usb_remove_sysfs_intf_files(interface);
@@ -1439,7 +1441,7 @@ free_interfaces:
1439 } 1441 }
1440 } 1442 }
1441 1443
1442 return ret; 1444 return 0;
1443} 1445}
1444 1446
1445// synchronous request completion model 1447// synchronous request completion model
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index d74b2d68a50e..4f97a4ad1ed3 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -657,8 +657,8 @@ qh_make (
657 * For control/bulk requests, the HC or TT handles these. 657 * For control/bulk requests, the HC or TT handles these.
658 */ 658 */
659 if (type == PIPE_INTERRUPT) { 659 if (type == PIPE_INTERRUPT) {
660 qh->usecs = usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0, 660 qh->usecs = NS_TO_US (usb_calc_bus_time (USB_SPEED_HIGH, is_input, 0,
661 hb_mult (maxp) * max_packet (maxp)); 661 hb_mult (maxp) * max_packet (maxp)));
662 qh->start = NO_FRAME; 662 qh->start = NO_FRAME;
663 663
664 if (urb->dev->speed == USB_SPEED_HIGH) { 664 if (urb->dev->speed == USB_SPEED_HIGH) {
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 68decab280dd..56b43f2a0e52 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -887,6 +887,10 @@ MODULE_LICENSE ("GPL");
887#include "ohci-sa1111.c" 887#include "ohci-sa1111.c"
888#endif 888#endif
889 889
890#ifdef CONFIG_ARCH_S3C2410
891#include "ohci-s3c2410.c"
892#endif
893
890#ifdef CONFIG_ARCH_OMAP 894#ifdef CONFIG_ARCH_OMAP
891#include "ohci-omap.c" 895#include "ohci-omap.c"
892#endif 896#endif
@@ -909,6 +913,7 @@ MODULE_LICENSE ("GPL");
909 913
910#if !(defined(CONFIG_PCI) \ 914#if !(defined(CONFIG_PCI) \
911 || defined(CONFIG_SA1111) \ 915 || defined(CONFIG_SA1111) \
916 || defined(CONFIG_ARCH_S3C2410) \
912 || defined(CONFIG_ARCH_OMAP) \ 917 || defined(CONFIG_ARCH_OMAP) \
913 || defined (CONFIG_ARCH_LH7A404) \ 918 || defined (CONFIG_ARCH_LH7A404) \
914 || defined (CONFIG_PXA27x) \ 919 || defined (CONFIG_PXA27x) \
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
new file mode 100644
index 000000000000..e9401662503c
--- /dev/null
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -0,0 +1,496 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 *
8 * USB Bus Glue for Samsung S3C2410
9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Rusell King et al.
12 *
13 * Modified for S3C2410 from ohci-sa1111.c, ohci-omap.c and ohci-lh7a40.c
14 * by Ben Dooks, <ben@simtec.co.uk>
15 * Copyright (C) 2004 Simtec Electronics
16 *
17 * Thanks to basprog@mail.ru for updates to newer kernels
18 *
19 * This file is licenced under the GPL.
20*/
21
22#include <asm/hardware.h>
23#include <asm/mach-types.h>
24#include <asm/hardware/clock.h>
25#include <asm/arch/usb-control.h>
26
27#define valid_port(idx) ((idx) == 1 || (idx) == 2)
28
29/* clock device associated with the hcd */
30
31static struct clk *clk;
32
33/* forward definitions */
34
35static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc);
36
37/* conversion functions */
38
39struct s3c2410_hcd_info *to_s3c2410_info(struct usb_hcd *hcd)
40{
41 return hcd->self.controller->platform_data;
42}
43
44static void s3c2410_start_hc(struct platform_device *dev, struct usb_hcd *hcd)
45{
46 struct s3c2410_hcd_info *info = dev->dev.platform_data;
47
48 dev_dbg(&dev->dev, "s3c2410_start_hc:\n");
49 clk_enable(clk);
50
51 if (info != NULL) {
52 info->hcd = hcd;
53 info->report_oc = s3c2410_hcd_oc;
54
55 if (info->enable_oc != NULL) {
56 (info->enable_oc)(info, 1);
57 }
58 }
59}
60
61static void s3c2410_stop_hc(struct platform_device *dev)
62{
63 struct s3c2410_hcd_info *info = dev->dev.platform_data;
64
65 dev_dbg(&dev->dev, "s3c2410_stop_hc:\n");
66
67 if (info != NULL) {
68 info->report_oc = NULL;
69 info->hcd = NULL;
70
71 if (info->enable_oc != NULL) {
72 (info->enable_oc)(info, 0);
73 }
74 }
75
76 clk_disable(clk);
77}
78
79/* ohci_s3c2410_hub_status_data
80 *
81 * update the status data from the hub with anything that
82 * has been detected by our system
83*/
84
85static int
86ohci_s3c2410_hub_status_data (struct usb_hcd *hcd, char *buf)
87{
88 struct s3c2410_hcd_info *info = to_s3c2410_info(hcd);
89 struct s3c2410_hcd_port *port;
90 int orig;
91 int portno;
92
93 orig = ohci_hub_status_data (hcd, buf);
94
95 if (info == NULL)
96 return orig;
97
98 port = &info->port[0];
99
100 /* mark any changed port as changed */
101
102 for (portno = 0; portno < 2; port++, portno++) {
103 if (port->oc_changed == 1 &&
104 port->flags & S3C_HCDFLG_USED) {
105 dev_dbg(hcd->self.controller,
106 "oc change on port %d\n", portno);
107
108 if (orig < 1)
109 orig = 1;
110
111 buf[0] |= 1<<(portno+1);
112 }
113 }
114
115 return orig;
116}
117
118/* s3c2410_usb_set_power
119 *
120 * configure the power on a port, by calling the platform device
121 * routine registered with the platform device
122*/
123
124static void s3c2410_usb_set_power(struct s3c2410_hcd_info *info,
125 int port, int to)
126{
127 if (info == NULL)
128 return;
129
130 if (info->power_control != NULL) {
131 info->port[port-1].power = to;
132 (info->power_control)(port, to);
133 }
134}
135
136/* ohci_s3c2410_hub_control
137 *
138 * look at control requests to the hub, and see if we need
139 * to take any action or over-ride the results from the
140 * request.
141*/
142
143static int ohci_s3c2410_hub_control (
144 struct usb_hcd *hcd,
145 u16 typeReq,
146 u16 wValue,
147 u16 wIndex,
148 char *buf,
149 u16 wLength)
150{
151 struct s3c2410_hcd_info *info = to_s3c2410_info(hcd);
152 struct usb_hub_descriptor *desc;
153 int ret = -EINVAL;
154 u32 *data = (u32 *)buf;
155
156 dev_dbg(hcd->self.controller,
157 "s3c2410_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
158 hcd, typeReq, wValue, wIndex, buf, wLength);
159
160 /* if we are only an humble host without any special capabilites
161 * process the request straight away and exit */
162
163 if (info == NULL) {
164 ret = ohci_hub_control(hcd, typeReq, wValue,
165 wIndex, buf, wLength);
166 goto out;
167 }
168
169 /* check the request to see if it needs handling */
170
171 switch (typeReq) {
172 case SetPortFeature:
173 if (wValue == USB_PORT_FEAT_POWER) {
174 dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
175 s3c2410_usb_set_power(info, wIndex, 1);
176 goto out;
177 }
178 break;
179
180 case ClearPortFeature:
181 switch (wValue) {
182 case USB_PORT_FEAT_C_OVER_CURRENT:
183 dev_dbg(hcd->self.controller,
184 "ClearPortFeature: C_OVER_CURRENT\n");
185
186 if (valid_port(wIndex)) {
187 info->port[wIndex-1].oc_changed = 0;
188 info->port[wIndex-1].oc_status = 0;
189 }
190
191 goto out;
192
193 case USB_PORT_FEAT_OVER_CURRENT:
194 dev_dbg(hcd->self.controller,
195 "ClearPortFeature: OVER_CURRENT\n");
196
197 if (valid_port(wIndex)) {
198 info->port[wIndex-1].oc_status = 0;
199 }
200
201 goto out;
202
203 case USB_PORT_FEAT_POWER:
204 dev_dbg(hcd->self.controller,
205 "ClearPortFeature: POWER\n");
206
207 if (valid_port(wIndex)) {
208 s3c2410_usb_set_power(info, wIndex, 0);
209 return 0;
210 }
211 }
212 break;
213 }
214
215 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
216 if (ret)
217 goto out;
218
219 switch (typeReq) {
220 case GetHubDescriptor:
221
222 /* update the hub's descriptor */
223
224 desc = (struct usb_hub_descriptor *)buf;
225
226 if (info->power_control == NULL)
227 return ret;
228
229 dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n",
230 desc->wHubCharacteristics);
231
232 /* remove the old configurations for power-switching, and
233 * over-current protection, and insert our new configuration
234 */
235
236 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
237 desc->wHubCharacteristics |= cpu_to_le16(0x0001);
238
239 if (info->enable_oc) {
240 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
241 desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001);
242 }
243
244 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
245 desc->wHubCharacteristics);
246
247 return ret;
248
249 case GetPortStatus:
250 /* check port status */
251
252 dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);
253
254 if (valid_port(wIndex)) {
255 if (info->port[wIndex-1].oc_changed) {
256 *data |= cpu_to_le32(RH_PS_OCIC);
257 }
258
259 if (info->port[wIndex-1].oc_status) {
260 *data |= cpu_to_le32(RH_PS_POCI);
261 }
262 }
263 }
264
265 out:
266 return ret;
267}
268
269/* s3c2410_hcd_oc
270 *
271 * handle an over-current report
272*/
273
274static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc)
275{
276 struct s3c2410_hcd_port *port;
277 struct usb_hcd *hcd;
278 unsigned long flags;
279 int portno;
280
281 if (info == NULL)
282 return;
283
284 port = &info->port[0];
285 hcd = info->hcd;
286
287 local_irq_save(flags);
288
289 for (portno = 0; portno < 2; port++, portno++) {
290 if (port_oc & (1<<portno) &&
291 port->flags & S3C_HCDFLG_USED) {
292 port->oc_status = 1;
293 port->oc_changed = 1;
294
295 /* ok, once over-current is detected,
296 the port needs to be powered down */
297 s3c2410_usb_set_power(info, portno+1, 0);
298 }
299 }
300
301 local_irq_restore(flags);
302}
303
304/* may be called without controller electrically present */
305/* may be called with controller, bus, and devices active */
306
307/*
308 * usb_hcd_s3c2410_remove - shutdown processing for HCD
309 * @dev: USB Host Controller being removed
310 * Context: !in_interrupt()
311 *
312 * Reverses the effect of usb_hcd_3c2410_probe(), first invoking
313 * the HCD's stop() method. It is always called from a thread
314 * context, normally "rmmod", "apmd", or something similar.
315 *
316*/
317
318void usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev)
319{
320 usb_remove_hcd(hcd);
321 s3c2410_stop_hc(dev);
322 iounmap(hcd->regs);
323 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
324 usb_put_hcd(hcd);
325}
326
327/**
328 * usb_hcd_s3c2410_probe - initialize S3C2410-based HCDs
329 * Context: !in_interrupt()
330 *
331 * Allocates basic resources for this USB host controller, and
332 * then invokes the start() method for the HCD associated with it
333 * through the hotplug entry's driver_data.
334 *
335 */
336int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
337 struct platform_device *dev)
338{
339 struct usb_hcd *hcd = NULL;
340 int retval;
341
342 s3c2410_usb_set_power(dev->dev.platform_data, 0, 1);
343 s3c2410_usb_set_power(dev->dev.platform_data, 1, 1);
344
345 hcd = usb_create_hcd(driver, &dev->dev, "s3c24xx");
346 if (hcd == NULL)
347 return -ENOMEM;
348
349 hcd->rsrc_start = dev->resource[0].start;
350 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
351
352 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
353 dev_err(&dev->dev, "request_mem_region failed");
354 retval = -EBUSY;
355 goto err0;
356 }
357
358 clk = clk_get(NULL, "usb-host");
359 if (IS_ERR(clk)) {
360 dev_err(&dev->dev, "cannot get usb-host clock\n");
361 retval = -ENOENT;
362 goto err1;
363 }
364
365 clk_use(clk);
366 s3c2410_start_hc(dev, hcd);
367
368 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
369 if (!hcd->regs) {
370 dev_err(&dev->dev, "ioremap failed\n");
371 retval = -ENOMEM;
372 goto err2;
373 }
374
375 ohci_hcd_init(hcd_to_ohci(hcd));
376
377 retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT);
378 if (retval != 0)
379 goto err2;
380
381 return 0;
382
383 err2:
384 s3c2410_stop_hc(dev);
385 iounmap(hcd->regs);
386 clk_unuse(clk);
387 clk_put(clk);
388
389 err1:
390 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
391
392 err0:
393 usb_put_hcd(hcd);
394 return retval;
395}
396
397/*-------------------------------------------------------------------------*/
398
399static int
400ohci_s3c2410_start (struct usb_hcd *hcd)
401{
402 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
403 int ret;
404
405 if ((ret = ohci_init(ohci)) < 0)
406 return ret;
407
408 if ((ret = ohci_run (ohci)) < 0) {
409 err ("can't start %s", hcd->self.bus_name);
410 ohci_stop (hcd);
411 return ret;
412 }
413
414 return 0;
415}
416
417
418static const struct hc_driver ohci_s3c2410_hc_driver = {
419 .description = hcd_name,
420 .product_desc = "S3C24XX OHCI",
421 .hcd_priv_size = sizeof(struct ohci_hcd),
422
423 /*
424 * generic hardware linkage
425 */
426 .irq = ohci_irq,
427 .flags = HCD_USB11 | HCD_MEMORY,
428
429 /*
430 * basic lifecycle operations
431 */
432 .start = ohci_s3c2410_start,
433 .stop = ohci_stop,
434
435 /*
436 * managing i/o requests and associated device resources
437 */
438 .urb_enqueue = ohci_urb_enqueue,
439 .urb_dequeue = ohci_urb_dequeue,
440 .endpoint_disable = ohci_endpoint_disable,
441
442 /*
443 * scheduling support
444 */
445 .get_frame_number = ohci_get_frame,
446
447 /*
448 * root hub support
449 */
450 .hub_status_data = ohci_s3c2410_hub_status_data,
451 .hub_control = ohci_s3c2410_hub_control,
452
453#if defined(CONFIG_USB_SUSPEND) && 0
454 .hub_suspend = ohci_hub_suspend,
455 .hub_resume = ohci_hub_resume,
456#endif
457};
458
459/* device driver */
460
461static int ohci_hcd_s3c2410_drv_probe(struct device *dev)
462{
463 struct platform_device *pdev = to_platform_device(dev);
464 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev);
465}
466
467static int ohci_hcd_s3c2410_drv_remove(struct device *dev)
468{
469 struct platform_device *pdev = to_platform_device(dev);
470 struct usb_hcd *hcd = dev_get_drvdata(dev);
471
472 usb_hcd_s3c2410_remove(hcd, pdev);
473 return 0;
474}
475
476static struct device_driver ohci_hcd_s3c2410_driver = {
477 .name = "s3c2410-ohci",
478 .bus = &platform_bus_type,
479 .probe = ohci_hcd_s3c2410_drv_probe,
480 .remove = ohci_hcd_s3c2410_drv_remove,
481 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */
482 /*.resume = ohci_hcd_s3c2410_drv_resume, */
483};
484
485static int __init ohci_hcd_s3c2410_init (void)
486{
487 return driver_register(&ohci_hcd_s3c2410_driver);
488}
489
490static void __exit ohci_hcd_s3c2410_cleanup (void)
491{
492 driver_unregister(&ohci_hcd_s3c2410_driver);
493}
494
495module_init (ohci_hcd_s3c2410_init);
496module_exit (ohci_hcd_s3c2410_cleanup);
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 7d21a4f5c425..c84e1486054f 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -361,8 +361,7 @@ int mts_scsi_queuecommand (Scsi_Cmnd *srb, mts_scsi_cmnd_callback callback );
361static void mts_transfer_cleanup( struct urb *transfer ); 361static void mts_transfer_cleanup( struct urb *transfer );
362static void mts_do_sg(struct urb * transfer, struct pt_regs *regs); 362static void mts_do_sg(struct urb * transfer, struct pt_regs *regs);
363 363
364 364static inline
365inline static
366void mts_int_submit_urb (struct urb* transfer, 365void mts_int_submit_urb (struct urb* transfer,
367 int pipe, 366 int pipe,
368 void* data, 367 void* data,
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index ebcf7c955800..13532f3e3efc 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/usb_input.h>
34 35
35/* 36/*
36 * Version Information 37 * Version Information
@@ -87,8 +88,8 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
87 if (prox) { 88 if (prox) {
88 int x = data[1] | (data[2] << 8); 89 int x = data[1] | (data[2] << 8);
89 int y = data[3] | (data[4] << 8); 90 int y = data[3] | (data[4] << 8);
90 /*Pressure should compute the same way for flair and 302*/ 91 /* Pressure should compute the same way for flair and 302 */
91 int pressure = data[5] | ((int)data[6] << 8); 92 int pressure = data[5] | (data[6] << 8);
92 int touch = data[0] & 0x01; 93 int touch = data[0] & 0x01;
93 int stylus = (data[0] & 0x10) >> 4; 94 int stylus = (data[0] & 0x10) >> 4;
94 int stylus2 = (data[0] & 0x20) >> 5; 95 int stylus2 = (data[0] & 0x20) >> 5;
@@ -104,9 +105,9 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
104 input_sync(dev); 105 input_sync(dev);
105 106
106resubmit: 107resubmit:
107 status = usb_submit_urb (urb, GFP_ATOMIC); 108 status = usb_submit_urb(urb, GFP_ATOMIC);
108 if (status) 109 if (status)
109 err ("can't resubmit intr, %s-%s/input0, status %d", 110 err("can't resubmit intr, %s-%s/input0, status %d",
110 acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status); 111 acecad->usbdev->bus->bus_name, acecad->usbdev->devpath, status);
111} 112}
112 113
@@ -212,10 +213,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
212 213
213 acecad->dev.name = acecad->name; 214 acecad->dev.name = acecad->name;
214 acecad->dev.phys = acecad->phys; 215 acecad->dev.phys = acecad->phys;
215 acecad->dev.id.bustype = BUS_USB; 216 usb_to_input_id(dev, &acecad->dev.id);
216 acecad->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
217 acecad->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
218 acecad->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
219 acecad->dev.dev = &intf->dev; 217 acecad->dev.dev = &intf->dev;
220 218
221 usb_fill_int_urb(acecad->irq, dev, pipe, 219 usb_fill_int_urb(acecad->irq, dev, pipe,
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 6bb0f25e8e93..cd0cbfe20723 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -77,6 +77,7 @@
77#include <linux/module.h> 77#include <linux/module.h>
78#include <linux/init.h> 78#include <linux/init.h>
79#include <linux/usb.h> 79#include <linux/usb.h>
80#include <linux/usb_input.h>
80#include <linux/sched.h> 81#include <linux/sched.h>
81#include <asm/uaccess.h> 82#include <asm/uaccess.h>
82#include <asm/unaligned.h> 83#include <asm/unaligned.h>
@@ -2125,10 +2126,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2125 aiptek->inputdev.absflat[ABS_WHEEL] = 0; 2126 aiptek->inputdev.absflat[ABS_WHEEL] = 0;
2126 aiptek->inputdev.name = "Aiptek"; 2127 aiptek->inputdev.name = "Aiptek";
2127 aiptek->inputdev.phys = aiptek->features.usbPath; 2128 aiptek->inputdev.phys = aiptek->features.usbPath;
2128 aiptek->inputdev.id.bustype = BUS_USB; 2129 usb_to_input_id(usbdev, &aiptek->inputdev.id);
2129 aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor);
2130 aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct);
2131 aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice);
2132 aiptek->inputdev.dev = &intf->dev; 2130 aiptek->inputdev.dev = &intf->dev;
2133 2131
2134 aiptek->usbdev = usbdev; 2132 aiptek->usbdev = usbdev;
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 654ac454744d..fd99681ee483 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -94,6 +94,7 @@
94#include <linux/moduleparam.h> 94#include <linux/moduleparam.h>
95#include <linux/input.h> 95#include <linux/input.h>
96#include <linux/usb.h> 96#include <linux/usb.h>
97#include <linux/usb_input.h>
97#include <linux/wait.h> 98#include <linux/wait.h>
98 99
99/* 100/*
@@ -635,11 +636,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
635 idev->name = ati_remote->name; 636 idev->name = ati_remote->name;
636 idev->phys = ati_remote->phys; 637 idev->phys = ati_remote->phys;
637 638
638 idev->id.bustype = BUS_USB; 639 usb_to_input_id(ati_remote->udev, &idev->id);
639 idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); 640 idev->dev = &ati_remote->udev->dev;
640 idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct);
641 idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice);
642 idev->dev = &(ati_remote->udev->dev);
643} 641}
644 642
645static int ati_remote_initialize(struct ati_remote *ati_remote) 643static int ati_remote_initialize(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 2350e7a5ad70..b2cb2b35892e 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -789,12 +789,12 @@ static __inline__ int search(__s32 *array, __s32 value, unsigned n)
789 return -1; 789 return -1;
790} 790}
791 791
792static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) 792static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt, struct pt_regs *regs)
793{ 793{
794 hid_dump_input(usage, value); 794 hid_dump_input(usage, value);
795 if (hid->claimed & HID_CLAIMED_INPUT) 795 if (hid->claimed & HID_CLAIMED_INPUT)
796 hidinput_hid_event(hid, field, usage, value, regs); 796 hidinput_hid_event(hid, field, usage, value, regs);
797 if (hid->claimed & HID_CLAIMED_HIDDEV) 797 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt)
798 hiddev_hid_event(hid, field, usage, value, regs); 798 hiddev_hid_event(hid, field, usage, value, regs);
799} 799}
800 800
@@ -804,7 +804,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
804 * reporting to the layer). 804 * reporting to the layer).
805 */ 805 */
806 806
807static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, struct pt_regs *regs) 807static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt, struct pt_regs *regs)
808{ 808{
809 unsigned n; 809 unsigned n;
810 unsigned count = field->report_count; 810 unsigned count = field->report_count;
@@ -831,19 +831,19 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u
831 for (n = 0; n < count; n++) { 831 for (n = 0; n < count; n++) {
832 832
833 if (HID_MAIN_ITEM_VARIABLE & field->flags) { 833 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
834 hid_process_event(hid, field, &field->usage[n], value[n], regs); 834 hid_process_event(hid, field, &field->usage[n], value[n], interrupt, regs);
835 continue; 835 continue;
836 } 836 }
837 837
838 if (field->value[n] >= min && field->value[n] <= max 838 if (field->value[n] >= min && field->value[n] <= max
839 && field->usage[field->value[n] - min].hid 839 && field->usage[field->value[n] - min].hid
840 && search(value, field->value[n], count)) 840 && search(value, field->value[n], count))
841 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, regs); 841 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt, regs);
842 842
843 if (value[n] >= min && value[n] <= max 843 if (value[n] >= min && value[n] <= max
844 && field->usage[value[n] - min].hid 844 && field->usage[value[n] - min].hid
845 && search(field->value, value[n], count)) 845 && search(field->value, value[n], count))
846 hid_process_event(hid, field, &field->usage[value[n] - min], 1, regs); 846 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt, regs);
847 } 847 }
848 848
849 memcpy(field->value, value, count * sizeof(__s32)); 849 memcpy(field->value, value, count * sizeof(__s32));
@@ -851,7 +851,7 @@ exit:
851 kfree(value); 851 kfree(value);
852} 852}
853 853
854static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs) 854static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_regs *regs)
855{ 855{
856 struct hid_device *hid = urb->context; 856 struct hid_device *hid = urb->context;
857 struct hid_report_enum *report_enum = hid->report_enum + type; 857 struct hid_report_enum *report_enum = hid->report_enum + type;
@@ -899,7 +899,7 @@ static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs)
899 hiddev_report_event(hid, report); 899 hiddev_report_event(hid, report);
900 900
901 for (n = 0; n < report->maxfield; n++) 901 for (n = 0; n < report->maxfield; n++)
902 hid_input_field(hid, report->field[n], data, regs); 902 hid_input_field(hid, report->field[n], data, interrupt, regs);
903 903
904 if (hid->claimed & HID_CLAIMED_INPUT) 904 if (hid->claimed & HID_CLAIMED_INPUT)
905 hidinput_report_event(hid, report); 905 hidinput_report_event(hid, report);
@@ -918,7 +918,7 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs)
918 918
919 switch (urb->status) { 919 switch (urb->status) {
920 case 0: /* success */ 920 case 0: /* success */
921 hid_input_report(HID_INPUT_REPORT, urb, regs); 921 hid_input_report(HID_INPUT_REPORT, urb, 1, regs);
922 break; 922 break;
923 case -ECONNRESET: /* unlink */ 923 case -ECONNRESET: /* unlink */
924 case -ENOENT: 924 case -ENOENT:
@@ -1142,7 +1142,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs)
1142 switch (urb->status) { 1142 switch (urb->status) {
1143 case 0: /* success */ 1143 case 0: /* success */
1144 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) 1144 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN)
1145 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, regs); 1145 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs);
1146 case -ESHUTDOWN: /* unplug */ 1146 case -ESHUTDOWN: /* unplug */
1147 case -EILSEQ: /* unplug timectrl on uhci */ 1147 case -EILSEQ: /* unplug timectrl on uhci */
1148 unplug = 1; 1148 unplug = 1;
@@ -1372,6 +1372,9 @@ void hid_init_reports(struct hid_device *hid)
1372#define USB_VENDOR_ID_A4TECH 0x09da 1372#define USB_VENDOR_ID_A4TECH 0x09da
1373#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 1373#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
1374 1374
1375#define USB_VENDOR_ID_AASHIMA 0x06D6
1376#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
1377
1375#define USB_VENDOR_ID_CYPRESS 0x04b4 1378#define USB_VENDOR_ID_CYPRESS 0x04b4
1376#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 1379#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
1377#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 1380#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
@@ -1548,6 +1551,7 @@ static struct hid_blacklist {
1548 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, 1551 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
1549 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, 1552 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
1550 1553
1554 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
1551 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 1555 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
1552 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 1556 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
1553 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 1557 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9ac1e9095334..63a4db721f7e 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -31,6 +31,7 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/usb.h> 33#include <linux/usb.h>
34#include <linux/usb_input.h>
34 35
35#undef DEBUG 36#undef DEBUG
36 37
@@ -397,11 +398,12 @@ ignore:
397 398
398void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) 399void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs)
399{ 400{
400 struct input_dev *input = &field->hidinput->input; 401 struct input_dev *input;
401 int *quirks = &hid->quirks; 402 int *quirks = &hid->quirks;
402 403
403 if (!input) 404 if (!field->hidinput)
404 return; 405 return;
406 input = &field->hidinput->input;
405 407
406 input_regs(input, regs); 408 input_regs(input, regs);
407 409
@@ -581,10 +583,7 @@ int hidinput_connect(struct hid_device *hid)
581 hidinput->input.name = hid->name; 583 hidinput->input.name = hid->name;
582 hidinput->input.phys = hid->phys; 584 hidinput->input.phys = hid->phys;
583 hidinput->input.uniq = hid->uniq; 585 hidinput->input.uniq = hid->uniq;
584 hidinput->input.id.bustype = BUS_USB; 586 usb_to_input_id(dev, &hidinput->input.id);
585 hidinput->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
586 hidinput->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
587 hidinput->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
588 hidinput->input.dev = &hid->intf->dev; 587 hidinput->input.dev = &hid->intf->dev;
589 } 588 }
590 589
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index 47dec6a1b344..0dc439f10823 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -53,6 +53,7 @@
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/usb_input.h>
56 57
57/* only an 8 byte buffer necessary for a single packet */ 58/* only an 8 byte buffer necessary for a single packet */
58#define ITM_BUFSIZE 8 59#define ITM_BUFSIZE 8
@@ -184,10 +185,7 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id
184 185
185 itmtouch->inputdev.name = itmtouch->name; 186 itmtouch->inputdev.name = itmtouch->name;
186 itmtouch->inputdev.phys = itmtouch->phys; 187 itmtouch->inputdev.phys = itmtouch->phys;
187 itmtouch->inputdev.id.bustype = BUS_USB; 188 usb_to_input_id(udev, &itmtouch->inputdev.id);
188 itmtouch->inputdev.id.vendor = udev->descriptor.idVendor;
189 itmtouch->inputdev.id.product = udev->descriptor.idProduct;
190 itmtouch->inputdev.id.version = udev->descriptor.bcdDevice;
191 itmtouch->inputdev.dev = &intf->dev; 189 itmtouch->inputdev.dev = &intf->dev;
192 190
193 if (!strlen(itmtouch->name)) 191 if (!strlen(itmtouch->name))
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index d2f0f90a9bcd..b6f6ac8d9c2f 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -4,6 +4,7 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/usb.h> 6#include <linux/usb.h>
7#include <linux/usb_input.h>
7#include <asm/unaligned.h> 8#include <asm/unaligned.h>
8#include <asm/byteorder.h> 9#include <asm/byteorder.h>
9 10
@@ -167,10 +168,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
167 168
168 kbtab->dev.name = "KB Gear Tablet"; 169 kbtab->dev.name = "KB Gear Tablet";
169 kbtab->dev.phys = kbtab->phys; 170 kbtab->dev.phys = kbtab->phys;
170 kbtab->dev.id.bustype = BUS_USB; 171 usb_to_input_id(dev, &kbtab->dev.id);
171 kbtab->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
172 kbtab->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
173 kbtab->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
174 kbtab->dev.dev = &intf->dev; 172 kbtab->dev.dev = &intf->dev;
175 kbtab->usbdev = dev; 173 kbtab->usbdev = dev;
176 174
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 09b5cc7c66de..ff9275057a18 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -53,6 +53,7 @@
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/usb_input.h>
56 57
57#define MTOUCHUSB_MIN_XC 0x0 58#define MTOUCHUSB_MIN_XC 0x0
58#define MTOUCHUSB_MAX_RAW_XC 0x4000 59#define MTOUCHUSB_MAX_RAW_XC 0x4000
@@ -232,10 +233,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
232 233
233 mtouch->input.name = mtouch->name; 234 mtouch->input.name = mtouch->name;
234 mtouch->input.phys = mtouch->phys; 235 mtouch->input.phys = mtouch->phys;
235 mtouch->input.id.bustype = BUS_USB; 236 usb_to_input_id(udev, &mtouch->input.id);
236 mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
237 mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
238 mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
239 mtouch->input.dev = &intf->dev; 237 mtouch->input.dev = &intf->dev;
240 238
241 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 239 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 3975b309d55f..ad4afe7e5897 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -35,6 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb_input.h>
38 39
39#define POWERMATE_VENDOR 0x077d /* Griffin Technology, Inc. */ 40#define POWERMATE_VENDOR 0x077d /* Griffin Technology, Inc. */
40#define POWERMATE_PRODUCT_NEW 0x0410 /* Griffin PowerMate */ 41#define POWERMATE_PRODUCT_NEW 0x0410 /* Griffin PowerMate */
@@ -389,10 +390,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
389 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); 390 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
390 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); 391 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL);
391 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); 392 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED);
392 pm->input.id.bustype = BUS_USB; 393 usb_to_input_id(udev, &pm->input.id);
393 pm->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
394 pm->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
395 pm->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
396 pm->input.event = powermate_input_event; 394 pm->input.event = powermate_input_event;
397 pm->input.dev = &intf->dev; 395 pm->input.dev = &intf->dev;
398 pm->input.phys = pm->phys; 396 pm->input.phys = pm->phys;
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 386595ee21c0..4276c24a5080 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -35,7 +35,7 @@
35#define DEBUG 35#define DEBUG
36#endif 36#endif
37#include <linux/usb.h> 37#include <linux/usb.h>
38 38#include <linux/usb_input.h>
39 39
40#define TOUCHKIT_MIN_XC 0x0 40#define TOUCHKIT_MIN_XC 0x0
41#define TOUCHKIT_MAX_XC 0x07ff 41#define TOUCHKIT_MAX_XC 0x07ff
@@ -202,10 +202,7 @@ static int touchkit_probe(struct usb_interface *intf,
202 202
203 touchkit->input.name = touchkit->name; 203 touchkit->input.name = touchkit->name;
204 touchkit->input.phys = touchkit->phys; 204 touchkit->input.phys = touchkit->phys;
205 touchkit->input.id.bustype = BUS_USB; 205 usb_to_input_id(udev, &touchkit->input.id);
206 touchkit->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
207 touchkit->input.id.product = le16_to_cpu(udev->descriptor.idProduct);
208 touchkit->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
209 touchkit->input.dev = &intf->dev; 206 touchkit->input.dev = &intf->dev;
210 207
211 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 208 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index f35db1974c42..28987f15eeee 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -32,6 +32,7 @@
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/usb_input.h>
35 36
36/* 37/*
37 * Version Information 38 * Version Information
@@ -288,10 +289,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
288 289
289 kbd->dev.name = kbd->name; 290 kbd->dev.name = kbd->name;
290 kbd->dev.phys = kbd->phys; 291 kbd->dev.phys = kbd->phys;
291 kbd->dev.id.bustype = BUS_USB; 292 usb_to_input_id(dev, &kbd->dev.id);
292 kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
293 kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
294 kbd->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
295 kbd->dev.dev = &iface->dev; 293 kbd->dev.dev = &iface->dev;
296 294
297 if (dev->manufacturer) 295 if (dev->manufacturer)
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 1ec41b5effe6..4104dec847fb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/usb_input.h>
35 36
36/* 37/*
37 * Version Information 38 * Version Information
@@ -171,10 +172,7 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
171 172
172 mouse->dev.name = mouse->name; 173 mouse->dev.name = mouse->name;
173 mouse->dev.phys = mouse->phys; 174 mouse->dev.phys = mouse->phys;
174 mouse->dev.id.bustype = BUS_USB; 175 usb_to_input_id(dev, &mouse->dev.id);
175 mouse->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
176 mouse->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
177 mouse->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
178 mouse->dev.dev = &intf->dev; 176 mouse->dev.dev = &intf->dev;
179 177
180 if (dev->manufacturer) 178 if (dev->manufacturer)
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index f6b34af66b3d..02412e31a46b 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -69,6 +69,7 @@
69#include <linux/module.h> 69#include <linux/module.h>
70#include <linux/init.h> 70#include <linux/init.h>
71#include <linux/usb.h> 71#include <linux/usb.h>
72#include <linux/usb_input.h>
72#include <asm/unaligned.h> 73#include <asm/unaligned.h>
73#include <asm/byteorder.h> 74#include <asm/byteorder.h>
74 75
@@ -823,10 +824,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
823 824
824 wacom->dev.name = wacom->features->name; 825 wacom->dev.name = wacom->features->name;
825 wacom->dev.phys = wacom->phys; 826 wacom->dev.phys = wacom->phys;
826 wacom->dev.id.bustype = BUS_USB; 827 usb_to_input_id(dev, &wacom->dev.id);
827 wacom->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
828 wacom->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
829 wacom->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
830 wacom->dev.dev = &intf->dev; 828 wacom->dev.dev = &intf->dev;
831 wacom->usbdev = dev; 829 wacom->usbdev = dev;
832 830
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index a7fa1b17dcfe..18125e0bffa2 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -62,6 +62,7 @@
62#include <linux/module.h> 62#include <linux/module.h>
63#include <linux/smp_lock.h> 63#include <linux/smp_lock.h>
64#include <linux/usb.h> 64#include <linux/usb.h>
65#include <linux/usb_input.h>
65 66
66#define DRIVER_VERSION "v0.0.5" 67#define DRIVER_VERSION "v0.0.5"
67#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" 68#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
@@ -256,10 +257,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
256 257
257 xpad->udev = udev; 258 xpad->udev = udev;
258 259
259 xpad->dev.id.bustype = BUS_USB; 260 usb_to_input_id(udev, &xpad->dev.id);
260 xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
261 xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct);
262 xpad->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
263 xpad->dev.dev = &intf->dev; 261 xpad->dev.dev = &intf->dev;
264 xpad->dev.private = xpad; 262 xpad->dev.private = xpad;
265 xpad->dev.name = xpad_device[i].name; 263 xpad->dev.name = xpad_device[i].name;
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
index 08521a2b4f3d..20ac9e1069d4 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/usb/media/konicawc.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/usb_input.h>
19 20
20#include "usbvideo.h" 21#include "usbvideo.h"
21 22
@@ -845,10 +846,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
845 cam->input.private = cam; 846 cam->input.private = cam;
846 cam->input.evbit[0] = BIT(EV_KEY); 847 cam->input.evbit[0] = BIT(EV_KEY);
847 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); 848 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
848 cam->input.id.bustype = BUS_USB; 849 usb_to_input_id(dev, &cam->input.id);
849 cam->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
850 cam->input.id.product = le16_to_cpu(dev->descriptor.idProduct);
851 cam->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice);
852 input_register_device(&cam->input); 850 input_register_device(&cam->input);
853 851
854 usb_make_path(dev, cam->input_physname, 56); 852 usb_make_path(dev, cam->input_physname, 56);
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 66ec88354b93..ad17892aac9e 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -23,6 +23,7 @@
23 * 23 *
24 * V0.1 (mh) Initial version 24 * V0.1 (mh) Initial version
25 * V0.11 (mh) Added raw support for HID 1.0 devices (no interrupt out endpoint) 25 * V0.11 (mh) Added raw support for HID 1.0 devices (no interrupt out endpoint)
26 * V0.12 (mh) Added kmalloc check for string buffer
26 */ 27 */
27 28
28#include <linux/config.h> 29#include <linux/config.h>
@@ -84,7 +85,7 @@ static struct usb_device_id ld_usb_table [] = {
84 { } /* Terminating entry */ 85 { } /* Terminating entry */
85}; 86};
86MODULE_DEVICE_TABLE(usb, ld_usb_table); 87MODULE_DEVICE_TABLE(usb, ld_usb_table);
87MODULE_VERSION("V0.11"); 88MODULE_VERSION("V0.12");
88MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>"); 89MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>");
89MODULE_DESCRIPTION("LD USB Driver"); 90MODULE_DESCRIPTION("LD USB Driver");
90MODULE_LICENSE("GPL"); 91MODULE_LICENSE("GPL");
@@ -635,6 +636,10 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
635 (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_COM3LAB)) && 636 (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_COM3LAB)) &&
636 (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) { 637 (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {
637 buffer = kmalloc(256, GFP_KERNEL); 638 buffer = kmalloc(256, GFP_KERNEL);
639 if (buffer == NULL) {
640 dev_err(&intf->dev, "Couldn't allocate string buffer\n");
641 goto error;
642 }
638 /* usb_string makes SETUP+STALL to leave always ControlReadLoop */ 643 /* usb_string makes SETUP+STALL to leave always ControlReadLoop */
639 usb_string(udev, 255, buffer, 256); 644 usb_string(udev, 255, buffer, 256);
640 kfree(buffer); 645 kfree(buffer);
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 5f4496d8dbac..fcd6d3ccef44 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -59,7 +59,6 @@ static const char driver_name[] = "pegasus";
59 59
60static int loopback = 0; 60static int loopback = 0;
61static int mii_mode = 0; 61static int mii_mode = 0;
62static int multicast_filter_limit = 32;
63 62
64static struct usb_eth_dev usb_dev_id[] = { 63static struct usb_eth_dev usb_dev_id[] = {
65#define PEGASUS_DEV(pn, vid, pid, flags) \ 64#define PEGASUS_DEV(pn, vid, pid, flags) \
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 626b016addff..59ab40ebb394 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -167,8 +167,6 @@ struct rtl8150 {
167 167
168typedef struct rtl8150 rtl8150_t; 168typedef struct rtl8150 rtl8150_t;
169 169
170static unsigned long multicast_filter_limit = 32;
171
172static void fill_skb_pool(rtl8150_t *); 170static void fill_skb_pool(rtl8150_t *);
173static void free_skb_pool(rtl8150_t *); 171static void free_skb_pool(rtl8150_t *);
174static inline struct sk_buff *pull_skb(rtl8150_t *); 172static inline struct sk_buff *pull_skb(rtl8150_t *);
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index 72b06129e20a..2a1d489e92c0 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -29,6 +29,7 @@ static struct usb_device_id zd1201_table[] = {
29 {USB_DEVICE(0x0ace, 0x1201)}, /* ZyDAS ZD1201 Wireless USB Adapter */ 29 {USB_DEVICE(0x0ace, 0x1201)}, /* ZyDAS ZD1201 Wireless USB Adapter */
30 {USB_DEVICE(0x050d, 0x6051)}, /* Belkin F5D6051 usb adapter */ 30 {USB_DEVICE(0x050d, 0x6051)}, /* Belkin F5D6051 usb adapter */
31 {USB_DEVICE(0x0db0, 0x6823)}, /* MSI UB11B usb adapter */ 31 {USB_DEVICE(0x0db0, 0x6823)}, /* MSI UB11B usb adapter */
32 {USB_DEVICE(0x1044, 0x8005)}, /* GIGABYTE GN-WLBZ201 usb adapter */
32 {} 33 {}
33}; 34};
34 35
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0b03ddab53d9..d1964a0c4168 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -429,6 +429,9 @@ static struct usb_device_id id_table_combined [] = {
429 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) }, 429 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
430 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, 430 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
431 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) }, 431 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
432 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) },
433 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) },
434 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
432 { } /* Terminating entry */ 435 { } /* Terminating entry */
433}; 436};
434 437
@@ -545,6 +548,7 @@ static struct usb_serial_device_type ftdi_sio_device = {
545 548
546 549
547#define WDR_TIMEOUT 5000 /* default urb timeout */ 550#define WDR_TIMEOUT 5000 /* default urb timeout */
551#define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */
548 552
549/* High and low are for DTR, RTS etc etc */ 553/* High and low are for DTR, RTS etc etc */
550#define HIGH 1 554#define HIGH 1
@@ -593,62 +597,59 @@ static __u32 ftdi_232bm_baud_to_divisor(int baud)
593 return(ftdi_232bm_baud_base_to_divisor(baud, 48000000)); 597 return(ftdi_232bm_baud_base_to_divisor(baud, 48000000));
594} 598}
595 599
596static int set_rts(struct usb_serial_port *port, int high_or_low) 600#define set_mctrl(port, set) update_mctrl((port), (set), 0)
601#define clear_mctrl(port, clear) update_mctrl((port), 0, (clear))
602
603static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear)
597{ 604{
598 struct ftdi_private *priv = usb_get_serial_port_data(port); 605 struct ftdi_private *priv = usb_get_serial_port_data(port);
599 char *buf; 606 char *buf;
600 unsigned ftdi_high_or_low; 607 unsigned urb_value;
601 int rv; 608 int rv;
602
603 buf = kmalloc(1, GFP_NOIO);
604 if (!buf)
605 return -ENOMEM;
606
607 if (high_or_low) {
608 ftdi_high_or_low = FTDI_SIO_SET_RTS_HIGH;
609 priv->last_dtr_rts |= TIOCM_RTS;
610 } else {
611 ftdi_high_or_low = FTDI_SIO_SET_RTS_LOW;
612 priv->last_dtr_rts &= ~TIOCM_RTS;
613 }
614 rv = usb_control_msg(port->serial->dev,
615 usb_sndctrlpipe(port->serial->dev, 0),
616 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
617 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
618 ftdi_high_or_low, priv->interface,
619 buf, 0, WDR_TIMEOUT);
620
621 kfree(buf);
622 return rv;
623}
624 609
610 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
611 dbg("%s - DTR|RTS not being set|cleared", __FUNCTION__);
612 return 0; /* no change */
613 }
625 614
626static int set_dtr(struct usb_serial_port *port, int high_or_low)
627{
628 struct ftdi_private *priv = usb_get_serial_port_data(port);
629 char *buf;
630 unsigned ftdi_high_or_low;
631 int rv;
632
633 buf = kmalloc(1, GFP_NOIO); 615 buf = kmalloc(1, GFP_NOIO);
634 if (!buf) 616 if (!buf) {
635 return -ENOMEM; 617 return -ENOMEM;
636
637 if (high_or_low) {
638 ftdi_high_or_low = FTDI_SIO_SET_DTR_HIGH;
639 priv->last_dtr_rts |= TIOCM_DTR;
640 } else {
641 ftdi_high_or_low = FTDI_SIO_SET_DTR_LOW;
642 priv->last_dtr_rts &= ~TIOCM_DTR;
643 } 618 }
619
620 clear &= ~set; /* 'set' takes precedence over 'clear' */
621 urb_value = 0;
622 if (clear & TIOCM_DTR)
623 urb_value |= FTDI_SIO_SET_DTR_LOW;
624 if (clear & TIOCM_RTS)
625 urb_value |= FTDI_SIO_SET_RTS_LOW;
626 if (set & TIOCM_DTR)
627 urb_value |= FTDI_SIO_SET_DTR_HIGH;
628 if (set & TIOCM_RTS)
629 urb_value |= FTDI_SIO_SET_RTS_HIGH;
644 rv = usb_control_msg(port->serial->dev, 630 rv = usb_control_msg(port->serial->dev,
645 usb_sndctrlpipe(port->serial->dev, 0), 631 usb_sndctrlpipe(port->serial->dev, 0),
646 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 632 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
647 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 633 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
648 ftdi_high_or_low, priv->interface, 634 urb_value, priv->interface,
649 buf, 0, WDR_TIMEOUT); 635 buf, 0, WDR_TIMEOUT);
650 636
651 kfree(buf); 637 kfree(buf);
638 if (rv < 0) {
639 err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
640 __FUNCTION__,
641 (set & TIOCM_DTR) ? "HIGH" :
642 (clear & TIOCM_DTR) ? "LOW" : "unchanged",
643 (set & TIOCM_RTS) ? "HIGH" :
644 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
645 } else {
646 dbg("%s - DTR %s, RTS %s", __FUNCTION__,
647 (set & TIOCM_DTR) ? "HIGH" :
648 (clear & TIOCM_DTR) ? "LOW" : "unchanged",
649 (set & TIOCM_RTS) ? "HIGH" :
650 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
651 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set;
652 }
652 return rv; 653 return rv;
653} 654}
654 655
@@ -681,7 +682,7 @@ static int change_speed(struct usb_serial_port *port)
681 FTDI_SIO_SET_BAUDRATE_REQUEST, 682 FTDI_SIO_SET_BAUDRATE_REQUEST,
682 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, 683 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
683 urb_value, urb_index, 684 urb_value, urb_index,
684 buf, 0, 100); 685 buf, 0, WDR_SHORT_TIMEOUT);
685 686
686 kfree(buf); 687 kfree(buf);
687 return rv; 688 return rv;
@@ -1219,12 +1220,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1219 /* FIXME: Flow control might be enabled, so it should be checked - 1220 /* FIXME: Flow control might be enabled, so it should be checked -
1220 we have no control of defaults! */ 1221 we have no control of defaults! */
1221 /* Turn on RTS and DTR since we are not flow controlling by default */ 1222 /* Turn on RTS and DTR since we are not flow controlling by default */
1222 if (set_dtr(port, HIGH) < 0) { 1223 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1223 err("%s Error from DTR HIGH urb", __FUNCTION__);
1224 }
1225 if (set_rts(port, HIGH) < 0){
1226 err("%s Error from RTS HIGH urb", __FUNCTION__);
1227 }
1228 1224
1229 /* Not throttled */ 1225 /* Not throttled */
1230 spin_lock_irqsave(&priv->rx_lock, flags); 1226 spin_lock_irqsave(&priv->rx_lock, flags);
@@ -1274,14 +1270,8 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1274 err("error from flowcontrol urb"); 1270 err("error from flowcontrol urb");
1275 } 1271 }
1276 1272
1277 /* drop DTR */ 1273 /* drop RTS and DTR */
1278 if (set_dtr(port, LOW) < 0){ 1274 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1279 err("Error from DTR LOW urb");
1280 }
1281 /* drop RTS */
1282 if (set_rts(port, LOW) < 0) {
1283 err("Error from RTS LOW urb");
1284 }
1285 } /* Note change no line if hupcl is off */ 1275 } /* Note change no line if hupcl is off */
1286 1276
1287 /* cancel any scheduled reading */ 1277 /* cancel any scheduled reading */
@@ -1797,7 +1787,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1797 FTDI_SIO_SET_DATA_REQUEST, 1787 FTDI_SIO_SET_DATA_REQUEST,
1798 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1788 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1799 urb_value , priv->interface, 1789 urb_value , priv->interface,
1800 buf, 0, 100) < 0) { 1790 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1801 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1791 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__);
1802 } 1792 }
1803 1793
@@ -1812,25 +1802,14 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1812 err("%s error from disable flowcontrol urb", __FUNCTION__); 1802 err("%s error from disable flowcontrol urb", __FUNCTION__);
1813 } 1803 }
1814 /* Drop RTS and DTR */ 1804 /* Drop RTS and DTR */
1815 if (set_dtr(port, LOW) < 0){ 1805 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1816 err("%s Error from DTR LOW urb", __FUNCTION__);
1817 }
1818 if (set_rts(port, LOW) < 0){
1819 err("%s Error from RTS LOW urb", __FUNCTION__);
1820 }
1821
1822 } else { 1806 } else {
1823 /* set the baudrate determined before */ 1807 /* set the baudrate determined before */
1824 if (change_speed(port)) { 1808 if (change_speed(port)) {
1825 err("%s urb failed to set baurdrate", __FUNCTION__); 1809 err("%s urb failed to set baurdrate", __FUNCTION__);
1826 } 1810 }
1827 /* Ensure RTS and DTR are raised */ 1811 /* Ensure RTS and DTR are raised */
1828 else if (set_dtr(port, HIGH) < 0){ 1812 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1829 err("%s Error from DTR HIGH urb", __FUNCTION__);
1830 }
1831 else if (set_rts(port, HIGH) < 0){
1832 err("%s Error from RTS HIGH urb", __FUNCTION__);
1833 }
1834 } 1813 }
1835 1814
1836 /* Set flow control */ 1815 /* Set flow control */
@@ -1942,35 +1921,8 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
1942 1921
1943static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 1922static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
1944{ 1923{
1945 int ret;
1946
1947 dbg("%s TIOCMSET", __FUNCTION__); 1924 dbg("%s TIOCMSET", __FUNCTION__);
1948 if (set & TIOCM_DTR){ 1925 return update_mctrl(port, set, clear);
1949 if ((ret = set_dtr(port, HIGH)) < 0) {
1950 err("Urb to set DTR failed");
1951 return(ret);
1952 }
1953 }
1954 if (set & TIOCM_RTS) {
1955 if ((ret = set_rts(port, HIGH)) < 0){
1956 err("Urb to set RTS failed");
1957 return(ret);
1958 }
1959 }
1960
1961 if (clear & TIOCM_DTR){
1962 if ((ret = set_dtr(port, LOW)) < 0){
1963 err("Urb to unset DTR failed");
1964 return(ret);
1965 }
1966 }
1967 if (clear & TIOCM_RTS) {
1968 if ((ret = set_rts(port, LOW)) < 0){
1969 err("Urb to unset RTS failed");
1970 return(ret);
1971 }
1972 }
1973 return(0);
1974} 1926}
1975 1927
1976 1928
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 8866376823a5..9f4342093e8b 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -265,10 +265,24 @@
265#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */ 265#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
266 266
267/* 267/*
268 * microHAM product IDs (http://www.microham.com).
269 * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>.
270 */
271#define FTDI_MHAM_Y6_PID 0xEEEA /* USB-Y6 interface */
272#define FTDI_MHAM_Y8_PID 0xEEEB /* USB-Y8 interface */
273
274/*
268 * Active Robots product ids. 275 * Active Robots product ids.
269 */ 276 */
270#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */ 277#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
271 278
279/*
280 * Evolution Robotics products (http://www.evolution.com/).
281 * Submitted by Shawn M. Lavelle.
282 */
283#define EVOLUTION_VID 0xDEEE /* Vendor ID */
284#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
285
272/* Commands */ 286/* Commands */
273#define FTDI_SIO_RESET 0 /* Reset the port */ 287#define FTDI_SIO_RESET 0 /* Reset the port */
274#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 288#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index b722175f108f..e9256408757f 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -12,14 +12,25 @@
12 History: 12 History:
13 13
14 2005-05-19 v0.1 Initial version, based on incomplete docs 14 2005-05-19 v0.1 Initial version, based on incomplete docs
15 and analysis of misbehavior of the standard driver 15 and analysis of misbehavior with the standard driver
16 2005-05-20 v0.2 Extended the input buffer to avoid losing 16 2005-05-20 v0.2 Extended the input buffer to avoid losing
17 random 64-byte chunks of data 17 random 64-byte chunks of data
18 2005-05-21 v0.3 implemented chars_in_buffer() 18 2005-05-21 v0.3 implemented chars_in_buffer()
19 turned on low_latency 19 turned on low_latency
20 simplified the code somewhat 20 simplified the code somewhat
21 2005-05-24 v0.4 option_write() sometimes deadlocked under heavy load
22 removed some dead code
23 added sponsor notice
24 coding style clean-up
25 2005-06-20 v0.4.1 add missing braces :-/
26 killed end-of-line whitespace
27 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2
28
29 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
30
21*/ 31*/
22#define DRIVER_VERSION "v0.3" 32
33#define DRIVER_VERSION "v0.4"
23#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 34#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
24#define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver" 35#define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver"
25 36
@@ -44,7 +55,6 @@ static int option_write_room (struct usb_serial_port *port);
44 55
45static void option_instat_callback(struct urb *urb, struct pt_regs *regs); 56static void option_instat_callback(struct urb *urb, struct pt_regs *regs);
46 57
47
48static int option_write (struct usb_serial_port *port, 58static int option_write (struct usb_serial_port *port,
49 const unsigned char *buf, int count); 59 const unsigned char *buf, int count);
50 60
@@ -60,14 +70,17 @@ static int option_tiocmset (struct usb_serial_port *port, struct file *file,
60static int option_send_setup (struct usb_serial_port *port); 70static int option_send_setup (struct usb_serial_port *port);
61 71
62/* Vendor and product IDs */ 72/* Vendor and product IDs */
63#define OPTION_VENDOR_ID 0x0AF0 73#define OPTION_VENDOR_ID 0x0AF0
74
75#define OPTION_PRODUCT_OLD 0x5000
76#define OPTION_PRODUCT_FUSION 0x6000
77#define OPTION_PRODUCT_FUSION2 0x6300
64 78
65#define OPTION_PRODUCT_OLD 0x5000
66#define OPTION_PRODUCT_WLAN 0x6000
67 79
68static struct usb_device_id option_ids[] = { 80static struct usb_device_id option_ids[] = {
69 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, 81 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
70 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) }, 82 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
83 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
71 { } /* Terminating entry */ 84 { } /* Terminating entry */
72}; 85};
73 86
@@ -85,58 +98,62 @@ static struct usb_driver option_driver = {
85 * recognizes separately, thus num_port=1. 98 * recognizes separately, thus num_port=1.
86 */ 99 */
87static struct usb_serial_device_type option_3port_device = { 100static struct usb_serial_device_type option_3port_device = {
88 .owner = THIS_MODULE, 101 .owner = THIS_MODULE,
89 .name = "Option 3-port card", 102 .name = "Option 3G data card",
90 .short_name = "option", 103 .short_name = "option",
91 .id_table = option_ids, 104 .id_table = option_ids,
92 .num_interrupt_in = NUM_DONT_CARE, 105 .num_interrupt_in = NUM_DONT_CARE,
93 .num_bulk_in = NUM_DONT_CARE, 106 .num_bulk_in = NUM_DONT_CARE,
94 .num_bulk_out = NUM_DONT_CARE, 107 .num_bulk_out = NUM_DONT_CARE,
95 .num_ports = 1, /* 3 */ 108 .num_ports = 1, /* 3, but the card reports its ports separately */
96 .open = option_open, 109 .open = option_open,
97 .close = option_close, 110 .close = option_close,
98 .write = option_write, 111 .write = option_write,
99 .write_room = option_write_room, 112 .write_room = option_write_room,
100 .chars_in_buffer = option_chars_in_buffer, 113 .chars_in_buffer = option_chars_in_buffer,
101 .throttle = option_rx_throttle, 114 .throttle = option_rx_throttle,
102 .unthrottle = option_rx_unthrottle, 115 .unthrottle = option_rx_unthrottle,
103 .ioctl = option_ioctl, 116 .ioctl = option_ioctl,
104 .set_termios = option_set_termios, 117 .set_termios = option_set_termios,
105 .break_ctl = option_break_ctl, 118 .break_ctl = option_break_ctl,
106 .tiocmget = option_tiocmget, 119 .tiocmget = option_tiocmget,
107 .tiocmset = option_tiocmset, 120 .tiocmset = option_tiocmset,
108 .attach = option_startup, 121 .attach = option_startup,
109 .shutdown = option_shutdown, 122 .shutdown = option_shutdown,
110 .read_int_callback = option_instat_callback, 123 .read_int_callback = option_instat_callback,
111}; 124};
112 125
126#ifdef CONFIG_USB_DEBUG
113static int debug; 127static int debug;
128#else
129#define debug 0
130#endif
131
114 132
115/* per port private data */ 133/* per port private data */
116 134
117#define N_IN_URB 4 135#define N_IN_URB 4
118#define N_OUT_URB 1 136#define N_OUT_URB 1
119#define IN_BUFLEN 1024 137#define IN_BUFLEN 1024
120#define OUT_BUFLEN 1024 138#define OUT_BUFLEN 128
121 139
122struct option_port_private { 140struct option_port_private {
123 /* Input endpoints and buffer for this port */ 141 /* Input endpoints and buffer for this port */
124 struct urb *in_urbs[N_IN_URB]; 142 struct urb *in_urbs[N_IN_URB];
125 char in_buffer[N_IN_URB][IN_BUFLEN]; 143 char in_buffer[N_IN_URB][IN_BUFLEN];
126 /* Output endpoints and buffer for this port */ 144 /* Output endpoints and buffer for this port */
127 struct urb *out_urbs[N_OUT_URB]; 145 struct urb *out_urbs[N_OUT_URB];
128 char out_buffer[N_OUT_URB][OUT_BUFLEN]; 146 char out_buffer[N_OUT_URB][OUT_BUFLEN];
129 147
130 /* Settings for the port */ 148 /* Settings for the port */
131 int rts_state; /* Handshaking pins (outputs) */ 149 int rts_state; /* Handshaking pins (outputs) */
132 int dtr_state; 150 int dtr_state;
133 int cts_state; /* Handshaking pins (inputs) */ 151 int cts_state; /* Handshaking pins (inputs) */
134 int dsr_state; 152 int dsr_state;
135 int dcd_state; 153 int dcd_state;
136 int ri_state; 154 int ri_state;
137 // int break_on; 155
138 156 unsigned long tx_start_time[N_OUT_URB];
139 unsigned long tx_start_time[N_OUT_URB];
140}; 157};
141 158
142 159
@@ -190,13 +207,13 @@ static void
190option_break_ctl (struct usb_serial_port *port, int break_state) 207option_break_ctl (struct usb_serial_port *port, int break_state)
191{ 208{
192 /* Unfortunately, I don't know how to send a break */ 209 /* Unfortunately, I don't know how to send a break */
193 dbg("%s", __FUNCTION__); 210 dbg("%s", __FUNCTION__);
194} 211}
195 212
196 213
197static void 214static void
198option_set_termios (struct usb_serial_port *port, 215option_set_termios (struct usb_serial_port *port,
199 struct termios *old_termios) 216 struct termios *old_termios)
200{ 217{
201 dbg("%s", __FUNCTION__); 218 dbg("%s", __FUNCTION__);
202 219
@@ -204,10 +221,10 @@ option_set_termios (struct usb_serial_port *port,
204} 221}
205 222
206static int 223static int
207option_tiocmget(struct usb_serial_port *port, struct file *file) 224option_tiocmget (struct usb_serial_port *port, struct file *file)
208{ 225{
209 unsigned int value; 226 unsigned int value;
210 struct option_port_private *portdata; 227 struct option_port_private *portdata;
211 228
212 portdata = usb_get_serial_port_data(port); 229 portdata = usb_get_serial_port_data(port);
213 230
@@ -225,7 +242,7 @@ static int
225option_tiocmset (struct usb_serial_port *port, struct file *file, 242option_tiocmset (struct usb_serial_port *port, struct file *file,
226 unsigned int set, unsigned int clear) 243 unsigned int set, unsigned int clear)
227{ 244{
228 struct option_port_private *portdata; 245 struct option_port_private *portdata;
229 246
230 portdata = usb_get_serial_port_data(port); 247 portdata = usb_get_serial_port_data(port);
231 248
@@ -250,71 +267,50 @@ option_ioctl (struct usb_serial_port *port, struct file *file,
250 267
251/* Write */ 268/* Write */
252static int 269static int
253option_write(struct usb_serial_port *port, 270option_write (struct usb_serial_port *port,
254 const unsigned char *buf, int count) 271 const unsigned char *buf, int count)
255{ 272{
256 struct option_port_private *portdata; 273 struct option_port_private *portdata;
257 int i; 274 int i;
258 int left, todo; 275 int left, todo;
259 struct urb *this_urb = NULL; /* spurious */ 276 struct urb *this_urb = NULL; /* spurious */
260 int err; 277 int err;
261 278
262 portdata = usb_get_serial_port_data(port); 279 portdata = usb_get_serial_port_data(port);
263 280
264 dbg("%s: write (%d chars)", __FUNCTION__, count); 281 dbg("%s: write (%d chars)", __FUNCTION__, count);
265 282
266#if 0
267 spin_lock(&port->lock);
268 if (port->write_urb_busy) {
269 spin_unlock(&port->lock);
270 dbg("%s: already writing", __FUNCTION__);
271 return 0;
272 }
273 port->write_urb_busy = 1;
274 spin_unlock(&port->lock);
275#endif
276
277 i = 0; 283 i = 0;
278 left = count; 284 left = count;
279 while (left>0) { 285 for (i=0; left > 0 && i < N_OUT_URB; i++) {
280 todo = left; 286 todo = left;
281 if (todo > OUT_BUFLEN) 287 if (todo > OUT_BUFLEN)
282 todo = OUT_BUFLEN; 288 todo = OUT_BUFLEN;
283 289
284 for (;i < N_OUT_URB; i++) { 290 this_urb = portdata->out_urbs[i];
285 /* Check we have a valid urb/endpoint before we use it... */ 291 if (this_urb->status == -EINPROGRESS) {
286 this_urb = portdata->out_urbs[i];
287 if (this_urb->status != -EINPROGRESS)
288 break;
289 if (this_urb->transfer_flags & URB_ASYNC_UNLINK) 292 if (this_urb->transfer_flags & URB_ASYNC_UNLINK)
290 continue; 293 continue;
291 if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) 294 if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ))
292 continue; 295 continue;
293 this_urb->transfer_flags |= URB_ASYNC_UNLINK; 296 this_urb->transfer_flags |= URB_ASYNC_UNLINK;
294 usb_unlink_urb(this_urb); 297 usb_unlink_urb(this_urb);
298 continue;
295 } 299 }
296 300 if (this_urb->status != 0)
297 if (i == N_OUT_URB) { 301 dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status);
298 /* no bulk out free! */
299 dbg("%s: no output urb -- left %d", __FUNCTION__,count-left);
300#if 0
301 port->write_urb_busy = 0;
302#endif
303 return count-left;
304 }
305 302
306 dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); 303 dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i);
307 304
305 /* send the data */
308 memcpy (this_urb->transfer_buffer, buf, todo); 306 memcpy (this_urb->transfer_buffer, buf, todo);
309
310 /* send the data out the bulk port */
311 this_urb->transfer_buffer_length = todo; 307 this_urb->transfer_buffer_length = todo;
312 308
313 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; 309 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
314 this_urb->dev = port->serial->dev; 310 this_urb->dev = port->serial->dev;
315 err = usb_submit_urb(this_urb, GFP_ATOMIC); 311 err = usb_submit_urb(this_urb, GFP_ATOMIC);
316 if (err) { 312 if (err) {
317 dbg("usb_submit_urb %p (write bulk) failed (%d,, has %d)", this_urb, err, this_urb->status); 313 dbg("usb_submit_urb %p (write bulk) failed (%d, has %d)", this_urb, err, this_urb->status);
318 continue; 314 continue;
319 } 315 }
320 portdata->tx_start_time[i] = jiffies; 316 portdata->tx_start_time[i] = jiffies;
@@ -323,9 +319,6 @@ option_write(struct usb_serial_port *port,
323 } 319 }
324 320
325 count -= left; 321 count -= left;
326#if 0
327 port->write_urb_busy = 0;
328#endif
329 dbg("%s: wrote (did %d)", __FUNCTION__, count); 322 dbg("%s: wrote (did %d)", __FUNCTION__, count);
330 return count; 323 return count;
331} 324}
@@ -333,7 +326,7 @@ option_write(struct usb_serial_port *port,
333static void 326static void
334option_indat_callback (struct urb *urb, struct pt_regs *regs) 327option_indat_callback (struct urb *urb, struct pt_regs *regs)
335{ 328{
336 int i, err; 329 int i, err;
337 int endpoint; 330 int endpoint;
338 struct usb_serial_port *port; 331 struct usb_serial_port *port;
339 struct tty_struct *tty; 332 struct tty_struct *tty;
@@ -444,10 +437,11 @@ option_write_room (struct usb_serial_port *port)
444 437
445 portdata = usb_get_serial_port_data(port); 438 portdata = usb_get_serial_port_data(port);
446 439
447 for (i=0; i < N_OUT_URB; i++) 440 for (i=0; i < N_OUT_URB; i++) {
448 this_urb = portdata->out_urbs[i]; 441 this_urb = portdata->out_urbs[i];
449 if (this_urb && this_urb->status != -EINPROGRESS) 442 if (this_urb && this_urb->status != -EINPROGRESS)
450 data_len += OUT_BUFLEN; 443 data_len += OUT_BUFLEN;
444 }
451 445
452 dbg("%s: %d", __FUNCTION__, data_len); 446 dbg("%s: %d", __FUNCTION__, data_len);
453 return data_len; 447 return data_len;
@@ -464,11 +458,11 @@ option_chars_in_buffer (struct usb_serial_port *port)
464 458
465 portdata = usb_get_serial_port_data(port); 459 portdata = usb_get_serial_port_data(port);
466 460
467 for (i=0; i < N_OUT_URB; i++) 461 for (i=0; i < N_OUT_URB; i++) {
468 this_urb = portdata->out_urbs[i]; 462 this_urb = portdata->out_urbs[i];
469 if (this_urb && this_urb->status == -EINPROGRESS) 463 if (this_urb && this_urb->status == -EINPROGRESS)
470 data_len += this_urb->transfer_buffer_length; 464 data_len += this_urb->transfer_buffer_length;
471 465 }
472 dbg("%s: %d", __FUNCTION__, data_len); 466 dbg("%s: %d", __FUNCTION__, data_len);
473 return data_len; 467 return data_len;
474} 468}
@@ -477,10 +471,10 @@ option_chars_in_buffer (struct usb_serial_port *port)
477static int 471static int
478option_open (struct usb_serial_port *port, struct file *filp) 472option_open (struct usb_serial_port *port, struct file *filp)
479{ 473{
480 struct option_port_private *portdata; 474 struct option_port_private *portdata;
481 struct usb_serial *serial = port->serial; 475 struct usb_serial *serial = port->serial;
482 int i, err; 476 int i, err;
483 struct urb *urb; 477 struct urb *urb;
484 478
485 portdata = usb_get_serial_port_data(port); 479 portdata = usb_get_serial_port_data(port);
486 480
@@ -528,7 +522,7 @@ option_open (struct usb_serial_port *port, struct file *filp)
528} 522}
529 523
530static inline void 524static inline void
531stop_urb(struct urb *urb) 525stop_urb (struct urb *urb)
532{ 526{
533 if (urb && urb->status == -EINPROGRESS) { 527 if (urb && urb->status == -EINPROGRESS) {
534 urb->transfer_flags &= ~URB_ASYNC_UNLINK; 528 urb->transfer_flags &= ~URB_ASYNC_UNLINK;
@@ -537,11 +531,11 @@ stop_urb(struct urb *urb)
537} 531}
538 532
539static void 533static void
540option_close(struct usb_serial_port *port, struct file *filp) 534option_close (struct usb_serial_port *port, struct file *filp)
541{ 535{
542 int i; 536 int i;
543 struct usb_serial *serial = port->serial; 537 struct usb_serial *serial = port->serial;
544 struct option_port_private *portdata; 538 struct option_port_private *portdata;
545 539
546 dbg("%s", __FUNCTION__); 540 dbg("%s", __FUNCTION__);
547 portdata = usb_get_serial_port_data(port); 541 portdata = usb_get_serial_port_data(port);
@@ -589,11 +583,11 @@ option_setup_urb (struct usb_serial *serial, int endpoint,
589 583
590/* Setup urbs */ 584/* Setup urbs */
591static void 585static void
592option_setup_urbs(struct usb_serial *serial) 586option_setup_urbs (struct usb_serial *serial)
593{ 587{
594 int j; 588 int j;
595 struct usb_serial_port *port; 589 struct usb_serial_port *port;
596 struct option_port_private *portdata; 590 struct option_port_private *portdata;
597 591
598 dbg("%s", __FUNCTION__); 592 dbg("%s", __FUNCTION__);
599 593
@@ -617,7 +611,7 @@ option_setup_urbs(struct usb_serial *serial)
617 611
618 612
619static int 613static int
620option_send_setup(struct usb_serial_port *port) 614option_send_setup (struct usb_serial_port *port)
621{ 615{
622 struct usb_serial *serial = port->serial; 616 struct usb_serial *serial = port->serial;
623 struct option_port_private *portdata; 617 struct option_port_private *portdata;
@@ -644,9 +638,9 @@ option_send_setup(struct usb_serial_port *port)
644static int 638static int
645option_startup (struct usb_serial *serial) 639option_startup (struct usb_serial *serial)
646{ 640{
647 int i, err; 641 int i, err;
648 struct usb_serial_port *port; 642 struct usb_serial_port *port;
649 struct option_port_private *portdata; 643 struct option_port_private *portdata;
650 644
651 dbg("%s", __FUNCTION__); 645 dbg("%s", __FUNCTION__);
652 646
@@ -677,9 +671,9 @@ option_startup (struct usb_serial *serial)
677static void 671static void
678option_shutdown (struct usb_serial *serial) 672option_shutdown (struct usb_serial *serial)
679{ 673{
680 int i, j; 674 int i, j;
681 struct usb_serial_port *port; 675 struct usb_serial_port *port;
682 struct option_port_private *portdata; 676 struct option_port_private *portdata;
683 677
684 dbg("%s", __FUNCTION__); 678 dbg("%s", __FUNCTION__);
685 679
@@ -724,6 +718,8 @@ MODULE_DESCRIPTION(DRIVER_DESC);
724MODULE_VERSION(DRIVER_VERSION); 718MODULE_VERSION(DRIVER_VERSION);
725MODULE_LICENSE("GPL"); 719MODULE_LICENSE("GPL");
726 720
721#ifdef CONFIG_USB_DEBUG
727module_param(debug, bool, S_IRUGO | S_IWUSR); 722module_param(debug, bool, S_IRUGO | S_IWUSR);
728MODULE_PARM_DESC(debug, "Debug messages"); 723MODULE_PARM_DESC(debug, "Debug messages");
724#endif
729 725
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 6051a646fe69..353f24d45bc1 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -257,7 +257,8 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
257 endpoint = &iface_desc->endpoint[i].desc; 257 endpoint = &iface_desc->endpoint[i].desc;
258 258
259 if (!dev->bulk_in_endpointAddr && 259 if (!dev->bulk_in_endpointAddr &&
260 (endpoint->bEndpointAddress & USB_DIR_IN) && 260 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
261 == USB_DIR_IN) &&
261 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 262 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
262 == USB_ENDPOINT_XFER_BULK)) { 263 == USB_ENDPOINT_XFER_BULK)) {
263 /* we found a bulk in endpoint */ 264 /* we found a bulk in endpoint */
@@ -272,7 +273,8 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
272 } 273 }
273 274
274 if (!dev->bulk_out_endpointAddr && 275 if (!dev->bulk_out_endpointAddr &&
275 !(endpoint->bEndpointAddress & USB_DIR_OUT) && 276 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
277 == USB_DIR_OUT) &&
276 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 278 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
277 == USB_ENDPOINT_XFER_BULK)) { 279 == USB_ENDPOINT_XFER_BULK)) {
278 /* we found a bulk out endpoint */ 280 /* we found a bulk out endpoint */