aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/c67x00/c67x00-ll-hpi.c13
-rw-r--r--drivers/usb/class/Kconfig11
-rw-r--r--drivers/usb/class/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/class/cdc-wdm.c740
-rw-r--r--drivers/usb/core/endpoint.c11
-rw-r--r--drivers/usb/core/generic.c5
-rw-r--r--drivers/usb/core/hcd.c6
-rw-r--r--drivers/usb/core/hcd.h2
-rw-r--r--drivers/usb/core/hub.c61
-rw-r--r--drivers/usb/core/message.c1
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/core/sysfs.c181
-rw-r--r--drivers/usb/core/usb.c1
-rw-r--r--drivers/usb/core/usb.h4
-rw-r--r--drivers/usb/gadget/amd5536udc.c10
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c48
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c2
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c20
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h8
-rw-r--r--drivers/usb/gadget/serial.c778
-rw-r--r--drivers/usb/host/Kconfig8
-rw-r--r--drivers/usb/host/ehci-au1xxx.c1
-rw-r--r--drivers/usb/host/ehci-fsl.c7
-rw-r--r--drivers/usb/host/ehci-hub.c16
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c4
-rw-r--r--drivers/usb/host/ehci-orion.c10
-rw-r--r--drivers/usb/host/ehci-pci.c4
-rw-r--r--drivers/usb/host/ehci-ppc-of.c2
-rw-r--r--drivers/usb/host/ehci-ppc-soc.c1
-rw-r--r--drivers/usb/host/ehci-ps3.c1
-rw-r--r--drivers/usb/host/ehci-sched.c67
-rw-r--r--drivers/usb/host/ehci.h5
-rw-r--r--drivers/usb/host/isp1760-hcd.c12
-rw-r--r--drivers/usb/host/isp1760-if.c6
-rw-r--r--drivers/usb/host/ohci-sm501.c2
-rw-r--r--drivers/usb/misc/Kconfig12
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/isight_firmware.c140
-rw-r--r--drivers/usb/misc/ldusb.c4
-rw-r--r--drivers/usb/misc/phidgetkit.c6
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c7
-rw-r--r--drivers/usb/misc/phidgetservo.c6
-rw-r--r--drivers/usb/misc/usbtest.c5
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/ch341.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c265
-rw-r--r--drivers/usb/serial/ftdi_sio.h273
-rw-r--r--drivers/usb/serial/moto_modem.c70
-rw-r--r--drivers/usb/serial/option.c48
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/pl2303.h2
-rw-r--r--drivers/usb/storage/unusual_devs.h79
54 files changed, 2290 insertions, 697 deletions
diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c
index f3430b372f09..a9636f43bca2 100644
--- a/drivers/usb/c67x00/c67x00-ll-hpi.c
+++ b/drivers/usb/c67x00/c67x00-ll-hpi.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/byteorder.h> 24#include <asm/byteorder.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/jiffies.h>
26#include <linux/usb/c67x00.h> 27#include <linux/usb/c67x00.h>
27#include "c67x00.h" 28#include "c67x00.h"
28 29
@@ -119,7 +120,7 @@ static void hpi_write_word(struct c67x00_device *dev, u16 reg, u16 value)
119 * Only data is little endian, addr has cpu endianess 120 * Only data is little endian, addr has cpu endianess
120 */ 121 */
121static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr, 122static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr,
122 u16 *data, u16 count) 123 __le16 *data, u16 count)
123{ 124{
124 unsigned long flags; 125 unsigned long flags;
125 int i; 126 int i;
@@ -128,7 +129,7 @@ static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr,
128 129
129 hpi_write_reg(dev, HPI_ADDR, addr); 130 hpi_write_reg(dev, HPI_ADDR, addr);
130 for (i = 0; i < count; i++) 131 for (i = 0; i < count; i++)
131 hpi_write_reg(dev, HPI_DATA, cpu_to_le16(*data++)); 132 hpi_write_reg(dev, HPI_DATA, le16_to_cpu(*data++));
132 133
133 spin_unlock_irqrestore(&dev->hpi.lock, flags); 134 spin_unlock_irqrestore(&dev->hpi.lock, flags);
134} 135}
@@ -137,7 +138,7 @@ static void hpi_write_words_le16(struct c67x00_device *dev, u16 addr,
137 * Only data is little endian, addr has cpu endianess 138 * Only data is little endian, addr has cpu endianess
138 */ 139 */
139static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr, 140static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr,
140 u16 *data, u16 count) 141 __le16 *data, u16 count)
141{ 142{
142 unsigned long flags; 143 unsigned long flags;
143 int i; 144 int i;
@@ -145,7 +146,7 @@ static void hpi_read_words_le16(struct c67x00_device *dev, u16 addr,
145 spin_lock_irqsave(&dev->hpi.lock, flags); 146 spin_lock_irqsave(&dev->hpi.lock, flags);
146 hpi_write_reg(dev, HPI_ADDR, addr); 147 hpi_write_reg(dev, HPI_ADDR, addr);
147 for (i = 0; i < count; i++) 148 for (i = 0; i < count; i++)
148 *data++ = le16_to_cpu(hpi_read_reg(dev, HPI_DATA)); 149 *data++ = cpu_to_le16(hpi_read_reg(dev, HPI_DATA));
149 150
150 spin_unlock_irqrestore(&dev->hpi.lock, flags); 151 spin_unlock_irqrestore(&dev->hpi.lock, flags);
151} 152}
@@ -424,7 +425,7 @@ void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr,
424 len--; 425 len--;
425 } 426 }
426 427
427 hpi_write_words_le16(dev, addr, (u16 *)buf, len / 2); 428 hpi_write_words_le16(dev, addr, (__le16 *)buf, len / 2);
428 buf += len & ~0x01; 429 buf += len & ~0x01;
429 addr += len & ~0x01; 430 addr += len & ~0x01;
430 len &= 0x01; 431 len &= 0x01;
@@ -455,7 +456,7 @@ void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr,
455 len--; 456 len--;
456 } 457 }
457 458
458 hpi_read_words_le16(dev, addr, (u16 *)buf, len / 2); 459 hpi_read_words_le16(dev, addr, (__le16 *)buf, len / 2);
459 buf += len & ~0x01; 460 buf += len & ~0x01;
460 addr += len & ~0x01; 461 addr += len & ~0x01;
461 len &= 0x01; 462 len &= 0x01;
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig
index 3a9102d2591b..66f17ed88cb5 100644
--- a/drivers/usb/class/Kconfig
+++ b/drivers/usb/class/Kconfig
@@ -29,3 +29,14 @@ config USB_PRINTER
29 To compile this driver as a module, choose M here: the 29 To compile this driver as a module, choose M here: the
30 module will be called usblp. 30 module will be called usblp.
31 31
32config USB_WDM
33 tristate "USB Wireless Device Management support"
34 depends on USB
35 ---help---
36 This driver supports the WMC Device Management functionality
37 of cell phones compliant to the CDC WMC specification. You can use
38 AT commands over this device.
39
40 To compile this driver as a module, choose M here: the
41 module will be called cdc-wdm.
42
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile
index cc391e6c2af8..535d59a30600 100644
--- a/drivers/usb/class/Makefile
+++ b/drivers/usb/class/Makefile
@@ -5,3 +5,4 @@
5 5
6obj-$(CONFIG_USB_ACM) += cdc-acm.o 6obj-$(CONFIG_USB_ACM) += cdc-acm.o
7obj-$(CONFIG_USB_PRINTER) += usblp.o 7obj-$(CONFIG_USB_PRINTER) += usblp.o
8obj-$(CONFIG_USB_WDM) += cdc-wdm.o
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index cefe7f2c6f75..63c34043b4d9 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1248,6 +1248,9 @@ static struct usb_device_id acm_ids[] = {
1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1250 }, 1250 },
1251 { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */
1252 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1253 },
1251 1254
1252 /* control interfaces with various AT-command sets */ 1255 /* control interfaces with various AT-command sets */
1253 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1256 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
new file mode 100644
index 000000000000..731db051070a
--- /dev/null
+++ b/drivers/usb/class/cdc-wdm.c
@@ -0,0 +1,740 @@
1/*
2 * cdc-wdm.c
3 *
4 * This driver supports USB CDC WCM Device Management.
5 *
6 * Copyright (c) 2007-2008 Oliver Neukum
7 *
8 * Some code taken from cdc-acm.c
9 *
10 * Released under the GPLv2.
11 *
12 * Many thanks to Carl Nordbeck
13 */
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/slab.h>
17#include <linux/module.h>
18#include <linux/smp_lock.h>
19#include <linux/mutex.h>
20#include <linux/uaccess.h>
21#include <linux/bitops.h>
22#include <linux/poll.h>
23#include <linux/usb.h>
24#include <linux/usb/cdc.h>
25#include <asm/byteorder.h>
26#include <asm/unaligned.h>
27
28/*
29 * Version Information
30 */
31#define DRIVER_VERSION "v0.02"
32#define DRIVER_AUTHOR "Oliver Neukum"
33
34static struct usb_device_id wdm_ids[] = {
35 {
36 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
37 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
38 .bInterfaceClass = USB_CLASS_COMM,
39 .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM
40 },
41 { }
42};
43
44#define WDM_MINOR_BASE 176
45
46
47#define WDM_IN_USE 1
48#define WDM_DISCONNECTING 2
49#define WDM_RESULT 3
50#define WDM_READ 4
51#define WDM_INT_STALL 5
52#define WDM_POLL_RUNNING 6
53
54
55#define WDM_MAX 16
56
57
58static DEFINE_MUTEX(wdm_mutex);
59
60/* --- method tables --- */
61
62struct wdm_device {
63 u8 *inbuf; /* buffer for response */
64 u8 *outbuf; /* buffer for command */
65 u8 *sbuf; /* buffer for status */
66 u8 *ubuf; /* buffer for copy to user space */
67
68 struct urb *command;
69 struct urb *response;
70 struct urb *validity;
71 struct usb_interface *intf;
72 struct usb_ctrlrequest *orq;
73 struct usb_ctrlrequest *irq;
74 spinlock_t iuspin;
75
76 unsigned long flags;
77 u16 bufsize;
78 u16 wMaxCommand;
79 u16 wMaxPacketSize;
80 u16 bMaxPacketSize0;
81 __le16 inum;
82 int reslength;
83 int length;
84 int read;
85 int count;
86 dma_addr_t shandle;
87 dma_addr_t ihandle;
88 struct mutex wlock;
89 struct mutex rlock;
90 wait_queue_head_t wait;
91 struct work_struct rxwork;
92 int werr;
93 int rerr;
94};
95
96static struct usb_driver wdm_driver;
97
98/* --- callbacks --- */
99static void wdm_out_callback(struct urb *urb)
100{
101 struct wdm_device *desc;
102 desc = urb->context;
103 spin_lock(&desc->iuspin);
104 desc->werr = urb->status;
105 spin_unlock(&desc->iuspin);
106 clear_bit(WDM_IN_USE, &desc->flags);
107 kfree(desc->outbuf);
108 wake_up(&desc->wait);
109}
110
111static void wdm_in_callback(struct urb *urb)
112{
113 struct wdm_device *desc = urb->context;
114 int status = urb->status;
115
116 spin_lock(&desc->iuspin);
117
118 if (status) {
119 switch (status) {
120 case -ENOENT:
121 dev_dbg(&desc->intf->dev,
122 "nonzero urb status received: -ENOENT");
123 break;
124 case -ECONNRESET:
125 dev_dbg(&desc->intf->dev,
126 "nonzero urb status received: -ECONNRESET");
127 break;
128 case -ESHUTDOWN:
129 dev_dbg(&desc->intf->dev,
130 "nonzero urb status received: -ESHUTDOWN");
131 break;
132 case -EPIPE:
133 err("nonzero urb status received: -EPIPE");
134 break;
135 default:
136 err("Unexpected error %d", status);
137 break;
138 }
139 }
140
141 desc->rerr = status;
142 desc->reslength = urb->actual_length;
143 memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
144 desc->length += desc->reslength;
145 wake_up(&desc->wait);
146
147 set_bit(WDM_READ, &desc->flags);
148 spin_unlock(&desc->iuspin);
149}
150
151static void wdm_int_callback(struct urb *urb)
152{
153 int rv = 0;
154 int status = urb->status;
155 struct wdm_device *desc;
156 struct usb_ctrlrequest *req;
157 struct usb_cdc_notification *dr;
158
159 desc = urb->context;
160 req = desc->irq;
161 dr = (struct usb_cdc_notification *)desc->sbuf;
162
163 if (status) {
164 switch (status) {
165 case -ESHUTDOWN:
166 case -ENOENT:
167 case -ECONNRESET:
168 return; /* unplug */
169 case -EPIPE:
170 set_bit(WDM_INT_STALL, &desc->flags);
171 err("Stall on int endpoint");
172 goto sw; /* halt is cleared in work */
173 default:
174 err("nonzero urb status received: %d", status);
175 break;
176 }
177 }
178
179 if (urb->actual_length < sizeof(struct usb_cdc_notification)) {
180 err("wdm_int_callback - %d bytes", urb->actual_length);
181 goto exit;
182 }
183
184 switch (dr->bNotificationType) {
185 case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
186 dev_dbg(&desc->intf->dev,
187 "NOTIFY_RESPONSE_AVAILABLE received: index %d len %d",
188 dr->wIndex, dr->wLength);
189 break;
190
191 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
192
193 dev_dbg(&desc->intf->dev,
194 "NOTIFY_NETWORK_CONNECTION %s network",
195 dr->wValue ? "connected to" : "disconnected from");
196 goto exit;
197 default:
198 clear_bit(WDM_POLL_RUNNING, &desc->flags);
199 err("unknown notification %d received: index %d len %d",
200 dr->bNotificationType, dr->wIndex, dr->wLength);
201 goto exit;
202 }
203
204 req->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
205 req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE;
206 req->wValue = 0;
207 req->wIndex = desc->inum;
208 req->wLength = cpu_to_le16(desc->bMaxPacketSize0);
209
210 usb_fill_control_urb(
211 desc->response,
212 interface_to_usbdev(desc->intf),
213 /* using common endpoint 0 */
214 usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0),
215 (unsigned char *)req,
216 desc->inbuf,
217 desc->bMaxPacketSize0,
218 wdm_in_callback,
219 desc
220 );
221 desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
222 spin_lock(&desc->iuspin);
223 clear_bit(WDM_READ, &desc->flags);
224 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
225 rv = usb_submit_urb(desc->response, GFP_ATOMIC);
226 dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
227 __func__, rv);
228 }
229 spin_unlock(&desc->iuspin);
230 if (rv < 0) {
231 if (rv == -EPERM)
232 return;
233 if (rv == -ENOMEM) {
234sw:
235 rv = schedule_work(&desc->rxwork);
236 if (rv)
237 err("Cannot schedule work");
238 }
239 }
240exit:
241 rv = usb_submit_urb(urb, GFP_ATOMIC);
242 if (rv)
243 err("%s - usb_submit_urb failed with result %d",
244 __func__, rv);
245
246}
247
248static void kill_urbs(struct wdm_device *desc)
249{
250 usb_kill_urb(desc->command);
251 usb_kill_urb(desc->validity);
252 usb_kill_urb(desc->response);
253}
254
255static void free_urbs(struct wdm_device *desc)
256{
257 usb_free_urb(desc->validity);
258 usb_free_urb(desc->response);
259 usb_free_urb(desc->command);
260}
261
262static void cleanup(struct wdm_device *desc)
263{
264 usb_buffer_free(interface_to_usbdev(desc->intf),
265 desc->wMaxPacketSize,
266 desc->sbuf,
267 desc->validity->transfer_dma);
268 usb_buffer_free(interface_to_usbdev(desc->intf),
269 desc->wMaxPacketSize,
270 desc->inbuf,
271 desc->response->transfer_dma);
272 kfree(desc->orq);
273 kfree(desc->irq);
274 kfree(desc->ubuf);
275 free_urbs(desc);
276 kfree(desc);
277}
278
279static ssize_t wdm_write
280(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
281{
282 u8 *buf;
283 int rv = -EMSGSIZE, r, we;
284 struct wdm_device *desc = file->private_data;
285 struct usb_ctrlrequest *req;
286
287 if (count > desc->wMaxCommand)
288 count = desc->wMaxCommand;
289
290 spin_lock_irq(&desc->iuspin);
291 we = desc->werr;
292 desc->werr = 0;
293 spin_unlock_irq(&desc->iuspin);
294 if (we < 0)
295 return -EIO;
296
297 r = mutex_lock_interruptible(&desc->wlock); /* concurrent writes */
298 rv = -ERESTARTSYS;
299 if (r)
300 goto outnl;
301
302 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
303 &desc->flags));
304 if (r < 0)
305 goto out;
306
307 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
308 rv = -ENODEV;
309 goto out;
310 }
311
312 desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
313 if (!buf) {
314 rv = -ENOMEM;
315 goto out;
316 }
317
318 r = copy_from_user(buf, buffer, count);
319 if (r > 0) {
320 kfree(buf);
321 rv = -EFAULT;
322 goto out;
323 }
324
325 req = desc->orq;
326 usb_fill_control_urb(
327 desc->command,
328 interface_to_usbdev(desc->intf),
329 /* using common endpoint 0 */
330 usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0),
331 (unsigned char *)req,
332 buf,
333 count,
334 wdm_out_callback,
335 desc
336 );
337
338 req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS |
339 USB_RECIP_INTERFACE);
340 req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND;
341 req->wValue = 0;
342 req->wIndex = desc->inum;
343 req->wLength = cpu_to_le16(count);
344 set_bit(WDM_IN_USE, &desc->flags);
345
346 rv = usb_submit_urb(desc->command, GFP_KERNEL);
347 if (rv < 0) {
348 kfree(buf);
349 clear_bit(WDM_IN_USE, &desc->flags);
350 } else {
351 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
352 req->wIndex);
353 }
354out:
355 mutex_unlock(&desc->wlock);
356outnl:
357 return rv < 0 ? rv : count;
358}
359
360static ssize_t wdm_read
361(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
362{
363 int rv, cntr;
364 int i = 0;
365 struct wdm_device *desc = file->private_data;
366
367
368 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
369 if (rv < 0)
370 return -ERESTARTSYS;
371
372 if (desc->length == 0) {
373 desc->read = 0;
374retry:
375 i++;
376 rv = wait_event_interruptible(desc->wait,
377 test_bit(WDM_READ, &desc->flags));
378
379 if (rv < 0) {
380 rv = -ERESTARTSYS;
381 goto err;
382 }
383
384 spin_lock_irq(&desc->iuspin);
385
386 if (desc->rerr) { /* read completed, error happened */
387 int t = desc->rerr;
388 desc->rerr = 0;
389 spin_unlock_irq(&desc->iuspin);
390 err("reading had resulted in %d", t);
391 rv = -EIO;
392 goto err;
393 }
394 /*
395 * recheck whether we've lost the race
396 * against the completion handler
397 */
398 if (!test_bit(WDM_READ, &desc->flags)) { /* lost race */
399 spin_unlock_irq(&desc->iuspin);
400 goto retry;
401 }
402 if (!desc->reslength) { /* zero length read */
403 spin_unlock_irq(&desc->iuspin);
404 goto retry;
405 }
406 clear_bit(WDM_READ, &desc->flags);
407 spin_unlock_irq(&desc->iuspin);
408 }
409
410 cntr = count > desc->length ? desc->length : count;
411 rv = copy_to_user(buffer, desc->ubuf, cntr);
412 if (rv > 0) {
413 rv = -EFAULT;
414 goto err;
415 }
416
417 for (i = 0; i < desc->length - cntr; i++)
418 desc->ubuf[i] = desc->ubuf[i + cntr];
419
420 desc->length -= cntr;
421 rv = cntr;
422
423err:
424 mutex_unlock(&desc->rlock);
425 if (rv < 0)
426 err("wdm_read: exit error");
427 return rv;
428}
429
430static int wdm_flush(struct file *file, fl_owner_t id)
431{
432 struct wdm_device *desc = file->private_data;
433
434 wait_event(desc->wait, !test_bit(WDM_IN_USE, &desc->flags));
435 if (desc->werr < 0)
436 err("Error in flush path: %d", desc->werr);
437
438 return desc->werr;
439}
440
441static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
442{
443 struct wdm_device *desc = file->private_data;
444 unsigned long flags;
445 unsigned int mask = 0;
446
447 spin_lock_irqsave(&desc->iuspin, flags);
448 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
449 mask = POLLERR;
450 spin_unlock_irqrestore(&desc->iuspin, flags);
451 goto desc_out;
452 }
453 if (test_bit(WDM_READ, &desc->flags))
454 mask = POLLIN | POLLRDNORM;
455 if (desc->rerr || desc->werr)
456 mask |= POLLERR;
457 if (!test_bit(WDM_IN_USE, &desc->flags))
458 mask |= POLLOUT | POLLWRNORM;
459 spin_unlock_irqrestore(&desc->iuspin, flags);
460
461 poll_wait(file, &desc->wait, wait);
462
463desc_out:
464 return mask;
465}
466
467static int wdm_open(struct inode *inode, struct file *file)
468{
469 int minor = iminor(inode);
470 int rv = -ENODEV;
471 struct usb_interface *intf;
472 struct wdm_device *desc;
473
474 mutex_lock(&wdm_mutex);
475 intf = usb_find_interface(&wdm_driver, minor);
476 if (!intf)
477 goto out;
478
479 desc = usb_get_intfdata(intf);
480 if (test_bit(WDM_DISCONNECTING, &desc->flags))
481 goto out;
482
483 desc->count++;
484 file->private_data = desc;
485
486 rv = usb_submit_urb(desc->validity, GFP_KERNEL);
487
488 if (rv < 0) {
489 desc->count--;
490 err("Error submitting int urb - %d", rv);
491 goto out;
492 }
493 rv = 0;
494
495out:
496 mutex_unlock(&wdm_mutex);
497 return rv;
498}
499
500static int wdm_release(struct inode *inode, struct file *file)
501{
502 struct wdm_device *desc = file->private_data;
503
504 mutex_lock(&wdm_mutex);
505 desc->count--;
506 if (!desc->count) {
507 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
508 kill_urbs(desc);
509 }
510 mutex_unlock(&wdm_mutex);
511 return 0;
512}
513
514static const struct file_operations wdm_fops = {
515 .owner = THIS_MODULE,
516 .read = wdm_read,
517 .write = wdm_write,
518 .open = wdm_open,
519 .flush = wdm_flush,
520 .release = wdm_release,
521 .poll = wdm_poll
522};
523
524static struct usb_class_driver wdm_class = {
525 .name = "cdc-wdm%d",
526 .fops = &wdm_fops,
527 .minor_base = WDM_MINOR_BASE,
528};
529
530/* --- error handling --- */
531static void wdm_rxwork(struct work_struct *work)
532{
533 struct wdm_device *desc = container_of(work, struct wdm_device, rxwork);
534 unsigned long flags;
535 int rv;
536
537 spin_lock_irqsave(&desc->iuspin, flags);
538 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
539 spin_unlock_irqrestore(&desc->iuspin, flags);
540 } else {
541 spin_unlock_irqrestore(&desc->iuspin, flags);
542 rv = usb_submit_urb(desc->response, GFP_KERNEL);
543 if (rv < 0 && rv != -EPERM) {
544 spin_lock_irqsave(&desc->iuspin, flags);
545 if (!test_bit(WDM_DISCONNECTING, &desc->flags))
546 schedule_work(&desc->rxwork);
547 spin_unlock_irqrestore(&desc->iuspin, flags);
548 }
549 }
550}
551
552/* --- hotplug --- */
553
554static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
555{
556 int rv = -EINVAL;
557 struct usb_device *udev = interface_to_usbdev(intf);
558 struct wdm_device *desc;
559 struct usb_host_interface *iface;
560 struct usb_endpoint_descriptor *ep;
561 struct usb_cdc_dmm_desc *dmhd;
562 u8 *buffer = intf->altsetting->extra;
563 int buflen = intf->altsetting->extralen;
564 u16 maxcom = 0;
565
566 if (!buffer)
567 goto out;
568
569 while (buflen > 0) {
570 if (buffer [1] != USB_DT_CS_INTERFACE) {
571 err("skipping garbage");
572 goto next_desc;
573 }
574
575 switch (buffer [2]) {
576 case USB_CDC_HEADER_TYPE:
577 break;
578 case USB_CDC_DMM_TYPE:
579 dmhd = (struct usb_cdc_dmm_desc *)buffer;
580 maxcom = le16_to_cpu(dmhd->wMaxCommand);
581 dev_dbg(&intf->dev,
582 "Finding maximum buffer length: %d", maxcom);
583 break;
584 default:
585 err("Ignoring extra header, type %d, length %d",
586 buffer[2], buffer[0]);
587 break;
588 }
589next_desc:
590 buflen -= buffer[0];
591 buffer += buffer[0];
592 }
593
594 rv = -ENOMEM;
595 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
596 if (!desc)
597 goto out;
598 mutex_init(&desc->wlock);
599 mutex_init(&desc->rlock);
600 spin_lock_init(&desc->iuspin);
601 init_waitqueue_head(&desc->wait);
602 desc->wMaxCommand = maxcom;
603 desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber);
604 desc->intf = intf;
605 INIT_WORK(&desc->rxwork, wdm_rxwork);
606
607 iface = &intf->altsetting[0];
608 ep = &iface->endpoint[0].desc;
609 if (!usb_endpoint_is_int_in(ep)) {
610 rv = -EINVAL;
611 goto err;
612 }
613
614 desc->wMaxPacketSize = le16_to_cpu(ep->wMaxPacketSize);
615 desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0;
616
617 desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
618 if (!desc->orq)
619 goto err;
620 desc->irq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
621 if (!desc->irq)
622 goto err;
623
624 desc->validity = usb_alloc_urb(0, GFP_KERNEL);
625 if (!desc->validity)
626 goto err;
627
628 desc->response = usb_alloc_urb(0, GFP_KERNEL);
629 if (!desc->response)
630 goto err;
631
632 desc->command = usb_alloc_urb(0, GFP_KERNEL);
633 if (!desc->command)
634 goto err;
635
636 desc->ubuf = kmalloc(desc->wMaxCommand, GFP_KERNEL);
637 if (!desc->ubuf)
638 goto err;
639
640 desc->sbuf = usb_buffer_alloc(interface_to_usbdev(intf),
641 desc->wMaxPacketSize,
642 GFP_KERNEL,
643 &desc->validity->transfer_dma);
644 if (!desc->sbuf)
645 goto err;
646
647 desc->inbuf = usb_buffer_alloc(interface_to_usbdev(intf),
648 desc->bMaxPacketSize0,
649 GFP_KERNEL,
650 &desc->response->transfer_dma);
651 if (!desc->inbuf)
652 goto err2;
653
654 usb_fill_int_urb(
655 desc->validity,
656 interface_to_usbdev(intf),
657 usb_rcvintpipe(interface_to_usbdev(intf), ep->bEndpointAddress),
658 desc->sbuf,
659 desc->wMaxPacketSize,
660 wdm_int_callback,
661 desc,
662 ep->bInterval
663 );
664 desc->validity->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
665
666 usb_set_intfdata(intf, desc);
667 rv = usb_register_dev(intf, &wdm_class);
668 dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n",
669 intf->minor - WDM_MINOR_BASE);
670 if (rv < 0)
671 goto err;
672out:
673 return rv;
674err2:
675 usb_buffer_free(interface_to_usbdev(desc->intf),
676 desc->wMaxPacketSize,
677 desc->sbuf,
678 desc->validity->transfer_dma);
679err:
680 free_urbs(desc);
681 kfree(desc->ubuf);
682 kfree(desc->orq);
683 kfree(desc->irq);
684 kfree(desc);
685 return rv;
686}
687
688static void wdm_disconnect(struct usb_interface *intf)
689{
690 struct wdm_device *desc;
691 unsigned long flags;
692
693 usb_deregister_dev(intf, &wdm_class);
694 mutex_lock(&wdm_mutex);
695 desc = usb_get_intfdata(intf);
696
697 /* the spinlock makes sure no new urbs are generated in the callbacks */
698 spin_lock_irqsave(&desc->iuspin, flags);
699 set_bit(WDM_DISCONNECTING, &desc->flags);
700 set_bit(WDM_READ, &desc->flags);
701 clear_bit(WDM_IN_USE, &desc->flags);
702 spin_unlock_irqrestore(&desc->iuspin, flags);
703 cancel_work_sync(&desc->rxwork);
704 kill_urbs(desc);
705 wake_up_all(&desc->wait);
706 if (!desc->count)
707 cleanup(desc);
708 mutex_unlock(&wdm_mutex);
709}
710
711static struct usb_driver wdm_driver = {
712 .name = "cdc_wdm",
713 .probe = wdm_probe,
714 .disconnect = wdm_disconnect,
715 .id_table = wdm_ids,
716};
717
718/* --- low level module stuff --- */
719
720static int __init wdm_init(void)
721{
722 int rv;
723
724 rv = usb_register(&wdm_driver);
725
726 return rv;
727}
728
729static void __exit wdm_exit(void)
730{
731 usb_deregister(&wdm_driver);
732}
733
734module_init(wdm_init);
735module_exit(wdm_exit);
736
737MODULE_AUTHOR(DRIVER_AUTHOR);
738MODULE_DESCRIPTION("USB Abstract Control Model driver for "
739 "USB WCM Device Management");
740MODULE_LICENSE("GPL");
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 99e5a68a3f12..fae55a31e26d 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -156,6 +156,10 @@ static struct attribute *ep_dev_attrs[] = {
156static struct attribute_group ep_dev_attr_grp = { 156static struct attribute_group ep_dev_attr_grp = {
157 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
158}; 158};
159static struct attribute_group *ep_dev_groups[] = {
160 &ep_dev_attr_grp,
161 NULL
162};
159 163
160static int usb_endpoint_major_init(void) 164static int usb_endpoint_major_init(void)
161{ 165{
@@ -298,6 +302,7 @@ int usb_create_ep_files(struct device *parent,
298 302
299 ep_dev->desc = &endpoint->desc; 303 ep_dev->desc = &endpoint->desc;
300 ep_dev->udev = udev; 304 ep_dev->udev = udev;
305 ep_dev->dev.groups = ep_dev_groups;
301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); 306 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
302 ep_dev->dev.class = ep_class->class; 307 ep_dev->dev.class = ep_class->class;
303 ep_dev->dev.parent = parent; 308 ep_dev->dev.parent = parent;
@@ -309,9 +314,6 @@ int usb_create_ep_files(struct device *parent,
309 retval = device_register(&ep_dev->dev); 314 retval = device_register(&ep_dev->dev);
310 if (retval) 315 if (retval)
311 goto error_chrdev; 316 goto error_chrdev;
312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
313 if (retval)
314 goto error_group;
315 317
316 /* create the symlink to the old-style "ep_XX" directory */ 318 /* create the symlink to the old-style "ep_XX" directory */
317 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 319 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
@@ -322,8 +324,6 @@ int usb_create_ep_files(struct device *parent,
322 return retval; 324 return retval;
323 325
324error_link: 326error_link:
325 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
326error_group:
327 device_unregister(&ep_dev->dev); 327 device_unregister(&ep_dev->dev);
328 destroy_endpoint_class(); 328 destroy_endpoint_class();
329 return retval; 329 return retval;
@@ -348,7 +348,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
348 348
349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
352 device_unregister(&ep_dev->dev); 351 device_unregister(&ep_dev->dev);
353 endpoint->ep_dev = NULL; 352 endpoint->ep_dev = NULL;
354 destroy_endpoint_class(); 353 destroy_endpoint_class();
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index c1cb94e9f242..7e912f21fd36 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -155,9 +155,6 @@ static int generic_probe(struct usb_device *udev)
155{ 155{
156 int err, c; 156 int err, c;
157 157
158 /* put device-specific files into sysfs */
159 usb_create_sysfs_dev_files(udev);
160
161 /* Choose and set the configuration. This registers the interfaces 158 /* Choose and set the configuration. This registers the interfaces
162 * with the driver core and lets interface drivers bind to them. 159 * with the driver core and lets interface drivers bind to them.
163 */ 160 */
@@ -189,8 +186,6 @@ static void generic_disconnect(struct usb_device *udev)
189 * unconfigure the device */ 186 * unconfigure the device */
190 if (udev->actconfig) 187 if (udev->actconfig)
191 usb_set_configuration(udev, -1); 188 usb_set_configuration(udev, -1);
192
193 usb_remove_sysfs_dev_files(udev);
194} 189}
195 190
196#ifdef CONFIG_PM 191#ifdef CONFIG_PM
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index bf10e9c4195e..09a53e7f3327 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -818,12 +818,12 @@ static int usb_register_bus(struct usb_bus *bus)
818 set_bit (busnum, busmap.busmap); 818 set_bit (busnum, busmap.busmap);
819 bus->busnum = busnum; 819 bus->busnum = busnum;
820 820
821 bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), 821 bus->dev = device_create_drvdata(usb_host_class, bus->controller,
822 "usb_host%d", busnum); 822 MKDEV(0, 0), bus,
823 "usb_host%d", busnum);
823 result = PTR_ERR(bus->dev); 824 result = PTR_ERR(bus->dev);
824 if (IS_ERR(bus->dev)) 825 if (IS_ERR(bus->dev))
825 goto error_create_class_dev; 826 goto error_create_class_dev;
826 dev_set_drvdata(bus->dev, bus);
827 827
828 /* Add it to the local list of buses */ 828 /* Add it to the local list of buses */
829 list_add (&bus->bus_list, &usb_bus_list); 829 list_add (&bus->bus_list, &usb_bus_list);
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 1e4b81e9eb50..a0bf5df6cb6f 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -213,6 +213,8 @@ struct hc_driver {
213 213
214 /* force handover of high-speed port to full-speed companion */ 214 /* force handover of high-speed port to full-speed companion */
215 void (*relinquish_port)(struct usb_hcd *, int); 215 void (*relinquish_port)(struct usb_hcd *, int);
216 /* has a port been handed over to a companion? */
217 int (*port_handed_over)(struct usb_hcd *, int);
216}; 218};
217 219
218extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); 220extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index eb57fcc701d7..94789be54ca3 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -644,6 +644,48 @@ static void hub_stop(struct usb_hub *hub)
644 644
645#ifdef CONFIG_PM 645#ifdef CONFIG_PM
646 646
647/* Try to identify which devices need USB-PERSIST handling */
648static int persistent_device(struct usb_device *udev)
649{
650 int i;
651 int retval;
652 struct usb_host_config *actconfig;
653
654 /* Explicitly not marked persistent? */
655 if (!udev->persist_enabled)
656 return 0;
657
658 /* No active config? */
659 actconfig = udev->actconfig;
660 if (!actconfig)
661 return 0;
662
663 /* FIXME! We should check whether it's open here or not! */
664
665 /*
666 * Check that all the interface drivers have a
667 * 'reset_resume' entrypoint
668 */
669 retval = 0;
670 for (i = 0; i < actconfig->desc.bNumInterfaces; i++) {
671 struct usb_interface *intf;
672 struct usb_driver *driver;
673
674 intf = actconfig->interface[i];
675 if (!intf->dev.driver)
676 continue;
677 driver = to_usb_driver(intf->dev.driver);
678 if (!driver->reset_resume)
679 return 0;
680 /*
681 * We have at least one driver, and that one
682 * has a reset_resume method.
683 */
684 retval = 1;
685 }
686 return retval;
687}
688
647static void hub_restart(struct usb_hub *hub, int type) 689static void hub_restart(struct usb_hub *hub, int type)
648{ 690{
649 struct usb_device *hdev = hub->hdev; 691 struct usb_device *hdev = hub->hdev;
@@ -689,8 +731,8 @@ static void hub_restart(struct usb_hub *hub, int type)
689 * turn off the various status changes to prevent 731 * turn off the various status changes to prevent
690 * khubd from disconnecting it later. 732 * khubd from disconnecting it later.
691 */ 733 */
692 if (udev->persist_enabled && status == 0 && 734 if (status == 0 && !(portstatus & USB_PORT_STAT_ENABLE) &&
693 !(portstatus & USB_PORT_STAT_ENABLE)) { 735 persistent_device(udev)) {
694 if (portchange & USB_PORT_STAT_C_ENABLE) 736 if (portchange & USB_PORT_STAT_C_ENABLE)
695 clear_port_feature(hub->hdev, port1, 737 clear_port_feature(hub->hdev, port1,
696 USB_PORT_FEAT_C_ENABLE); 738 USB_PORT_FEAT_C_ENABLE);
@@ -1326,6 +1368,12 @@ void usb_disconnect(struct usb_device **pdev)
1326 1368
1327 usb_unlock_device(udev); 1369 usb_unlock_device(udev);
1328 1370
1371 /* Remove the device-specific files from sysfs. This must be
1372 * done with udev unlocked, because some of the attribute
1373 * routines try to acquire the device lock.
1374 */
1375 usb_remove_sysfs_dev_files(udev);
1376
1329 /* Unregister the device. The device driver is responsible 1377 /* Unregister the device. The device driver is responsible
1330 * for removing the device files from usbfs and sysfs and for 1378 * for removing the device files from usbfs and sysfs and for
1331 * de-configuring the device. 1379 * de-configuring the device.
@@ -1541,6 +1589,9 @@ int usb_new_device(struct usb_device *udev)
1541 goto fail; 1589 goto fail;
1542 } 1590 }
1543 1591
1592 /* put device-specific files into sysfs */
1593 usb_create_sysfs_dev_files(udev);
1594
1544 /* Tell the world! */ 1595 /* Tell the world! */
1545 announce_device(udev); 1596 announce_device(udev);
1546 return err; 1597 return err;
@@ -2744,7 +2795,11 @@ loop:
2744 if ((status == -ENOTCONN) || (status == -ENOTSUPP)) 2795 if ((status == -ENOTCONN) || (status == -ENOTSUPP))
2745 break; 2796 break;
2746 } 2797 }
2747 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", port1); 2798 if (hub->hdev->parent ||
2799 !hcd->driver->port_handed_over ||
2800 !(hcd->driver->port_handed_over)(hcd, port1))
2801 dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
2802 port1);
2748 2803
2749done: 2804done:
2750 hub_port_disable(hub, port1, 1); 2805 hub_port_disable(hub, port1, 1);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3e69266e1f4d..fe47d145255a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1607,6 +1607,7 @@ free_interfaces:
1607 intf->dev.driver = NULL; 1607 intf->dev.driver = NULL;
1608 intf->dev.bus = &usb_bus_type; 1608 intf->dev.bus = &usb_bus_type;
1609 intf->dev.type = &usb_if_device_type; 1609 intf->dev.type = &usb_if_device_type;
1610 intf->dev.groups = usb_interface_groups;
1610 intf->dev.dma_mask = dev->dev.dma_mask; 1611 intf->dev.dma_mask = dev->dev.dma_mask;
1611 device_initialize(&intf->dev); 1612 device_initialize(&intf->dev);
1612 mark_quiesced(intf); 1613 mark_quiesced(intf);
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 2e2019390290..3da1ab4b389d 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -47,6 +47,10 @@ static const struct usb_device_id usb_quirk_list[] = {
47 /* Edirol SD-20 */ 47 /* Edirol SD-20 */
48 { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME }, 48 { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
49 49
50 /* Avision AV600U */
51 { USB_DEVICE(0x0638, 0x0a13), .driver_info =
52 USB_QUIRK_STRING_FETCH_255 },
53
50 /* M-Systems Flash Disk Pioneers */ 54 /* M-Systems Flash Disk Pioneers */
51 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, 55 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
52 56
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 5b20a60de8ba..5e1f5d55bf04 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -538,6 +538,46 @@ static struct attribute_group dev_attr_grp = {
538 .attrs = dev_attrs, 538 .attrs = dev_attrs,
539}; 539};
540 540
541/* When modifying this list, be sure to modify dev_string_attrs_are_visible()
542 * accordingly.
543 */
544static struct attribute *dev_string_attrs[] = {
545 &dev_attr_manufacturer.attr,
546 &dev_attr_product.attr,
547 &dev_attr_serial.attr,
548 NULL
549};
550
551static mode_t dev_string_attrs_are_visible(struct kobject *kobj,
552 struct attribute *a, int n)
553{
554 struct usb_device *udev = to_usb_device(
555 container_of(kobj, struct device, kobj));
556
557 if (a == &dev_attr_manufacturer.attr) {
558 if (udev->manufacturer == NULL)
559 return 0;
560 } else if (a == &dev_attr_product.attr) {
561 if (udev->product == NULL)
562 return 0;
563 } else if (a == &dev_attr_serial.attr) {
564 if (udev->serial == NULL)
565 return 0;
566 }
567 return a->mode;
568}
569
570static struct attribute_group dev_string_attr_grp = {
571 .attrs = dev_string_attrs,
572 .is_visible = dev_string_attrs_are_visible,
573};
574
575struct attribute_group *usb_device_groups[] = {
576 &dev_attr_grp,
577 &dev_string_attr_grp,
578 NULL
579};
580
541/* Binary descriptors */ 581/* Binary descriptors */
542 582
543static ssize_t 583static ssize_t
@@ -548,35 +588,33 @@ read_descriptors(struct kobject *kobj, struct bin_attribute *attr,
548 container_of(kobj, struct device, kobj)); 588 container_of(kobj, struct device, kobj));
549 size_t nleft = count; 589 size_t nleft = count;
550 size_t srclen, n; 590 size_t srclen, n;
591 int cfgno;
592 void *src;
551 593
552 usb_lock_device(udev); 594 /* The binary attribute begins with the device descriptor.
553 595 * Following that are the raw descriptor entries for all the
554 /* The binary attribute begins with the device descriptor */ 596 * configurations (config plus subsidiary descriptors).
555 srclen = sizeof(struct usb_device_descriptor);
556 if (off < srclen) {
557 n = min_t(size_t, nleft, srclen - off);
558 memcpy(buf, off + (char *) &udev->descriptor, n);
559 nleft -= n;
560 buf += n;
561 off = 0;
562 } else {
563 off -= srclen;
564 }
565
566 /* Then follows the raw descriptor entry for the current
567 * configuration (config plus subsidiary descriptors).
568 */ 597 */
569 if (udev->actconfig) { 598 for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations &&
570 int cfgno = udev->actconfig - udev->config; 599 nleft > 0; ++cfgno) {
571 600 if (cfgno < 0) {
572 srclen = __le16_to_cpu(udev->actconfig->desc.wTotalLength); 601 src = &udev->descriptor;
602 srclen = sizeof(struct usb_device_descriptor);
603 } else {
604 src = udev->rawdescriptors[cfgno];
605 srclen = __le16_to_cpu(udev->config[cfgno].desc.
606 wTotalLength);
607 }
573 if (off < srclen) { 608 if (off < srclen) {
574 n = min_t(size_t, nleft, srclen - off); 609 n = min(nleft, srclen - (size_t) off);
575 memcpy(buf, off + udev->rawdescriptors[cfgno], n); 610 memcpy(buf, src + off, n);
576 nleft -= n; 611 nleft -= n;
612 buf += n;
613 off = 0;
614 } else {
615 off -= srclen;
577 } 616 }
578 } 617 }
579 usb_unlock_device(udev);
580 return count - nleft; 618 return count - nleft;
581} 619}
582 620
@@ -591,10 +629,9 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
591 struct device *dev = &udev->dev; 629 struct device *dev = &udev->dev;
592 int retval; 630 int retval;
593 631
594 retval = sysfs_create_group(&dev->kobj, &dev_attr_grp); 632 /* Unforunately these attributes cannot be created before
595 if (retval) 633 * the uevent is broadcast.
596 return retval; 634 */
597
598 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 635 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
599 if (retval) 636 if (retval)
600 goto error; 637 goto error;
@@ -607,21 +644,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
607 if (retval) 644 if (retval)
608 goto error; 645 goto error;
609 646
610 if (udev->manufacturer) {
611 retval = device_create_file(dev, &dev_attr_manufacturer);
612 if (retval)
613 goto error;
614 }
615 if (udev->product) {
616 retval = device_create_file(dev, &dev_attr_product);
617 if (retval)
618 goto error;
619 }
620 if (udev->serial) {
621 retval = device_create_file(dev, &dev_attr_serial);
622 if (retval)
623 goto error;
624 }
625 retval = usb_create_ep_files(dev, &udev->ep0, udev); 647 retval = usb_create_ep_files(dev, &udev->ep0, udev);
626 if (retval) 648 if (retval)
627 goto error; 649 goto error;
@@ -636,13 +658,9 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
636 struct device *dev = &udev->dev; 658 struct device *dev = &udev->dev;
637 659
638 usb_remove_ep_files(&udev->ep0); 660 usb_remove_ep_files(&udev->ep0);
639 device_remove_file(dev, &dev_attr_manufacturer);
640 device_remove_file(dev, &dev_attr_product);
641 device_remove_file(dev, &dev_attr_serial);
642 remove_power_attributes(dev); 661 remove_power_attributes(dev);
643 remove_persist_attributes(dev); 662 remove_persist_attributes(dev);
644 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 663 device_remove_bin_file(dev, &dev_bin_attr_descriptors);
645 sysfs_remove_group(&dev->kobj, &dev_attr_grp);
646} 664}
647 665
648/* Interface Accociation Descriptor fields */ 666/* Interface Accociation Descriptor fields */
@@ -688,17 +706,15 @@ static ssize_t show_interface_string(struct device *dev,
688 struct device_attribute *attr, char *buf) 706 struct device_attribute *attr, char *buf)
689{ 707{
690 struct usb_interface *intf; 708 struct usb_interface *intf;
691 struct usb_device *udev; 709 char *string;
692 int len;
693 710
694 intf = to_usb_interface(dev); 711 intf = to_usb_interface(dev);
695 udev = interface_to_usbdev(intf); 712 string = intf->cur_altsetting->string;
696 len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); 713 barrier(); /* The altsetting might change! */
697 if (len < 0) 714
715 if (!string)
698 return 0; 716 return 0;
699 buf[len] = '\n'; 717 return sprintf(buf, "%s\n", string);
700 buf[len+1] = 0;
701 return len+1;
702} 718}
703static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 719static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
704 720
@@ -727,18 +743,6 @@ static ssize_t show_modalias(struct device *dev,
727} 743}
728static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 744static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
729 745
730static struct attribute *intf_assoc_attrs[] = {
731 &dev_attr_iad_bFirstInterface.attr,
732 &dev_attr_iad_bInterfaceCount.attr,
733 &dev_attr_iad_bFunctionClass.attr,
734 &dev_attr_iad_bFunctionSubClass.attr,
735 &dev_attr_iad_bFunctionProtocol.attr,
736 NULL,
737};
738static struct attribute_group intf_assoc_attr_grp = {
739 .attrs = intf_assoc_attrs,
740};
741
742static struct attribute *intf_attrs[] = { 746static struct attribute *intf_attrs[] = {
743 &dev_attr_bInterfaceNumber.attr, 747 &dev_attr_bInterfaceNumber.attr,
744 &dev_attr_bAlternateSetting.attr, 748 &dev_attr_bAlternateSetting.attr,
@@ -753,6 +757,37 @@ static struct attribute_group intf_attr_grp = {
753 .attrs = intf_attrs, 757 .attrs = intf_attrs,
754}; 758};
755 759
760static struct attribute *intf_assoc_attrs[] = {
761 &dev_attr_iad_bFirstInterface.attr,
762 &dev_attr_iad_bInterfaceCount.attr,
763 &dev_attr_iad_bFunctionClass.attr,
764 &dev_attr_iad_bFunctionSubClass.attr,
765 &dev_attr_iad_bFunctionProtocol.attr,
766 NULL,
767};
768
769static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
770 struct attribute *a, int n)
771{
772 struct usb_interface *intf = to_usb_interface(
773 container_of(kobj, struct device, kobj));
774
775 if (intf->intf_assoc == NULL)
776 return 0;
777 return a->mode;
778}
779
780static struct attribute_group intf_assoc_attr_grp = {
781 .attrs = intf_assoc_attrs,
782 .is_visible = intf_assoc_attrs_are_visible,
783};
784
785struct attribute_group *usb_interface_groups[] = {
786 &intf_attr_grp,
787 &intf_assoc_attr_grp,
788 NULL
789};
790
756static inline void usb_create_intf_ep_files(struct usb_interface *intf, 791static inline void usb_create_intf_ep_files(struct usb_interface *intf,
757 struct usb_device *udev) 792 struct usb_device *udev)
758{ 793{
@@ -777,23 +812,21 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
777 812
778int usb_create_sysfs_intf_files(struct usb_interface *intf) 813int usb_create_sysfs_intf_files(struct usb_interface *intf)
779{ 814{
780 struct device *dev = &intf->dev;
781 struct usb_device *udev = interface_to_usbdev(intf); 815 struct usb_device *udev = interface_to_usbdev(intf);
782 struct usb_host_interface *alt = intf->cur_altsetting; 816 struct usb_host_interface *alt = intf->cur_altsetting;
783 int retval; 817 int retval;
784 818
785 if (intf->sysfs_files_created) 819 if (intf->sysfs_files_created)
786 return 0; 820 return 0;
787 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
788 if (retval)
789 return retval;
790 821
822 /* The interface string may be present in some altsettings
823 * and missing in others. Hence its attribute cannot be created
824 * before the uevent is broadcast.
825 */
791 if (alt->string == NULL) 826 if (alt->string == NULL)
792 alt->string = usb_cache_string(udev, alt->desc.iInterface); 827 alt->string = usb_cache_string(udev, alt->desc.iInterface);
793 if (alt->string) 828 if (alt->string)
794 retval = device_create_file(dev, &dev_attr_interface); 829 retval = device_create_file(&intf->dev, &dev_attr_interface);
795 if (intf->intf_assoc)
796 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
797 usb_create_intf_ep_files(intf, udev); 830 usb_create_intf_ep_files(intf, udev);
798 intf->sysfs_files_created = 1; 831 intf->sysfs_files_created = 1;
799 return 0; 832 return 0;
@@ -807,7 +840,5 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
807 return; 840 return;
808 usb_remove_intf_ep_files(intf); 841 usb_remove_intf_ep_files(intf);
809 device_remove_file(dev, &dev_attr_interface); 842 device_remove_file(dev, &dev_attr_interface);
810 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
811 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
812 intf->sysfs_files_created = 0; 843 intf->sysfs_files_created = 0;
813} 844}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 1f0db51190cc..325774375837 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -291,6 +291,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
291 device_initialize(&dev->dev); 291 device_initialize(&dev->dev);
292 dev->dev.bus = &usb_bus_type; 292 dev->dev.bus = &usb_bus_type;
293 dev->dev.type = &usb_device_type; 293 dev->dev.type = &usb_device_type;
294 dev->dev.groups = usb_device_groups;
294 dev->dev.dma_mask = bus->controller->dma_mask; 295 dev->dev.dma_mask = bus->controller->dma_mask;
295 set_dev_node(&dev->dev, dev_to_node(bus->controller)); 296 set_dev_node(&dev->dev, dev_to_node(bus->controller));
296 dev->state = USB_STATE_ATTACHED; 297 dev->state = USB_STATE_ATTACHED;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 1bf8ccb9c58d..1a8bc21c335e 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -130,6 +130,10 @@ static inline int is_active(const struct usb_interface *f)
130/* for labeling diagnostics */ 130/* for labeling diagnostics */
131extern const char *usbcore_name; 131extern const char *usbcore_name;
132 132
133/* sysfs stuff */
134extern struct attribute_group *usb_device_groups[];
135extern struct attribute_group *usb_interface_groups[];
136
133/* usbfs stuff */ 137/* usbfs stuff */
134extern struct mutex usbfs_mutex; 138extern struct mutex usbfs_mutex;
135extern struct usb_driver usbfs_driver; 139extern struct usb_driver usbfs_driver;
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index ce337cb5d137..f261d2a9a5f0 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3251,7 +3251,7 @@ static int udc_pci_probe(
3251 /* pci setup */ 3251 /* pci setup */
3252 if (pci_enable_device(pdev) < 0) { 3252 if (pci_enable_device(pdev) < 0) {
3253 kfree(dev); 3253 kfree(dev);
3254 dev = 0; 3254 dev = NULL;
3255 retval = -ENODEV; 3255 retval = -ENODEV;
3256 goto finished; 3256 goto finished;
3257 } 3257 }
@@ -3264,7 +3264,7 @@ static int udc_pci_probe(
3264 if (!request_mem_region(resource, len, name)) { 3264 if (!request_mem_region(resource, len, name)) {
3265 dev_dbg(&pdev->dev, "pci device used already\n"); 3265 dev_dbg(&pdev->dev, "pci device used already\n");
3266 kfree(dev); 3266 kfree(dev);
3267 dev = 0; 3267 dev = NULL;
3268 retval = -EBUSY; 3268 retval = -EBUSY;
3269 goto finished; 3269 goto finished;
3270 } 3270 }
@@ -3274,7 +3274,7 @@ static int udc_pci_probe(
3274 if (dev->virt_addr == NULL) { 3274 if (dev->virt_addr == NULL) {
3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n"); 3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n");
3276 kfree(dev); 3276 kfree(dev);
3277 dev = 0; 3277 dev = NULL;
3278 retval = -EFAULT; 3278 retval = -EFAULT;
3279 goto finished; 3279 goto finished;
3280 } 3280 }
@@ -3282,7 +3282,7 @@ static int udc_pci_probe(
3282 if (!pdev->irq) { 3282 if (!pdev->irq) {
3283 dev_err(&dev->pdev->dev, "irq not set\n"); 3283 dev_err(&dev->pdev->dev, "irq not set\n");
3284 kfree(dev); 3284 kfree(dev);
3285 dev = 0; 3285 dev = NULL;
3286 retval = -ENODEV; 3286 retval = -ENODEV;
3287 goto finished; 3287 goto finished;
3288 } 3288 }
@@ -3290,7 +3290,7 @@ static int udc_pci_probe(
3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { 3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); 3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
3292 kfree(dev); 3292 kfree(dev);
3293 dev = 0; 3293 dev = NULL;
3294 retval = -EBUSY; 3294 retval = -EBUSY;
3295 goto finished; 3295 goto finished;
3296 } 3296 }
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index e756023362c2..07e5a0b5dcda 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -649,7 +649,13 @@ static int usba_ep_disable(struct usb_ep *_ep)
649 649
650 if (!ep->desc) { 650 if (!ep->desc) {
651 spin_unlock_irqrestore(&udc->lock, flags); 651 spin_unlock_irqrestore(&udc->lock, flags);
652 DBG(DBG_ERR, "ep_disable: %s not enabled\n", ep->ep.name); 652 /* REVISIT because this driver disables endpoints in
653 * reset_all_endpoints() before calling disconnect(),
654 * most gadget drivers would trigger this non-error ...
655 */
656 if (udc->gadget.speed != USB_SPEED_UNKNOWN)
657 DBG(DBG_ERR, "ep_disable: %s not enabled\n",
658 ep->ep.name);
653 return -EINVAL; 659 return -EINVAL;
654 } 660 }
655 ep->desc = NULL; 661 ep->desc = NULL;
@@ -1032,8 +1038,6 @@ static struct usba_udc the_udc = {
1032 .release = nop_release, 1038 .release = nop_release,
1033 }, 1039 },
1034 }, 1040 },
1035
1036 .lock = SPIN_LOCK_UNLOCKED,
1037}; 1041};
1038 1042
1039/* 1043/*
@@ -1052,6 +1056,12 @@ static void reset_all_endpoints(struct usba_udc *udc)
1052 request_complete(ep, req, -ECONNRESET); 1056 request_complete(ep, req, -ECONNRESET);
1053 } 1057 }
1054 1058
1059 /* NOTE: normally, the next call to the gadget driver is in
1060 * charge of disabling endpoints... usually disconnect().
1061 * The exception would be entering a high speed test mode.
1062 *
1063 * FIXME remove this code ... and retest thoroughly.
1064 */
1055 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { 1065 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
1056 if (ep->desc) { 1066 if (ep->desc) {
1057 spin_unlock(&udc->lock); 1067 spin_unlock(&udc->lock);
@@ -1219,7 +1229,7 @@ static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq)
1219static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, 1229static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1220 struct usb_ctrlrequest *crq) 1230 struct usb_ctrlrequest *crq)
1221{ 1231{
1222 int retval = 0;; 1232 int retval = 0;
1223 1233
1224 switch (crq->bRequest) { 1234 switch (crq->bRequest) {
1225 case USB_REQ_GET_STATUS: { 1235 case USB_REQ_GET_STATUS: {
@@ -1693,6 +1703,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1693 usba_writel(udc, INT_CLR, USBA_END_OF_RESET); 1703 usba_writel(udc, INT_CLR, USBA_END_OF_RESET);
1694 reset_all_endpoints(udc); 1704 reset_all_endpoints(udc);
1695 1705
1706 if (udc->gadget.speed != USB_SPEED_UNKNOWN
1707 && udc->driver->disconnect) {
1708 udc->gadget.speed = USB_SPEED_UNKNOWN;
1709 spin_unlock(&udc->lock);
1710 udc->driver->disconnect(&udc->gadget);
1711 spin_lock(&udc->lock);
1712 }
1713
1696 if (status & USBA_HIGH_SPEED) { 1714 if (status & USBA_HIGH_SPEED) {
1697 DBG(DBG_BUS, "High-speed bus reset detected\n"); 1715 DBG(DBG_BUS, "High-speed bus reset detected\n");
1698 udc->gadget.speed = USB_SPEED_HIGH; 1716 udc->gadget.speed = USB_SPEED_HIGH;
@@ -1716,9 +1734,13 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1716 | USBA_DET_SUSPEND 1734 | USBA_DET_SUSPEND
1717 | USBA_END_OF_RESUME)); 1735 | USBA_END_OF_RESUME));
1718 1736
1737 /*
1738 * Unclear why we hit this irregularly, e.g. in usbtest,
1739 * but it's clearly harmless...
1740 */
1719 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) 1741 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED))
1720 dev_warn(&udc->pdev->dev, 1742 dev_dbg(&udc->pdev->dev,
1721 "WARNING: EP0 configuration is invalid!\n"); 1743 "ODD: EP0 configuration is invalid!\n");
1722 } 1744 }
1723 1745
1724 spin_unlock(&udc->lock); 1746 spin_unlock(&udc->lock);
@@ -1751,9 +1773,11 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
1751 reset_all_endpoints(udc); 1773 reset_all_endpoints(udc);
1752 toggle_bias(0); 1774 toggle_bias(0);
1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1775 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1754 spin_unlock(&udc->lock); 1776 if (udc->driver->disconnect) {
1755 udc->driver->disconnect(&udc->gadget); 1777 spin_unlock(&udc->lock);
1756 spin_lock(&udc->lock); 1778 udc->driver->disconnect(&udc->gadget);
1779 spin_lock(&udc->lock);
1780 }
1757 } 1781 }
1758 udc->vbus_prev = vbus; 1782 udc->vbus_prev = vbus;
1759 } 1783 }
@@ -1825,7 +1849,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1825 1849
1826 if (!udc->pdev) 1850 if (!udc->pdev)
1827 return -ENODEV; 1851 return -ENODEV;
1828 if (driver != udc->driver) 1852 if (driver != udc->driver || !driver->unbind)
1829 return -EINVAL; 1853 return -EINVAL;
1830 1854
1831 if (udc->vbus_pin != -1) 1855 if (udc->vbus_pin != -1)
@@ -1840,6 +1864,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1840 toggle_bias(0); 1864 toggle_bias(0);
1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1865 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1842 1866
1867 if (udc->driver->disconnect)
1868 udc->driver->disconnect(&udc->gadget);
1869
1843 driver->unbind(&udc->gadget); 1870 driver->unbind(&udc->gadget);
1844 udc->gadget.dev.driver = NULL; 1871 udc->gadget.dev.driver = NULL;
1845 udc->driver = NULL; 1872 udc->driver = NULL;
@@ -1879,6 +1906,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1879 goto err_get_hclk; 1906 goto err_get_hclk;
1880 } 1907 }
1881 1908
1909 spin_lock_init(&udc->lock);
1882 udc->pdev = pdev; 1910 udc->pdev = pdev;
1883 udc->pclk = pclk; 1911 udc->pclk = pclk;
1884 udc->hclk = hclk; 1912 udc->hclk = hclk;
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 651b82701394..18687543d7fa 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -1627,7 +1627,9 @@ static int reset_queues(struct fsl_udc *udc)
1627 udc_reset_ep_queue(udc, pipe); 1627 udc_reset_ep_queue(udc, pipe);
1628 1628
1629 /* report disconnect; the driver is already quiesced */ 1629 /* report disconnect; the driver is already quiesced */
1630 spin_unlock(&udc->lock);
1630 udc->driver->disconnect(&udc->gadget); 1631 udc->driver->disconnect(&udc->gadget);
1632 spin_lock(&udc->lock);
1631 1633
1632 return 0; 1634 return 0;
1633} 1635}
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 75eba202f737..e02bfd4df3a6 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1526,7 +1526,8 @@ static void udc_disable(struct pxa_udc *udc)
1526 1526
1527 ep0_idle(udc); 1527 ep0_idle(udc);
1528 udc->gadget.speed = USB_SPEED_UNKNOWN; 1528 udc->gadget.speed = USB_SPEED_UNKNOWN;
1529 udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 1529 if (udc->mach->udc_command)
1530 udc->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
1530} 1531}
1531 1532
1532/** 1533/**
@@ -1546,7 +1547,6 @@ static __init void udc_init_data(struct pxa_udc *dev)
1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); 1547 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; 1548 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0];
1548 ep0_idle(dev); 1549 ep0_idle(dev);
1549 strcpy(dev->dev->bus_id, "");
1550 1550
1551 /* PXA endpoints init */ 1551 /* PXA endpoints init */
1552 for (i = 0; i < NR_PXA_ENDPOINTS; i++) { 1552 for (i = 0; i < NR_PXA_ENDPOINTS; i++) {
@@ -1746,13 +1746,10 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc,
1746 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); 1746 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i);
1747 } 1747 }
1748 1748
1749 le16_to_cpus(&u.r.wValue);
1750 le16_to_cpus(&u.r.wIndex);
1751 le16_to_cpus(&u.r.wLength);
1752
1753 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", 1749 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n",
1754 u.r.bRequestType, u.r.bRequest, 1750 u.r.bRequestType, u.r.bRequest,
1755 u.r.wValue, u.r.wIndex, u.r.wLength); 1751 le16_to_cpu(u.r.wValue), le16_to_cpu(u.r.wIndex),
1752 le16_to_cpu(u.r.wLength));
1756 if (unlikely(have_extrabytes)) 1753 if (unlikely(have_extrabytes))
1757 goto stall; 1754 goto stall;
1758 1755
@@ -2296,7 +2293,8 @@ static void pxa_udc_shutdown(struct platform_device *_dev)
2296{ 2293{
2297 struct pxa_udc *udc = platform_get_drvdata(_dev); 2294 struct pxa_udc *udc = platform_get_drvdata(_dev);
2298 2295
2299 udc_disable(udc); 2296 if (udc_readl(udc, UDCCR) & UDCCR_UDE)
2297 udc_disable(udc);
2300} 2298}
2301 2299
2302#ifdef CONFIG_PM 2300#ifdef CONFIG_PM
@@ -2361,9 +2359,8 @@ static int pxa_udc_resume(struct platform_device *_dev)
2361 * Upon exit from sleep mode and before clearing OTGPH, 2359 * Upon exit from sleep mode and before clearing OTGPH,
2362 * Software must configure the USB OTG pad, UDC, and UHC 2360 * Software must configure the USB OTG pad, UDC, and UHC
2363 * to the state they were in before entering sleep mode. 2361 * to the state they were in before entering sleep mode.
2364 *
2365 * Should be : PSSR |= PSSR_OTGPH;
2366 */ 2362 */
2363 PSSR |= PSSR_OTGPH;
2367 2364
2368 return 0; 2365 return 0;
2369} 2366}
@@ -2387,6 +2384,9 @@ static struct platform_driver udc_driver = {
2387 2384
2388static int __init udc_init(void) 2385static int __init udc_init(void)
2389{ 2386{
2387 if (!cpu_is_pxa27x())
2388 return -ENODEV;
2389
2390 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2390 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
2391 return platform_driver_probe(&udc_driver, pxa_udc_probe); 2391 return platform_driver_probe(&udc_driver, pxa_udc_probe);
2392} 2392}
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 1d1b7936ee11..97453db924ff 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -484,4 +484,12 @@ static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget)
484#define ep_warn(ep, fmt, arg...) \ 484#define ep_warn(ep, fmt, arg...) \
485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) 485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg)
486 486
487/*
488 * Cannot include pxa-regs.h, as register names are similar.
489 * So PSSR is redefined here. This should be removed once UDC registers will
490 * be gone from pxa-regs.h.
491 */
492#define PSSR __REG(0x40F00004) /* Power Manager Sleep Status */
493#define PSSR_OTGPH (1 << 6) /* OTG Peripheral Hold */
494
487#endif /* __LINUX_USB_GADGET_PXA27X_H */ 495#endif /* __LINUX_USB_GADGET_PXA27X_H */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 54cdd6f94034..fa019fa73334 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -14,7 +14,6 @@
14 * This software is distributed under the terms of the GNU General 14 * This software is distributed under the terms of the GNU General
15 * Public License ("GPL") as published by the Free Software Foundation, 15 * Public License ("GPL") as published by the Free Software Foundation,
16 * either version 2 of that License or (at your option) any later version. 16 * either version 2 of that License or (at your option) any later version.
17 *
18 */ 17 */
19 18
20#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -33,7 +32,7 @@
33/* Defines */ 32/* Defines */
34 33
35#define GS_VERSION_STR "v2.2" 34#define GS_VERSION_STR "v2.2"
36#define GS_VERSION_NUM 0x0202 35#define GS_VERSION_NUM 0x2200
37 36
38#define GS_LONG_NAME "Gadget Serial" 37#define GS_LONG_NAME "Gadget Serial"
39#define GS_SHORT_NAME "g_serial" 38#define GS_SHORT_NAME "g_serial"
@@ -41,7 +40,11 @@
41#define GS_MAJOR 127 40#define GS_MAJOR 127
42#define GS_MINOR_START 0 41#define GS_MINOR_START 0
43 42
44#define GS_NUM_PORTS 16 43/* REVISIT only one port is supported for now;
44 * see gs_{send,recv}_packet() ... no multiplexing,
45 * and no support for multiple ACM devices.
46 */
47#define GS_NUM_PORTS 1
45 48
46#define GS_NUM_CONFIGS 1 49#define GS_NUM_CONFIGS 1
47#define GS_NO_CONFIG_ID 0 50#define GS_NO_CONFIG_ID 0
@@ -65,6 +68,9 @@
65 68
66#define GS_DEFAULT_USE_ACM 0 69#define GS_DEFAULT_USE_ACM 0
67 70
71/* 9600-8-N-1 ... matches init_termios.c_cflag and defaults
72 * expected by "usbser.sys" on MS-Windows.
73 */
68#define GS_DEFAULT_DTE_RATE 9600 74#define GS_DEFAULT_DTE_RATE 9600
69#define GS_DEFAULT_DATA_BITS 8 75#define GS_DEFAULT_DATA_BITS 8
70#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY 76#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY
@@ -107,10 +113,6 @@ static int debug = 1;
107#define GS_NOTIFY_MAXPACKET 8 113#define GS_NOTIFY_MAXPACKET 8
108 114
109 115
110/* Structures */
111
112struct gs_dev;
113
114/* circular buffer */ 116/* circular buffer */
115struct gs_buf { 117struct gs_buf {
116 unsigned int buf_size; 118 unsigned int buf_size;
@@ -119,12 +121,6 @@ struct gs_buf {
119 char *buf_put; 121 char *buf_put;
120}; 122};
121 123
122/* list of requests */
123struct gs_req_entry {
124 struct list_head re_entry;
125 struct usb_request *re_req;
126};
127
128/* the port structure holds info for each port, one for each minor number */ 124/* the port structure holds info for each port, one for each minor number */
129struct gs_port { 125struct gs_port {
130 struct gs_dev *port_dev; /* pointer to device struct */ 126 struct gs_dev *port_dev; /* pointer to device struct */
@@ -164,26 +160,7 @@ struct gs_dev {
164 160
165/* Functions */ 161/* Functions */
166 162
167/* module */ 163/* tty driver internals */
168static int __init gs_module_init(void);
169static void __exit gs_module_exit(void);
170
171/* tty driver */
172static int gs_open(struct tty_struct *tty, struct file *file);
173static void gs_close(struct tty_struct *tty, struct file *file);
174static int gs_write(struct tty_struct *tty,
175 const unsigned char *buf, int count);
176static int gs_put_char(struct tty_struct *tty, unsigned char ch);
177static void gs_flush_chars(struct tty_struct *tty);
178static int gs_write_room(struct tty_struct *tty);
179static int gs_chars_in_buffer(struct tty_struct *tty);
180static void gs_throttle(struct tty_struct * tty);
181static void gs_unthrottle(struct tty_struct * tty);
182static void gs_break(struct tty_struct *tty, int break_state);
183static int gs_ioctl(struct tty_struct *tty, struct file *file,
184 unsigned int cmd, unsigned long arg);
185static void gs_set_termios(struct tty_struct *tty, struct ktermios *old);
186
187static int gs_send(struct gs_dev *dev); 164static int gs_send(struct gs_dev *dev);
188static int gs_send_packet(struct gs_dev *dev, char *packet, 165static int gs_send_packet(struct gs_dev *dev, char *packet,
189 unsigned int size); 166 unsigned int size);
@@ -192,19 +169,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet,
192static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); 169static void gs_read_complete(struct usb_ep *ep, struct usb_request *req);
193static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); 170static void gs_write_complete(struct usb_ep *ep, struct usb_request *req);
194 171
195/* gadget driver */ 172/* gadget driver internals */
196static int gs_bind(struct usb_gadget *gadget);
197static void gs_unbind(struct usb_gadget *gadget);
198static int gs_setup(struct usb_gadget *gadget,
199 const struct usb_ctrlrequest *ctrl);
200static int gs_setup_standard(struct usb_gadget *gadget,
201 const struct usb_ctrlrequest *ctrl);
202static int gs_setup_class(struct usb_gadget *gadget,
203 const struct usb_ctrlrequest *ctrl);
204static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req);
205static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
206 struct usb_request *req);
207static void gs_disconnect(struct usb_gadget *gadget);
208static int gs_set_config(struct gs_dev *dev, unsigned config); 173static int gs_set_config(struct gs_dev *dev, unsigned config);
209static void gs_reset_config(struct gs_dev *dev); 174static void gs_reset_config(struct gs_dev *dev);
210static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, 175static int gs_build_config_buf(u8 *buf, struct usb_gadget *g,
@@ -214,10 +179,6 @@ static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
214 gfp_t kmalloc_flags); 179 gfp_t kmalloc_flags);
215static void gs_free_req(struct usb_ep *ep, struct usb_request *req); 180static void gs_free_req(struct usb_ep *ep, struct usb_request *req);
216 181
217static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len,
218 gfp_t kmalloc_flags);
219static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req);
220
221static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); 182static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags);
222static void gs_free_ports(struct gs_dev *dev); 183static void gs_free_ports(struct gs_dev *dev);
223 184
@@ -232,62 +193,15 @@ static unsigned int gs_buf_put(struct gs_buf *gb, const char *buf,
232static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, 193static unsigned int gs_buf_get(struct gs_buf *gb, char *buf,
233 unsigned int count); 194 unsigned int count);
234 195
235/* external functions */
236extern int net2280_set_fifo_mode(struct usb_gadget *gadget, int mode);
237
238 196
239/* Globals */ 197/* Globals */
240 198
241static struct gs_dev *gs_device; 199static struct gs_dev *gs_device;
242 200
243static const char *EP_IN_NAME;
244static const char *EP_OUT_NAME;
245static const char *EP_NOTIFY_NAME;
246
247static struct mutex gs_open_close_lock[GS_NUM_PORTS]; 201static struct mutex gs_open_close_lock[GS_NUM_PORTS];
248 202
249static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
250static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
251
252static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
253
254static unsigned int use_acm = GS_DEFAULT_USE_ACM;
255
256
257/* tty driver struct */
258static const struct tty_operations gs_tty_ops = {
259 .open = gs_open,
260 .close = gs_close,
261 .write = gs_write,
262 .put_char = gs_put_char,
263 .flush_chars = gs_flush_chars,
264 .write_room = gs_write_room,
265 .ioctl = gs_ioctl,
266 .set_termios = gs_set_termios,
267 .throttle = gs_throttle,
268 .unthrottle = gs_unthrottle,
269 .break_ctl = gs_break,
270 .chars_in_buffer = gs_chars_in_buffer,
271};
272static struct tty_driver *gs_tty_driver;
273
274/* gadget driver struct */
275static struct usb_gadget_driver gs_gadget_driver = {
276#ifdef CONFIG_USB_GADGET_DUALSPEED
277 .speed = USB_SPEED_HIGH,
278#else
279 .speed = USB_SPEED_FULL,
280#endif /* CONFIG_USB_GADGET_DUALSPEED */
281 .function = GS_LONG_NAME,
282 .bind = gs_bind,
283 .unbind = gs_unbind,
284 .setup = gs_setup,
285 .disconnect = gs_disconnect,
286 .driver = {
287 .name = GS_SHORT_NAME,
288 },
289};
290 203
204/*-------------------------------------------------------------------------*/
291 205
292/* USB descriptors */ 206/* USB descriptors */
293 207
@@ -304,7 +218,6 @@ static char manufacturer[50];
304static struct usb_string gs_strings[] = { 218static struct usb_string gs_strings[] = {
305 { GS_MANUFACTURER_STR_ID, manufacturer }, 219 { GS_MANUFACTURER_STR_ID, manufacturer },
306 { GS_PRODUCT_STR_ID, GS_LONG_NAME }, 220 { GS_PRODUCT_STR_ID, GS_LONG_NAME },
307 { GS_SERIAL_STR_ID, "0" },
308 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, 221 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" },
309 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, 222 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" },
310 { GS_CONTROL_STR_ID, "Gadget Serial Control" }, 223 { GS_CONTROL_STR_ID, "Gadget Serial Control" },
@@ -327,7 +240,6 @@ static struct usb_device_descriptor gs_device_desc = {
327 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), 240 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID),
328 .iManufacturer = GS_MANUFACTURER_STR_ID, 241 .iManufacturer = GS_MANUFACTURER_STR_ID,
329 .iProduct = GS_PRODUCT_STR_ID, 242 .iProduct = GS_PRODUCT_STR_ID,
330 .iSerialNumber = GS_SERIAL_STR_ID,
331 .bNumConfigurations = GS_NUM_CONFIGS, 243 .bNumConfigurations = GS_NUM_CONFIGS,
332}; 244};
333 245
@@ -364,7 +276,7 @@ static const struct usb_interface_descriptor gs_bulk_interface_desc = {
364 .bDescriptorType = USB_DT_INTERFACE, 276 .bDescriptorType = USB_DT_INTERFACE,
365 .bInterfaceNumber = GS_BULK_INTERFACE_ID, 277 .bInterfaceNumber = GS_BULK_INTERFACE_ID,
366 .bNumEndpoints = 2, 278 .bNumEndpoints = 2,
367 .bInterfaceClass = USB_CLASS_CDC_DATA, 279 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
368 .bInterfaceSubClass = 0, 280 .bInterfaceSubClass = 0,
369 .bInterfaceProtocol = 0, 281 .bInterfaceProtocol = 0,
370 .iInterface = GS_DATA_STR_ID, 282 .iInterface = GS_DATA_STR_ID,
@@ -521,6 +433,8 @@ static const struct usb_descriptor_header *gs_acm_highspeed_function[] = {
521}; 433};
522 434
523 435
436/*-------------------------------------------------------------------------*/
437
524/* Module */ 438/* Module */
525MODULE_DESCRIPTION(GS_LONG_NAME); 439MODULE_DESCRIPTION(GS_LONG_NAME);
526MODULE_AUTHOR("Al Borchers"); 440MODULE_AUTHOR("Al Borchers");
@@ -531,84 +445,23 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
531MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); 445MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on");
532#endif 446#endif
533 447
448static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
534module_param(read_q_size, uint, S_IRUGO); 449module_param(read_q_size, uint, S_IRUGO);
535MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); 450MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32");
536 451
452static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
537module_param(write_q_size, uint, S_IRUGO); 453module_param(write_q_size, uint, S_IRUGO);
538MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); 454MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32");
539 455
456static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
540module_param(write_buf_size, uint, S_IRUGO); 457module_param(write_buf_size, uint, S_IRUGO);
541MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); 458MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192");
542 459
460static unsigned int use_acm = GS_DEFAULT_USE_ACM;
543module_param(use_acm, uint, S_IRUGO); 461module_param(use_acm, uint, S_IRUGO);
544MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); 462MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no");
545 463
546module_init(gs_module_init); 464/*-------------------------------------------------------------------------*/
547module_exit(gs_module_exit);
548
549/*
550* gs_module_init
551*
552* Register as a USB gadget driver and a tty driver.
553*/
554static int __init gs_module_init(void)
555{
556 int i;
557 int retval;
558
559 retval = usb_gadget_register_driver(&gs_gadget_driver);
560 if (retval) {
561 pr_err("gs_module_init: cannot register gadget driver, "
562 "ret=%d\n", retval);
563 return retval;
564 }
565
566 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
567 if (!gs_tty_driver)
568 return -ENOMEM;
569 gs_tty_driver->owner = THIS_MODULE;
570 gs_tty_driver->driver_name = GS_SHORT_NAME;
571 gs_tty_driver->name = "ttygs";
572 gs_tty_driver->major = GS_MAJOR;
573 gs_tty_driver->minor_start = GS_MINOR_START;
574 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
575 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
576 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
577 gs_tty_driver->init_termios = tty_std_termios;
578 gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
579 tty_set_operations(gs_tty_driver, &gs_tty_ops);
580
581 for (i=0; i < GS_NUM_PORTS; i++)
582 mutex_init(&gs_open_close_lock[i]);
583
584 retval = tty_register_driver(gs_tty_driver);
585 if (retval) {
586 usb_gadget_unregister_driver(&gs_gadget_driver);
587 put_tty_driver(gs_tty_driver);
588 pr_err("gs_module_init: cannot register tty driver, "
589 "ret=%d\n", retval);
590 return retval;
591 }
592
593 pr_info("gs_module_init: %s %s loaded\n",
594 GS_LONG_NAME, GS_VERSION_STR);
595 return 0;
596}
597
598/*
599* gs_module_exit
600*
601* Unregister as a tty driver and a USB gadget driver.
602*/
603static void __exit gs_module_exit(void)
604{
605 tty_unregister_driver(gs_tty_driver);
606 put_tty_driver(gs_tty_driver);
607 usb_gadget_unregister_driver(&gs_gadget_driver);
608
609 pr_info("gs_module_exit: %s %s unloaded\n",
610 GS_LONG_NAME, GS_VERSION_STR);
611}
612 465
613/* TTY Driver */ 466/* TTY Driver */
614 467
@@ -753,15 +606,15 @@ exit_unlock_dev:
753 * gs_close 606 * gs_close
754 */ 607 */
755 608
756#define GS_WRITE_FINISHED_EVENT_SAFELY(p) \ 609static int gs_write_finished_event_safely(struct gs_port *p)
757({ \ 610{
758 int cond; \ 611 int cond;
759 \ 612
760 spin_lock_irq(&(p)->port_lock); \ 613 spin_lock_irq(&(p)->port_lock);
761 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \ 614 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf);
762 spin_unlock_irq(&(p)->port_lock); \ 615 spin_unlock_irq(&(p)->port_lock);
763 cond; \ 616 return cond;
764}) 617}
765 618
766static void gs_close(struct tty_struct *tty, struct file *file) 619static void gs_close(struct tty_struct *tty, struct file *file)
767{ 620{
@@ -807,7 +660,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
807 if (gs_buf_data_avail(port->port_write_buf) > 0) { 660 if (gs_buf_data_avail(port->port_write_buf) > 0) {
808 spin_unlock_irq(&port->port_lock); 661 spin_unlock_irq(&port->port_lock);
809 wait_event_interruptible_timeout(port->port_write_wait, 662 wait_event_interruptible_timeout(port->port_write_wait,
810 GS_WRITE_FINISHED_EVENT_SAFELY(port), 663 gs_write_finished_event_safely(port),
811 GS_CLOSE_TIMEOUT * HZ); 664 GS_CLOSE_TIMEOUT * HZ);
812 spin_lock_irq(&port->port_lock); 665 spin_lock_irq(&port->port_lock);
813 } 666 }
@@ -1065,6 +918,23 @@ static void gs_set_termios(struct tty_struct *tty, struct ktermios *old)
1065{ 918{
1066} 919}
1067 920
921static const struct tty_operations gs_tty_ops = {
922 .open = gs_open,
923 .close = gs_close,
924 .write = gs_write,
925 .put_char = gs_put_char,
926 .flush_chars = gs_flush_chars,
927 .write_room = gs_write_room,
928 .ioctl = gs_ioctl,
929 .set_termios = gs_set_termios,
930 .throttle = gs_throttle,
931 .unthrottle = gs_unthrottle,
932 .break_ctl = gs_break,
933 .chars_in_buffer = gs_chars_in_buffer,
934};
935
936/*-------------------------------------------------------------------------*/
937
1068/* 938/*
1069* gs_send 939* gs_send
1070* 940*
@@ -1080,7 +950,6 @@ static int gs_send(struct gs_dev *dev)
1080 unsigned long flags; 950 unsigned long flags;
1081 struct usb_ep *ep; 951 struct usb_ep *ep;
1082 struct usb_request *req; 952 struct usb_request *req;
1083 struct gs_req_entry *req_entry;
1084 953
1085 if (dev == NULL) { 954 if (dev == NULL) {
1086 pr_err("gs_send: NULL device pointer\n"); 955 pr_err("gs_send: NULL device pointer\n");
@@ -1093,10 +962,8 @@ static int gs_send(struct gs_dev *dev)
1093 962
1094 while(!list_empty(&dev->dev_req_list)) { 963 while(!list_empty(&dev->dev_req_list)) {
1095 964
1096 req_entry = list_entry(dev->dev_req_list.next, 965 req = list_entry(dev->dev_req_list.next,
1097 struct gs_req_entry, re_entry); 966 struct usb_request, list);
1098
1099 req = req_entry->re_req;
1100 967
1101 len = gs_send_packet(dev, req->buf, ep->maxpacket); 968 len = gs_send_packet(dev, req->buf, ep->maxpacket);
1102 969
@@ -1106,7 +973,7 @@ static int gs_send(struct gs_dev *dev)
1106 *((unsigned char *)req->buf), 973 *((unsigned char *)req->buf),
1107 *((unsigned char *)req->buf+1), 974 *((unsigned char *)req->buf+1),
1108 *((unsigned char *)req->buf+2)); 975 *((unsigned char *)req->buf+2));
1109 list_del(&req_entry->re_entry); 976 list_del(&req->list);
1110 req->length = len; 977 req->length = len;
1111 spin_unlock_irqrestore(&dev->dev_lock, flags); 978 spin_unlock_irqrestore(&dev->dev_lock, flags);
1112 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 979 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) {
@@ -1289,7 +1156,6 @@ requeue:
1289static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) 1156static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1290{ 1157{
1291 struct gs_dev *dev = ep->driver_data; 1158 struct gs_dev *dev = ep->driver_data;
1292 struct gs_req_entry *gs_req = req->context;
1293 1159
1294 if (dev == NULL) { 1160 if (dev == NULL) {
1295 pr_err("gs_write_complete: NULL device pointer\n"); 1161 pr_err("gs_write_complete: NULL device pointer\n");
@@ -1300,13 +1166,8 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1300 case 0: 1166 case 0:
1301 /* normal completion */ 1167 /* normal completion */
1302requeue: 1168requeue:
1303 if (gs_req == NULL) {
1304 pr_err("gs_write_complete: NULL request pointer\n");
1305 return;
1306 }
1307
1308 spin_lock(&dev->dev_lock); 1169 spin_lock(&dev->dev_lock);
1309 list_add(&gs_req->re_entry, &dev->dev_req_list); 1170 list_add(&req->list, &dev->dev_req_list);
1310 spin_unlock(&dev->dev_lock); 1171 spin_unlock(&dev->dev_lock);
1311 1172
1312 gs_send(dev); 1173 gs_send(dev);
@@ -1328,9 +1189,39 @@ requeue:
1328 } 1189 }
1329} 1190}
1330 1191
1192/*-------------------------------------------------------------------------*/
1193
1331/* Gadget Driver */ 1194/* Gadget Driver */
1332 1195
1333/* 1196/*
1197 * gs_unbind
1198 *
1199 * Called on module unload. Frees the control request and device
1200 * structure.
1201 */
1202static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1203{
1204 struct gs_dev *dev = get_gadget_data(gadget);
1205
1206 gs_device = NULL;
1207
1208 /* read/write requests already freed, only control request remains */
1209 if (dev != NULL) {
1210 if (dev->dev_ctrl_req != NULL) {
1211 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1212 dev->dev_ctrl_req = NULL;
1213 }
1214 gs_reset_config(dev);
1215 gs_free_ports(dev);
1216 kfree(dev);
1217 set_gadget_data(gadget, NULL);
1218 }
1219
1220 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1221 GS_VERSION_STR);
1222}
1223
1224/*
1334 * gs_bind 1225 * gs_bind
1335 * 1226 *
1336 * Called on module load. Allocates and initializes the device 1227 * Called on module load. Allocates and initializes the device
@@ -1362,19 +1253,23 @@ static int __init gs_bind(struct usb_gadget *gadget)
1362 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); 1253 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099);
1363 } 1254 }
1364 1255
1256 dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL);
1257 if (dev == NULL)
1258 return -ENOMEM;
1259
1365 usb_ep_autoconfig_reset(gadget); 1260 usb_ep_autoconfig_reset(gadget);
1366 1261
1367 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); 1262 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
1368 if (!ep) 1263 if (!ep)
1369 goto autoconf_fail; 1264 goto autoconf_fail;
1370 EP_IN_NAME = ep->name; 1265 dev->dev_in_ep = ep;
1371 ep->driver_data = ep; /* claim the endpoint */ 1266 ep->driver_data = dev; /* claim the endpoint */
1372 1267
1373 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); 1268 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
1374 if (!ep) 1269 if (!ep)
1375 goto autoconf_fail; 1270 goto autoconf_fail;
1376 EP_OUT_NAME = ep->name; 1271 dev->dev_out_ep = ep;
1377 ep->driver_data = ep; /* claim the endpoint */ 1272 ep->driver_data = dev; /* claim the endpoint */
1378 1273
1379 if (use_acm) { 1274 if (use_acm) {
1380 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); 1275 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc);
@@ -1384,8 +1279,8 @@ static int __init gs_bind(struct usb_gadget *gadget)
1384 } 1279 }
1385 gs_device_desc.idProduct = __constant_cpu_to_le16( 1280 gs_device_desc.idProduct = __constant_cpu_to_le16(
1386 GS_CDC_PRODUCT_ID), 1281 GS_CDC_PRODUCT_ID),
1387 EP_NOTIFY_NAME = ep->name; 1282 dev->dev_notify_ep = ep;
1388 ep->driver_data = ep; /* claim the endpoint */ 1283 ep->driver_data = dev; /* claim the endpoint */
1389 } 1284 }
1390 1285
1391 gs_device_desc.bDeviceClass = use_acm 1286 gs_device_desc.bDeviceClass = use_acm
@@ -1415,9 +1310,7 @@ static int __init gs_bind(struct usb_gadget *gadget)
1415 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1310 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
1416 } 1311 }
1417 1312
1418 gs_device = dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); 1313 gs_device = dev;
1419 if (dev == NULL)
1420 return -ENOMEM;
1421 1314
1422 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1315 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s",
1423 init_utsname()->sysname, init_utsname()->release, 1316 init_utsname()->sysname, init_utsname()->release,
@@ -1441,8 +1334,6 @@ static int __init gs_bind(struct usb_gadget *gadget)
1441 gs_unbind(gadget); 1334 gs_unbind(gadget);
1442 return -ENOMEM; 1335 return -ENOMEM;
1443 } 1336 }
1444 dev->dev_ctrl_req->complete = gs_setup_complete;
1445
1446 gadget->ep0->driver_data = dev; 1337 gadget->ep0->driver_data = dev;
1447 1338
1448 pr_info("gs_bind: %s %s bound\n", 1339 pr_info("gs_bind: %s %s bound\n",
@@ -1451,99 +1342,11 @@ static int __init gs_bind(struct usb_gadget *gadget)
1451 return 0; 1342 return 0;
1452 1343
1453autoconf_fail: 1344autoconf_fail:
1345 kfree(dev);
1454 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); 1346 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name);
1455 return -ENODEV; 1347 return -ENODEV;
1456} 1348}
1457 1349
1458/*
1459 * gs_unbind
1460 *
1461 * Called on module unload. Frees the control request and device
1462 * structure.
1463 */
1464static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1465{
1466 struct gs_dev *dev = get_gadget_data(gadget);
1467
1468 gs_device = NULL;
1469
1470 /* read/write requests already freed, only control request remains */
1471 if (dev != NULL) {
1472 if (dev->dev_ctrl_req != NULL) {
1473 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1474 dev->dev_ctrl_req = NULL;
1475 }
1476 gs_free_ports(dev);
1477 if (dev->dev_notify_ep)
1478 usb_ep_disable(dev->dev_notify_ep);
1479 if (dev->dev_in_ep)
1480 usb_ep_disable(dev->dev_in_ep);
1481 if (dev->dev_out_ep)
1482 usb_ep_disable(dev->dev_out_ep);
1483 kfree(dev);
1484 set_gadget_data(gadget, NULL);
1485 }
1486
1487 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1488 GS_VERSION_STR);
1489}
1490
1491/*
1492 * gs_setup
1493 *
1494 * Implements all the control endpoint functionality that's not
1495 * handled in hardware or the hardware driver.
1496 *
1497 * Returns the size of the data sent to the host, or a negative
1498 * error number.
1499 */
1500static int gs_setup(struct usb_gadget *gadget,
1501 const struct usb_ctrlrequest *ctrl)
1502{
1503 int ret = -EOPNOTSUPP;
1504 struct gs_dev *dev = get_gadget_data(gadget);
1505 struct usb_request *req = dev->dev_ctrl_req;
1506 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1507 u16 wValue = le16_to_cpu(ctrl->wValue);
1508 u16 wLength = le16_to_cpu(ctrl->wLength);
1509
1510 req->complete = gs_setup_complete;
1511
1512 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1513 case USB_TYPE_STANDARD:
1514 ret = gs_setup_standard(gadget,ctrl);
1515 break;
1516
1517 case USB_TYPE_CLASS:
1518 ret = gs_setup_class(gadget,ctrl);
1519 break;
1520
1521 default:
1522 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1523 "value=%04x, index=%04x, length=%d\n",
1524 ctrl->bRequestType, ctrl->bRequest,
1525 wValue, wIndex, wLength);
1526 break;
1527 }
1528
1529 /* respond with data transfer before status phase? */
1530 if (ret >= 0) {
1531 req->length = ret;
1532 req->zero = ret < wLength
1533 && (ret % gadget->ep0->maxpacket) == 0;
1534 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1535 if (ret < 0) {
1536 pr_err("gs_setup: cannot queue response, ret=%d\n",
1537 ret);
1538 req->status = 0;
1539 gs_setup_complete(gadget->ep0, req);
1540 }
1541 }
1542
1543 /* device either stalls (ret < 0) or reports success */
1544 return ret;
1545}
1546
1547static int gs_setup_standard(struct usb_gadget *gadget, 1350static int gs_setup_standard(struct usb_gadget *gadget,
1548 const struct usb_ctrlrequest *ctrl) 1351 const struct usb_ctrlrequest *ctrl)
1549{ 1352{
@@ -1673,6 +1476,42 @@ set_interface_done:
1673 return ret; 1476 return ret;
1674} 1477}
1675 1478
1479static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
1480 struct usb_request *req)
1481{
1482 struct gs_dev *dev = ep->driver_data;
1483 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */
1484
1485 switch (req->status) {
1486 case 0:
1487 /* normal completion */
1488 if (req->actual != sizeof(port->port_line_coding))
1489 usb_ep_set_halt(ep);
1490 else if (port) {
1491 struct usb_cdc_line_coding *value = req->buf;
1492
1493 /* REVISIT: we currently just remember this data.
1494 * If we change that, (a) validate it first, then
1495 * (b) update whatever hardware needs updating.
1496 */
1497 spin_lock(&port->port_lock);
1498 port->port_line_coding = *value;
1499 spin_unlock(&port->port_lock);
1500 }
1501 break;
1502
1503 case -ESHUTDOWN:
1504 /* disconnect */
1505 gs_free_req(ep, req);
1506 break;
1507
1508 default:
1509 /* unexpected */
1510 break;
1511 }
1512 return;
1513}
1514
1676static int gs_setup_class(struct usb_gadget *gadget, 1515static int gs_setup_class(struct usb_gadget *gadget,
1677 const struct usb_ctrlrequest *ctrl) 1516 const struct usb_ctrlrequest *ctrl)
1678{ 1517{
@@ -1734,52 +1573,72 @@ static int gs_setup_class(struct usb_gadget *gadget,
1734 return ret; 1573 return ret;
1735} 1574}
1736 1575
1737static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 1576/*
1738 struct usb_request *req) 1577 * gs_setup_complete
1578 */
1579static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req)
1739{ 1580{
1740 struct gs_dev *dev = ep->driver_data; 1581 if (req->status || req->actual != req->length) {
1741 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ 1582 pr_err("gs_setup_complete: status error, status=%d, "
1583 "actual=%d, length=%d\n",
1584 req->status, req->actual, req->length);
1585 }
1586}
1742 1587
1743 switch (req->status) { 1588/*
1744 case 0: 1589 * gs_setup
1745 /* normal completion */ 1590 *
1746 if (req->actual != sizeof(port->port_line_coding)) 1591 * Implements all the control endpoint functionality that's not
1747 usb_ep_set_halt(ep); 1592 * handled in hardware or the hardware driver.
1748 else if (port) { 1593 *
1749 struct usb_cdc_line_coding *value = req->buf; 1594 * Returns the size of the data sent to the host, or a negative
1595 * error number.
1596 */
1597static int gs_setup(struct usb_gadget *gadget,
1598 const struct usb_ctrlrequest *ctrl)
1599{
1600 int ret = -EOPNOTSUPP;
1601 struct gs_dev *dev = get_gadget_data(gadget);
1602 struct usb_request *req = dev->dev_ctrl_req;
1603 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1604 u16 wValue = le16_to_cpu(ctrl->wValue);
1605 u16 wLength = le16_to_cpu(ctrl->wLength);
1750 1606
1751 /* REVISIT: we currently just remember this data. 1607 req->complete = gs_setup_complete;
1752 * If we change that, (a) validate it first, then 1608
1753 * (b) update whatever hardware needs updating. 1609 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1754 */ 1610 case USB_TYPE_STANDARD:
1755 spin_lock(&port->port_lock); 1611 ret = gs_setup_standard(gadget, ctrl);
1756 port->port_line_coding = *value;
1757 spin_unlock(&port->port_lock);
1758 }
1759 break; 1612 break;
1760 1613
1761 case -ESHUTDOWN: 1614 case USB_TYPE_CLASS:
1762 /* disconnect */ 1615 ret = gs_setup_class(gadget, ctrl);
1763 gs_free_req(ep, req);
1764 break; 1616 break;
1765 1617
1766 default: 1618 default:
1767 /* unexpected */ 1619 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1620 "value=%04x, index=%04x, length=%d\n",
1621 ctrl->bRequestType, ctrl->bRequest,
1622 wValue, wIndex, wLength);
1768 break; 1623 break;
1769 } 1624 }
1770 return;
1771}
1772 1625
1773/* 1626 /* respond with data transfer before status phase? */
1774 * gs_setup_complete 1627 if (ret >= 0) {
1775 */ 1628 req->length = ret;
1776static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) 1629 req->zero = ret < wLength
1777{ 1630 && (ret % gadget->ep0->maxpacket) == 0;
1778 if (req->status || req->actual != req->length) { 1631 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1779 pr_err("gs_setup_complete: status error, status=%d, " 1632 if (ret < 0) {
1780 "actual=%d, length=%d\n", 1633 pr_err("gs_setup: cannot queue response, ret=%d\n",
1781 req->status, req->actual, req->length); 1634 ret);
1635 req->status = 0;
1636 gs_setup_complete(gadget->ep0, req);
1637 }
1782 } 1638 }
1639
1640 /* device either stalls (ret < 0) or reports success */
1641 return ret;
1783} 1642}
1784 1643
1785/* 1644/*
@@ -1811,6 +1670,23 @@ static void gs_disconnect(struct usb_gadget *gadget)
1811 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1670 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME);
1812} 1671}
1813 1672
1673static struct usb_gadget_driver gs_gadget_driver = {
1674#ifdef CONFIG_USB_GADGET_DUALSPEED
1675 .speed = USB_SPEED_HIGH,
1676#else
1677 .speed = USB_SPEED_FULL,
1678#endif /* CONFIG_USB_GADGET_DUALSPEED */
1679 .function = GS_LONG_NAME,
1680 .bind = gs_bind,
1681 .unbind = gs_unbind,
1682 .setup = gs_setup,
1683 .disconnect = gs_disconnect,
1684 .driver = {
1685 .name = GS_SHORT_NAME,
1686 .owner = THIS_MODULE,
1687 },
1688};
1689
1814/* 1690/*
1815 * gs_set_config 1691 * gs_set_config
1816 * 1692 *
@@ -1826,9 +1702,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1826 int ret = 0; 1702 int ret = 0;
1827 struct usb_gadget *gadget = dev->dev_gadget; 1703 struct usb_gadget *gadget = dev->dev_gadget;
1828 struct usb_ep *ep; 1704 struct usb_ep *ep;
1829 struct usb_endpoint_descriptor *ep_desc; 1705 struct usb_endpoint_descriptor *out, *in, *notify;
1830 struct usb_request *req; 1706 struct usb_request *req;
1831 struct gs_req_entry *req_entry;
1832 1707
1833 if (dev == NULL) { 1708 if (dev == NULL) {
1834 pr_err("gs_set_config: NULL device pointer\n"); 1709 pr_err("gs_set_config: NULL device pointer\n");
@@ -1846,86 +1721,62 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1846 case GS_BULK_CONFIG_ID: 1721 case GS_BULK_CONFIG_ID:
1847 if (use_acm) 1722 if (use_acm)
1848 return -EINVAL; 1723 return -EINVAL;
1849 /* device specific optimizations */
1850 if (gadget_is_net2280(gadget))
1851 net2280_set_fifo_mode(gadget, 1);
1852 break; 1724 break;
1853 case GS_ACM_CONFIG_ID: 1725 case GS_ACM_CONFIG_ID:
1854 if (!use_acm) 1726 if (!use_acm)
1855 return -EINVAL; 1727 return -EINVAL;
1856 /* device specific optimizations */
1857 if (gadget_is_net2280(gadget))
1858 net2280_set_fifo_mode(gadget, 1);
1859 break; 1728 break;
1860 default: 1729 default:
1861 return -EINVAL; 1730 return -EINVAL;
1862 } 1731 }
1863 1732
1864 dev->dev_config = config; 1733 in = choose_ep_desc(gadget,
1865 1734 &gs_highspeed_in_desc,
1866 gadget_for_each_ep(ep, gadget) { 1735 &gs_fullspeed_in_desc);
1867 1736 out = choose_ep_desc(gadget,
1868 if (EP_NOTIFY_NAME 1737 &gs_highspeed_out_desc,
1869 && strcmp(ep->name, EP_NOTIFY_NAME) == 0) { 1738 &gs_fullspeed_out_desc);
1870 ep_desc = choose_ep_desc(gadget, 1739 notify = dev->dev_notify_ep
1740 ? choose_ep_desc(gadget,
1871 &gs_highspeed_notify_desc, 1741 &gs_highspeed_notify_desc,
1872 &gs_fullspeed_notify_desc); 1742 &gs_fullspeed_notify_desc)
1873 ret = usb_ep_enable(ep,ep_desc); 1743 : NULL;
1874 if (ret == 0) {
1875 ep->driver_data = dev;
1876 dev->dev_notify_ep = ep;
1877 dev->dev_notify_ep_desc = ep_desc;
1878 } else {
1879 pr_err("gs_set_config: cannot enable NOTIFY "
1880 "endpoint %s, ret=%d\n",
1881 ep->name, ret);
1882 goto exit_reset_config;
1883 }
1884 }
1885
1886 else if (strcmp(ep->name, EP_IN_NAME) == 0) {
1887 ep_desc = choose_ep_desc(gadget,
1888 &gs_highspeed_in_desc,
1889 &gs_fullspeed_in_desc);
1890 ret = usb_ep_enable(ep,ep_desc);
1891 if (ret == 0) {
1892 ep->driver_data = dev;
1893 dev->dev_in_ep = ep;
1894 dev->dev_in_ep_desc = ep_desc;
1895 } else {
1896 pr_err("gs_set_config: cannot enable IN "
1897 "endpoint %s, ret=%d\n",
1898 ep->name, ret);
1899 goto exit_reset_config;
1900 }
1901 }
1902 1744
1903 else if (strcmp(ep->name, EP_OUT_NAME) == 0) { 1745 ret = usb_ep_enable(dev->dev_in_ep, in);
1904 ep_desc = choose_ep_desc(gadget, 1746 if (ret == 0) {
1905 &gs_highspeed_out_desc, 1747 dev->dev_in_ep_desc = in;
1906 &gs_fullspeed_out_desc); 1748 } else {
1907 ret = usb_ep_enable(ep,ep_desc); 1749 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1908 if (ret == 0) { 1750 __func__, "IN", dev->dev_in_ep->name, ret);
1909 ep->driver_data = dev; 1751 return ret;
1910 dev->dev_out_ep = ep; 1752 }
1911 dev->dev_out_ep_desc = ep_desc;
1912 } else {
1913 pr_err("gs_set_config: cannot enable OUT "
1914 "endpoint %s, ret=%d\n",
1915 ep->name, ret);
1916 goto exit_reset_config;
1917 }
1918 }
1919 1753
1754 ret = usb_ep_enable(dev->dev_out_ep, out);
1755 if (ret == 0) {
1756 dev->dev_out_ep_desc = out;
1757 } else {
1758 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1759 __func__, "OUT", dev->dev_out_ep->name, ret);
1760fail0:
1761 usb_ep_disable(dev->dev_in_ep);
1762 return ret;
1920 } 1763 }
1921 1764
1922 if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL 1765 if (notify) {
1923 || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { 1766 ret = usb_ep_enable(dev->dev_notify_ep, notify);
1924 pr_err("gs_set_config: cannot find endpoints\n"); 1767 if (ret == 0) {
1925 ret = -ENODEV; 1768 dev->dev_notify_ep_desc = notify;
1926 goto exit_reset_config; 1769 } else {
1770 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1771 __func__, "NOTIFY",
1772 dev->dev_notify_ep->name, ret);
1773 usb_ep_disable(dev->dev_out_ep);
1774 goto fail0;
1775 }
1927 } 1776 }
1928 1777
1778 dev->dev_config = config;
1779
1929 /* allocate and queue read requests */ 1780 /* allocate and queue read requests */
1930 ep = dev->dev_out_ep; 1781 ep = dev->dev_out_ep;
1931 for (i=0; i<read_q_size && ret == 0; i++) { 1782 for (i=0; i<read_q_size && ret == 0; i++) {
@@ -1946,9 +1797,10 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1946 /* allocate write requests, and put on free list */ 1797 /* allocate write requests, and put on free list */
1947 ep = dev->dev_in_ep; 1798 ep = dev->dev_in_ep;
1948 for (i=0; i<write_q_size; i++) { 1799 for (i=0; i<write_q_size; i++) {
1949 if ((req_entry=gs_alloc_req_entry(ep, ep->maxpacket, GFP_ATOMIC))) { 1800 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
1950 req_entry->re_req->complete = gs_write_complete; 1801 if (req) {
1951 list_add(&req_entry->re_entry, &dev->dev_req_list); 1802 req->complete = gs_write_complete;
1803 list_add(&req->list, &dev->dev_req_list);
1952 } else { 1804 } else {
1953 pr_err("gs_set_config: cannot allocate " 1805 pr_err("gs_set_config: cannot allocate "
1954 "write requests\n"); 1806 "write requests\n");
@@ -1986,7 +1838,7 @@ exit_reset_config:
1986 */ 1838 */
1987static void gs_reset_config(struct gs_dev *dev) 1839static void gs_reset_config(struct gs_dev *dev)
1988{ 1840{
1989 struct gs_req_entry *req_entry; 1841 struct usb_request *req;
1990 1842
1991 if (dev == NULL) { 1843 if (dev == NULL) {
1992 pr_err("gs_reset_config: NULL device pointer\n"); 1844 pr_err("gs_reset_config: NULL device pointer\n");
@@ -2000,26 +1852,18 @@ static void gs_reset_config(struct gs_dev *dev)
2000 1852
2001 /* free write requests on the free list */ 1853 /* free write requests on the free list */
2002 while(!list_empty(&dev->dev_req_list)) { 1854 while(!list_empty(&dev->dev_req_list)) {
2003 req_entry = list_entry(dev->dev_req_list.next, 1855 req = list_entry(dev->dev_req_list.next,
2004 struct gs_req_entry, re_entry); 1856 struct usb_request, list);
2005 list_del(&req_entry->re_entry); 1857 list_del(&req->list);
2006 gs_free_req_entry(dev->dev_in_ep, req_entry); 1858 gs_free_req(dev->dev_in_ep, req);
2007 } 1859 }
2008 1860
2009 /* disable endpoints, forcing completion of pending i/o; */ 1861 /* disable endpoints, forcing completion of pending i/o; */
2010 /* completion handlers free their requests in this case */ 1862 /* completion handlers free their requests in this case */
2011 if (dev->dev_notify_ep) { 1863 if (dev->dev_notify_ep)
2012 usb_ep_disable(dev->dev_notify_ep); 1864 usb_ep_disable(dev->dev_notify_ep);
2013 dev->dev_notify_ep = NULL; 1865 usb_ep_disable(dev->dev_in_ep);
2014 } 1866 usb_ep_disable(dev->dev_out_ep);
2015 if (dev->dev_in_ep) {
2016 usb_ep_disable(dev->dev_in_ep);
2017 dev->dev_in_ep = NULL;
2018 }
2019 if (dev->dev_out_ep) {
2020 usb_ep_disable(dev->dev_out_ep);
2021 dev->dev_out_ep = NULL;
2022 }
2023} 1867}
2024 1868
2025/* 1869/*
@@ -2113,46 +1957,6 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req)
2113} 1957}
2114 1958
2115/* 1959/*
2116 * gs_alloc_req_entry
2117 *
2118 * Allocates a request and its buffer, using the given
2119 * endpoint, buffer len, and kmalloc flags.
2120 */
2121static struct gs_req_entry *
2122gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
2123{
2124 struct gs_req_entry *req;
2125
2126 req = kmalloc(sizeof(struct gs_req_entry), kmalloc_flags);
2127 if (req == NULL)
2128 return NULL;
2129
2130 req->re_req = gs_alloc_req(ep, len, kmalloc_flags);
2131 if (req->re_req == NULL) {
2132 kfree(req);
2133 return NULL;
2134 }
2135
2136 req->re_req->context = req;
2137
2138 return req;
2139}
2140
2141/*
2142 * gs_free_req_entry
2143 *
2144 * Frees a request and its buffer.
2145 */
2146static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req)
2147{
2148 if (ep != NULL && req != NULL) {
2149 if (req->re_req != NULL)
2150 gs_free_req(ep, req->re_req);
2151 kfree(req);
2152 }
2153}
2154
2155/*
2156 * gs_alloc_ports 1960 * gs_alloc_ports
2157 * 1961 *
2158 * Allocate all ports and set the gs_dev struct to point to them. 1962 * Allocate all ports and set the gs_dev struct to point to them.
@@ -2233,6 +2037,8 @@ static void gs_free_ports(struct gs_dev *dev)
2233 } 2037 }
2234} 2038}
2235 2039
2040/*-------------------------------------------------------------------------*/
2041
2236/* Circular Buffer */ 2042/* Circular Buffer */
2237 2043
2238/* 2044/*
@@ -2393,3 +2199,77 @@ gs_buf_get(struct gs_buf *gb, char *buf, unsigned int count)
2393 2199
2394 return count; 2200 return count;
2395} 2201}
2202
2203/*-------------------------------------------------------------------------*/
2204
2205static struct tty_driver *gs_tty_driver;
2206
2207/*
2208 * gs_module_init
2209 *
2210 * Register as a USB gadget driver and a tty driver.
2211 */
2212static int __init gs_module_init(void)
2213{
2214 int i;
2215 int retval;
2216
2217 retval = usb_gadget_register_driver(&gs_gadget_driver);
2218 if (retval) {
2219 pr_err("gs_module_init: cannot register gadget driver, "
2220 "ret=%d\n", retval);
2221 return retval;
2222 }
2223
2224 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
2225 if (!gs_tty_driver)
2226 return -ENOMEM;
2227 gs_tty_driver->owner = THIS_MODULE;
2228 gs_tty_driver->driver_name = GS_SHORT_NAME;
2229 gs_tty_driver->name = "ttygs";
2230 gs_tty_driver->major = GS_MAJOR;
2231 gs_tty_driver->minor_start = GS_MINOR_START;
2232 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
2233 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
2234 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
2235 gs_tty_driver->init_termios = tty_std_termios;
2236 /* must match GS_DEFAULT_DTE_RATE and friends */
2237 gs_tty_driver->init_termios.c_cflag =
2238 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2239 gs_tty_driver->init_termios.c_ispeed = GS_DEFAULT_DTE_RATE;
2240 gs_tty_driver->init_termios.c_ospeed = GS_DEFAULT_DTE_RATE;
2241 tty_set_operations(gs_tty_driver, &gs_tty_ops);
2242
2243 for (i = 0; i < GS_NUM_PORTS; i++)
2244 mutex_init(&gs_open_close_lock[i]);
2245
2246 retval = tty_register_driver(gs_tty_driver);
2247 if (retval) {
2248 usb_gadget_unregister_driver(&gs_gadget_driver);
2249 put_tty_driver(gs_tty_driver);
2250 pr_err("gs_module_init: cannot register tty driver, "
2251 "ret=%d\n", retval);
2252 return retval;
2253 }
2254
2255 pr_info("gs_module_init: %s %s loaded\n",
2256 GS_LONG_NAME, GS_VERSION_STR);
2257 return 0;
2258}
2259module_init(gs_module_init);
2260
2261/*
2262 * gs_module_exit
2263 *
2264 * Unregister as a tty driver and a USB gadget driver.
2265 */
2266static void __exit gs_module_exit(void)
2267{
2268 tty_unregister_driver(gs_tty_driver);
2269 put_tty_driver(gs_tty_driver);
2270 usb_gadget_unregister_driver(&gs_gadget_driver);
2271
2272 pr_info("gs_module_exit: %s %s unloaded\n",
2273 GS_LONG_NAME, GS_VERSION_STR);
2274}
2275module_exit(gs_module_exit);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1ef6df395e0c..228797e54f9c 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -300,8 +300,8 @@ config USB_R8A66597_HCD
300 module will be called r8a66597-hcd. 300 module will be called r8a66597-hcd.
301 301
302config SUPERH_ON_CHIP_R8A66597 302config SUPERH_ON_CHIP_R8A66597
303 boolean "Enable SuperH on-chip USB like the R8A66597" 303 boolean "Enable SuperH on-chip R8A66597 USB"
304 depends on USB_R8A66597_HCD && CPU_SUBTYPE_SH7366 304 depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723)
305 help 305 help
306 Renesas SuperH processor has USB like the R8A66597. 306 This driver enables support for the on-chip R8A66597 in the
307 This driver supported processor is SH7366. 307 SH7366 and SH7723 processors.
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 8b5f991e949c..08a4335401a9 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -223,6 +223,7 @@ static const struct hc_driver ehci_au1xxx_hc_driver = {
223 .bus_suspend = ehci_bus_suspend, 223 .bus_suspend = ehci_bus_suspend,
224 .bus_resume = ehci_bus_resume, 224 .bus_resume = ehci_bus_resume,
225 .relinquish_port = ehci_relinquish_port, 225 .relinquish_port = ehci_relinquish_port,
226 .port_handed_over = ehci_port_handed_over,
226}; 227};
227 228
228/*-------------------------------------------------------------------------*/ 229/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6d9bed6c1f48..7370d6187c64 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -269,7 +269,7 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
269 if (retval) 269 if (retval)
270 return retval; 270 return retval;
271 271
272 ehci->is_tdi_rh_tt = 1; 272 hcd->has_tt = 1;
273 273
274 ehci->sbrn = 0x20; 274 ehci->sbrn = 0x20;
275 275
@@ -295,10 +295,6 @@ static const struct hc_driver ehci_fsl_hc_driver = {
295 */ 295 */
296 .reset = ehci_fsl_setup, 296 .reset = ehci_fsl_setup,
297 .start = ehci_run, 297 .start = ehci_run,
298#ifdef CONFIG_PM
299 .suspend = ehci_bus_suspend,
300 .resume = ehci_bus_resume,
301#endif
302 .stop = ehci_stop, 298 .stop = ehci_stop,
303 .shutdown = ehci_shutdown, 299 .shutdown = ehci_shutdown,
304 300
@@ -322,6 +318,7 @@ static const struct hc_driver ehci_fsl_hc_driver = {
322 .bus_suspend = ehci_bus_suspend, 318 .bus_suspend = ehci_bus_suspend,
323 .bus_resume = ehci_bus_resume, 319 .bus_resume = ehci_bus_resume,
324 .relinquish_port = ehci_relinquish_port, 320 .relinquish_port = ehci_relinquish_port,
321 .port_handed_over = ehci_port_handed_over,
325}; 322};
326 323
327static int ehci_fsl_drv_probe(struct platform_device *pdev) 324static int ehci_fsl_drv_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 382587c4457c..740835bb8575 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -609,7 +609,7 @@ static int ehci_hub_control (
609 } 609 }
610 break; 610 break;
611 case USB_PORT_FEAT_C_SUSPEND: 611 case USB_PORT_FEAT_C_SUSPEND:
612 /* we auto-clear this feature */ 612 clear_bit(wIndex, &ehci->port_c_suspend);
613 break; 613 break;
614 case USB_PORT_FEAT_POWER: 614 case USB_PORT_FEAT_POWER:
615 if (HCS_PPC (ehci->hcs_params)) 615 if (HCS_PPC (ehci->hcs_params))
@@ -688,7 +688,7 @@ static int ehci_hub_control (
688 /* resume completed? */ 688 /* resume completed? */
689 else if (time_after_eq(jiffies, 689 else if (time_after_eq(jiffies,
690 ehci->reset_done[wIndex])) { 690 ehci->reset_done[wIndex])) {
691 status |= 1 << USB_PORT_FEAT_C_SUSPEND; 691 set_bit(wIndex, &ehci->port_c_suspend);
692 ehci->reset_done[wIndex] = 0; 692 ehci->reset_done[wIndex] = 0;
693 693
694 /* stop resume signaling */ 694 /* stop resume signaling */
@@ -765,6 +765,8 @@ static int ehci_hub_control (
765 status |= 1 << USB_PORT_FEAT_RESET; 765 status |= 1 << USB_PORT_FEAT_RESET;
766 if (temp & PORT_POWER) 766 if (temp & PORT_POWER)
767 status |= 1 << USB_PORT_FEAT_POWER; 767 status |= 1 << USB_PORT_FEAT_POWER;
768 if (test_bit(wIndex, &ehci->port_c_suspend))
769 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
768 770
769#ifndef VERBOSE_DEBUG 771#ifndef VERBOSE_DEBUG
770 if (status & ~0xffff) /* only if wPortChange is interesting */ 772 if (status & ~0xffff) /* only if wPortChange is interesting */
@@ -875,3 +877,13 @@ static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum)
875 set_owner(ehci, --portnum, PORT_OWNER); 877 set_owner(ehci, --portnum, PORT_OWNER);
876} 878}
877 879
880static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum)
881{
882 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
883 u32 __iomem *reg;
884
885 if (ehci_is_TDI(ehci))
886 return 0;
887 reg = &ehci->regs->port_status[portnum - 1];
888 return ehci_readl(ehci, reg) & PORT_OWNER;
889}
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index 601c8795a854..9d042f220097 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -26,7 +26,7 @@ static int ixp4xx_ehci_init(struct usb_hcd *hcd)
26 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); 26 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
27 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 27 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
28 28
29 ehci->is_tdi_rh_tt = 1; 29 hcd->has_tt = 1;
30 ehci_reset(ehci); 30 ehci_reset(ehci);
31 31
32 retval = ehci_init(hcd); 32 retval = ehci_init(hcd);
@@ -58,6 +58,8 @@ static const struct hc_driver ixp4xx_ehci_hc_driver = {
58 .bus_suspend = ehci_bus_suspend, 58 .bus_suspend = ehci_bus_suspend,
59 .bus_resume = ehci_bus_resume, 59 .bus_resume = ehci_bus_resume,
60#endif 60#endif
61 .relinquish_port = ehci_relinquish_port,
62 .port_handed_over = ehci_port_handed_over,
61}; 63};
62 64
63static int ixp4xx_ehci_probe(struct platform_device *pdev) 65static int ixp4xx_ehci_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index d187d0313742..ab625f0ba1d9 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -115,6 +115,8 @@ static int ehci_orion_setup(struct usb_hcd *hcd)
115 if (retval) 115 if (retval)
116 return retval; 116 return retval;
117 117
118 hcd->has_tt = 1;
119
118 ehci_reset(ehci); 120 ehci_reset(ehci);
119 ehci_port_power(ehci, 0); 121 ehci_port_power(ehci, 0);
120 122
@@ -137,10 +139,6 @@ static const struct hc_driver ehci_orion_hc_driver = {
137 */ 139 */
138 .reset = ehci_orion_setup, 140 .reset = ehci_orion_setup,
139 .start = ehci_run, 141 .start = ehci_run,
140#ifdef CONFIG_PM
141 .suspend = ehci_bus_suspend,
142 .resume = ehci_bus_resume,
143#endif
144 .stop = ehci_stop, 142 .stop = ehci_stop,
145 .shutdown = ehci_shutdown, 143 .shutdown = ehci_shutdown,
146 144
@@ -163,6 +161,8 @@ static const struct hc_driver ehci_orion_hc_driver = {
163 .hub_control = ehci_hub_control, 161 .hub_control = ehci_hub_control,
164 .bus_suspend = ehci_bus_suspend, 162 .bus_suspend = ehci_bus_suspend,
165 .bus_resume = ehci_bus_resume, 163 .bus_resume = ehci_bus_resume,
164 .relinquish_port = ehci_relinquish_port,
165 .port_handed_over = ehci_port_handed_over,
166}; 166};
167 167
168static void __init 168static void __init
@@ -248,7 +248,7 @@ static int __init ehci_orion_drv_probe(struct platform_device *pdev)
248 ehci->regs = hcd->regs + 0x100 + 248 ehci->regs = hcd->regs + 0x100 +
249 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); 249 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
250 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 250 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
251 ehci->is_tdi_rh_tt = 1; 251 hcd->has_tt = 1;
252 ehci->sbrn = 0x20; 252 ehci->sbrn = 0x20;
253 253
254 /* 254 /*
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 5bb7f6bb13f3..c46a58f9181d 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -129,7 +129,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
129 switch (pdev->vendor) { 129 switch (pdev->vendor) {
130 case PCI_VENDOR_ID_TDI: 130 case PCI_VENDOR_ID_TDI:
131 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 131 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
132 ehci->is_tdi_rh_tt = 1;
133 hcd->has_tt = 1; 132 hcd->has_tt = 1;
134 tdi_reset(ehci); 133 tdi_reset(ehci);
135 } 134 }
@@ -379,7 +378,8 @@ static const struct hc_driver ehci_pci_hc_driver = {
379 .hub_control = ehci_hub_control, 378 .hub_control = ehci_hub_control,
380 .bus_suspend = ehci_bus_suspend, 379 .bus_suspend = ehci_bus_suspend,
381 .bus_resume = ehci_bus_resume, 380 .bus_resume = ehci_bus_resume,
382 .relinquish_port = ehci_relinquish_port, 381 .relinquish_port = ehci_relinquish_port,
382 .port_handed_over = ehci_port_handed_over,
383}; 383};
384 384
385/*-------------------------------------------------------------------------*/ 385/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index ee305b1f99ff..b018deed2e8f 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -76,6 +76,8 @@ static const struct hc_driver ehci_ppc_of_hc_driver = {
76 .bus_suspend = ehci_bus_suspend, 76 .bus_suspend = ehci_bus_suspend,
77 .bus_resume = ehci_bus_resume, 77 .bus_resume = ehci_bus_resume,
78#endif 78#endif
79 .relinquish_port = ehci_relinquish_port,
80 .port_handed_over = ehci_port_handed_over,
79}; 81};
80 82
81 83
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c
index 6c76036783a1..529590eb4037 100644
--- a/drivers/usb/host/ehci-ppc-soc.c
+++ b/drivers/usb/host/ehci-ppc-soc.c
@@ -163,6 +163,7 @@ static const struct hc_driver ehci_ppc_soc_hc_driver = {
163 .bus_suspend = ehci_bus_suspend, 163 .bus_suspend = ehci_bus_suspend,
164 .bus_resume = ehci_bus_resume, 164 .bus_resume = ehci_bus_resume,
165 .relinquish_port = ehci_relinquish_port, 165 .relinquish_port = ehci_relinquish_port,
166 .port_handed_over = ehci_port_handed_over,
166}; 167};
167 168
168static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) 169static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 69782221bcf3..37e6abeb794c 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -73,6 +73,7 @@ static const struct hc_driver ps3_ehci_hc_driver = {
73 .bus_resume = ehci_bus_resume, 73 .bus_resume = ehci_bus_resume,
74#endif 74#endif
75 .relinquish_port = ehci_relinquish_port, 75 .relinquish_port = ehci_relinquish_port,
76 .port_handed_over = ehci_port_handed_over,
76}; 77};
77 78
78static int ps3_ehci_probe(struct ps3_system_bus_device *dev) 79static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index be575e46eac3..b7853c8bac0f 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1349,18 +1349,27 @@ iso_stream_schedule (
1349 /* when's the last uframe this urb could start? */ 1349 /* when's the last uframe this urb could start? */
1350 max = now + mod; 1350 max = now + mod;
1351 1351
1352 /* typical case: reuse current schedule. stream is still active, 1352 /* Typical case: reuse current schedule, stream is still active.
1353 * and no gaps from host falling behind (irq delays etc) 1353 * Hopefully there are no gaps from the host falling behind
1354 * (irq delays etc), but if there are we'll take the next
1355 * slot in the schedule, implicitly assuming URB_ISO_ASAP.
1354 */ 1356 */
1355 if (likely (!list_empty (&stream->td_list))) { 1357 if (likely (!list_empty (&stream->td_list))) {
1356 start = stream->next_uframe; 1358 start = stream->next_uframe;
1357 if (start < now) 1359 if (start < now)
1358 start += mod; 1360 start += mod;
1359 if (likely ((start + sched->span) < max)) 1361
1360 goto ready; 1362 /* Fell behind (by up to twice the slop amount)? */
1361 /* else fell behind; someday, try to reschedule */ 1363 if (start >= max - 2 * 8 * SCHEDULE_SLOP)
1362 status = -EL2NSYNC; 1364 start += stream->interval * DIV_ROUND_UP(
1363 goto fail; 1365 max - start, stream->interval) - mod;
1366
1367 /* Tried to schedule too far into the future? */
1368 if (unlikely((start + sched->span) >= max)) {
1369 status = -EFBIG;
1370 goto fail;
1371 }
1372 goto ready;
1364 } 1373 }
1365 1374
1366 /* need to schedule; when's the next (u)frame we could start? 1375 /* need to schedule; when's the next (u)frame we could start?
@@ -1613,6 +1622,9 @@ itd_complete (
1613 } else if (likely ((t & EHCI_ISOC_ACTIVE) == 0)) { 1622 } else if (likely ((t & EHCI_ISOC_ACTIVE) == 0)) {
1614 desc->status = 0; 1623 desc->status = 0;
1615 desc->actual_length = EHCI_ITD_LENGTH (t); 1624 desc->actual_length = EHCI_ITD_LENGTH (t);
1625 } else {
1626 /* URB was too late */
1627 desc->status = -EXDEV;
1616 } 1628 }
1617 } 1629 }
1618 1630
@@ -2095,7 +2107,7 @@ done:
2095static void 2107static void
2096scan_periodic (struct ehci_hcd *ehci) 2108scan_periodic (struct ehci_hcd *ehci)
2097{ 2109{
2098 unsigned frame, clock, now_uframe, mod; 2110 unsigned now_uframe, frame, clock, clock_frame, mod;
2099 unsigned modified; 2111 unsigned modified;
2100 2112
2101 mod = ehci->periodic_size << 3; 2113 mod = ehci->periodic_size << 3;
@@ -2111,6 +2123,7 @@ scan_periodic (struct ehci_hcd *ehci)
2111 else 2123 else
2112 clock = now_uframe + mod - 1; 2124 clock = now_uframe + mod - 1;
2113 clock %= mod; 2125 clock %= mod;
2126 clock_frame = clock >> 3;
2114 2127
2115 for (;;) { 2128 for (;;) {
2116 union ehci_shadow q, *q_p; 2129 union ehci_shadow q, *q_p;
@@ -2157,22 +2170,26 @@ restart:
2157 case Q_TYPE_ITD: 2170 case Q_TYPE_ITD:
2158 /* If this ITD is still active, leave it for 2171 /* If this ITD is still active, leave it for
2159 * later processing ... check the next entry. 2172 * later processing ... check the next entry.
2173 * No need to check for activity unless the
2174 * frame is current.
2160 */ 2175 */
2161 rmb (); 2176 if (frame == clock_frame && live) {
2162 for (uf = 0; uf < 8 && live; uf++) { 2177 rmb();
2163 if (0 == (q.itd->hw_transaction [uf] 2178 for (uf = 0; uf < 8; uf++) {
2164 & ITD_ACTIVE(ehci))) 2179 if (q.itd->hw_transaction[uf] &
2165 continue; 2180 ITD_ACTIVE(ehci))
2166 incomplete = true; 2181 break;
2167 q_p = &q.itd->itd_next; 2182 }
2168 hw_p = &q.itd->hw_next; 2183 if (uf < 8) {
2169 type = Q_NEXT_TYPE(ehci, 2184 incomplete = true;
2185 q_p = &q.itd->itd_next;
2186 hw_p = &q.itd->hw_next;
2187 type = Q_NEXT_TYPE(ehci,
2170 q.itd->hw_next); 2188 q.itd->hw_next);
2171 q = *q_p; 2189 q = *q_p;
2172 break; 2190 break;
2191 }
2173 } 2192 }
2174 if (uf < 8 && live)
2175 break;
2176 2193
2177 /* Take finished ITDs out of the schedule 2194 /* Take finished ITDs out of the schedule
2178 * and process them: recycle, maybe report 2195 * and process them: recycle, maybe report
@@ -2189,9 +2206,12 @@ restart:
2189 case Q_TYPE_SITD: 2206 case Q_TYPE_SITD:
2190 /* If this SITD is still active, leave it for 2207 /* If this SITD is still active, leave it for
2191 * later processing ... check the next entry. 2208 * later processing ... check the next entry.
2209 * No need to check for activity unless the
2210 * frame is current.
2192 */ 2211 */
2193 if ((q.sitd->hw_results & SITD_ACTIVE(ehci)) 2212 if (frame == clock_frame && live &&
2194 && live) { 2213 (q.sitd->hw_results &
2214 SITD_ACTIVE(ehci))) {
2195 incomplete = true; 2215 incomplete = true;
2196 q_p = &q.sitd->sitd_next; 2216 q_p = &q.sitd->sitd_next;
2197 hw_p = &q.sitd->hw_next; 2217 hw_p = &q.sitd->hw_next;
@@ -2260,6 +2280,7 @@ restart:
2260 2280
2261 /* rescan the rest of this frame, then ... */ 2281 /* rescan the rest of this frame, then ... */
2262 clock = now; 2282 clock = now;
2283 clock_frame = clock >> 3;
2263 } else { 2284 } else {
2264 now_uframe++; 2285 now_uframe++;
2265 now_uframe %= mod; 2286 now_uframe %= mod;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bf92d209a1a9..35a03095757e 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -97,6 +97,8 @@ struct ehci_hcd { /* one per controller */
97 dedicated to the companion controller */ 97 dedicated to the companion controller */
98 unsigned long owned_ports; /* which ports are 98 unsigned long owned_ports; /* which ports are
99 owned by the companion during a bus suspend */ 99 owned by the companion during a bus suspend */
100 unsigned long port_c_suspend; /* which ports have
101 the change-suspend feature turned on */
100 102
101 /* per-HC memory pools (could be per-bus, but ...) */ 103 /* per-HC memory pools (could be per-bus, but ...) */
102 struct dma_pool *qh_pool; /* qh per active urb */ 104 struct dma_pool *qh_pool; /* qh per active urb */
@@ -112,7 +114,6 @@ struct ehci_hcd { /* one per controller */
112 u32 command; 114 u32 command;
113 115
114 /* SILICON QUIRKS */ 116 /* SILICON QUIRKS */
115 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */
116 unsigned no_selective_suspend:1; 117 unsigned no_selective_suspend:1;
117 unsigned has_fsl_port_bug:1; /* FreeScale */ 118 unsigned has_fsl_port_bug:1; /* FreeScale */
118 unsigned big_endian_mmio:1; 119 unsigned big_endian_mmio:1;
@@ -678,7 +679,7 @@ struct ehci_fstn {
678 * needed (mostly in root hub code). 679 * needed (mostly in root hub code).
679 */ 680 */
680 681
681#define ehci_is_TDI(e) ((e)->is_tdi_rh_tt) 682#define ehci_is_TDI(e) (ehci_to_hcd(e)->has_tt)
682 683
683/* Returns the speed of a device attached to a port on the root hub. */ 684/* Returns the speed of a device attached to a port on the root hub. */
684static inline unsigned int 685static inline unsigned int
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 4ba96c1e060c..65aa5ecf569a 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -988,7 +988,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
988 * This did not trigger for a long time now. 988 * This did not trigger for a long time now.
989 */ 989 */
990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " 990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: "
991 "%d of %d done: %08x cur: %08x\n", qtd, 991 "%d of %zu done: %08x cur: %08x\n", qtd,
992 urb, qh, PTD_XFERRED_LENGTH(dw3), 992 urb, qh, PTD_XFERRED_LENGTH(dw3),
993 qtd->length, done_map, 993 qtd->length, done_map,
994 (1 << queue_entry)); 994 (1 << queue_entry));
@@ -1088,7 +1088,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) {
1089 /* short BULK received */ 1089 /* short BULK received */
1090 1090
1091 printk(KERN_ERR "short bulk, %d instead %d\n", length, 1091 printk(KERN_ERR "short bulk, %d instead %zu\n", length,
1092 qtd->length); 1092 qtd->length);
1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) { 1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) {
1094 urb->status = -EREMOTEIO; 1094 urb->status = -EREMOTEIO;
@@ -2207,14 +2207,14 @@ struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq,
2207 goto err_put; 2207 goto err_put;
2208 } 2208 }
2209 2209
2210 ret = usb_add_hcd(hcd, irq, irqflags);
2211 if (ret)
2212 goto err_unmap;
2213
2214 hcd->irq = irq; 2210 hcd->irq = irq;
2215 hcd->rsrc_start = res_start; 2211 hcd->rsrc_start = res_start;
2216 hcd->rsrc_len = res_len; 2212 hcd->rsrc_len = res_len;
2217 2213
2214 ret = usb_add_hcd(hcd, irq, irqflags);
2215 if (ret)
2216 goto err_unmap;
2217
2218 return hcd; 2218 return hcd;
2219 2219
2220err_unmap: 2220err_unmap:
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 73fb2a38f1e4..c9db3fe98726 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -104,8 +104,8 @@ static u32 nxp_pci_io_base;
104static u32 iolength; 104static u32 iolength;
105static u32 pci_mem_phy0; 105static u32 pci_mem_phy0;
106static u32 length; 106static u32 length;
107static u8 *chip_addr; 107static u8 __iomem *chip_addr;
108static u8 *iobase; 108static u8 __iomem *iobase;
109 109
110static int __devinit isp1761_pci_probe(struct pci_dev *dev, 110static int __devinit isp1761_pci_probe(struct pci_dev *dev,
111 const struct pci_device_id *id) 111 const struct pci_device_id *id)
@@ -256,7 +256,7 @@ static struct pci_driver isp1761_pci_driver = {
256 256
257static int __init isp1760_init(void) 257static int __init isp1760_init(void)
258{ 258{
259 int ret; 259 int ret = -ENODEV;
260 260
261 init_kmem_once(); 261 init_kmem_once();
262 262
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 77204f001b9a..e899a77dfb83 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -90,7 +90,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
90 struct device *dev = &pdev->dev; 90 struct device *dev = &pdev->dev;
91 struct resource *res, *mem; 91 struct resource *res, *mem;
92 int retval, irq; 92 int retval, irq;
93 struct usb_hcd *hcd = 0; 93 struct usb_hcd *hcd = NULL;
94 94
95 irq = retval = platform_get_irq(pdev, 0); 95 irq = retval = platform_get_irq(pdev, 0);
96 if (retval < 0) 96 if (retval < 0)
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index a53db1d4e07a..001789c9a11a 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -269,3 +269,15 @@ config USB_TEST
269 See <http://www.linux-usb.org/usbtest/> for more information, 269 See <http://www.linux-usb.org/usbtest/> for more information,
270 including sample test device firmware and "how to use it". 270 including sample test device firmware and "how to use it".
271 271
272config USB_ISIGHTFW
273 tristate "iSight firmware loading support"
274 depends on USB
275 select FW_LOADER
276 help
277 This driver loads firmware for USB Apple iSight cameras, allowing
278 them to be driven by the USB video class driver available at
279 http://linux-uvc.berlios.de
280
281 The firmware for this driver must be extracted from the MacOS
282 driver beforehand. Tools for doing so are available at
283 http://bersace03.free.fr
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index b68e6b774f1a..aba091cb5ec0 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_EMI62) += emi62.o
14obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o 14obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
15obj-$(CONFIG_USB_IDMOUSE) += idmouse.o 15obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
16obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o 16obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
17obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
17obj-$(CONFIG_USB_LCD) += usblcd.o 18obj-$(CONFIG_USB_LCD) += usblcd.o
18obj-$(CONFIG_USB_LD) += ldusb.o 19obj-$(CONFIG_USB_LD) += ldusb.o
19obj-$(CONFIG_USB_LED) += usbled.o 20obj-$(CONFIG_USB_LED) += usbled.o
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c
new file mode 100644
index 000000000000..9f30aa1f8a5d
--- /dev/null
+++ b/drivers/usb/misc/isight_firmware.c
@@ -0,0 +1,140 @@
1/*
2 * Driver for loading USB isight firmware
3 *
4 * Copyright (C) 2008 Matthew Garrett <mjg@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, version 2.
9 *
10 * The USB isight cameras in recent Apples are roughly compatible with the USB
11 * video class specification, and can be driven by uvcvideo. However, they
12 * need firmware to be loaded beforehand. After firmware loading, the device
13 * detaches from the USB bus and reattaches with a new device ID. It can then
14 * be claimed by the uvc driver.
15 *
16 * The firmware is non-free and must be extracted by the user. Tools to do this
17 * are available at http://bersace03.free.fr/ift/
18 *
19 * The isight firmware loading was reverse engineered by Johannes Berg
20 * <johannes@sipsolutions.de>, and this driver is based on code by Ronald
21 * Bultje <rbultje@ronald.bitfreak.net>
22 */
23
24#include <linux/usb.h>
25#include <linux/firmware.h>
26#include <linux/errno.h>
27#include <linux/module.h>
28
29static struct usb_device_id id_table[] = {
30 {USB_DEVICE(0x05ac, 0x8300)},
31 {},
32};
33
34MODULE_DEVICE_TABLE(usb, id_table);
35
36static int isight_firmware_load(struct usb_interface *intf,
37 const struct usb_device_id *id)
38{
39 struct usb_device *dev = interface_to_usbdev(intf);
40 int llen, len, req, ret = 0;
41 const struct firmware *firmware;
42 unsigned char *buf = kmalloc(50, GFP_KERNEL);
43 unsigned char data[4];
44 u8 *ptr;
45
46 if (!buf)
47 return -ENOMEM;
48
49 if (request_firmware(&firmware, "isight.fw", &dev->dev) != 0) {
50 printk(KERN_ERR "Unable to load isight firmware\n");
51 return -ENODEV;
52 }
53
54 ptr = firmware->data;
55
56 if (usb_control_msg
57 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\1", 1,
58 300) != 1) {
59 printk(KERN_ERR
60 "Failed to initialise isight firmware loader\n");
61 ret = -ENODEV;
62 goto out;
63 }
64
65 while (ptr+4 <= firmware->data+firmware->size) {
66 memcpy(data, ptr, 4);
67 len = (data[0] << 8 | data[1]);
68 req = (data[2] << 8 | data[3]);
69 ptr += 4;
70
71 if (len == 0x8001)
72 break; /* success */
73 else if (len == 0)
74 continue;
75
76 for (; len > 0; req += 50) {
77 llen = min(len, 50);
78 len -= llen;
79 if (ptr+llen > firmware->data+firmware->size) {
80 printk(KERN_ERR
81 "Malformed isight firmware");
82 ret = -ENODEV;
83 goto out;
84 }
85 memcpy(buf, ptr, llen);
86
87 ptr += llen;
88
89 if (usb_control_msg
90 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, req, 0,
91 buf, llen, 300) != llen) {
92 printk(KERN_ERR
93 "Failed to load isight firmware\n");
94 kfree(buf);
95 ret = -ENODEV;
96 goto out;
97 }
98
99 }
100 }
101
102 if (usb_control_msg
103 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\0", 1,
104 300) != 1) {
105 printk(KERN_ERR "isight firmware loading completion failed\n");
106 ret = -ENODEV;
107 }
108
109out:
110 kfree(buf);
111 release_firmware(firmware);
112 return ret;
113}
114
115static void isight_firmware_disconnect(struct usb_interface *intf)
116{
117}
118
119static struct usb_driver isight_firmware_driver = {
120 .name = "isight_firmware",
121 .probe = isight_firmware_load,
122 .disconnect = isight_firmware_disconnect,
123 .id_table = id_table,
124};
125
126static int __init isight_firmware_init(void)
127{
128 return usb_register(&isight_firmware_driver);
129}
130
131static void __exit isight_firmware_exit(void)
132{
133 usb_deregister(&isight_firmware_driver);
134}
135
136module_init(isight_firmware_init);
137module_exit(isight_firmware_exit);
138
139MODULE_LICENSE("GPL");
140MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7aafd53fbcab..189a9db03509 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -63,9 +63,6 @@
63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
65 65
66#define USB_VENDOR_ID_MICROCHIP 0x04d8
67#define USB_DEVICE_ID_PICDEM 0x000c
68
69#ifdef CONFIG_USB_DYNAMIC_MINORS 66#ifdef CONFIG_USB_DYNAMIC_MINORS
70#define USB_LD_MINOR_BASE 0 67#define USB_LD_MINOR_BASE 0
71#else 68#else
@@ -92,7 +89,6 @@ static struct usb_device_id ld_usb_table [] = {
92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 89 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
93 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 90 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
94 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 91 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
95 { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) },
96 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
97 { } /* Terminating entry */ 93 { } /* Terminating entry */
98}; 94};
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 24230c638b8e..4cfa25b0f44e 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -595,14 +595,14 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
595 } while(value); 595 } while(value);
596 kit->dev_no = bit; 596 kit->dev_no = bit;
597 597
598 kit->dev = device_create(phidget_class, &kit->udev->dev, 0, 598 kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev,
599 "interfacekit%d", kit->dev_no); 599 MKDEV(0, 0), kit,
600 "interfacekit%d", kit->dev_no);
600 if (IS_ERR(kit->dev)) { 601 if (IS_ERR(kit->dev)) {
601 rc = PTR_ERR(kit->dev); 602 rc = PTR_ERR(kit->dev);
602 kit->dev = NULL; 603 kit->dev = NULL;
603 goto out; 604 goto out;
604 } 605 }
605 dev_set_drvdata(kit->dev, kit);
606 606
607 if (usb_submit_urb(kit->irq, GFP_KERNEL)) { 607 if (usb_submit_urb(kit->irq, GFP_KERNEL)) {
608 rc = -EIO; 608 rc = -EIO;
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index f0113c17cc5a..9b4696f21b22 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -365,16 +365,15 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
365 } while(value); 365 } while(value);
366 mc->dev_no = bit; 366 mc->dev_no = bit;
367 367
368 mc->dev = device_create(phidget_class, &mc->udev->dev, 0, 368 mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev,
369 "motorcontrol%d", mc->dev_no); 369 MKDEV(0, 0), mc,
370 "motorcontrol%d", mc->dev_no);
370 if (IS_ERR(mc->dev)) { 371 if (IS_ERR(mc->dev)) {
371 rc = PTR_ERR(mc->dev); 372 rc = PTR_ERR(mc->dev);
372 mc->dev = NULL; 373 mc->dev = NULL;
373 goto out; 374 goto out;
374 } 375 }
375 376
376 dev_set_drvdata(mc->dev, mc);
377
378 if (usb_submit_urb(mc->irq, GFP_KERNEL)) { 377 if (usb_submit_urb(mc->irq, GFP_KERNEL)) {
379 rc = -EIO; 378 rc = -EIO;
380 goto out; 379 goto out;
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 7d590c09434a..1ca7ddb41d4d 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -275,14 +275,14 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
275 } while (value); 275 } while (value);
276 dev->dev_no = bit; 276 dev->dev_no = bit;
277 277
278 dev->dev = device_create(phidget_class, &dev->udev->dev, 0, 278 dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev,
279 "servo%d", dev->dev_no); 279 MKDEV(0, 0), dev,
280 "servo%d", dev->dev_no);
280 if (IS_ERR(dev->dev)) { 281 if (IS_ERR(dev->dev)) {
281 rc = PTR_ERR(dev->dev); 282 rc = PTR_ERR(dev->dev);
282 dev->dev = NULL; 283 dev->dev = NULL;
283 goto out; 284 goto out;
284 } 285 }
285 dev_set_drvdata(dev->dev, dev);
286 286
287 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1; 287 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
288 288
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 742be3c35947..054dedd28127 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -856,6 +856,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
856 struct urb *u; 856 struct urb *u;
857 struct usb_ctrlrequest req; 857 struct usb_ctrlrequest req;
858 struct subcase *reqp; 858 struct subcase *reqp;
859
860 /* sign of this variable means:
861 * -: tested code must return this (negative) error code
862 * +: tested code may return this (negative too) error code
863 */
859 int expected = 0; 864 int expected = 0;
860 865
861 /* requests here are mostly expected to succeed on any 866 /* requests here are mostly expected to succeed on any
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2cffec85ee7e..9ba64ccc1359 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -447,6 +447,15 @@ config USB_SERIAL_MOS7840
447 To compile this driver as a module, choose M here: the 447 To compile this driver as a module, choose M here: the
448 module will be called mos7840. If unsure, choose N. 448 module will be called mos7840. If unsure, choose N.
449 449
450config USB_SERIAL_MOTOROLA
451 tristate "USB Motorola Phone modem driver"
452 ---help---
453 Say Y here if you want to use a Motorola phone with a USB
454 connector as a modem link.
455
456 To compile this driver as a module, choose M here: the
457 module will be called moto_modem. If unsure, choose N.
458
450config USB_SERIAL_NAVMAN 459config USB_SERIAL_NAVMAN
451 tristate "USB Navman GPS device" 460 tristate "USB Navman GPS device"
452 help 461 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 756859510d8c..17a762ab6769 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o 40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
42obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o
42obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 43obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
43obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 44obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
44obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index ba28fdc9ccd2..1f7c86bd8297 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -28,6 +28,7 @@ static int debug;
28 28
29static struct usb_device_id id_table [] = { 29static struct usb_device_id id_table [] = {
30 { USB_DEVICE(0x4348, 0x5523) }, 30 { USB_DEVICE(0x4348, 0x5523) },
31 { USB_DEVICE(0x1a86, 0x7523) },
31 { }, 32 { },
32}; 33};
33MODULE_DEVICE_TABLE(usb, id_table); 34MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 5b349ece7247..5234e7a3bd2c 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -174,8 +174,270 @@ static struct usb_device_id id_table_combined [] = {
174 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, 174 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
175 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, 175 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
176 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 176 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
177 { USB_DEVICE(MTXORB_VK_VID, MTXORB_VK_PID), 177 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) },
178 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) },
179 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) },
180 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) },
181 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) },
182 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) },
183 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) },
184 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) },
185 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) },
186 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) },
187 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) },
188 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) },
189 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) },
190 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) },
191 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) },
192 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) },
193 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) },
194 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) },
195 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) },
196 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) },
197 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) },
198 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) },
199 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) },
200 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) },
201 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) },
202 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) },
203 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) },
204 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) },
205 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) },
206 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) },
207 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) },
208 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) },
209 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) },
210 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) },
211 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) },
212 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) },
213 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) },
214 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) },
215 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) },
216 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID),
178 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk }, 217 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
218 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) },
219 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) },
220 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) },
221 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) },
222 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID),
223 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
224 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) },
225 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) },
226 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) },
227 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) },
228 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) },
229 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) },
230 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) },
231 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) },
232 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) },
233 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) },
234 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) },
235 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) },
236 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) },
237 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) },
238 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) },
239 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) },
240 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) },
241 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) },
242 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) },
243 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) },
244 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) },
245 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) },
246 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) },
247 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) },
248 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) },
249 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) },
250 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) },
251 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) },
252 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) },
253 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) },
254 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) },
255 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) },
256 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) },
257 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) },
258 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) },
259 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) },
260 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) },
261 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) },
262 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID),
263 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
264 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID),
265 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
266 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID),
267 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
268 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID),
269 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
270 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID),
271 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
272 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID),
273 .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
274 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) },
275 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) },
276 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) },
277 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) },
278 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) },
279 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) },
280 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) },
281 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) },
282 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) },
283 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) },
284 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) },
285 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) },
286 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) },
287 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) },
288 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) },
289 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) },
290 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) },
291 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) },
292 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) },
293 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) },
294 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) },
295 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) },
296 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) },
297 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) },
298 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) },
299 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) },
300 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) },
301 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) },
302 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) },
303 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) },
304 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) },
305 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) },
306 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) },
307 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) },
308 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) },
309 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) },
310 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) },
311 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) },
312 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) },
313 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) },
314 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) },
315 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) },
316 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) },
317 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) },
318 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) },
319 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) },
320 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) },
321 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) },
322 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) },
323 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) },
324 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) },
325 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) },
326 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) },
327 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) },
328 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) },
329 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) },
330 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) },
331 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) },
332 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) },
333 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) },
334 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) },
335 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) },
336 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) },
337 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) },
338 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) },
339 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) },
340 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) },
341 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) },
342 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) },
343 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) },
344 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) },
345 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) },
346 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) },
347 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) },
348 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) },
349 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) },
350 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) },
351 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) },
352 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) },
353 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) },
354 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) },
355 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) },
356 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) },
357 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) },
358 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) },
359 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) },
360 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) },
361 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) },
362 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) },
363 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) },
364 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) },
365 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) },
366 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) },
367 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) },
368 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) },
369 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) },
370 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) },
371 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) },
372 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) },
373 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) },
374 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) },
375 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) },
376 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) },
377 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) },
378 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) },
379 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) },
380 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) },
381 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) },
382 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) },
383 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) },
384 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) },
385 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) },
386 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) },
387 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) },
388 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) },
389 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) },
390 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) },
391 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) },
392 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) },
393 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) },
394 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) },
395 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) },
396 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) },
397 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) },
398 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) },
399 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) },
400 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) },
401 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) },
402 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) },
403 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) },
404 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) },
405 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) },
406 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) },
407 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) },
408 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) },
409 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) },
410 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) },
411 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) },
412 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) },
413 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) },
414 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) },
415 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) },
416 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) },
417 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) },
418 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) },
419 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) },
420 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) },
421 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) },
422 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) },
423 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) },
424 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) },
425 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) },
426 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) },
427 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) },
428 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) },
429 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) },
430 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) },
431 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) },
432 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) },
433 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) },
434 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) },
435 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) },
436 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) },
437 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) },
438 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) },
439 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) },
440 { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) },
179 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 441 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
180 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 442 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
181 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, 443 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
@@ -374,6 +636,7 @@ static struct usb_device_id id_table_combined [] = {
374 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 636 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
375 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), 637 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
376 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 638 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
639 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
377 { }, /* Optional parameter entry */ 640 { }, /* Optional parameter entry */
378 { } /* Terminating entry */ 641 { } /* Terminating entry */
379}; 642};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 504edf8c3a3f..06e0ecabb3eb 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -114,11 +114,268 @@
114#define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */ 114#define FTDI_OOCDLINK_PID 0xbaf8 /* Amontec JTAGkey */
115 115
116/* 116/*
117 * The following are the values for the Matrix Orbital VK204-25-USB 117 * The following are the values for the Matrix Orbital FTDI Range
118 * display, which use the FT232RL. 118 * Anything in this range will use an FT232RL.
119 */ 119 */
120#define MTXORB_VK_VID 0x1b3d 120#define MTXORB_VID 0x1B3D
121#define MTXORB_VK_PID 0x0158 121#define MTXORB_FTDI_RANGE_0100_PID 0x0100
122#define MTXORB_FTDI_RANGE_0101_PID 0x0101
123#define MTXORB_FTDI_RANGE_0102_PID 0x0102
124#define MTXORB_FTDI_RANGE_0103_PID 0x0103
125#define MTXORB_FTDI_RANGE_0104_PID 0x0104
126#define MTXORB_FTDI_RANGE_0105_PID 0x0105
127#define MTXORB_FTDI_RANGE_0106_PID 0x0106
128#define MTXORB_FTDI_RANGE_0107_PID 0x0107
129#define MTXORB_FTDI_RANGE_0108_PID 0x0108
130#define MTXORB_FTDI_RANGE_0109_PID 0x0109
131#define MTXORB_FTDI_RANGE_010A_PID 0x010A
132#define MTXORB_FTDI_RANGE_010B_PID 0x010B
133#define MTXORB_FTDI_RANGE_010C_PID 0x010C
134#define MTXORB_FTDI_RANGE_010D_PID 0x010D
135#define MTXORB_FTDI_RANGE_010E_PID 0x010E
136#define MTXORB_FTDI_RANGE_010F_PID 0x010F
137#define MTXORB_FTDI_RANGE_0110_PID 0x0110
138#define MTXORB_FTDI_RANGE_0111_PID 0x0111
139#define MTXORB_FTDI_RANGE_0112_PID 0x0112
140#define MTXORB_FTDI_RANGE_0113_PID 0x0113
141#define MTXORB_FTDI_RANGE_0114_PID 0x0114
142#define MTXORB_FTDI_RANGE_0115_PID 0x0115
143#define MTXORB_FTDI_RANGE_0116_PID 0x0116
144#define MTXORB_FTDI_RANGE_0117_PID 0x0117
145#define MTXORB_FTDI_RANGE_0118_PID 0x0118
146#define MTXORB_FTDI_RANGE_0119_PID 0x0119
147#define MTXORB_FTDI_RANGE_011A_PID 0x011A
148#define MTXORB_FTDI_RANGE_011B_PID 0x011B
149#define MTXORB_FTDI_RANGE_011C_PID 0x011C
150#define MTXORB_FTDI_RANGE_011D_PID 0x011D
151#define MTXORB_FTDI_RANGE_011E_PID 0x011E
152#define MTXORB_FTDI_RANGE_011F_PID 0x011F
153#define MTXORB_FTDI_RANGE_0120_PID 0x0120
154#define MTXORB_FTDI_RANGE_0121_PID 0x0121
155#define MTXORB_FTDI_RANGE_0122_PID 0x0122
156#define MTXORB_FTDI_RANGE_0123_PID 0x0123
157#define MTXORB_FTDI_RANGE_0124_PID 0x0124
158#define MTXORB_FTDI_RANGE_0125_PID 0x0125
159#define MTXORB_FTDI_RANGE_0126_PID 0x0126
160#define MTXORB_FTDI_RANGE_0127_PID 0x0127
161#define MTXORB_FTDI_RANGE_0128_PID 0x0128
162#define MTXORB_FTDI_RANGE_0129_PID 0x0129
163#define MTXORB_FTDI_RANGE_012A_PID 0x012A
164#define MTXORB_FTDI_RANGE_012B_PID 0x012B
165#define MTXORB_FTDI_RANGE_012C_PID 0x012C
166#define MTXORB_FTDI_RANGE_012D_PID 0x012D
167#define MTXORB_FTDI_RANGE_012E_PID 0x012E
168#define MTXORB_FTDI_RANGE_012F_PID 0x012F
169#define MTXORB_FTDI_RANGE_0130_PID 0x0130
170#define MTXORB_FTDI_RANGE_0131_PID 0x0131
171#define MTXORB_FTDI_RANGE_0132_PID 0x0132
172#define MTXORB_FTDI_RANGE_0133_PID 0x0133
173#define MTXORB_FTDI_RANGE_0134_PID 0x0134
174#define MTXORB_FTDI_RANGE_0135_PID 0x0135
175#define MTXORB_FTDI_RANGE_0136_PID 0x0136
176#define MTXORB_FTDI_RANGE_0137_PID 0x0137
177#define MTXORB_FTDI_RANGE_0138_PID 0x0138
178#define MTXORB_FTDI_RANGE_0139_PID 0x0139
179#define MTXORB_FTDI_RANGE_013A_PID 0x013A
180#define MTXORB_FTDI_RANGE_013B_PID 0x013B
181#define MTXORB_FTDI_RANGE_013C_PID 0x013C
182#define MTXORB_FTDI_RANGE_013D_PID 0x013D
183#define MTXORB_FTDI_RANGE_013E_PID 0x013E
184#define MTXORB_FTDI_RANGE_013F_PID 0x013F
185#define MTXORB_FTDI_RANGE_0140_PID 0x0140
186#define MTXORB_FTDI_RANGE_0141_PID 0x0141
187#define MTXORB_FTDI_RANGE_0142_PID 0x0142
188#define MTXORB_FTDI_RANGE_0143_PID 0x0143
189#define MTXORB_FTDI_RANGE_0144_PID 0x0144
190#define MTXORB_FTDI_RANGE_0145_PID 0x0145
191#define MTXORB_FTDI_RANGE_0146_PID 0x0146
192#define MTXORB_FTDI_RANGE_0147_PID 0x0147
193#define MTXORB_FTDI_RANGE_0148_PID 0x0148
194#define MTXORB_FTDI_RANGE_0149_PID 0x0149
195#define MTXORB_FTDI_RANGE_014A_PID 0x014A
196#define MTXORB_FTDI_RANGE_014B_PID 0x014B
197#define MTXORB_FTDI_RANGE_014C_PID 0x014C
198#define MTXORB_FTDI_RANGE_014D_PID 0x014D
199#define MTXORB_FTDI_RANGE_014E_PID 0x014E
200#define MTXORB_FTDI_RANGE_014F_PID 0x014F
201#define MTXORB_FTDI_RANGE_0150_PID 0x0150
202#define MTXORB_FTDI_RANGE_0151_PID 0x0151
203#define MTXORB_FTDI_RANGE_0152_PID 0x0152
204#define MTXORB_FTDI_RANGE_0153_PID 0x0153
205#define MTXORB_FTDI_RANGE_0154_PID 0x0154
206#define MTXORB_FTDI_RANGE_0155_PID 0x0155
207#define MTXORB_FTDI_RANGE_0156_PID 0x0156
208#define MTXORB_FTDI_RANGE_0157_PID 0x0157
209#define MTXORB_FTDI_RANGE_0158_PID 0x0158
210#define MTXORB_FTDI_RANGE_0159_PID 0x0159
211#define MTXORB_FTDI_RANGE_015A_PID 0x015A
212#define MTXORB_FTDI_RANGE_015B_PID 0x015B
213#define MTXORB_FTDI_RANGE_015C_PID 0x015C
214#define MTXORB_FTDI_RANGE_015D_PID 0x015D
215#define MTXORB_FTDI_RANGE_015E_PID 0x015E
216#define MTXORB_FTDI_RANGE_015F_PID 0x015F
217#define MTXORB_FTDI_RANGE_0160_PID 0x0160
218#define MTXORB_FTDI_RANGE_0161_PID 0x0161
219#define MTXORB_FTDI_RANGE_0162_PID 0x0162
220#define MTXORB_FTDI_RANGE_0163_PID 0x0163
221#define MTXORB_FTDI_RANGE_0164_PID 0x0164
222#define MTXORB_FTDI_RANGE_0165_PID 0x0165
223#define MTXORB_FTDI_RANGE_0166_PID 0x0166
224#define MTXORB_FTDI_RANGE_0167_PID 0x0167
225#define MTXORB_FTDI_RANGE_0168_PID 0x0168
226#define MTXORB_FTDI_RANGE_0169_PID 0x0169
227#define MTXORB_FTDI_RANGE_016A_PID 0x016A
228#define MTXORB_FTDI_RANGE_016B_PID 0x016B
229#define MTXORB_FTDI_RANGE_016C_PID 0x016C
230#define MTXORB_FTDI_RANGE_016D_PID 0x016D
231#define MTXORB_FTDI_RANGE_016E_PID 0x016E
232#define MTXORB_FTDI_RANGE_016F_PID 0x016F
233#define MTXORB_FTDI_RANGE_0170_PID 0x0170
234#define MTXORB_FTDI_RANGE_0171_PID 0x0171
235#define MTXORB_FTDI_RANGE_0172_PID 0x0172
236#define MTXORB_FTDI_RANGE_0173_PID 0x0173
237#define MTXORB_FTDI_RANGE_0174_PID 0x0174
238#define MTXORB_FTDI_RANGE_0175_PID 0x0175
239#define MTXORB_FTDI_RANGE_0176_PID 0x0176
240#define MTXORB_FTDI_RANGE_0177_PID 0x0177
241#define MTXORB_FTDI_RANGE_0178_PID 0x0178
242#define MTXORB_FTDI_RANGE_0179_PID 0x0179
243#define MTXORB_FTDI_RANGE_017A_PID 0x017A
244#define MTXORB_FTDI_RANGE_017B_PID 0x017B
245#define MTXORB_FTDI_RANGE_017C_PID 0x017C
246#define MTXORB_FTDI_RANGE_017D_PID 0x017D
247#define MTXORB_FTDI_RANGE_017E_PID 0x017E
248#define MTXORB_FTDI_RANGE_017F_PID 0x017F
249#define MTXORB_FTDI_RANGE_0180_PID 0x0180
250#define MTXORB_FTDI_RANGE_0181_PID 0x0181
251#define MTXORB_FTDI_RANGE_0182_PID 0x0182
252#define MTXORB_FTDI_RANGE_0183_PID 0x0183
253#define MTXORB_FTDI_RANGE_0184_PID 0x0184
254#define MTXORB_FTDI_RANGE_0185_PID 0x0185
255#define MTXORB_FTDI_RANGE_0186_PID 0x0186
256#define MTXORB_FTDI_RANGE_0187_PID 0x0187
257#define MTXORB_FTDI_RANGE_0188_PID 0x0188
258#define MTXORB_FTDI_RANGE_0189_PID 0x0189
259#define MTXORB_FTDI_RANGE_018A_PID 0x018A
260#define MTXORB_FTDI_RANGE_018B_PID 0x018B
261#define MTXORB_FTDI_RANGE_018C_PID 0x018C
262#define MTXORB_FTDI_RANGE_018D_PID 0x018D
263#define MTXORB_FTDI_RANGE_018E_PID 0x018E
264#define MTXORB_FTDI_RANGE_018F_PID 0x018F
265#define MTXORB_FTDI_RANGE_0190_PID 0x0190
266#define MTXORB_FTDI_RANGE_0191_PID 0x0191
267#define MTXORB_FTDI_RANGE_0192_PID 0x0192
268#define MTXORB_FTDI_RANGE_0193_PID 0x0193
269#define MTXORB_FTDI_RANGE_0194_PID 0x0194
270#define MTXORB_FTDI_RANGE_0195_PID 0x0195
271#define MTXORB_FTDI_RANGE_0196_PID 0x0196
272#define MTXORB_FTDI_RANGE_0197_PID 0x0197
273#define MTXORB_FTDI_RANGE_0198_PID 0x0198
274#define MTXORB_FTDI_RANGE_0199_PID 0x0199
275#define MTXORB_FTDI_RANGE_019A_PID 0x019A
276#define MTXORB_FTDI_RANGE_019B_PID 0x019B
277#define MTXORB_FTDI_RANGE_019C_PID 0x019C
278#define MTXORB_FTDI_RANGE_019D_PID 0x019D
279#define MTXORB_FTDI_RANGE_019E_PID 0x019E
280#define MTXORB_FTDI_RANGE_019F_PID 0x019F
281#define MTXORB_FTDI_RANGE_01A0_PID 0x01A0
282#define MTXORB_FTDI_RANGE_01A1_PID 0x01A1
283#define MTXORB_FTDI_RANGE_01A2_PID 0x01A2
284#define MTXORB_FTDI_RANGE_01A3_PID 0x01A3
285#define MTXORB_FTDI_RANGE_01A4_PID 0x01A4
286#define MTXORB_FTDI_RANGE_01A5_PID 0x01A5
287#define MTXORB_FTDI_RANGE_01A6_PID 0x01A6
288#define MTXORB_FTDI_RANGE_01A7_PID 0x01A7
289#define MTXORB_FTDI_RANGE_01A8_PID 0x01A8
290#define MTXORB_FTDI_RANGE_01A9_PID 0x01A9
291#define MTXORB_FTDI_RANGE_01AA_PID 0x01AA
292#define MTXORB_FTDI_RANGE_01AB_PID 0x01AB
293#define MTXORB_FTDI_RANGE_01AC_PID 0x01AC
294#define MTXORB_FTDI_RANGE_01AD_PID 0x01AD
295#define MTXORB_FTDI_RANGE_01AE_PID 0x01AE
296#define MTXORB_FTDI_RANGE_01AF_PID 0x01AF
297#define MTXORB_FTDI_RANGE_01B0_PID 0x01B0
298#define MTXORB_FTDI_RANGE_01B1_PID 0x01B1
299#define MTXORB_FTDI_RANGE_01B2_PID 0x01B2
300#define MTXORB_FTDI_RANGE_01B3_PID 0x01B3
301#define MTXORB_FTDI_RANGE_01B4_PID 0x01B4
302#define MTXORB_FTDI_RANGE_01B5_PID 0x01B5
303#define MTXORB_FTDI_RANGE_01B6_PID 0x01B6
304#define MTXORB_FTDI_RANGE_01B7_PID 0x01B7
305#define MTXORB_FTDI_RANGE_01B8_PID 0x01B8
306#define MTXORB_FTDI_RANGE_01B9_PID 0x01B9
307#define MTXORB_FTDI_RANGE_01BA_PID 0x01BA
308#define MTXORB_FTDI_RANGE_01BB_PID 0x01BB
309#define MTXORB_FTDI_RANGE_01BC_PID 0x01BC
310#define MTXORB_FTDI_RANGE_01BD_PID 0x01BD
311#define MTXORB_FTDI_RANGE_01BE_PID 0x01BE
312#define MTXORB_FTDI_RANGE_01BF_PID 0x01BF
313#define MTXORB_FTDI_RANGE_01C0_PID 0x01C0
314#define MTXORB_FTDI_RANGE_01C1_PID 0x01C1
315#define MTXORB_FTDI_RANGE_01C2_PID 0x01C2
316#define MTXORB_FTDI_RANGE_01C3_PID 0x01C3
317#define MTXORB_FTDI_RANGE_01C4_PID 0x01C4
318#define MTXORB_FTDI_RANGE_01C5_PID 0x01C5
319#define MTXORB_FTDI_RANGE_01C6_PID 0x01C6
320#define MTXORB_FTDI_RANGE_01C7_PID 0x01C7
321#define MTXORB_FTDI_RANGE_01C8_PID 0x01C8
322#define MTXORB_FTDI_RANGE_01C9_PID 0x01C9
323#define MTXORB_FTDI_RANGE_01CA_PID 0x01CA
324#define MTXORB_FTDI_RANGE_01CB_PID 0x01CB
325#define MTXORB_FTDI_RANGE_01CC_PID 0x01CC
326#define MTXORB_FTDI_RANGE_01CD_PID 0x01CD
327#define MTXORB_FTDI_RANGE_01CE_PID 0x01CE
328#define MTXORB_FTDI_RANGE_01CF_PID 0x01CF
329#define MTXORB_FTDI_RANGE_01D0_PID 0x01D0
330#define MTXORB_FTDI_RANGE_01D1_PID 0x01D1
331#define MTXORB_FTDI_RANGE_01D2_PID 0x01D2
332#define MTXORB_FTDI_RANGE_01D3_PID 0x01D3
333#define MTXORB_FTDI_RANGE_01D4_PID 0x01D4
334#define MTXORB_FTDI_RANGE_01D5_PID 0x01D5
335#define MTXORB_FTDI_RANGE_01D6_PID 0x01D6
336#define MTXORB_FTDI_RANGE_01D7_PID 0x01D7
337#define MTXORB_FTDI_RANGE_01D8_PID 0x01D8
338#define MTXORB_FTDI_RANGE_01D9_PID 0x01D9
339#define MTXORB_FTDI_RANGE_01DA_PID 0x01DA
340#define MTXORB_FTDI_RANGE_01DB_PID 0x01DB
341#define MTXORB_FTDI_RANGE_01DC_PID 0x01DC
342#define MTXORB_FTDI_RANGE_01DD_PID 0x01DD
343#define MTXORB_FTDI_RANGE_01DE_PID 0x01DE
344#define MTXORB_FTDI_RANGE_01DF_PID 0x01DF
345#define MTXORB_FTDI_RANGE_01E0_PID 0x01E0
346#define MTXORB_FTDI_RANGE_01E1_PID 0x01E1
347#define MTXORB_FTDI_RANGE_01E2_PID 0x01E2
348#define MTXORB_FTDI_RANGE_01E3_PID 0x01E3
349#define MTXORB_FTDI_RANGE_01E4_PID 0x01E4
350#define MTXORB_FTDI_RANGE_01E5_PID 0x01E5
351#define MTXORB_FTDI_RANGE_01E6_PID 0x01E6
352#define MTXORB_FTDI_RANGE_01E7_PID 0x01E7
353#define MTXORB_FTDI_RANGE_01E8_PID 0x01E8
354#define MTXORB_FTDI_RANGE_01E9_PID 0x01E9
355#define MTXORB_FTDI_RANGE_01EA_PID 0x01EA
356#define MTXORB_FTDI_RANGE_01EB_PID 0x01EB
357#define MTXORB_FTDI_RANGE_01EC_PID 0x01EC
358#define MTXORB_FTDI_RANGE_01ED_PID 0x01ED
359#define MTXORB_FTDI_RANGE_01EE_PID 0x01EE
360#define MTXORB_FTDI_RANGE_01EF_PID 0x01EF
361#define MTXORB_FTDI_RANGE_01F0_PID 0x01F0
362#define MTXORB_FTDI_RANGE_01F1_PID 0x01F1
363#define MTXORB_FTDI_RANGE_01F2_PID 0x01F2
364#define MTXORB_FTDI_RANGE_01F3_PID 0x01F3
365#define MTXORB_FTDI_RANGE_01F4_PID 0x01F4
366#define MTXORB_FTDI_RANGE_01F5_PID 0x01F5
367#define MTXORB_FTDI_RANGE_01F6_PID 0x01F6
368#define MTXORB_FTDI_RANGE_01F7_PID 0x01F7
369#define MTXORB_FTDI_RANGE_01F8_PID 0x01F8
370#define MTXORB_FTDI_RANGE_01F9_PID 0x01F9
371#define MTXORB_FTDI_RANGE_01FA_PID 0x01FA
372#define MTXORB_FTDI_RANGE_01FB_PID 0x01FB
373#define MTXORB_FTDI_RANGE_01FC_PID 0x01FC
374#define MTXORB_FTDI_RANGE_01FD_PID 0x01FD
375#define MTXORB_FTDI_RANGE_01FE_PID 0x01FE
376#define MTXORB_FTDI_RANGE_01FF_PID 0x01FF
377
378
122 379
123/* Interbiometrics USB I/O Board */ 380/* Interbiometrics USB I/O Board */
124/* Developed for Interbiometrics by Rudolf Gugler */ 381/* Developed for Interbiometrics by Rudolf Gugler */
@@ -592,6 +849,12 @@
592#define FIC_NEO1973_DEBUG_PID 0x5118 849#define FIC_NEO1973_DEBUG_PID 0x5118
593 850
594/* 851/*
852 * RATOC REX-USB60F
853 */
854#define RATOC_VENDOR_ID 0x0584
855#define RATOC_PRODUCT_ID_USB60F 0xb020
856
857/*
595 * BmRequestType: 1100 0000b 858 * BmRequestType: 1100 0000b
596 * bRequest: FTDI_E2_READ 859 * bRequest: FTDI_E2_READ
597 * wValue: 0 860 * wValue: 0
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c
new file mode 100644
index 000000000000..2e8e05462ef7
--- /dev/null
+++ b/drivers/usb/serial/moto_modem.c
@@ -0,0 +1,70 @@
1/*
2 * Motorola USB Phone driver
3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * {sigh}
11 * Mororola should be using the CDC ACM USB spec, but instead
12 * they try to just "do their own thing"... This driver should handle a
13 * few phones in which a basic "dumb serial connection" is needed to be
14 * able to get a connection through to them.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/tty.h>
20#include <linux/module.h>
21#include <linux/usb.h>
22#include <linux/usb/serial.h>
23
24static struct usb_device_id id_table [] = {
25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */
26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */
27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
28 { },
29};
30MODULE_DEVICE_TABLE(usb, id_table);
31
32static struct usb_driver moto_driver = {
33 .name = "moto-modem",
34 .probe = usb_serial_probe,
35 .disconnect = usb_serial_disconnect,
36 .id_table = id_table,
37 .no_dynamic_id = 1,
38};
39
40static struct usb_serial_driver moto_device = {
41 .driver = {
42 .owner = THIS_MODULE,
43 .name = "moto-modem",
44 },
45 .id_table = id_table,
46 .num_ports = 1,
47};
48
49static int __init moto_init(void)
50{
51 int retval;
52
53 retval = usb_serial_register(&moto_device);
54 if (retval)
55 return retval;
56 retval = usb_register(&moto_driver);
57 if (retval)
58 usb_serial_deregister(&moto_device);
59 return retval;
60}
61
62static void __exit moto_exit(void)
63{
64 usb_deregister(&moto_driver);
65 usb_serial_deregister(&moto_device);
66}
67
68module_init(moto_init);
69module_exit(moto_exit);
70MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e4be2d442b1e..43cfde83a93b 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -154,8 +154,6 @@ static int option_send_setup(struct usb_serial_port *port);
154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100 154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100
155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
156 156
157#define NOVATELWIRELESS_PRODUCT_U727 0x5010
158
159/* FUTURE NOVATEL PRODUCTS */ 157/* FUTURE NOVATEL PRODUCTS */
160#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 158#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000
161#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 159#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000
@@ -184,6 +182,10 @@ static int option_send_setup(struct usb_serial_port *port);
184#define AXESSTEL_VENDOR_ID 0x1726 182#define AXESSTEL_VENDOR_ID 0x1726
185#define AXESSTEL_PRODUCT_MV110H 0x1000 183#define AXESSTEL_PRODUCT_MV110H 0x1000
186 184
185#define ONDA_VENDOR_ID 0x19d2
186#define ONDA_PRODUCT_MSA501HS 0x0001
187#define ONDA_PRODUCT_ET502HS 0x0002
188
187#define BANDRICH_VENDOR_ID 0x1A8D 189#define BANDRICH_VENDOR_ID 0x1A8D
188#define BANDRICH_PRODUCT_C100_1 0x1002 190#define BANDRICH_PRODUCT_C100_1 0x1002
189#define BANDRICH_PRODUCT_C100_2 0x1003 191#define BANDRICH_PRODUCT_C100_2 0x1003
@@ -195,6 +197,9 @@ static int option_send_setup(struct usb_serial_port *port);
195 197
196#define MAXON_VENDOR_ID 0x16d8 198#define MAXON_VENDOR_ID 0x16d8
197 199
200#define TELIT_VENDOR_ID 0x1bc7
201#define TELIT_PRODUCT_UC864E 0x1003
202
198static struct usb_device_id option_ids[] = { 203static struct usb_device_id option_ids[] = {
199 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 204 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
200 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 205 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -231,25 +236,25 @@ static struct usb_device_id option_ids[] = {
231 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_EX) }, 236 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_NETWORK_EX) },
232 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) }, 237 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_MODEM) },
233 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, 238 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) },
234 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 239 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600, 0xff, 0xff, 0xff) },
235 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) }, 240 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220, 0xff, 0xff, 0xff) },
236 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) }, 241 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS, 0xff, 0xff, 0xff) },
237 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1401) }, 242 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1401, 0xff, 0xff, 0xff) },
238 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1403) }, 243 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1403, 0xff, 0xff, 0xff) },
239 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1405) }, 244 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1405, 0xff, 0xff, 0xff) },
240 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1406) }, 245 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1406, 0xff, 0xff, 0xff) },
241 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1408) }, 246 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1408, 0xff, 0xff, 0xff) },
242 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1409) }, 247 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1409, 0xff, 0xff, 0xff) },
243 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1410) }, 248 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1410, 0xff, 0xff, 0xff) },
244 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1411) }, 249 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1411, 0xff, 0xff, 0xff) },
245 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1412) }, 250 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1412, 0xff, 0xff, 0xff) },
246 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1413) }, 251 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1413, 0xff, 0xff, 0xff) },
247 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1414) }, 252 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1414, 0xff, 0xff, 0xff) },
248 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1415) }, 253 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1415, 0xff, 0xff, 0xff) },
249 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1416) }, 254 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1416, 0xff, 0xff, 0xff) },
250 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1417) }, 255 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1417, 0xff, 0xff, 0xff) },
251 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1418) }, 256 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1418, 0xff, 0xff, 0xff) },
252 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1419) }, 257 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1419, 0xff, 0xff, 0xff) },
253 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) }, 258 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) },
254 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */ 259 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */
255 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */ 260 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */
@@ -269,7 +274,6 @@ static struct usb_device_id option_ids[] = {
269 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 276 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel U727 */
273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 277 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */
274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 278 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */
275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ 279 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */
@@ -293,14 +297,18 @@ static struct usb_device_id option_ids[] = {
293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 297 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 298 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 299 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */
300 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
296 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 301 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) },
297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 302 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
298 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 303 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
304 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_MSA501HS) },
305 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) },
299 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 306 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
300 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 307 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
301 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 308 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
302 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 309 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
303 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 310 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
311 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
304 { } /* Terminating entry */ 312 { } /* Terminating entry */
305}; 313};
306MODULE_DEVICE_TABLE(usb, option_ids); 314MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index c605fb68f807..103195abd417 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -56,6 +56,7 @@ static struct usb_device_id id_table [] = {
56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, 57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
58 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, 58 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) },
59 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
59 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 60 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
60 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 61 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
61 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 62 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
@@ -66,7 +67,6 @@ static struct usb_device_id id_table [] = {
66 { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, 67 { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) },
67 { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, 68 { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) },
68 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, 69 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) },
69 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
70 { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, 70 { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) },
71 { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, 71 { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) },
72 { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, 72 { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) },
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 10cf872e5ecb..cff160abb130 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -14,6 +14,7 @@
14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0 14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2
16#define PL2303_PRODUCT_ID_ALDIGA 0x0611 16#define PL2303_PRODUCT_ID_ALDIGA 0x0611
17#define PL2303_PRODUCT_ID_MMX 0x0612
17 18
18#define ATEN_VENDOR_ID 0x0557 19#define ATEN_VENDOR_ID 0x0557
19#define ATEN_VENDOR_ID2 0x0547 20#define ATEN_VENDOR_ID2 0x0547
@@ -36,7 +37,6 @@
36 37
37#define RATOC_VENDOR_ID 0x0584 38#define RATOC_VENDOR_ID 0x0584
38#define RATOC_PRODUCT_ID 0xb000 39#define RATOC_PRODUCT_ID 0xb000
39#define RATOC_PRODUCT_ID_USB60F 0xb020
40 40
41#define TRIPP_VENDOR_ID 0x2478 41#define TRIPP_VENDOR_ID 0x2478
42#define TRIPP_PRODUCT_ID 0x2008 42#define TRIPP_PRODUCT_ID 0x2008
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index a0ed889230aa..45fe3663fa7f 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -401,6 +401,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
401 US_SC_DEVICE, US_PR_DEVICE, NULL, 401 US_SC_DEVICE, US_PR_DEVICE, NULL,
402 US_FL_IGNORE_RESIDUE ), 402 US_FL_IGNORE_RESIDUE ),
403 403
404#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
405UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
406 "Cypress",
407 "Cypress AT2LP",
408 US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
409 0),
410#endif
411
404/* Reported by Simon Levitt <simon@whattf.com> 412/* Reported by Simon Levitt <simon@whattf.com>
405 * This entry needs Sub and Proto fields */ 413 * This entry needs Sub and Proto fields */
406UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, 414UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
@@ -539,17 +547,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
539 "CD-RW Device", 547 "CD-RW Device",
540 US_SC_8020, US_PR_CB, NULL, 0), 548 US_SC_8020, US_PR_CB, NULL, 0),
541 549
542/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
543 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
544 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
545 */
546
547UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
548 "Kobian Mercury",
549 "Binocam DCB-132",
550 US_SC_DEVICE, US_PR_DEVICE, NULL,
551 US_FL_BULK32),
552
553#ifdef CONFIG_USB_STORAGE_USBAT 550#ifdef CONFIG_USB_STORAGE_USBAT
554UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 551UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
555 "Shuttle/SCM", 552 "Shuttle/SCM",
@@ -565,6 +562,16 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
565 US_SC_DEVICE, US_PR_DEVICE, NULL, 562 US_SC_DEVICE, US_PR_DEVICE, NULL,
566 US_FL_MAX_SECTORS_64), 563 US_FL_MAX_SECTORS_64),
567 564
565/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
566 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
567 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
568 */
569UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
570 "Kobian Mercury",
571 "Binocam DCB-132",
572 US_SC_DEVICE, US_PR_DEVICE, NULL,
573 US_FL_BULK32),
574
568/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ 575/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */
569UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, 576UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
570 "Belkin", 577 "Belkin",
@@ -1304,6 +1311,16 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1304 US_SC_DEVICE, US_PR_DEVICE, NULL, 1311 US_SC_DEVICE, US_PR_DEVICE, NULL,
1305 US_FL_IGNORE_DEVICE ), 1312 US_FL_IGNORE_DEVICE ),
1306 1313
1314/* Reported by F. Aben <f.aben@option.com>
1315 * This device (wrongly) has a vendor-specific device descriptor.
1316 * The entry is needed so usb-storage can bind to it's mass-storage
1317 * interface as an interface driver */
1318UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1319 "Option",
1320 "GI 0401 SD-Card",
1321 US_SC_DEVICE, US_PR_DEVICE, NULL,
1322 0 ),
1323
1307#ifdef CONFIG_USB_STORAGE_ISD200 1324#ifdef CONFIG_USB_STORAGE_ISD200
1308UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1325UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1309 "ATI", 1326 "ATI",
@@ -1361,13 +1378,6 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1361 US_SC_DEVICE, US_PR_DEVICE, NULL, 1378 US_SC_DEVICE, US_PR_DEVICE, NULL,
1362 US_FL_FIX_INQUIRY), 1379 US_FL_FIX_INQUIRY),
1363 1380
1364/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1365UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1366 "INTOVA",
1367 "Pixtreme",
1368 US_SC_DEVICE, US_PR_DEVICE, NULL,
1369 US_FL_FIX_CAPACITY ),
1370
1371/* 1381/*
1372 * Entry for Jenoptik JD 5200z3 1382 * Entry for Jenoptik JD 5200z3
1373 * 1383 *
@@ -1512,7 +1522,7 @@ UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
1512 "Sony Ericsson", 1522 "Sony Ericsson",
1513 "M600i", 1523 "M600i",
1514 US_SC_DEVICE, US_PR_DEVICE, NULL, 1524 US_SC_DEVICE, US_PR_DEVICE, NULL,
1515 US_FL_FIX_CAPACITY ), 1525 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
1516 1526
1517/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1527/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1518 * Tested on hardware version 1.10. 1528 * Tested on hardware version 1.10.
@@ -1684,6 +1694,16 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
1684 US_SC_DEVICE, US_PR_DEVICE, NULL, 1694 US_SC_DEVICE, US_PR_DEVICE, NULL,
1685 US_FL_IGNORE_RESIDUE ), 1695 US_FL_IGNORE_RESIDUE ),
1686 1696
1697/* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it>
1698 * This entry is needed to bypass the ZeroCD mechanism
1699 * and to properly load as a modem device.
1700 */
1701UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000,
1702 "Onda ET502HS",
1703 "USB MMC Storage",
1704 US_SC_DEVICE, US_PR_DEVICE, NULL,
1705 US_FL_IGNORE_DEVICE),
1706
1687/* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 1707/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
1688 * and Renato Perini <rperini@email.it> 1708 * and Renato Perini <rperini@email.it>
1689 */ 1709 */
@@ -1696,10 +1716,12 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
1696/* 1716/*
1697 * Patch by Pete Zaitcev <zaitcev@redhat.com> 1717 * Patch by Pete Zaitcev <zaitcev@redhat.com>
1698 * Report by Mark Patton. Red Hat bz#208928. 1718 * Report by Mark Patton. Red Hat bz#208928.
1719 * Added support for rev 0x0002 (Motorola ROKR W5)
1720 * by Javier Smaldone <javier@smaldone.com.ar>
1699 */ 1721 */
1700UNUSUAL_DEV( 0x22b8, 0x4810, 0x0001, 0x0001, 1722UNUSUAL_DEV( 0x22b8, 0x4810, 0x0001, 0x0002,
1701 "Motorola", 1723 "Motorola",
1702 "RAZR V3i", 1724 "RAZR V3i/ROKR W5",
1703 US_SC_DEVICE, US_PR_DEVICE, NULL, 1725 US_SC_DEVICE, US_PR_DEVICE, NULL,
1704 US_FL_FIX_CAPACITY), 1726 US_FL_FIX_CAPACITY),
1705 1727
@@ -1721,6 +1743,13 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1721 US_SC_DEVICE, US_PR_DEVICE, NULL, 1743 US_SC_DEVICE, US_PR_DEVICE, NULL,
1722 US_FL_GO_SLOW ), 1744 US_FL_GO_SLOW ),
1723 1745
1746/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1747UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1748 "INTOVA",
1749 "Pixtreme",
1750 US_SC_DEVICE, US_PR_DEVICE, NULL,
1751 US_FL_FIX_CAPACITY ),
1752
1724/* 1753/*
1725 * David Härdeman <david@2gen.com> 1754 * David Härdeman <david@2gen.com>
1726 * The key makes the SCSI stack print confusing (but harmless) messages 1755 * The key makes the SCSI stack print confusing (but harmless) messages
@@ -1745,14 +1774,6 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1745 US_SC_DEVICE, US_PR_DEVICE, NULL, 1774 US_SC_DEVICE, US_PR_DEVICE, NULL,
1746 US_FL_CAPACITY_HEURISTICS), 1775 US_FL_CAPACITY_HEURISTICS),
1747 1776
1748#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
1749UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
1750 "Cypress",
1751 "Cypress AT2LP",
1752 US_SC_CYP_ATACB, US_PR_BULK, NULL,
1753 0),
1754#endif
1755
1756/* Control/Bulk transport for all SubClass values */ 1777/* Control/Bulk transport for all SubClass values */
1757USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1778USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1758USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1779USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),