aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/cdc-acm.c18
-rw-r--r--drivers/usb/class/usbtmc.c2
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/ether.c9
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c2
-rw-r--r--drivers/usb/gadget/imx_udc.c8
-rw-r--r--drivers/usb/gadget/r8a66597-udc.h105
-rw-r--r--drivers/usb/host/ehci-sched.c13
-rw-r--r--drivers/usb/host/isp1362-hcd.c18
-rw-r--r--drivers/usb/host/isp1362.h12
-rw-r--r--drivers/usb/host/ohci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-pci.c20
-rw-r--r--drivers/usb/host/ohci-q.c18
-rw-r--r--drivers/usb/host/ohci.h9
-rw-r--r--drivers/usb/host/pci-quirks.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c23
-rw-r--r--drivers/usb/host/whci/asl.c23
-rw-r--r--drivers/usb/host/whci/pzl.c24
-rw-r--r--drivers/usb/host/xhci-hcd.c29
-rw-r--r--drivers/usb/host/xhci-mem.c10
-rw-r--r--drivers/usb/host/xhci-ring.c7
-rw-r--r--drivers/usb/misc/usblcd.c3
-rw-r--r--drivers/usb/mon/mon_bin.c11
-rw-r--r--drivers/usb/musb/Kconfig4
-rw-r--r--drivers/usb/musb/blackfin.c1
-rw-r--r--drivers/usb/musb/musb_core.h7
-rw-r--r--drivers/usb/musb/musb_regs.h9
-rw-r--r--drivers/usb/serial/aircable.c10
-rw-r--r--drivers/usb/serial/cp210x.c22
-rw-r--r--drivers/usb/serial/cypress_m8.c12
-rw-r--r--drivers/usb/serial/digi_acceleport.c8
-rw-r--r--drivers/usb/serial/empeg.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c422
-rw-r--r--drivers/usb/serial/garmin_gps.c12
-rw-r--r--drivers/usb/serial/generic.c2
-rw-r--r--drivers/usb/serial/ipaq.c9
-rw-r--r--drivers/usb/serial/keyspan_pda.c2
-rw-r--r--drivers/usb/serial/kl5kusb105.c2
-rw-r--r--drivers/usb/serial/mct_u232.c14
-rw-r--r--drivers/usb/serial/opticon.c13
-rw-r--r--drivers/usb/serial/option.c14
-rw-r--r--drivers/usb/serial/oti6858.c6
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/sierra.c40
-rw-r--r--drivers/usb/serial/symbolserial.c22
-rw-r--r--drivers/usb/serial/usb-serial.c10
-rw-r--r--drivers/usb/serial/visor.c28
-rw-r--r--drivers/usb/serial/whiteheat.c10
-rw-r--r--drivers/usb/storage/transport.c46
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/usb/wusbcore/security.c41
51 files changed, 599 insertions, 556 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e3861b21e776..e4eca7810bcf 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -609,9 +609,9 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
609 609
610 acm->throttle = 0; 610 acm->throttle = 0;
611 611
612 tasklet_schedule(&acm->urb_task);
613 set_bit(ASYNCB_INITIALIZED, &acm->port.flags); 612 set_bit(ASYNCB_INITIALIZED, &acm->port.flags);
614 rv = tty_port_block_til_ready(&acm->port, tty, filp); 613 rv = tty_port_block_til_ready(&acm->port, tty, filp);
614 tasklet_schedule(&acm->urb_task);
615done: 615done:
616 mutex_unlock(&acm->mutex); 616 mutex_unlock(&acm->mutex);
617err_out: 617err_out:
@@ -686,15 +686,21 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
686 686
687 /* Perform the closing process and see if we need to do the hardware 687 /* Perform the closing process and see if we need to do the hardware
688 shutdown */ 688 shutdown */
689 if (!acm || tty_port_close_start(&acm->port, tty, filp) == 0) 689 if (!acm)
690 return;
691 if (tty_port_close_start(&acm->port, tty, filp) == 0) {
692 mutex_lock(&open_mutex);
693 if (!acm->dev) {
694 tty_port_tty_set(&acm->port, NULL);
695 acm_tty_unregister(acm);
696 tty->driver_data = NULL;
697 }
698 mutex_unlock(&open_mutex);
690 return; 699 return;
700 }
691 acm_port_down(acm, 0); 701 acm_port_down(acm, 0);
692 tty_port_close_end(&acm->port, tty); 702 tty_port_close_end(&acm->port, tty);
693 mutex_lock(&open_mutex);
694 tty_port_tty_set(&acm->port, NULL); 703 tty_port_tty_set(&acm->port, NULL);
695 if (!acm->dev)
696 acm_tty_unregister(acm);
697 mutex_unlock(&open_mutex);
698} 704}
699 705
700static int acm_tty_write(struct tty_struct *tty, 706static int acm_tty_write(struct tty_struct *tty,
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 864f0ba6a344..2473cf0c6b1d 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -39,7 +39,7 @@
39#define USBTMC_SIZE_IOBUFFER 2048 39#define USBTMC_SIZE_IOBUFFER 2048
40 40
41/* Default USB timeout (in milliseconds) */ 41/* Default USB timeout (in milliseconds) */
42#define USBTMC_TIMEOUT 10 42#define USBTMC_TIMEOUT 5000
43 43
44/* 44/*
45 * Maximum number of read cycles to empty bulk in endpoint during CLEAR and 45 * Maximum number of read cycles to empty bulk in endpoint during CLEAR and
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 33351312327f..a18e3c5dd82e 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -223,6 +223,7 @@ config USB_OTG
223config USB_GADGET_PXA25X 223config USB_GADGET_PXA25X
224 boolean "PXA 25x or IXP 4xx" 224 boolean "PXA 25x or IXP 4xx"
225 depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX 225 depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX
226 select USB_OTG_UTILS
226 help 227 help
227 Intel's PXA 25x series XScale ARM-5TE processors include 228 Intel's PXA 25x series XScale ARM-5TE processors include
228 an integrated full speed USB 1.1 device controller. The 229 an integrated full speed USB 1.1 device controller. The
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index f37de283d0ab..167cb2a8ecef 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -61,11 +61,6 @@
61 * simpler, Microsoft pushes their own approach: RNDIS. The published 61 * simpler, Microsoft pushes their own approach: RNDIS. The published
62 * RNDIS specs are ambiguous and appear to be incomplete, and are also 62 * RNDIS specs are ambiguous and appear to be incomplete, and are also
63 * needlessly complex. They borrow more from CDC ACM than CDC ECM. 63 * needlessly complex. They borrow more from CDC ACM than CDC ECM.
64 *
65 * While CDC ECM, CDC Subset, and RNDIS are designed to extend the ethernet
66 * interface to the target, CDC EEM was designed to use ethernet over the USB
67 * link between the host and target. CDC EEM is implemented as an alternative
68 * to those other protocols when that communication model is more appropriate
69 */ 64 */
70 65
71#define DRIVER_DESC "Ethernet Gadget" 66#define DRIVER_DESC "Ethernet Gadget"
@@ -157,8 +152,8 @@ static inline bool has_rndis(void)
157#define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */ 152#define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */
158 153
159/* For EEM gadgets */ 154/* For EEM gadgets */
160#define EEM_VENDOR_NUM 0x0525 /* INVALID - NEEDS TO BE ALLOCATED */ 155#define EEM_VENDOR_NUM 0x1d6b /* Linux Foundation */
161#define EEM_PRODUCT_NUM 0xa4a1 /* INVALID - NEEDS TO BE ALLOCATED */ 156#define EEM_PRODUCT_NUM 0x0102 /* EEM Gadget */
162 157
163/*-------------------------------------------------------------------------*/ 158/*-------------------------------------------------------------------------*/
164 159
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 42a74b8a0bb8..fa3d142ba64d 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2139,7 +2139,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
2139static void fsl_udc_release(struct device *dev) 2139static void fsl_udc_release(struct device *dev)
2140{ 2140{
2141 complete(udc_controller->done); 2141 complete(udc_controller->done);
2142 dma_free_coherent(dev, udc_controller->ep_qh_size, 2142 dma_free_coherent(dev->parent, udc_controller->ep_qh_size,
2143 udc_controller->ep_qh, udc_controller->ep_qh_dma); 2143 udc_controller->ep_qh, udc_controller->ep_qh_dma);
2144 kfree(udc_controller); 2144 kfree(udc_controller);
2145} 2145}
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index c52a681f376c..01ee0b9bc957 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -1402,7 +1402,8 @@ static int __init imx_udc_probe(struct platform_device *pdev)
1402 struct clk *clk; 1402 struct clk *clk;
1403 void __iomem *base; 1403 void __iomem *base;
1404 int ret = 0; 1404 int ret = 0;
1405 int i, res_size; 1405 int i;
1406 resource_size_t res_size;
1406 1407
1407 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1408 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1408 if (!res) { 1409 if (!res) {
@@ -1416,7 +1417,7 @@ static int __init imx_udc_probe(struct platform_device *pdev)
1416 return -ENODEV; 1417 return -ENODEV;
1417 } 1418 }
1418 1419
1419 res_size = res->end - res->start + 1; 1420 res_size = resource_size(res);
1420 if (!request_mem_region(res->start, res_size, res->name)) { 1421 if (!request_mem_region(res->start, res_size, res->name)) {
1421 dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n", 1422 dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
1422 res_size, res->start); 1423 res_size, res->start);
@@ -1527,8 +1528,7 @@ static int __exit imx_udc_remove(struct platform_device *pdev)
1527 clk_disable(imx_usb->clk); 1528 clk_disable(imx_usb->clk);
1528 iounmap(imx_usb->base); 1529 iounmap(imx_usb->base);
1529 1530
1530 release_mem_region(imx_usb->res->start, 1531 release_mem_region(imx_usb->res->start, resource_size(imx_usb->res));
1531 imx_usb->res->end - imx_usb->res->start + 1);
1532 1532
1533 if (pdata->exit) 1533 if (pdata->exit)
1534 pdata->exit(&pdev->dev); 1534 pdata->exit(&pdev->dev);
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h
index 03087e7b9190..9a537aa07968 100644
--- a/drivers/usb/gadget/r8a66597-udc.h
+++ b/drivers/usb/gadget/r8a66597-udc.h
@@ -131,31 +131,48 @@ static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset)
131} 131}
132 132
133static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, 133static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
134 unsigned long offset, u16 *buf, 134 unsigned long offset,
135 unsigned char *buf,
135 int len) 136 int len)
136{ 137{
138 unsigned long fifoaddr = r8a66597->reg + offset;
139 unsigned int data;
140 int i;
141
137 if (r8a66597->pdata->on_chip) { 142 if (r8a66597->pdata->on_chip) {
138 unsigned long fifoaddr = r8a66597->reg + offset; 143 /* 32-bit accesses for on_chip controllers */
139 unsigned long count; 144
140 union { 145 /* aligned buf case */
141 unsigned long dword; 146 if (len >= 4 && !((unsigned long)buf & 0x03)) {
142 unsigned char byte[4]; 147 insl(fifoaddr, buf, len / 4);
143 } data; 148 buf += len & ~0x03;
144 unsigned char *pb; 149 len &= 0x03;
145 int i; 150 }
146 151
147 count = len / 4; 152 /* unaligned buf case */
148 insl(fifoaddr, buf, count); 153 for (i = 0; i < len; i++) {
149 154 if (!(i & 0x03))
150 if (len & 0x00000003) { 155 data = inl(fifoaddr);
151 data.dword = inl(fifoaddr); 156
152 pb = (unsigned char *)buf + count * 4; 157 buf[i] = (data >> ((i & 0x03) * 8)) & 0xff;
153 for (i = 0; i < (len & 0x00000003); i++)
154 pb[i] = data.byte[i];
155 } 158 }
156 } else { 159 } else {
157 len = (len + 1) / 2; 160 /* 16-bit accesses for external controllers */
158 insw(r8a66597->reg + offset, buf, len); 161
162 /* aligned buf case */
163 if (len >= 2 && !((unsigned long)buf & 0x01)) {
164 insw(fifoaddr, buf, len / 2);
165 buf += len & ~0x01;
166 len &= 0x01;
167 }
168
169 /* unaligned buf case */
170 for (i = 0; i < len; i++) {
171 if (!(i & 0x01))
172 data = inw(fifoaddr);
173
174 buf[i] = (data >> ((i & 0x01) * 8)) & 0xff;
175 }
159 } 176 }
160} 177}
161 178
@@ -166,38 +183,40 @@ static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
166} 183}
167 184
168static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, 185static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
169 unsigned long offset, u16 *buf, 186 unsigned long offset,
187 unsigned char *buf,
170 int len) 188 int len)
171{ 189{
172 unsigned long fifoaddr = r8a66597->reg + offset; 190 unsigned long fifoaddr = r8a66597->reg + offset;
191 int adj = 0;
192 int i;
173 193
174 if (r8a66597->pdata->on_chip) { 194 if (r8a66597->pdata->on_chip) {
175 unsigned long count; 195 /* 32-bit access only if buf is 32-bit aligned */
176 unsigned char *pb; 196 if (len >= 4 && !((unsigned long)buf & 0x03)) {
177 int i; 197 outsl(fifoaddr, buf, len / 4);
178 198 buf += len & ~0x03;
179 count = len / 4; 199 len &= 0x03;
180 outsl(fifoaddr, buf, count);
181
182 if (len & 0x00000003) {
183 pb = (unsigned char *)buf + count * 4;
184 for (i = 0; i < (len & 0x00000003); i++) {
185 if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND)
186 outb(pb[i], fifoaddr + i);
187 else
188 outb(pb[i], fifoaddr + 3 - i);
189 }
190 } 200 }
191 } else { 201 } else {
192 int odd = len & 0x0001; 202 /* 16-bit access only if buf is 16-bit aligned */
193 203 if (len >= 2 && !((unsigned long)buf & 0x01)) {
194 len = len / 2; 204 outsw(fifoaddr, buf, len / 2);
195 outsw(fifoaddr, buf, len); 205 buf += len & ~0x01;
196 if (unlikely(odd)) { 206 len &= 0x01;
197 buf = &buf[len];
198 outb((unsigned char)*buf, fifoaddr);
199 } 207 }
200 } 208 }
209
210 /* adjust fifo address in the little endian case */
211 if (!(r8a66597_read(r8a66597, CFIFOSEL) & BIGEND)) {
212 if (r8a66597->pdata->on_chip)
213 adj = 0x03; /* 32-bit wide */
214 else
215 adj = 0x01; /* 16-bit wide */
216 }
217
218 for (i = 0; i < len; i++)
219 outb(buf[i], fifoaddr + adj - (i & adj));
201} 220}
202 221
203static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, 222static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 3ea05936851f..b25cdea93a1f 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1400,6 +1400,10 @@ iso_stream_schedule (
1400 goto fail; 1400 goto fail;
1401 } 1401 }
1402 1402
1403 period = urb->interval;
1404 if (!stream->highspeed)
1405 period <<= 3;
1406
1403 now = ehci_readl(ehci, &ehci->regs->frame_index) % mod; 1407 now = ehci_readl(ehci, &ehci->regs->frame_index) % mod;
1404 1408
1405 /* when's the last uframe this urb could start? */ 1409 /* when's the last uframe this urb could start? */
@@ -1417,14 +1421,15 @@ iso_stream_schedule (
1417 1421
1418 /* Fell behind (by up to twice the slop amount)? */ 1422 /* Fell behind (by up to twice the slop amount)? */
1419 if (start >= max - 2 * 8 * SCHEDULE_SLOP) 1423 if (start >= max - 2 * 8 * SCHEDULE_SLOP)
1420 start += stream->interval * DIV_ROUND_UP( 1424 start += period * DIV_ROUND_UP(
1421 max - start, stream->interval) - mod; 1425 max - start, period) - mod;
1422 1426
1423 /* Tried to schedule too far into the future? */ 1427 /* Tried to schedule too far into the future? */
1424 if (unlikely((start + sched->span) >= max)) { 1428 if (unlikely((start + sched->span) >= max)) {
1425 status = -EFBIG; 1429 status = -EFBIG;
1426 goto fail; 1430 goto fail;
1427 } 1431 }
1432 stream->next_uframe = start;
1428 goto ready; 1433 goto ready;
1429 } 1434 }
1430 1435
@@ -1440,10 +1445,6 @@ iso_stream_schedule (
1440 1445
1441 /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ 1446 /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */
1442 1447
1443 period = urb->interval;
1444 if (!stream->highspeed)
1445 period <<= 3;
1446
1447 /* find a uframe slot with enough bandwidth */ 1448 /* find a uframe slot with enough bandwidth */
1448 for (; start < (stream->next_uframe + period); start++) { 1449 for (; start < (stream->next_uframe + period); start++) {
1449 int enough_space; 1450 int enough_space;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index e35d82808bab..5c774ab98252 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2284,10 +2284,10 @@ static int isp1362_mem_config(struct usb_hcd *hcd)
2284 dev_info(hcd->self.controller, "ISP1362 Memory usage:\n"); 2284 dev_info(hcd->self.controller, "ISP1362 Memory usage:\n");
2285 dev_info(hcd->self.controller, " ISTL: 2 * %4d: %4d @ $%04x:$%04x\n", 2285 dev_info(hcd->self.controller, " ISTL: 2 * %4d: %4d @ $%04x:$%04x\n",
2286 istl_size / 2, istl_size, 0, istl_size / 2); 2286 istl_size / 2, istl_size, 0, istl_size / 2);
2287 dev_info(hcd->self.controller, " INTL: %4d * (%3u+8): %4d @ $%04x\n", 2287 dev_info(hcd->self.controller, " INTL: %4d * (%3lu+8): %4d @ $%04x\n",
2288 ISP1362_INTL_BUFFERS, intl_blksize - PTD_HEADER_SIZE, 2288 ISP1362_INTL_BUFFERS, intl_blksize - PTD_HEADER_SIZE,
2289 intl_size, istl_size); 2289 intl_size, istl_size);
2290 dev_info(hcd->self.controller, " ATL : %4d * (%3u+8): %4d @ $%04x\n", 2290 dev_info(hcd->self.controller, " ATL : %4d * (%3lu+8): %4d @ $%04x\n",
2291 atl_buffers, atl_blksize - PTD_HEADER_SIZE, 2291 atl_buffers, atl_blksize - PTD_HEADER_SIZE,
2292 atl_size, istl_size + intl_size); 2292 atl_size, istl_size + intl_size);
2293 dev_info(hcd->self.controller, " USED/FREE: %4d %4d\n", total, 2293 dev_info(hcd->self.controller, " USED/FREE: %4d %4d\n", total,
@@ -2677,12 +2677,12 @@ static int __devexit isp1362_remove(struct platform_device *pdev)
2677 DBG(0, "%s: Removing HCD\n", __func__); 2677 DBG(0, "%s: Removing HCD\n", __func__);
2678 usb_remove_hcd(hcd); 2678 usb_remove_hcd(hcd);
2679 2679
2680 DBG(0, "%s: Unmapping data_reg @ %08x\n", __func__, 2680 DBG(0, "%s: Unmapping data_reg @ %p\n", __func__,
2681 (u32)isp1362_hcd->data_reg); 2681 isp1362_hcd->data_reg);
2682 iounmap(isp1362_hcd->data_reg); 2682 iounmap(isp1362_hcd->data_reg);
2683 2683
2684 DBG(0, "%s: Unmapping addr_reg @ %08x\n", __func__, 2684 DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__,
2685 (u32)isp1362_hcd->addr_reg); 2685 isp1362_hcd->addr_reg);
2686 iounmap(isp1362_hcd->addr_reg); 2686 iounmap(isp1362_hcd->addr_reg);
2687 2687
2688 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2688 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -2810,16 +2810,16 @@ static int __init isp1362_probe(struct platform_device *pdev)
2810 return 0; 2810 return 0;
2811 2811
2812 err6: 2812 err6:
2813 DBG(0, "%s: Freeing dev %08x\n", __func__, (u32)isp1362_hcd); 2813 DBG(0, "%s: Freeing dev %p\n", __func__, isp1362_hcd);
2814 usb_put_hcd(hcd); 2814 usb_put_hcd(hcd);
2815 err5: 2815 err5:
2816 DBG(0, "%s: Unmapping data_reg @ %08x\n", __func__, (u32)data_reg); 2816 DBG(0, "%s: Unmapping data_reg @ %p\n", __func__, data_reg);
2817 iounmap(data_reg); 2817 iounmap(data_reg);
2818 err4: 2818 err4:
2819 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start); 2819 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start);
2820 release_mem_region(data->start, resource_len(data)); 2820 release_mem_region(data->start, resource_len(data));
2821 err3: 2821 err3:
2822 DBG(0, "%s: Unmapping addr_reg @ %08x\n", __func__, (u32)addr_reg); 2822 DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__, addr_reg);
2823 iounmap(addr_reg); 2823 iounmap(addr_reg);
2824 err2: 2824 err2:
2825 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start); 2825 DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start);
diff --git a/drivers/usb/host/isp1362.h b/drivers/usb/host/isp1362.h
index fe60f62a32f3..1a253ebf7e50 100644
--- a/drivers/usb/host/isp1362.h
+++ b/drivers/usb/host/isp1362.h
@@ -580,7 +580,7 @@ static inline const char *ISP1362_INT_NAME(int n)
580 580
581static inline void ALIGNSTAT(struct isp1362_hcd *isp1362_hcd, void *ptr) 581static inline void ALIGNSTAT(struct isp1362_hcd *isp1362_hcd, void *ptr)
582{ 582{
583 unsigned p = (unsigned)ptr; 583 unsigned long p = (unsigned long)ptr;
584 if (!(p & 0xf)) 584 if (!(p & 0xf))
585 isp1362_hcd->stat16++; 585 isp1362_hcd->stat16++;
586 else if (!(p & 0x7)) 586 else if (!(p & 0x7))
@@ -770,7 +770,7 @@ static void isp1362_write_fifo(struct isp1362_hcd *isp1362_hcd, void *buf, u16 l
770 if (!len) 770 if (!len)
771 return; 771 return;
772 772
773 if ((unsigned)dp & 0x1) { 773 if ((unsigned long)dp & 0x1) {
774 /* not aligned */ 774 /* not aligned */
775 for (; len > 1; len -= 2) { 775 for (; len > 1; len -= 2) {
776 data = *dp++; 776 data = *dp++;
@@ -962,8 +962,8 @@ static void isp1362_read_buffer(struct isp1362_hcd *isp1362_hcd, void *buf, u16
962 962
963 isp1362_write_diraddr(isp1362_hcd, offset, len); 963 isp1362_write_diraddr(isp1362_hcd, offset, len);
964 964
965 DBG(3, "%s: Reading %d byte from buffer @%04x to memory @ %08x\n", __func__, 965 DBG(3, "%s: Reading %d byte from buffer @%04x to memory @ %p\n",
966 len, offset, (u32)buf); 966 __func__, len, offset, buf);
967 967
968 isp1362_write_reg16(isp1362_hcd, HCuPINT, HCuPINT_EOT); 968 isp1362_write_reg16(isp1362_hcd, HCuPINT, HCuPINT_EOT);
969 _WARN_ON((isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_EOT)); 969 _WARN_ON((isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_EOT));
@@ -982,8 +982,8 @@ static void isp1362_write_buffer(struct isp1362_hcd *isp1362_hcd, void *buf, u16
982 982
983 isp1362_write_diraddr(isp1362_hcd, offset, len); 983 isp1362_write_diraddr(isp1362_hcd, offset, len);
984 984
985 DBG(3, "%s: Writing %d byte to buffer @%04x from memory @ %08x\n", __func__, 985 DBG(3, "%s: Writing %d byte to buffer @%04x from memory @ %p\n",
986 len, offset, (u32)buf); 986 __func__, len, offset, buf);
987 987
988 isp1362_write_reg16(isp1362_hcd, HCuPINT, HCuPINT_EOT); 988 isp1362_write_reg16(isp1362_hcd, HCuPINT, HCuPINT_EOT);
989 _WARN_ON((isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_EOT)); 989 _WARN_ON((isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_EOT));
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 78bb7710f36d..24eb74781919 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -87,6 +87,7 @@ static int ohci_restart (struct ohci_hcd *ohci);
87#ifdef CONFIG_PCI 87#ifdef CONFIG_PCI
88static void quirk_amd_pll(int state); 88static void quirk_amd_pll(int state);
89static void amd_iso_dev_put(void); 89static void amd_iso_dev_put(void);
90static void sb800_prefetch(struct ohci_hcd *ohci, int on);
90#else 91#else
91static inline void quirk_amd_pll(int state) 92static inline void quirk_amd_pll(int state)
92{ 93{
@@ -96,6 +97,10 @@ static inline void amd_iso_dev_put(void)
96{ 97{
97 return; 98 return;
98} 99}
100static inline void sb800_prefetch(struct ohci_hcd *ohci, int on)
101{
102 return;
103}
99#endif 104#endif
100 105
101 106
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index d2ba04dd785e..b8a1148f248e 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -177,6 +177,13 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
177 return 0; 177 return 0;
178 178
179 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev); 179 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);
180
181 /* SB800 needs pre-fetch fix */
182 if ((rev >= 0x40) && (rev <= 0x4f)) {
183 ohci->flags |= OHCI_QUIRK_AMD_PREFETCH;
184 ohci_dbg(ohci, "enabled AMD prefetch quirk\n");
185 }
186
180 if ((rev > 0x3b) || (rev < 0x30)) { 187 if ((rev > 0x3b) || (rev < 0x30)) {
181 pci_dev_put(amd_smbus_dev); 188 pci_dev_put(amd_smbus_dev);
182 amd_smbus_dev = NULL; 189 amd_smbus_dev = NULL;
@@ -262,6 +269,19 @@ static void amd_iso_dev_put(void)
262 269
263} 270}
264 271
272static void sb800_prefetch(struct ohci_hcd *ohci, int on)
273{
274 struct pci_dev *pdev;
275 u16 misc;
276
277 pdev = to_pci_dev(ohci_to_hcd(ohci)->self.controller);
278 pci_read_config_word(pdev, 0x50, &misc);
279 if (on == 0)
280 pci_write_config_word(pdev, 0x50, misc & 0xfcff);
281 else
282 pci_write_config_word(pdev, 0x50, misc | 0x0300);
283}
284
265/* List of quirks for OHCI */ 285/* List of quirks for OHCI */
266static const struct pci_device_id ohci_pci_quirks[] = { 286static const struct pci_device_id ohci_pci_quirks[] = {
267 { 287 {
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 16fecb8ecc39..35288bcae0db 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -49,9 +49,12 @@ __acquires(ohci->lock)
49 switch (usb_pipetype (urb->pipe)) { 49 switch (usb_pipetype (urb->pipe)) {
50 case PIPE_ISOCHRONOUS: 50 case PIPE_ISOCHRONOUS:
51 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--; 51 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--;
52 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 52 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) {
53 && quirk_amdiso(ohci)) 53 if (quirk_amdiso(ohci))
54 quirk_amd_pll(1); 54 quirk_amd_pll(1);
55 if (quirk_amdprefetch(ohci))
56 sb800_prefetch(ohci, 0);
57 }
55 break; 58 break;
56 case PIPE_INTERRUPT: 59 case PIPE_INTERRUPT:
57 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--; 60 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--;
@@ -680,9 +683,12 @@ static void td_submit_urb (
680 data + urb->iso_frame_desc [cnt].offset, 683 data + urb->iso_frame_desc [cnt].offset,
681 urb->iso_frame_desc [cnt].length, urb, cnt); 684 urb->iso_frame_desc [cnt].length, urb, cnt);
682 } 685 }
683 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 686 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) {
684 && quirk_amdiso(ohci)) 687 if (quirk_amdiso(ohci))
685 quirk_amd_pll(0); 688 quirk_amd_pll(0);
689 if (quirk_amdprefetch(ohci))
690 sb800_prefetch(ohci, 1);
691 }
686 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 692 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0
687 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; 693 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0;
688 break; 694 break;
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 222011f6172c..5bf15fed0d9f 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -402,6 +402,7 @@ struct ohci_hcd {
402#define OHCI_QUIRK_FRAME_NO 0x80 /* no big endian frame_no shift */ 402#define OHCI_QUIRK_FRAME_NO 0x80 /* no big endian frame_no shift */
403#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ 403#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */
404#define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/ 404#define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/
405#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
405 // there are also chip quirks/bugs in init logic 406 // there are also chip quirks/bugs in init logic
406 407
407 struct work_struct nec_work; /* Worker for NEC quirk */ 408 struct work_struct nec_work; /* Worker for NEC quirk */
@@ -433,6 +434,10 @@ static inline int quirk_amdiso(struct ohci_hcd *ohci)
433{ 434{
434 return ohci->flags & OHCI_QUIRK_AMD_ISO; 435 return ohci->flags & OHCI_QUIRK_AMD_ISO;
435} 436}
437static inline int quirk_amdprefetch(struct ohci_hcd *ohci)
438{
439 return ohci->flags & OHCI_QUIRK_AMD_PREFETCH;
440}
436#else 441#else
437static inline int quirk_nec(struct ohci_hcd *ohci) 442static inline int quirk_nec(struct ohci_hcd *ohci)
438{ 443{
@@ -446,6 +451,10 @@ static inline int quirk_amdiso(struct ohci_hcd *ohci)
446{ 451{
447 return 0; 452 return 0;
448} 453}
454static inline int quirk_amdprefetch(struct ohci_hcd *ohci)
455{
456 return 0;
457}
449#endif 458#endif
450 459
451/* convert between an hcd pointer and the corresponding ohci_hcd */ 460/* convert between an hcd pointer and the corresponding ohci_hcd */
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 23cf3bde4762..83b5f9cea85a 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -475,4 +475,4 @@ static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
475 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI) 475 else if (pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
476 quirk_usb_handoff_xhci(pdev); 476 quirk_usb_handoff_xhci(pdev);
477} 477}
478DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff); 478DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 749b53742828..e33d36256350 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1003,19 +1003,20 @@ static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port,
1003 if (syssts == SE0) { 1003 if (syssts == SE0) {
1004 r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port)); 1004 r8a66597_write(r8a66597, ~ATTCH, get_intsts_reg(port));
1005 r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port)); 1005 r8a66597_bset(r8a66597, ATTCHE, get_intenb_reg(port));
1006 return; 1006 } else {
1007 } 1007 if (syssts == FS_JSTS)
1008 r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port));
1009 else if (syssts == LS_JSTS)
1010 r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port));
1008 1011
1009 if (syssts == FS_JSTS) 1012 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port));
1010 r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); 1013 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port));
1011 else if (syssts == LS_JSTS)
1012 r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port));
1013 1014
1014 r8a66597_write(r8a66597, ~DTCH, get_intsts_reg(port)); 1015 if (r8a66597->bus_suspended)
1015 r8a66597_bset(r8a66597, DTCHE, get_intenb_reg(port)); 1016 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1017 }
1016 1018
1017 if (r8a66597->bus_suspended) 1019 usb_hcd_poll_rh_status(r8a66597_to_hcd(r8a66597));
1018 usb_hcd_resume_root_hub(r8a66597_to_hcd(r8a66597));
1019} 1020}
1020 1021
1021/* this function must be called with interrupt disabled */ 1022/* this function must be called with interrupt disabled */
@@ -1024,6 +1025,8 @@ static void r8a66597_usb_connect(struct r8a66597 *r8a66597, int port)
1024 u16 speed = get_rh_usb_speed(r8a66597, port); 1025 u16 speed = get_rh_usb_speed(r8a66597, port);
1025 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; 1026 struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
1026 1027
1028 rh->port &= ~((1 << USB_PORT_FEAT_HIGHSPEED) |
1029 (1 << USB_PORT_FEAT_LOWSPEED));
1027 if (speed == HSMODE) 1030 if (speed == HSMODE)
1028 rh->port |= (1 << USB_PORT_FEAT_HIGHSPEED); 1031 rh->port |= (1 << USB_PORT_FEAT_HIGHSPEED);
1029 else if (speed == LSMODE) 1032 else if (speed == LSMODE)
diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c
index c632437c7649..562eba108816 100644
--- a/drivers/usb/host/whci/asl.c
+++ b/drivers/usb/host/whci/asl.c
@@ -115,6 +115,10 @@ static uint32_t process_qset(struct whc *whc, struct whc_qset *qset)
115 if (status & QTD_STS_HALTED) { 115 if (status & QTD_STS_HALTED) {
116 /* Ug, an error. */ 116 /* Ug, an error. */
117 process_halted_qtd(whc, qset, td); 117 process_halted_qtd(whc, qset, td);
118 /* A halted qTD always triggers an update
119 because the qset was either removed or
120 reactivated. */
121 update |= WHC_UPDATE_UPDATED;
118 goto done; 122 goto done;
119 } 123 }
120 124
@@ -305,6 +309,7 @@ int asl_urb_dequeue(struct whc *whc, struct urb *urb, int status)
305 struct whc_urb *wurb = urb->hcpriv; 309 struct whc_urb *wurb = urb->hcpriv;
306 struct whc_qset *qset = wurb->qset; 310 struct whc_qset *qset = wurb->qset;
307 struct whc_std *std, *t; 311 struct whc_std *std, *t;
312 bool has_qtd = false;
308 int ret; 313 int ret;
309 unsigned long flags; 314 unsigned long flags;
310 315
@@ -315,17 +320,21 @@ int asl_urb_dequeue(struct whc *whc, struct urb *urb, int status)
315 goto out; 320 goto out;
316 321
317 list_for_each_entry_safe(std, t, &qset->stds, list_node) { 322 list_for_each_entry_safe(std, t, &qset->stds, list_node) {
318 if (std->urb == urb) 323 if (std->urb == urb) {
324 if (std->qtd)
325 has_qtd = true;
319 qset_free_std(whc, std); 326 qset_free_std(whc, std);
320 else 327 } else
321 std->qtd = NULL; /* so this std is re-added when the qset is */ 328 std->qtd = NULL; /* so this std is re-added when the qset is */
322 } 329 }
323 330
324 asl_qset_remove(whc, qset); 331 if (has_qtd) {
325 wurb->status = status; 332 asl_qset_remove(whc, qset);
326 wurb->is_async = true; 333 wurb->status = status;
327 queue_work(whc->workqueue, &wurb->dequeue_work); 334 wurb->is_async = true;
328 335 queue_work(whc->workqueue, &wurb->dequeue_work);
336 } else
337 qset_remove_urb(whc, qset, urb, status);
329out: 338out:
330 spin_unlock_irqrestore(&whc->lock, flags); 339 spin_unlock_irqrestore(&whc->lock, flags);
331 340
diff --git a/drivers/usb/host/whci/pzl.c b/drivers/usb/host/whci/pzl.c
index a9e05bac6646..0db3fb2dc03a 100644
--- a/drivers/usb/host/whci/pzl.c
+++ b/drivers/usb/host/whci/pzl.c
@@ -121,6 +121,10 @@ static enum whc_update pzl_process_qset(struct whc *whc, struct whc_qset *qset)
121 if (status & QTD_STS_HALTED) { 121 if (status & QTD_STS_HALTED) {
122 /* Ug, an error. */ 122 /* Ug, an error. */
123 process_halted_qtd(whc, qset, td); 123 process_halted_qtd(whc, qset, td);
124 /* A halted qTD always triggers an update
125 because the qset was either removed or
126 reactivated. */
127 update |= WHC_UPDATE_UPDATED;
124 goto done; 128 goto done;
125 } 129 }
126 130
@@ -333,6 +337,7 @@ int pzl_urb_dequeue(struct whc *whc, struct urb *urb, int status)
333 struct whc_urb *wurb = urb->hcpriv; 337 struct whc_urb *wurb = urb->hcpriv;
334 struct whc_qset *qset = wurb->qset; 338 struct whc_qset *qset = wurb->qset;
335 struct whc_std *std, *t; 339 struct whc_std *std, *t;
340 bool has_qtd = false;
336 int ret; 341 int ret;
337 unsigned long flags; 342 unsigned long flags;
338 343
@@ -343,17 +348,22 @@ int pzl_urb_dequeue(struct whc *whc, struct urb *urb, int status)
343 goto out; 348 goto out;
344 349
345 list_for_each_entry_safe(std, t, &qset->stds, list_node) { 350 list_for_each_entry_safe(std, t, &qset->stds, list_node) {
346 if (std->urb == urb) 351 if (std->urb == urb) {
352 if (std->qtd)
353 has_qtd = true;
347 qset_free_std(whc, std); 354 qset_free_std(whc, std);
348 else 355 } else
349 std->qtd = NULL; /* so this std is re-added when the qset is */ 356 std->qtd = NULL; /* so this std is re-added when the qset is */
350 } 357 }
351 358
352 pzl_qset_remove(whc, qset); 359 if (has_qtd) {
353 wurb->status = status; 360 pzl_qset_remove(whc, qset);
354 wurb->is_async = false; 361 update_pzl_hw_view(whc);
355 queue_work(whc->workqueue, &wurb->dequeue_work); 362 wurb->status = status;
356 363 wurb->is_async = false;
364 queue_work(whc->workqueue, &wurb->dequeue_work);
365 } else
366 qset_remove_urb(whc, qset, urb, status);
357out: 367out:
358 spin_unlock_irqrestore(&whc->lock, flags); 368 spin_unlock_irqrestore(&whc->lock, flags);
359 369
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 99911e727e0b..932f99938481 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -335,6 +335,12 @@ void xhci_event_ring_work(unsigned long arg)
335 spin_lock_irqsave(&xhci->lock, flags); 335 spin_lock_irqsave(&xhci->lock, flags);
336 temp = xhci_readl(xhci, &xhci->op_regs->status); 336 temp = xhci_readl(xhci, &xhci->op_regs->status);
337 xhci_dbg(xhci, "op reg status = 0x%x\n", temp); 337 xhci_dbg(xhci, "op reg status = 0x%x\n", temp);
338 if (temp == 0xffffffff) {
339 xhci_dbg(xhci, "HW died, polling stopped.\n");
340 spin_unlock_irqrestore(&xhci->lock, flags);
341 return;
342 }
343
338 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending); 344 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
339 xhci_dbg(xhci, "ir_set 0 pending = 0x%x\n", temp); 345 xhci_dbg(xhci, "ir_set 0 pending = 0x%x\n", temp);
340 xhci_dbg(xhci, "No-op commands handled = %d\n", xhci->noops_handled); 346 xhci_dbg(xhci, "No-op commands handled = %d\n", xhci->noops_handled);
@@ -776,6 +782,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
776{ 782{
777 unsigned long flags; 783 unsigned long flags;
778 int ret; 784 int ret;
785 u32 temp;
779 struct xhci_hcd *xhci; 786 struct xhci_hcd *xhci;
780 struct xhci_td *td; 787 struct xhci_td *td;
781 unsigned int ep_index; 788 unsigned int ep_index;
@@ -788,6 +795,17 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
788 ret = usb_hcd_check_unlink_urb(hcd, urb, status); 795 ret = usb_hcd_check_unlink_urb(hcd, urb, status);
789 if (ret || !urb->hcpriv) 796 if (ret || !urb->hcpriv)
790 goto done; 797 goto done;
798 temp = xhci_readl(xhci, &xhci->op_regs->status);
799 if (temp == 0xffffffff) {
800 xhci_dbg(xhci, "HW died, freeing TD.\n");
801 td = (struct xhci_td *) urb->hcpriv;
802
803 usb_hcd_unlink_urb_from_ep(hcd, urb);
804 spin_unlock_irqrestore(&xhci->lock, flags);
805 usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, -ESHUTDOWN);
806 kfree(td);
807 return ret;
808 }
791 809
792 xhci_dbg(xhci, "Cancel URB %p\n", urb); 810 xhci_dbg(xhci, "Cancel URB %p\n", urb);
793 xhci_dbg(xhci, "Event ring:\n"); 811 xhci_dbg(xhci, "Event ring:\n");
@@ -877,7 +895,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
877 ctrl_ctx->drop_flags |= drop_flag; 895 ctrl_ctx->drop_flags |= drop_flag;
878 new_drop_flags = ctrl_ctx->drop_flags; 896 new_drop_flags = ctrl_ctx->drop_flags;
879 897
880 ctrl_ctx->add_flags = ~drop_flag; 898 ctrl_ctx->add_flags &= ~drop_flag;
881 new_add_flags = ctrl_ctx->add_flags; 899 new_add_flags = ctrl_ctx->add_flags;
882 900
883 last_ctx = xhci_last_valid_endpoint(ctrl_ctx->add_flags); 901 last_ctx = xhci_last_valid_endpoint(ctrl_ctx->add_flags);
@@ -1410,11 +1428,20 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
1410{ 1428{
1411 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 1429 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
1412 unsigned long flags; 1430 unsigned long flags;
1431 u32 state;
1413 1432
1414 if (udev->slot_id == 0) 1433 if (udev->slot_id == 0)
1415 return; 1434 return;
1416 1435
1417 spin_lock_irqsave(&xhci->lock, flags); 1436 spin_lock_irqsave(&xhci->lock, flags);
1437 /* Don't disable the slot if the host controller is dead. */
1438 state = xhci_readl(xhci, &xhci->op_regs->status);
1439 if (state == 0xffffffff) {
1440 xhci_free_virt_device(xhci, udev->slot_id);
1441 spin_unlock_irqrestore(&xhci->lock, flags);
1442 return;
1443 }
1444
1418 if (xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id)) { 1445 if (xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id)) {
1419 spin_unlock_irqrestore(&xhci->lock, flags); 1446 spin_unlock_irqrestore(&xhci->lock, flags);
1420 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); 1447 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1db4fea8c170..b8fd270a8b0d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -802,9 +802,11 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
802 int i; 802 int i;
803 803
804 /* Free the Event Ring Segment Table and the actual Event Ring */ 804 /* Free the Event Ring Segment Table and the actual Event Ring */
805 xhci_writel(xhci, 0, &xhci->ir_set->erst_size); 805 if (xhci->ir_set) {
806 xhci_write_64(xhci, 0, &xhci->ir_set->erst_base); 806 xhci_writel(xhci, 0, &xhci->ir_set->erst_size);
807 xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue); 807 xhci_write_64(xhci, 0, &xhci->ir_set->erst_base);
808 xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue);
809 }
808 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 810 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
809 if (xhci->erst.entries) 811 if (xhci->erst.entries)
810 pci_free_consistent(pdev, size, 812 pci_free_consistent(pdev, size,
@@ -841,9 +843,9 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
841 xhci->dcbaa, xhci->dcbaa->dma); 843 xhci->dcbaa, xhci->dcbaa->dma);
842 xhci->dcbaa = NULL; 844 xhci->dcbaa = NULL;
843 845
846 scratchpad_free(xhci);
844 xhci->page_size = 0; 847 xhci->page_size = 0;
845 xhci->page_shift = 0; 848 xhci->page_shift = 0;
846 scratchpad_free(xhci);
847} 849}
848 850
849int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 851int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 173c39c76489..821b7b4709de 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -864,9 +864,11 @@ static struct xhci_segment *trb_in_td(
864 cur_seg = start_seg; 864 cur_seg = start_seg;
865 865
866 do { 866 do {
867 if (start_dma == 0)
868 return 0;
867 /* We may get an event for a Link TRB in the middle of a TD */ 869 /* We may get an event for a Link TRB in the middle of a TD */
868 end_seg_dma = xhci_trb_virt_to_dma(cur_seg, 870 end_seg_dma = xhci_trb_virt_to_dma(cur_seg,
869 &start_seg->trbs[TRBS_PER_SEGMENT - 1]); 871 &cur_seg->trbs[TRBS_PER_SEGMENT - 1]);
870 /* If the end TRB isn't in this segment, this is set to 0 */ 872 /* If the end TRB isn't in this segment, this is set to 0 */
871 end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb); 873 end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb);
872 874
@@ -893,8 +895,9 @@ static struct xhci_segment *trb_in_td(
893 } 895 }
894 cur_seg = cur_seg->next; 896 cur_seg = cur_seg->next;
895 start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]); 897 start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]);
896 } while (1); 898 } while (cur_seg != start_seg);
897 899
900 return 0;
898} 901}
899 902
900/* 903/*
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 29092b8e59ce..4fb120357c55 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -313,7 +313,8 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id
313 313
314 if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) { 314 if (le16_to_cpu(dev->udev->descriptor.idProduct) != 0x0001) {
315 dev_warn(&interface->dev, "USBLCD model not supported.\n"); 315 dev_warn(&interface->dev, "USBLCD model not supported.\n");
316 return -ENODEV; 316 retval = -ENODEV;
317 goto error;
317 } 318 }
318 319
319 /* set up the endpoint information */ 320 /* set up the endpoint information */
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 9ed3e741bee1..10f3205798e8 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -348,12 +348,12 @@ static unsigned int mon_buff_area_alloc_contiguous(struct mon_reader_bin *rp,
348 348
349/* 349/*
350 * Return a few (kilo-)bytes to the head of the buffer. 350 * Return a few (kilo-)bytes to the head of the buffer.
351 * This is used if a DMA fetch fails. 351 * This is used if a data fetch fails.
352 */ 352 */
353static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int size) 353static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int size)
354{ 354{
355 355
356 size = (size + PKT_ALIGN-1) & ~(PKT_ALIGN-1); 356 /* size &= ~(PKT_ALIGN-1); -- we're called with aligned size */
357 rp->b_cnt -= size; 357 rp->b_cnt -= size;
358 if (rp->b_in < size) 358 if (rp->b_in < size)
359 rp->b_in += rp->b_size; 359 rp->b_in += rp->b_size;
@@ -433,6 +433,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
433 unsigned int urb_length; 433 unsigned int urb_length;
434 unsigned int offset; 434 unsigned int offset;
435 unsigned int length; 435 unsigned int length;
436 unsigned int delta;
436 unsigned int ndesc, lendesc; 437 unsigned int ndesc, lendesc;
437 unsigned char dir; 438 unsigned char dir;
438 struct mon_bin_hdr *ep; 439 struct mon_bin_hdr *ep;
@@ -537,8 +538,10 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
537 if (length != 0) { 538 if (length != 0) {
538 ep->flag_data = mon_bin_get_data(rp, offset, urb, length); 539 ep->flag_data = mon_bin_get_data(rp, offset, urb, length);
539 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */ 540 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */
540 ep->len_cap = 0; 541 delta = (ep->len_cap + PKT_ALIGN-1) & ~(PKT_ALIGN-1);
541 mon_buff_area_shrink(rp, length); 542 ep->len_cap -= length;
543 delta -= (ep->len_cap + PKT_ALIGN-1) & ~(PKT_ALIGN-1);
544 mon_buff_area_shrink(rp, delta);
542 } 545 }
543 } else { 546 } else {
544 ep->flag_data = data_tag; 547 ep->flag_data = data_tag;
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 803adcb5ac1d..b84abd8ee8a5 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -8,8 +8,8 @@ comment "Enable Host or Gadget support to see Inventra options"
8 8
9# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller 9# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
10config USB_MUSB_HDRC 10config USB_MUSB_HDRC
11 depends on (USB || USB_GADGET) && HAVE_CLK 11 depends on (USB || USB_GADGET)
12 depends on !SUPERH 12 depends on (ARM || BLACKFIN)
13 select NOP_USB_XCEIV if ARCH_DAVINCI 13 select NOP_USB_XCEIV if ARCH_DAVINCI
14 select TWL4030_USB if MACH_OMAP_3430SDP 14 select TWL4030_USB if MACH_OMAP_3430SDP
15 select NOP_USB_XCEIV if MACH_OMAP3EVM 15 select NOP_USB_XCEIV if MACH_OMAP3EVM
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index f2f66ebc7362..fcec87ea709e 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -14,7 +14,6 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/clk.h>
18#include <linux/gpio.h> 17#include <linux/gpio.h>
19#include <linux/io.h> 18#include <linux/io.h>
20 19
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 381d648a36b8..6aa5f22e5274 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -95,6 +95,13 @@ struct musb_ep;
95#endif 95#endif
96#endif /* need MUSB gadget selection */ 96#endif /* need MUSB gadget selection */
97 97
98#ifndef CONFIG_HAVE_CLK
99/* Dummy stub for clk framework */
100#define clk_get(dev, id) NULL
101#define clk_put(clock) do {} while (0)
102#define clk_enable(clock) do {} while (0)
103#define clk_disable(clock) do {} while (0)
104#endif
98 105
99#ifdef CONFIG_PROC_FS 106#ifdef CONFIG_PROC_FS
100#include <linux/fs.h> 107#include <linux/fs.h>
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index fbfd3fd9ce1f..cc1d71b57d3c 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -439,15 +439,6 @@ static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
439/* Not implemented - HW has seperate Tx/Rx FIFO */ 439/* Not implemented - HW has seperate Tx/Rx FIFO */
440#define MUSB_TXCSR_MODE 0x0000 440#define MUSB_TXCSR_MODE 0x0000
441 441
442/*
443 * Dummy stub for clk framework, it will be removed
444 * until Blackfin supports clk framework
445 */
446#define clk_get(dev, id) NULL
447#define clk_put(clock) do {} while (0)
448#define clk_enable(clock) do {} while (0)
449#define clk_disable(clock) do {} while (0)
450
451static inline void musb_write_txfifosz(void __iomem *mbase, u8 c_size) 442static inline void musb_write_txfifosz(void __iomem *mbase, u8 c_size)
452{ 443{
453} 444}
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 2cbfab3716e5..b10ac8409411 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -554,13 +554,12 @@ static void aircable_throttle(struct tty_struct *tty)
554{ 554{
555 struct usb_serial_port *port = tty->driver_data; 555 struct usb_serial_port *port = tty->driver_data;
556 struct aircable_private *priv = usb_get_serial_port_data(port); 556 struct aircable_private *priv = usb_get_serial_port_data(port);
557 unsigned long flags;
558 557
559 dbg("%s - port %d", __func__, port->number); 558 dbg("%s - port %d", __func__, port->number);
560 559
561 spin_lock_irqsave(&priv->rx_lock, flags); 560 spin_lock_irq(&priv->rx_lock);
562 priv->rx_flags |= THROTTLED; 561 priv->rx_flags |= THROTTLED;
563 spin_unlock_irqrestore(&priv->rx_lock, flags); 562 spin_unlock_irq(&priv->rx_lock);
564} 563}
565 564
566/* Based on ftdi_sio.c unthrottle */ 565/* Based on ftdi_sio.c unthrottle */
@@ -569,14 +568,13 @@ static void aircable_unthrottle(struct tty_struct *tty)
569 struct usb_serial_port *port = tty->driver_data; 568 struct usb_serial_port *port = tty->driver_data;
570 struct aircable_private *priv = usb_get_serial_port_data(port); 569 struct aircable_private *priv = usb_get_serial_port_data(port);
571 int actually_throttled; 570 int actually_throttled;
572 unsigned long flags;
573 571
574 dbg("%s - port %d", __func__, port->number); 572 dbg("%s - port %d", __func__, port->number);
575 573
576 spin_lock_irqsave(&priv->rx_lock, flags); 574 spin_lock_irq(&priv->rx_lock);
577 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 575 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
578 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 576 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
579 spin_unlock_irqrestore(&priv->rx_lock, flags); 577 spin_unlock_irq(&priv->rx_lock);
580 578
581 if (actually_throttled) 579 if (actually_throttled)
582 schedule_work(&priv->rx_work); 580 schedule_work(&priv->rx_work);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 4a208fe85bc9..bd254ec97d14 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -50,6 +50,8 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, struct file *,
50static void cp210x_break_ctl(struct tty_struct *, int); 50static void cp210x_break_ctl(struct tty_struct *, int);
51static int cp210x_startup(struct usb_serial *); 51static int cp210x_startup(struct usb_serial *);
52static void cp210x_disconnect(struct usb_serial *); 52static void cp210x_disconnect(struct usb_serial *);
53static void cp210x_dtr_rts(struct usb_serial_port *p, int on);
54static int cp210x_carrier_raised(struct usb_serial_port *p);
53 55
54static int debug; 56static int debug;
55 57
@@ -113,6 +115,7 @@ static struct usb_device_id id_table [] = {
113 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ 115 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */
114 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 116 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
115 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 117 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
118 { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
116 { } /* Terminating Entry */ 119 { } /* Terminating Entry */
117}; 120};
118 121
@@ -142,6 +145,8 @@ static struct usb_serial_driver cp210x_device = {
142 .tiocmset = cp210x_tiocmset, 145 .tiocmset = cp210x_tiocmset,
143 .attach = cp210x_startup, 146 .attach = cp210x_startup,
144 .disconnect = cp210x_disconnect, 147 .disconnect = cp210x_disconnect,
148 .dtr_rts = cp210x_dtr_rts,
149 .carrier_raised = cp210x_carrier_raised
145}; 150};
146 151
147/* Config request types */ 152/* Config request types */
@@ -745,6 +750,14 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, struct file *file,
745 return cp210x_set_config(port, CP210X_SET_MHS, &control, 2); 750 return cp210x_set_config(port, CP210X_SET_MHS, &control, 2);
746} 751}
747 752
753static void cp210x_dtr_rts(struct usb_serial_port *p, int on)
754{
755 if (on)
756 cp210x_tiocmset_port(p, NULL, TIOCM_DTR|TIOCM_RTS, 0);
757 else
758 cp210x_tiocmset_port(p, NULL, 0, TIOCM_DTR|TIOCM_RTS);
759}
760
748static int cp210x_tiocmget (struct tty_struct *tty, struct file *file) 761static int cp210x_tiocmget (struct tty_struct *tty, struct file *file)
749{ 762{
750 struct usb_serial_port *port = tty->driver_data; 763 struct usb_serial_port *port = tty->driver_data;
@@ -767,6 +780,15 @@ static int cp210x_tiocmget (struct tty_struct *tty, struct file *file)
767 return result; 780 return result;
768} 781}
769 782
783static int cp210x_carrier_raised(struct usb_serial_port *p)
784{
785 unsigned int control;
786 cp210x_get_config(p, CP210X_GET_MDMSTS, &control, 1);
787 if (control & CONTROL_DCD)
788 return 1;
789 return 0;
790}
791
770static void cp210x_break_ctl (struct tty_struct *tty, int break_state) 792static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
771{ 793{
772 struct usb_serial_port *port = tty->driver_data; 794 struct usb_serial_port *port = tty->driver_data;
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index e0a8b715f2f2..a591ebec0f89 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1155,13 +1155,12 @@ static void cypress_throttle(struct tty_struct *tty)
1155{ 1155{
1156 struct usb_serial_port *port = tty->driver_data; 1156 struct usb_serial_port *port = tty->driver_data;
1157 struct cypress_private *priv = usb_get_serial_port_data(port); 1157 struct cypress_private *priv = usb_get_serial_port_data(port);
1158 unsigned long flags;
1159 1158
1160 dbg("%s - port %d", __func__, port->number); 1159 dbg("%s - port %d", __func__, port->number);
1161 1160
1162 spin_lock_irqsave(&priv->lock, flags); 1161 spin_lock_irq(&priv->lock);
1163 priv->rx_flags = THROTTLED; 1162 priv->rx_flags = THROTTLED;
1164 spin_unlock_irqrestore(&priv->lock, flags); 1163 spin_unlock_irq(&priv->lock);
1165} 1164}
1166 1165
1167 1166
@@ -1170,14 +1169,13 @@ static void cypress_unthrottle(struct tty_struct *tty)
1170 struct usb_serial_port *port = tty->driver_data; 1169 struct usb_serial_port *port = tty->driver_data;
1171 struct cypress_private *priv = usb_get_serial_port_data(port); 1170 struct cypress_private *priv = usb_get_serial_port_data(port);
1172 int actually_throttled, result; 1171 int actually_throttled, result;
1173 unsigned long flags;
1174 1172
1175 dbg("%s - port %d", __func__, port->number); 1173 dbg("%s - port %d", __func__, port->number);
1176 1174
1177 spin_lock_irqsave(&priv->lock, flags); 1175 spin_lock_irq(&priv->lock);
1178 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 1176 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
1179 priv->rx_flags = 0; 1177 priv->rx_flags = 0;
1180 spin_unlock_irqrestore(&priv->lock, flags); 1178 spin_unlock_irq(&priv->lock);
1181 1179
1182 if (!priv->comm_is_ok) 1180 if (!priv->comm_is_ok)
1183 return; 1181 return;
@@ -1185,7 +1183,7 @@ static void cypress_unthrottle(struct tty_struct *tty)
1185 if (actually_throttled) { 1183 if (actually_throttled) {
1186 port->interrupt_in_urb->dev = port->serial->dev; 1184 port->interrupt_in_urb->dev = port->serial->dev;
1187 1185
1188 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1186 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
1189 if (result) { 1187 if (result) {
1190 dev_err(&port->dev, "%s - failed submitting read urb, " 1188 dev_err(&port->dev, "%s - failed submitting read urb, "
1191 "error %d\n", __func__, result); 1189 "error %d\n", __func__, result);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index ab3dd991586b..68e80be6b9e1 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -898,16 +898,16 @@ static void digi_rx_unthrottle(struct tty_struct *tty)
898 898
899 spin_lock_irqsave(&priv->dp_port_lock, flags); 899 spin_lock_irqsave(&priv->dp_port_lock, flags);
900 900
901 /* turn throttle off */
902 priv->dp_throttled = 0;
903 priv->dp_throttle_restart = 0;
904
905 /* restart read chain */ 901 /* restart read chain */
906 if (priv->dp_throttle_restart) { 902 if (priv->dp_throttle_restart) {
907 port->read_urb->dev = port->serial->dev; 903 port->read_urb->dev = port->serial->dev;
908 ret = usb_submit_urb(port->read_urb, GFP_ATOMIC); 904 ret = usb_submit_urb(port->read_urb, GFP_ATOMIC);
909 } 905 }
910 906
907 /* turn throttle off */
908 priv->dp_throttled = 0;
909 priv->dp_throttle_restart = 0;
910
911 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 911 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
912 912
913 if (ret) 913 if (ret)
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 33c9e9cf9eb2..7dd0e3eadbe6 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -391,7 +391,7 @@ static void empeg_unthrottle(struct tty_struct *tty)
391 dbg("%s - port %d", __func__, port->number); 391 dbg("%s - port %d", __func__, port->number);
392 392
393 port->read_urb->dev = port->serial->dev; 393 port->read_urb->dev = port->serial->dev;
394 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 394 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
395 if (result) 395 if (result)
396 dev_err(&port->dev, 396 dev_err(&port->dev,
397 "%s - failed submitting read urb, error %d\n", 397 "%s - failed submitting read urb, error %d\n",
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4f883b1773d0..9c60d6d4908a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -76,13 +76,7 @@ struct ftdi_private {
76 unsigned long last_dtr_rts; /* saved modem control outputs */ 76 unsigned long last_dtr_rts; /* saved modem control outputs */
77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 77 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
78 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 78 char prev_status, diff_status; /* Used for TIOCMIWAIT */
79 __u8 rx_flags; /* receive state flags (throttling) */
80 spinlock_t rx_lock; /* spinlock for receive state */
81 struct delayed_work rx_work;
82 struct usb_serial_port *port; 79 struct usb_serial_port *port;
83 int rx_processed;
84 unsigned long rx_bytes;
85
86 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface 80 __u16 interface; /* FT2232C, FT2232H or FT4232H port interface
87 (0 for FT232/245) */ 81 (0 for FT232/245) */
88 82
@@ -737,10 +731,6 @@ static const char *ftdi_chip_name[] = {
737/* Constants for read urb and write urb */ 731/* Constants for read urb and write urb */
738#define BUFSZ 512 732#define BUFSZ 512
739 733
740/* rx_flags */
741#define THROTTLED 0x01
742#define ACTUALLY_THROTTLED 0x02
743
744/* Used for TIOCMIWAIT */ 734/* Used for TIOCMIWAIT */
745#define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD) 735#define FTDI_STATUS_B0_MASK (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
746#define FTDI_STATUS_B1_MASK (FTDI_RS_BI) 736#define FTDI_STATUS_B1_MASK (FTDI_RS_BI)
@@ -763,7 +753,7 @@ static int ftdi_write_room(struct tty_struct *tty);
763static int ftdi_chars_in_buffer(struct tty_struct *tty); 753static int ftdi_chars_in_buffer(struct tty_struct *tty);
764static void ftdi_write_bulk_callback(struct urb *urb); 754static void ftdi_write_bulk_callback(struct urb *urb);
765static void ftdi_read_bulk_callback(struct urb *urb); 755static void ftdi_read_bulk_callback(struct urb *urb);
766static void ftdi_process_read(struct work_struct *work); 756static void ftdi_process_read(struct usb_serial_port *port);
767static void ftdi_set_termios(struct tty_struct *tty, 757static void ftdi_set_termios(struct tty_struct *tty,
768 struct usb_serial_port *port, struct ktermios *old); 758 struct usb_serial_port *port, struct ktermios *old);
769static int ftdi_tiocmget(struct tty_struct *tty, struct file *file); 759static int ftdi_tiocmget(struct tty_struct *tty, struct file *file);
@@ -1234,7 +1224,6 @@ static int set_serial_info(struct tty_struct *tty,
1234 (new_serial.flags & ASYNC_FLAGS)); 1224 (new_serial.flags & ASYNC_FLAGS));
1235 priv->custom_divisor = new_serial.custom_divisor; 1225 priv->custom_divisor = new_serial.custom_divisor;
1236 1226
1237 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1238 write_latency_timer(port); 1227 write_latency_timer(port);
1239 1228
1240check_and_exit: 1229check_and_exit:
@@ -1527,7 +1516,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1527 } 1516 }
1528 1517
1529 kref_init(&priv->kref); 1518 kref_init(&priv->kref);
1530 spin_lock_init(&priv->rx_lock);
1531 spin_lock_init(&priv->tx_lock); 1519 spin_lock_init(&priv->tx_lock);
1532 init_waitqueue_head(&priv->delta_msr_wait); 1520 init_waitqueue_head(&priv->delta_msr_wait);
1533 /* This will push the characters through immediately rather 1521 /* This will push the characters through immediately rather
@@ -1549,7 +1537,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1549 port->read_urb->transfer_buffer_length = BUFSZ; 1537 port->read_urb->transfer_buffer_length = BUFSZ;
1550 } 1538 }
1551 1539
1552 INIT_DELAYED_WORK(&priv->rx_work, ftdi_process_read);
1553 priv->port = port; 1540 priv->port = port;
1554 1541
1555 /* Free port's existing write urb and transfer buffer. */ 1542 /* Free port's existing write urb and transfer buffer. */
@@ -1686,6 +1673,26 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1686 return 0; 1673 return 0;
1687} 1674}
1688 1675
1676static int ftdi_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
1677{
1678 struct urb *urb = port->read_urb;
1679 struct usb_serial *serial = port->serial;
1680 int result;
1681
1682 usb_fill_bulk_urb(urb, serial->dev,
1683 usb_rcvbulkpipe(serial->dev,
1684 port->bulk_in_endpointAddress),
1685 urb->transfer_buffer,
1686 urb->transfer_buffer_length,
1687 ftdi_read_bulk_callback, port);
1688 result = usb_submit_urb(urb, mem_flags);
1689 if (result)
1690 dev_err(&port->dev,
1691 "%s - failed submitting read urb, error %d\n",
1692 __func__, result);
1693 return result;
1694}
1695
1689static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) 1696static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1690{ /* ftdi_open */ 1697{ /* ftdi_open */
1691 struct usb_device *dev = port->serial->dev; 1698 struct usb_device *dev = port->serial->dev;
@@ -1700,12 +1707,6 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1700 spin_lock_irqsave(&priv->tx_lock, flags); 1707 spin_lock_irqsave(&priv->tx_lock, flags);
1701 priv->tx_bytes = 0; 1708 priv->tx_bytes = 0;
1702 spin_unlock_irqrestore(&priv->tx_lock, flags); 1709 spin_unlock_irqrestore(&priv->tx_lock, flags);
1703 spin_lock_irqsave(&priv->rx_lock, flags);
1704 priv->rx_bytes = 0;
1705 spin_unlock_irqrestore(&priv->rx_lock, flags);
1706
1707 if (tty)
1708 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1709 1710
1710 write_latency_timer(port); 1711 write_latency_timer(port);
1711 1712
@@ -1725,23 +1726,14 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1725 ftdi_set_termios(tty, port, tty->termios); 1726 ftdi_set_termios(tty, port, tty->termios);
1726 1727
1727 /* Not throttled */ 1728 /* Not throttled */
1728 spin_lock_irqsave(&priv->rx_lock, flags); 1729 spin_lock_irqsave(&port->lock, flags);
1729 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 1730 port->throttled = 0;
1730 spin_unlock_irqrestore(&priv->rx_lock, flags); 1731 port->throttle_req = 0;
1732 spin_unlock_irqrestore(&port->lock, flags);
1731 1733
1732 /* Start reading from the device */ 1734 /* Start reading from the device */
1733 priv->rx_processed = 0; 1735 result = ftdi_submit_read_urb(port, GFP_KERNEL);
1734 usb_fill_bulk_urb(port->read_urb, dev, 1736 if (!result)
1735 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
1736 port->read_urb->transfer_buffer,
1737 port->read_urb->transfer_buffer_length,
1738 ftdi_read_bulk_callback, port);
1739 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
1740 if (result)
1741 dev_err(&port->dev,
1742 "%s - failed submitting read urb, error %d\n",
1743 __func__, result);
1744 else
1745 kref_get(&priv->kref); 1737 kref_get(&priv->kref);
1746 1738
1747 return result; 1739 return result;
@@ -1787,10 +1779,6 @@ static void ftdi_close(struct usb_serial_port *port)
1787 1779
1788 dbg("%s", __func__); 1780 dbg("%s", __func__);
1789 1781
1790
1791 /* cancel any scheduled reading */
1792 cancel_delayed_work_sync(&priv->rx_work);
1793
1794 /* shutdown our bulk read */ 1782 /* shutdown our bulk read */
1795 usb_kill_urb(port->read_urb); 1783 usb_kill_urb(port->read_urb);
1796 kref_put(&priv->kref, ftdi_sio_priv_release); 1784 kref_put(&priv->kref, ftdi_sio_priv_release);
@@ -2013,271 +2001,121 @@ static int ftdi_chars_in_buffer(struct tty_struct *tty)
2013 return buffered; 2001 return buffered;
2014} 2002}
2015 2003
2016static void ftdi_read_bulk_callback(struct urb *urb) 2004static int ftdi_process_packet(struct tty_struct *tty,
2005 struct usb_serial_port *port, struct ftdi_private *priv,
2006 char *packet, int len)
2017{ 2007{
2018 struct usb_serial_port *port = urb->context; 2008 int i;
2019 struct tty_struct *tty; 2009 char status;
2020 struct ftdi_private *priv; 2010 char flag;
2021 unsigned long countread; 2011 char *ch;
2022 unsigned long flags;
2023 int status = urb->status;
2024
2025 if (urb->number_of_packets > 0) {
2026 dev_err(&port->dev, "%s transfer_buffer_length %d "
2027 "actual_length %d number of packets %d\n", __func__,
2028 urb->transfer_buffer_length,
2029 urb->actual_length, urb->number_of_packets);
2030 dev_err(&port->dev, "%s transfer_flags %x\n", __func__,
2031 urb->transfer_flags);
2032 }
2033 2012
2034 dbg("%s - port %d", __func__, port->number); 2013 dbg("%s - port %d", __func__, port->number);
2035 2014
2036 if (port->port.count <= 0) 2015 if (len < 2) {
2037 return; 2016 dbg("malformed packet");
2038 2017 return 0;
2039 tty = tty_port_tty_get(&port->port);
2040 if (!tty) {
2041 dbg("%s - bad tty pointer - exiting", __func__);
2042 return;
2043 } 2018 }
2044 2019
2045 priv = usb_get_serial_port_data(port); 2020 /* Compare new line status to the old one, signal if different/
2046 if (!priv) { 2021 N.B. packet may be processed more than once, but differences
2047 dbg("%s - bad port private data pointer - exiting", __func__); 2022 are only processed once. */
2048 goto out; 2023 status = packet[0] & FTDI_STATUS_B0_MASK;
2024 if (status != priv->prev_status) {
2025 priv->diff_status |= status ^ priv->prev_status;
2026 wake_up_interruptible(&priv->delta_msr_wait);
2027 priv->prev_status = status;
2049 } 2028 }
2050 2029
2051 if (urb != port->read_urb) 2030 /*
2052 dev_err(&port->dev, "%s - Not my urb!\n", __func__); 2031 * Although the device uses a bitmask and hence can have multiple
2053 2032 * errors on a packet - the order here sets the priority the error is
2054 if (status) { 2033 * returned to the tty layer.
2055 /* This will happen at close every time so it is a dbg not an 2034 */
2056 err */ 2035 flag = TTY_NORMAL;
2057 dbg("(this is ok on close) nonzero read bulk status received: %d", status); 2036 if (packet[1] & FTDI_RS_OE) {
2058 goto out; 2037 flag = TTY_OVERRUN;
2038 dbg("OVERRRUN error");
2039 }
2040 if (packet[1] & FTDI_RS_BI) {
2041 flag = TTY_BREAK;
2042 dbg("BREAK received");
2043 usb_serial_handle_break(port);
2044 }
2045 if (packet[1] & FTDI_RS_PE) {
2046 flag = TTY_PARITY;
2047 dbg("PARITY error");
2048 }
2049 if (packet[1] & FTDI_RS_FE) {
2050 flag = TTY_FRAME;
2051 dbg("FRAMING error");
2059 } 2052 }
2060 2053
2061 /* count data bytes, but not status bytes */ 2054 len -= 2;
2062 countread = urb->actual_length; 2055 if (!len)
2063 countread -= 2 * DIV_ROUND_UP(countread, priv->max_packet_size); 2056 return 0; /* status only */
2064 spin_lock_irqsave(&priv->rx_lock, flags); 2057 ch = packet + 2;
2065 priv->rx_bytes += countread; 2058
2066 spin_unlock_irqrestore(&priv->rx_lock, flags); 2059 if (!(port->console && port->sysrq) && flag == TTY_NORMAL)
2067 2060 tty_insert_flip_string(tty, ch, len);
2068 ftdi_process_read(&priv->rx_work.work); 2061 else {
2069out: 2062 for (i = 0; i < len; i++, ch++) {
2070 tty_kref_put(tty); 2063 if (!usb_serial_handle_sysrq_char(tty, port, *ch))
2071} /* ftdi_read_bulk_callback */ 2064 tty_insert_flip_char(tty, *ch, flag);
2072 2065 }
2066 }
2067 return len;
2068}
2073 2069
2074static void ftdi_process_read(struct work_struct *work) 2070static void ftdi_process_read(struct usb_serial_port *port)
2075{ /* ftdi_process_read */ 2071{
2076 struct ftdi_private *priv = 2072 struct urb *urb = port->read_urb;
2077 container_of(work, struct ftdi_private, rx_work.work);
2078 struct usb_serial_port *port = priv->port;
2079 struct urb *urb;
2080 struct tty_struct *tty; 2073 struct tty_struct *tty;
2081 char error_flag; 2074 struct ftdi_private *priv = usb_get_serial_port_data(port);
2082 unsigned char *data; 2075 char *data = (char *)urb->transfer_buffer;
2083
2084 int i; 2076 int i;
2085 int result; 2077 int len;
2086 int need_flip; 2078 int count = 0;
2087 int packet_offset;
2088 unsigned long flags;
2089
2090 dbg("%s - port %d", __func__, port->number);
2091
2092 if (port->port.count <= 0)
2093 return;
2094 2079
2095 tty = tty_port_tty_get(&port->port); 2080 tty = tty_port_tty_get(&port->port);
2096 if (!tty) { 2081 if (!tty)
2097 dbg("%s - bad tty pointer - exiting", __func__);
2098 return; 2082 return;
2099 }
2100
2101 priv = usb_get_serial_port_data(port);
2102 if (!priv) {
2103 dbg("%s - bad port private data pointer - exiting", __func__);
2104 goto out;
2105 }
2106
2107 urb = port->read_urb;
2108 if (!urb) {
2109 dbg("%s - bad read_urb pointer - exiting", __func__);
2110 goto out;
2111 }
2112
2113 data = urb->transfer_buffer;
2114 2083
2115 if (priv->rx_processed) { 2084 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) {
2116 dbg("%s - already processed: %d bytes, %d remain", __func__, 2085 len = min_t(int, urb->actual_length - i, priv->max_packet_size);
2117 priv->rx_processed, 2086 count += ftdi_process_packet(tty, port, priv, &data[i], len);
2118 urb->actual_length - priv->rx_processed);
2119 } else {
2120 /* The first two bytes of every read packet are status */
2121 if (urb->actual_length > 2)
2122 usb_serial_debug_data(debug, &port->dev, __func__,
2123 urb->actual_length, data);
2124 else
2125 dbg("Status only: %03oo %03oo", data[0], data[1]);
2126 } 2087 }
2127 2088
2128 2089 if (count)
2129 /* TO DO -- check for hung up line and handle appropriately: */
2130 /* send hangup */
2131 /* See acm.c - you do a tty_hangup - eg tty_hangup(tty) */
2132 /* if CD is dropped and the line is not CLOCAL then we should hangup */
2133
2134 need_flip = 0;
2135 for (packet_offset = priv->rx_processed;
2136 packet_offset < urb->actual_length; packet_offset += priv->max_packet_size) {
2137 int length;
2138
2139 /* Compare new line status to the old one, signal if different/
2140 N.B. packet may be processed more than once, but differences
2141 are only processed once. */
2142 char new_status = data[packet_offset + 0] &
2143 FTDI_STATUS_B0_MASK;
2144 if (new_status != priv->prev_status) {
2145 priv->diff_status |=
2146 new_status ^ priv->prev_status;
2147 wake_up_interruptible(&priv->delta_msr_wait);
2148 priv->prev_status = new_status;
2149 }
2150
2151 length = min_t(u32, priv->max_packet_size, urb->actual_length-packet_offset)-2;
2152 if (length < 0) {
2153 dev_err(&port->dev, "%s - bad packet length: %d\n",
2154 __func__, length+2);
2155 length = 0;
2156 }
2157
2158 if (priv->rx_flags & THROTTLED) {
2159 dbg("%s - throttled", __func__);
2160 break;
2161 }
2162 if (tty_buffer_request_room(tty, length) < length) {
2163 /* break out & wait for throttling/unthrottling to
2164 happen */
2165 dbg("%s - receive room low", __func__);
2166 break;
2167 }
2168
2169 /* Handle errors and break */
2170 error_flag = TTY_NORMAL;
2171 /* Although the device uses a bitmask and hence can have
2172 multiple errors on a packet - the order here sets the
2173 priority the error is returned to the tty layer */
2174
2175 if (data[packet_offset+1] & FTDI_RS_OE) {
2176 error_flag = TTY_OVERRUN;
2177 dbg("OVERRRUN error");
2178 }
2179 if (data[packet_offset+1] & FTDI_RS_BI) {
2180 error_flag = TTY_BREAK;
2181 dbg("BREAK received");
2182 usb_serial_handle_break(port);
2183 }
2184 if (data[packet_offset+1] & FTDI_RS_PE) {
2185 error_flag = TTY_PARITY;
2186 dbg("PARITY error");
2187 }
2188 if (data[packet_offset+1] & FTDI_RS_FE) {
2189 error_flag = TTY_FRAME;
2190 dbg("FRAMING error");
2191 }
2192 if (length > 0) {
2193 for (i = 2; i < length+2; i++) {
2194 /* Note that the error flag is duplicated for
2195 every character received since we don't know
2196 which character it applied to */
2197 if (!usb_serial_handle_sysrq_char(tty, port,
2198 data[packet_offset + i]))
2199 tty_insert_flip_char(tty,
2200 data[packet_offset + i],
2201 error_flag);
2202 }
2203 need_flip = 1;
2204 }
2205
2206#ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW
2207 /* if a parity error is detected you get status packets forever
2208 until a character is sent without a parity error.
2209 This doesn't work well since the application receives a
2210 never ending stream of bad data - even though new data
2211 hasn't been sent. Therefore I (bill) have taken this out.
2212 However - this might make sense for framing errors and so on
2213 so I am leaving the code in for now.
2214 */
2215 else {
2216 if (error_flag != TTY_NORMAL) {
2217 dbg("error_flag is not normal");
2218 /* In this case it is just status - if that is
2219 an error send a bad character */
2220 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
2221 tty_flip_buffer_push(tty);
2222 tty_insert_flip_char(tty, 0xff, error_flag);
2223 need_flip = 1;
2224 }
2225 }
2226#endif
2227 } /* "for(packet_offset=0..." */
2228
2229 /* Low latency */
2230 if (need_flip)
2231 tty_flip_buffer_push(tty); 2090 tty_flip_buffer_push(tty);
2091 tty_kref_put(tty);
2092}
2232 2093
2233 if (packet_offset < urb->actual_length) { 2094static void ftdi_read_bulk_callback(struct urb *urb)
2234 /* not completely processed - record progress */ 2095{
2235 priv->rx_processed = packet_offset; 2096 struct usb_serial_port *port = urb->context;
2236 dbg("%s - incomplete, %d bytes processed, %d remain", 2097 unsigned long flags;
2237 __func__, packet_offset,
2238 urb->actual_length - packet_offset);
2239 /* check if we were throttled while processing */
2240 spin_lock_irqsave(&priv->rx_lock, flags);
2241 if (priv->rx_flags & THROTTLED) {
2242 priv->rx_flags |= ACTUALLY_THROTTLED;
2243 spin_unlock_irqrestore(&priv->rx_lock, flags);
2244 dbg("%s - deferring remainder until unthrottled",
2245 __func__);
2246 goto out;
2247 }
2248 spin_unlock_irqrestore(&priv->rx_lock, flags);
2249 /* if the port is closed stop trying to read */
2250 if (port->port.count > 0)
2251 /* delay processing of remainder */
2252 schedule_delayed_work(&priv->rx_work, 1);
2253 else
2254 dbg("%s - port is closed", __func__);
2255 goto out;
2256 }
2257
2258 /* urb is completely processed */
2259 priv->rx_processed = 0;
2260 2098
2261 /* if the port is closed stop trying to read */ 2099 dbg("%s - port %d", __func__, port->number);
2262 if (port->port.count > 0) {
2263 /* Continue trying to always read */
2264 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
2265 usb_rcvbulkpipe(port->serial->dev,
2266 port->bulk_in_endpointAddress),
2267 port->read_urb->transfer_buffer,
2268 port->read_urb->transfer_buffer_length,
2269 ftdi_read_bulk_callback, port);
2270 2100
2271 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 2101 if (urb->status) {
2272 if (result) 2102 dbg("%s - nonzero read bulk status received: %d",
2273 dev_err(&port->dev, 2103 __func__, urb->status);
2274 "%s - failed resubmitting read urb, error %d\n", 2104 return;
2275 __func__, result);
2276 } 2105 }
2277out:
2278 tty_kref_put(tty);
2279} /* ftdi_process_read */
2280 2106
2107 usb_serial_debug_data(debug, &port->dev, __func__,
2108 urb->actual_length, urb->transfer_buffer);
2109 ftdi_process_read(port);
2110
2111 spin_lock_irqsave(&port->lock, flags);
2112 port->throttled = port->throttle_req;
2113 if (!port->throttled) {
2114 spin_unlock_irqrestore(&port->lock, flags);
2115 ftdi_submit_read_urb(port, GFP_ATOMIC);
2116 } else
2117 spin_unlock_irqrestore(&port->lock, flags);
2118}
2281 2119
2282static void ftdi_break_ctl(struct tty_struct *tty, int break_state) 2120static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2283{ 2121{
@@ -2609,33 +2447,31 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
2609static void ftdi_throttle(struct tty_struct *tty) 2447static void ftdi_throttle(struct tty_struct *tty)
2610{ 2448{
2611 struct usb_serial_port *port = tty->driver_data; 2449 struct usb_serial_port *port = tty->driver_data;
2612 struct ftdi_private *priv = usb_get_serial_port_data(port);
2613 unsigned long flags; 2450 unsigned long flags;
2614 2451
2615 dbg("%s - port %d", __func__, port->number); 2452 dbg("%s - port %d", __func__, port->number);
2616 2453
2617 spin_lock_irqsave(&priv->rx_lock, flags); 2454 spin_lock_irqsave(&port->lock, flags);
2618 priv->rx_flags |= THROTTLED; 2455 port->throttle_req = 1;
2619 spin_unlock_irqrestore(&priv->rx_lock, flags); 2456 spin_unlock_irqrestore(&port->lock, flags);
2620} 2457}
2621 2458
2622 2459void ftdi_unthrottle(struct tty_struct *tty)
2623static void ftdi_unthrottle(struct tty_struct *tty)
2624{ 2460{
2625 struct usb_serial_port *port = tty->driver_data; 2461 struct usb_serial_port *port = tty->driver_data;
2626 struct ftdi_private *priv = usb_get_serial_port_data(port); 2462 int was_throttled;
2627 int actually_throttled;
2628 unsigned long flags; 2463 unsigned long flags;
2629 2464
2630 dbg("%s - port %d", __func__, port->number); 2465 dbg("%s - port %d", __func__, port->number);
2631 2466
2632 spin_lock_irqsave(&priv->rx_lock, flags); 2467 spin_lock_irqsave(&port->lock, flags);
2633 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED; 2468 was_throttled = port->throttled;
2634 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 2469 port->throttled = port->throttle_req = 0;
2635 spin_unlock_irqrestore(&priv->rx_lock, flags); 2470 spin_unlock_irqrestore(&port->lock, flags);
2636 2471
2637 if (actually_throttled) 2472 /* Resubmit urb if throttled and open. */
2638 schedule_delayed_work(&priv->rx_work, 0); 2473 if (was_throttled && test_bit(ASYNCB_INITIALIZED, &port->port.flags))
2474 ftdi_submit_read_urb(port, GFP_KERNEL);
2639} 2475}
2640 2476
2641static int __init ftdi_init(void) 2477static int __init ftdi_init(void)
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 20432d345529..5ac900e5a50e 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1390,14 +1390,13 @@ static void garmin_throttle(struct tty_struct *tty)
1390{ 1390{
1391 struct usb_serial_port *port = tty->driver_data; 1391 struct usb_serial_port *port = tty->driver_data;
1392 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1392 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1393 unsigned long flags;
1394 1393
1395 dbg("%s - port %d", __func__, port->number); 1394 dbg("%s - port %d", __func__, port->number);
1396 /* set flag, data received will be put into a queue 1395 /* set flag, data received will be put into a queue
1397 for later processing */ 1396 for later processing */
1398 spin_lock_irqsave(&garmin_data_p->lock, flags); 1397 spin_lock_irq(&garmin_data_p->lock);
1399 garmin_data_p->flags |= FLAGS_QUEUING|FLAGS_THROTTLED; 1398 garmin_data_p->flags |= FLAGS_QUEUING|FLAGS_THROTTLED;
1400 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1399 spin_unlock_irq(&garmin_data_p->lock);
1401} 1400}
1402 1401
1403 1402
@@ -1405,13 +1404,12 @@ static void garmin_unthrottle(struct tty_struct *tty)
1405{ 1404{
1406 struct usb_serial_port *port = tty->driver_data; 1405 struct usb_serial_port *port = tty->driver_data;
1407 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1406 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1408 unsigned long flags;
1409 int status; 1407 int status;
1410 1408
1411 dbg("%s - port %d", __func__, port->number); 1409 dbg("%s - port %d", __func__, port->number);
1412 spin_lock_irqsave(&garmin_data_p->lock, flags); 1410 spin_lock_irq(&garmin_data_p->lock);
1413 garmin_data_p->flags &= ~FLAGS_THROTTLED; 1411 garmin_data_p->flags &= ~FLAGS_THROTTLED;
1414 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1412 spin_unlock_irq(&garmin_data_p->lock);
1415 1413
1416 /* in native mode send queued data to tty, in 1414 /* in native mode send queued data to tty, in
1417 serial mode nothing needs to be done here */ 1415 serial mode nothing needs to be done here */
@@ -1419,7 +1417,7 @@ static void garmin_unthrottle(struct tty_struct *tty)
1419 garmin_flush_queue(garmin_data_p); 1417 garmin_flush_queue(garmin_data_p);
1420 1418
1421 if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { 1419 if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
1422 status = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1420 status = usb_submit_urb(port->read_urb, GFP_KERNEL);
1423 if (status) 1421 if (status)
1424 dev_err(&port->dev, 1422 dev_err(&port->dev,
1425 "%s - failed resubmitting read urb, error %d\n", 1423 "%s - failed resubmitting read urb, error %d\n",
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index deba08c7a015..bbe005cefcfb 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -546,7 +546,7 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
546 546
547 if (was_throttled) { 547 if (was_throttled) {
548 /* Resume reading from device */ 548 /* Resume reading from device */
549 usb_serial_generic_resubmit_read_urb(port, GFP_KERNEL); 549 flush_and_resubmit_read_urb(port);
550 } 550 }
551} 551}
552 552
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 24fcc64b837d..d6231c38813e 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -966,6 +966,15 @@ static int ipaq_calc_num_ports(struct usb_serial *serial)
966static int ipaq_startup(struct usb_serial *serial) 966static int ipaq_startup(struct usb_serial *serial)
967{ 967{
968 dbg("%s", __func__); 968 dbg("%s", __func__);
969
970 /* Some of the devices in ipaq_id_table[] are composite, and we
971 * shouldn't bind to all the interfaces. This test will rule out
972 * some obviously invalid possibilities.
973 */
974 if (serial->num_bulk_in < serial->num_ports ||
975 serial->num_bulk_out < serial->num_ports)
976 return -ENODEV;
977
969 if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 978 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
970 /* 979 /*
971 * FIXME: HP iPaq rx3715, possibly others, have 1 config that 980 * FIXME: HP iPaq rx3715, possibly others, have 1 config that
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 257c16cc6b2a..1296a097f5c3 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -290,7 +290,7 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
290 /* just restart the receive interrupt URB */ 290 /* just restart the receive interrupt URB */
291 dbg("keyspan_pda_rx_unthrottle port %d", port->number); 291 dbg("keyspan_pda_rx_unthrottle port %d", port->number);
292 port->interrupt_in_urb->dev = port->serial->dev; 292 port->interrupt_in_urb->dev = port->serial->dev;
293 if (usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC)) 293 if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL))
294 dbg(" usb_submit_urb(read urb) failed"); 294 dbg(" usb_submit_urb(read urb) failed");
295 return; 295 return;
296} 296}
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index f7373371b137..3a7873806f46 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -951,7 +951,7 @@ static void klsi_105_unthrottle(struct tty_struct *tty)
951 dbg("%s - port %d", __func__, port->number); 951 dbg("%s - port %d", __func__, port->number);
952 952
953 port->read_urb->dev = port->serial->dev; 953 port->read_urb->dev = port->serial->dev;
954 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 954 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
955 if (result) 955 if (result)
956 dev_err(&port->dev, 956 dev_err(&port->dev,
957 "%s - failed submitting read urb, error %d\n", 957 "%s - failed submitting read urb, error %d\n",
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index ad4998bbf16f..cd009cb280a5 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -777,20 +777,19 @@ static void mct_u232_throttle(struct tty_struct *tty)
777{ 777{
778 struct usb_serial_port *port = tty->driver_data; 778 struct usb_serial_port *port = tty->driver_data;
779 struct mct_u232_private *priv = usb_get_serial_port_data(port); 779 struct mct_u232_private *priv = usb_get_serial_port_data(port);
780 unsigned long flags;
781 unsigned int control_state; 780 unsigned int control_state;
782 781
783 dbg("%s - port %d", __func__, port->number); 782 dbg("%s - port %d", __func__, port->number);
784 783
785 spin_lock_irqsave(&priv->lock, flags); 784 spin_lock_irq(&priv->lock);
786 priv->rx_flags |= THROTTLED; 785 priv->rx_flags |= THROTTLED;
787 if (C_CRTSCTS(tty)) { 786 if (C_CRTSCTS(tty)) {
788 priv->control_state &= ~TIOCM_RTS; 787 priv->control_state &= ~TIOCM_RTS;
789 control_state = priv->control_state; 788 control_state = priv->control_state;
790 spin_unlock_irqrestore(&priv->lock, flags); 789 spin_unlock_irq(&priv->lock);
791 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 790 (void) mct_u232_set_modem_ctrl(port->serial, control_state);
792 } else { 791 } else {
793 spin_unlock_irqrestore(&priv->lock, flags); 792 spin_unlock_irq(&priv->lock);
794 } 793 }
795} 794}
796 795
@@ -799,20 +798,19 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
799{ 798{
800 struct usb_serial_port *port = tty->driver_data; 799 struct usb_serial_port *port = tty->driver_data;
801 struct mct_u232_private *priv = usb_get_serial_port_data(port); 800 struct mct_u232_private *priv = usb_get_serial_port_data(port);
802 unsigned long flags;
803 unsigned int control_state; 801 unsigned int control_state;
804 802
805 dbg("%s - port %d", __func__, port->number); 803 dbg("%s - port %d", __func__, port->number);
806 804
807 spin_lock_irqsave(&priv->lock, flags); 805 spin_lock_irq(&priv->lock);
808 if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) { 806 if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) {
809 priv->rx_flags &= ~THROTTLED; 807 priv->rx_flags &= ~THROTTLED;
810 priv->control_state |= TIOCM_RTS; 808 priv->control_state |= TIOCM_RTS;
811 control_state = priv->control_state; 809 control_state = priv->control_state;
812 spin_unlock_irqrestore(&priv->lock, flags); 810 spin_unlock_irq(&priv->lock);
813 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 811 (void) mct_u232_set_modem_ctrl(port->serial, control_state);
814 } else { 812 } else {
815 spin_unlock_irqrestore(&priv->lock, flags); 813 spin_unlock_irq(&priv->lock);
816 } 814 }
817} 815}
818 816
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 1085a577c5c1..80f59b6350cb 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -314,21 +314,24 @@ static void opticon_unthrottle(struct tty_struct *tty)
314 struct usb_serial_port *port = tty->driver_data; 314 struct usb_serial_port *port = tty->driver_data;
315 struct opticon_private *priv = usb_get_serial_data(port->serial); 315 struct opticon_private *priv = usb_get_serial_data(port->serial);
316 unsigned long flags; 316 unsigned long flags;
317 int result; 317 int result, was_throttled;
318 318
319 dbg("%s - port %d", __func__, port->number); 319 dbg("%s - port %d", __func__, port->number);
320 320
321 spin_lock_irqsave(&priv->lock, flags); 321 spin_lock_irqsave(&priv->lock, flags);
322 priv->throttled = false; 322 priv->throttled = false;
323 was_throttled = priv->actually_throttled;
323 priv->actually_throttled = false; 324 priv->actually_throttled = false;
324 spin_unlock_irqrestore(&priv->lock, flags); 325 spin_unlock_irqrestore(&priv->lock, flags);
325 326
326 priv->bulk_read_urb->dev = port->serial->dev; 327 priv->bulk_read_urb->dev = port->serial->dev;
327 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC); 328 if (was_throttled) {
328 if (result) 329 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
329 dev_err(&port->dev, 330 if (result)
330 "%s - failed submitting read urb, error %d\n", 331 dev_err(&port->dev,
332 "%s - failed submitting read urb, error %d\n",
331 __func__, result); 333 __func__, result);
334 }
332} 335}
333 336
334static int opticon_tiocmget(struct tty_struct *tty, struct file *file) 337static int opticon_tiocmget(struct tty_struct *tty, struct file *file)
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f66e39883218..319aaf9725b3 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -165,6 +165,7 @@ static int option_resume(struct usb_serial *serial);
165#define HUAWEI_PRODUCT_E143D 0x143D 165#define HUAWEI_PRODUCT_E143D 0x143D
166#define HUAWEI_PRODUCT_E143E 0x143E 166#define HUAWEI_PRODUCT_E143E 0x143E
167#define HUAWEI_PRODUCT_E143F 0x143F 167#define HUAWEI_PRODUCT_E143F 0x143F
168#define HUAWEI_PRODUCT_E14AC 0x14AC
168 169
169#define QUANTA_VENDOR_ID 0x0408 170#define QUANTA_VENDOR_ID 0x0408
170#define QUANTA_PRODUCT_Q101 0xEA02 171#define QUANTA_PRODUCT_Q101 0xEA02
@@ -307,6 +308,7 @@ static int option_resume(struct usb_serial *serial);
307 308
308#define DLINK_VENDOR_ID 0x1186 309#define DLINK_VENDOR_ID 0x1186
309#define DLINK_PRODUCT_DWM_652 0x3e04 310#define DLINK_PRODUCT_DWM_652 0x3e04
311#define DLINK_PRODUCT_DWM_652_U5 0xce16
310 312
311#define QISDA_VENDOR_ID 0x1da5 313#define QISDA_VENDOR_ID 0x1da5
312#define QISDA_PRODUCT_H21_4512 0x4512 314#define QISDA_PRODUCT_H21_4512 0x4512
@@ -314,10 +316,14 @@ static int option_resume(struct usb_serial *serial);
314#define QISDA_PRODUCT_H20_4515 0x4515 316#define QISDA_PRODUCT_H20_4515 0x4515
315#define QISDA_PRODUCT_H20_4519 0x4519 317#define QISDA_PRODUCT_H20_4519 0x4519
316 318
319/* TLAYTECH PRODUCTS */
320#define TLAYTECH_VENDOR_ID 0x20B9
321#define TLAYTECH_PRODUCT_TEU800 0x1682
317 322
318/* TOSHIBA PRODUCTS */ 323/* TOSHIBA PRODUCTS */
319#define TOSHIBA_VENDOR_ID 0x0930 324#define TOSHIBA_VENDOR_ID 0x0930
320#define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302 325#define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302
326#define TOSHIBA_PRODUCT_G450 0x0d45
321 327
322#define ALINK_VENDOR_ID 0x1e0e 328#define ALINK_VENDOR_ID 0x1e0e
323#define ALINK_PRODUCT_3GU 0x9200 329#define ALINK_PRODUCT_3GU 0x9200
@@ -326,6 +332,9 @@ static int option_resume(struct usb_serial *serial);
326#define ALCATEL_VENDOR_ID 0x1bbb 332#define ALCATEL_VENDOR_ID 0x1bbb
327#define ALCATEL_PRODUCT_X060S 0x0000 333#define ALCATEL_PRODUCT_X060S 0x0000
328 334
335/* Airplus products */
336#define AIRPLUS_VENDOR_ID 0x1011
337#define AIRPLUS_PRODUCT_MCD650 0x3198
329 338
330static struct usb_device_id option_ids[] = { 339static struct usb_device_id option_ids[] = {
331 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 340 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
@@ -424,6 +433,7 @@ static struct usb_device_id option_ids[] = {
424 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) }, 433 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) },
425 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) }, 434 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) },
426 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) }, 435 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) },
436 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14AC) },
427 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) }, 437 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_9508) },
428 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */ 438 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, /* Novatel Merlin V640/XV620 */
429 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */ 439 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) }, /* Novatel Merlin V620/S620 */
@@ -577,14 +587,18 @@ static struct usb_device_id option_ids[] = {
577 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 587 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
578 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 588 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
579 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 589 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
590 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
580 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 591 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
581 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 592 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
582 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 593 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
583 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) }, 594 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) },
595 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
584 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 596 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
585 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) }, 597 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
586 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) }, 598 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
587 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 599 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) },
600 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
601 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
588 { } /* Terminating entry */ 602 { } /* Terminating entry */
589}; 603};
590MODULE_DEVICE_TABLE(usb, option_ids); 604MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 0f4a70ce3823..c644e26394b4 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -288,7 +288,7 @@ static void setup_line(struct work_struct *work)
288 288
289 dbg("%s(): submitting interrupt urb", __func__); 289 dbg("%s(): submitting interrupt urb", __func__);
290 port->interrupt_in_urb->dev = port->serial->dev; 290 port->interrupt_in_urb->dev = port->serial->dev;
291 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 291 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
292 if (result != 0) { 292 if (result != 0) {
293 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 293 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
294 " with error %d\n", __func__, result); 294 " with error %d\n", __func__, result);
@@ -335,7 +335,7 @@ void send_data(struct work_struct *work)
335 335
336 dbg("%s(): submitting interrupt urb", __func__); 336 dbg("%s(): submitting interrupt urb", __func__);
337 port->interrupt_in_urb->dev = port->serial->dev; 337 port->interrupt_in_urb->dev = port->serial->dev;
338 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 338 result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
339 if (result != 0) { 339 if (result != 0) {
340 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 340 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
341 " with error %d\n", __func__, result); 341 " with error %d\n", __func__, result);
@@ -349,7 +349,7 @@ void send_data(struct work_struct *work)
349 349
350 port->write_urb->transfer_buffer_length = count; 350 port->write_urb->transfer_buffer_length = count;
351 port->write_urb->dev = port->serial->dev; 351 port->write_urb->dev = port->serial->dev;
352 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 352 result = usb_submit_urb(port->write_urb, GFP_NOIO);
353 if (result != 0) { 353 if (result != 0) {
354 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 354 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
355 " with error %d\n", __func__, result); 355 " with error %d\n", __func__, result);
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 1128e01525b1..9ec1a49e2362 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -1046,13 +1046,15 @@ static void pl2303_push_data(struct tty_struct *tty,
1046 /* overrun is special, not associated with a char */ 1046 /* overrun is special, not associated with a char */
1047 if (line_status & UART_OVERRUN_ERROR) 1047 if (line_status & UART_OVERRUN_ERROR)
1048 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1048 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1049 if (port->console && port->sysrq) { 1049
1050 if (tty_flag == TTY_NORMAL && !(port->console && port->sysrq))
1051 tty_insert_flip_string(tty, data, urb->actual_length);
1052 else {
1050 int i; 1053 int i;
1051 for (i = 0; i < urb->actual_length; ++i) 1054 for (i = 0; i < urb->actual_length; ++i)
1052 if (!usb_serial_handle_sysrq_char(tty, port, data[i])) 1055 if (!usb_serial_handle_sysrq_char(tty, port, data[i]))
1053 tty_insert_flip_char(tty, data[i], tty_flag); 1056 tty_insert_flip_char(tty, data[i], tty_flag);
1054 } else 1057 }
1055 tty_insert_flip_string(tty, data, urb->actual_length);
1056 tty_flip_buffer_push(tty); 1058 tty_flip_buffer_push(tty);
1057} 1059}
1058 1060
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 8c075b2416bb..5019325ba25d 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -17,7 +17,7 @@
17 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 17 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
18*/ 18*/
19 19
20#define DRIVER_VERSION "v.1.3.7" 20#define DRIVER_VERSION "v.1.3.8"
21#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" 21#define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
22#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 22#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
23 23
@@ -296,7 +296,6 @@ struct sierra_port_private {
296 int dsr_state; 296 int dsr_state;
297 int dcd_state; 297 int dcd_state;
298 int ri_state; 298 int ri_state;
299
300 unsigned int opened:1; 299 unsigned int opened:1;
301}; 300};
302 301
@@ -306,6 +305,8 @@ static int sierra_send_setup(struct usb_serial_port *port)
306 struct sierra_port_private *portdata; 305 struct sierra_port_private *portdata;
307 __u16 interface = 0; 306 __u16 interface = 0;
308 int val = 0; 307 int val = 0;
308 int do_send = 0;
309 int retval;
309 310
310 dev_dbg(&port->dev, "%s\n", __func__); 311 dev_dbg(&port->dev, "%s\n", __func__);
311 312
@@ -324,10 +325,7 @@ static int sierra_send_setup(struct usb_serial_port *port)
324 */ 325 */
325 if (port->interrupt_in_urb) { 326 if (port->interrupt_in_urb) {
326 /* send control message */ 327 /* send control message */
327 return usb_control_msg(serial->dev, 328 do_send = 1;
328 usb_rcvctrlpipe(serial->dev, 0),
329 0x22, 0x21, val, interface,
330 NULL, 0, USB_CTRL_SET_TIMEOUT);
331 } 329 }
332 } 330 }
333 331
@@ -339,12 +337,18 @@ static int sierra_send_setup(struct usb_serial_port *port)
339 interface = 1; 337 interface = 1;
340 else if (port->bulk_out_endpointAddress == 5) 338 else if (port->bulk_out_endpointAddress == 5)
341 interface = 2; 339 interface = 2;
342 return usb_control_msg(serial->dev, 340
343 usb_rcvctrlpipe(serial->dev, 0), 341 do_send = 1;
344 0x22, 0x21, val, interface,
345 NULL, 0, USB_CTRL_SET_TIMEOUT);
346 } 342 }
347 return 0; 343 if (!do_send)
344 return 0;
345
346 usb_autopm_get_interface(serial->interface);
347 retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
348 0x22, 0x21, val, interface, NULL, 0, USB_CTRL_SET_TIMEOUT);
349 usb_autopm_put_interface(serial->interface);
350
351 return retval;
348} 352}
349 353
350static void sierra_set_termios(struct tty_struct *tty, 354static void sierra_set_termios(struct tty_struct *tty,
@@ -773,8 +777,11 @@ static void sierra_close(struct usb_serial_port *port)
773 777
774 if (serial->dev) { 778 if (serial->dev) {
775 mutex_lock(&serial->disc_mutex); 779 mutex_lock(&serial->disc_mutex);
776 if (!serial->disconnected) 780 if (!serial->disconnected) {
781 serial->interface->needs_remote_wakeup = 0;
782 usb_autopm_get_interface(serial->interface);
777 sierra_send_setup(port); 783 sierra_send_setup(port);
784 }
778 mutex_unlock(&serial->disc_mutex); 785 mutex_unlock(&serial->disc_mutex);
779 spin_lock_irq(&intfdata->susp_lock); 786 spin_lock_irq(&intfdata->susp_lock);
780 portdata->opened = 0; 787 portdata->opened = 0;
@@ -788,8 +795,6 @@ static void sierra_close(struct usb_serial_port *port)
788 sierra_release_urb(portdata->in_urbs[i]); 795 sierra_release_urb(portdata->in_urbs[i]);
789 portdata->in_urbs[i] = NULL; 796 portdata->in_urbs[i] = NULL;
790 } 797 }
791 usb_autopm_get_interface(serial->interface);
792 serial->interface->needs_remote_wakeup = 0;
793 } 798 }
794} 799}
795 800
@@ -827,6 +832,8 @@ static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)
827 if (err) { 832 if (err) {
828 /* get rid of everything as in close */ 833 /* get rid of everything as in close */
829 sierra_close(port); 834 sierra_close(port);
835 /* restore balance for autopm */
836 usb_autopm_put_interface(serial->interface);
830 return err; 837 return err;
831 } 838 }
832 sierra_send_setup(port); 839 sierra_send_setup(port);
@@ -915,7 +922,7 @@ static void sierra_release(struct usb_serial *serial)
915#ifdef CONFIG_PM 922#ifdef CONFIG_PM
916static void stop_read_write_urbs(struct usb_serial *serial) 923static void stop_read_write_urbs(struct usb_serial *serial)
917{ 924{
918 int i, j; 925 int i;
919 struct usb_serial_port *port; 926 struct usb_serial_port *port;
920 struct sierra_port_private *portdata; 927 struct sierra_port_private *portdata;
921 928
@@ -923,8 +930,7 @@ static void stop_read_write_urbs(struct usb_serial *serial)
923 for (i = 0; i < serial->num_ports; ++i) { 930 for (i = 0; i < serial->num_ports; ++i) {
924 port = serial->port[i]; 931 port = serial->port[i];
925 portdata = usb_get_serial_port_data(port); 932 portdata = usb_get_serial_port_data(port);
926 for (j = 0; j < N_IN_URB; j++) 933 sierra_stop_rx_urbs(port);
927 usb_kill_urb(portdata->in_urbs[j]);
928 usb_kill_anchored_urbs(&portdata->active); 934 usb_kill_anchored_urbs(&portdata->active);
929 } 935 }
930} 936}
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index cb7e95f9fcbf..b282c0f2d8e5 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -165,34 +165,36 @@ static void symbol_throttle(struct tty_struct *tty)
165{ 165{
166 struct usb_serial_port *port = tty->driver_data; 166 struct usb_serial_port *port = tty->driver_data;
167 struct symbol_private *priv = usb_get_serial_data(port->serial); 167 struct symbol_private *priv = usb_get_serial_data(port->serial);
168 unsigned long flags;
169 168
170 dbg("%s - port %d", __func__, port->number); 169 dbg("%s - port %d", __func__, port->number);
171 spin_lock_irqsave(&priv->lock, flags); 170 spin_lock_irq(&priv->lock);
172 priv->throttled = true; 171 priv->throttled = true;
173 spin_unlock_irqrestore(&priv->lock, flags); 172 spin_unlock_irq(&priv->lock);
174} 173}
175 174
176static void symbol_unthrottle(struct tty_struct *tty) 175static void symbol_unthrottle(struct tty_struct *tty)
177{ 176{
178 struct usb_serial_port *port = tty->driver_data; 177 struct usb_serial_port *port = tty->driver_data;
179 struct symbol_private *priv = usb_get_serial_data(port->serial); 178 struct symbol_private *priv = usb_get_serial_data(port->serial);
180 unsigned long flags;
181 int result; 179 int result;
180 bool was_throttled;
182 181
183 dbg("%s - port %d", __func__, port->number); 182 dbg("%s - port %d", __func__, port->number);
184 183
185 spin_lock_irqsave(&priv->lock, flags); 184 spin_lock_irq(&priv->lock);
186 priv->throttled = false; 185 priv->throttled = false;
186 was_throttled = priv->actually_throttled;
187 priv->actually_throttled = false; 187 priv->actually_throttled = false;
188 spin_unlock_irqrestore(&priv->lock, flags); 188 spin_unlock_irq(&priv->lock);
189 189
190 priv->int_urb->dev = port->serial->dev; 190 priv->int_urb->dev = port->serial->dev;
191 result = usb_submit_urb(priv->int_urb, GFP_ATOMIC); 191 if (was_throttled) {
192 if (result) 192 result = usb_submit_urb(priv->int_urb, GFP_KERNEL);
193 dev_err(&port->dev, 193 if (result)
194 "%s - failed submitting read urb, error %d\n", 194 dev_err(&port->dev,
195 "%s - failed submitting read urb, error %d\n",
195 __func__, result); 196 __func__, result);
197 }
196} 198}
197 199
198static int symbol_startup(struct usb_serial *serial) 200static int symbol_startup(struct usb_serial *serial)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index aa6b2ae951ae..bd3fa7ff15b1 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -156,7 +156,8 @@ static void destroy_serial(struct kref *kref)
156 if (serial->minor != SERIAL_TTY_NO_MINOR) 156 if (serial->minor != SERIAL_TTY_NO_MINOR)
157 return_serial(serial); 157 return_serial(serial);
158 158
159 serial->type->release(serial); 159 if (serial->attached)
160 serial->type->release(serial);
160 161
161 /* Now that nothing is using the ports, they can be freed */ 162 /* Now that nothing is using the ports, they can be freed */
162 for (i = 0; i < serial->num_port_pointers; ++i) { 163 for (i = 0; i < serial->num_port_pointers; ++i) {
@@ -1059,12 +1060,15 @@ int usb_serial_probe(struct usb_interface *interface,
1059 module_put(type->driver.owner); 1060 module_put(type->driver.owner);
1060 if (retval < 0) 1061 if (retval < 0)
1061 goto probe_error; 1062 goto probe_error;
1063 serial->attached = 1;
1062 if (retval > 0) { 1064 if (retval > 0) {
1063 /* quietly accept this device, but don't bind to a 1065 /* quietly accept this device, but don't bind to a
1064 serial port as it's about to disappear */ 1066 serial port as it's about to disappear */
1065 serial->num_ports = 0; 1067 serial->num_ports = 0;
1066 goto exit; 1068 goto exit;
1067 } 1069 }
1070 } else {
1071 serial->attached = 1;
1068 } 1072 }
1069 1073
1070 if (get_free_serial(serial, num_ports, &minor) == NULL) { 1074 if (get_free_serial(serial, num_ports, &minor) == NULL) {
@@ -1164,8 +1168,10 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
1164 1168
1165 if (serial->type->suspend) { 1169 if (serial->type->suspend) {
1166 r = serial->type->suspend(serial, message); 1170 r = serial->type->suspend(serial, message);
1167 if (r < 0) 1171 if (r < 0) {
1172 serial->suspending = 0;
1168 goto err_out; 1173 goto err_out;
1174 }
1169 } 1175 }
1170 1176
1171 for (i = 0; i < serial->num_ports; ++i) { 1177 for (i = 0; i < serial->num_ports; ++i) {
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 1aa5d20a5d99..ad1f9232292d 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -513,7 +513,8 @@ static void visor_read_bulk_callback(struct urb *urb)
513 tty_kref_put(tty); 513 tty_kref_put(tty);
514 } 514 }
515 spin_lock(&priv->lock); 515 spin_lock(&priv->lock);
516 priv->bytes_in += available_room; 516 if (tty)
517 priv->bytes_in += available_room;
517 518
518 } else { 519 } else {
519 spin_lock(&priv->lock); 520 spin_lock(&priv->lock);
@@ -582,12 +583,11 @@ static void visor_throttle(struct tty_struct *tty)
582{ 583{
583 struct usb_serial_port *port = tty->driver_data; 584 struct usb_serial_port *port = tty->driver_data;
584 struct visor_private *priv = usb_get_serial_port_data(port); 585 struct visor_private *priv = usb_get_serial_port_data(port);
585 unsigned long flags;
586 586
587 dbg("%s - port %d", __func__, port->number); 587 dbg("%s - port %d", __func__, port->number);
588 spin_lock_irqsave(&priv->lock, flags); 588 spin_lock_irq(&priv->lock);
589 priv->throttled = 1; 589 priv->throttled = 1;
590 spin_unlock_irqrestore(&priv->lock, flags); 590 spin_unlock_irq(&priv->lock);
591} 591}
592 592
593 593
@@ -595,21 +595,23 @@ static void visor_unthrottle(struct tty_struct *tty)
595{ 595{
596 struct usb_serial_port *port = tty->driver_data; 596 struct usb_serial_port *port = tty->driver_data;
597 struct visor_private *priv = usb_get_serial_port_data(port); 597 struct visor_private *priv = usb_get_serial_port_data(port);
598 unsigned long flags; 598 int result, was_throttled;
599 int result;
600 599
601 dbg("%s - port %d", __func__, port->number); 600 dbg("%s - port %d", __func__, port->number);
602 spin_lock_irqsave(&priv->lock, flags); 601 spin_lock_irq(&priv->lock);
603 priv->throttled = 0; 602 priv->throttled = 0;
603 was_throttled = priv->actually_throttled;
604 priv->actually_throttled = 0; 604 priv->actually_throttled = 0;
605 spin_unlock_irqrestore(&priv->lock, flags); 605 spin_unlock_irq(&priv->lock);
606 606
607 port->read_urb->dev = port->serial->dev; 607 if (was_throttled) {
608 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 608 port->read_urb->dev = port->serial->dev;
609 if (result) 609 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
610 dev_err(&port->dev, 610 if (result)
611 "%s - failed submitting read urb, error %d\n", 611 dev_err(&port->dev,
612 "%s - failed submitting read urb, error %d\n",
612 __func__, result); 613 __func__, result);
614 }
613} 615}
614 616
615static int palm_os_3_probe(struct usb_serial *serial, 617static int palm_os_3_probe(struct usb_serial *serial,
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 62424eec33ec..1093d2eb046a 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -949,13 +949,12 @@ static void whiteheat_throttle(struct tty_struct *tty)
949{ 949{
950 struct usb_serial_port *port = tty->driver_data; 950 struct usb_serial_port *port = tty->driver_data;
951 struct whiteheat_private *info = usb_get_serial_port_data(port); 951 struct whiteheat_private *info = usb_get_serial_port_data(port);
952 unsigned long flags;
953 952
954 dbg("%s - port %d", __func__, port->number); 953 dbg("%s - port %d", __func__, port->number);
955 954
956 spin_lock_irqsave(&info->lock, flags); 955 spin_lock_irq(&info->lock);
957 info->flags |= THROTTLED; 956 info->flags |= THROTTLED;
958 spin_unlock_irqrestore(&info->lock, flags); 957 spin_unlock_irq(&info->lock);
959 958
960 return; 959 return;
961} 960}
@@ -966,14 +965,13 @@ static void whiteheat_unthrottle(struct tty_struct *tty)
966 struct usb_serial_port *port = tty->driver_data; 965 struct usb_serial_port *port = tty->driver_data;
967 struct whiteheat_private *info = usb_get_serial_port_data(port); 966 struct whiteheat_private *info = usb_get_serial_port_data(port);
968 int actually_throttled; 967 int actually_throttled;
969 unsigned long flags;
970 968
971 dbg("%s - port %d", __func__, port->number); 969 dbg("%s - port %d", __func__, port->number);
972 970
973 spin_lock_irqsave(&info->lock, flags); 971 spin_lock_irq(&info->lock);
974 actually_throttled = info->flags & ACTUALLY_THROTTLED; 972 actually_throttled = info->flags & ACTUALLY_THROTTLED;
975 info->flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 973 info->flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
976 spin_unlock_irqrestore(&info->lock, flags); 974 spin_unlock_irq(&info->lock);
977 975
978 if (actually_throttled) 976 if (actually_throttled)
979 rx_data_softint(&info->rx_work); 977 rx_data_softint(&info->rx_work);
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index e20dc525d177..589f6b4404f0 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -696,7 +696,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
696 /* device supports and needs bigger sense buffer */ 696 /* device supports and needs bigger sense buffer */
697 if (us->fflags & US_FL_SANE_SENSE) 697 if (us->fflags & US_FL_SANE_SENSE)
698 sense_size = ~0; 698 sense_size = ~0;
699 699Retry_Sense:
700 US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); 700 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
701 701
702 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size); 702 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
@@ -720,6 +720,21 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
720 srb->result = DID_ABORT << 16; 720 srb->result = DID_ABORT << 16;
721 goto Handle_Errors; 721 goto Handle_Errors;
722 } 722 }
723
724 /* Some devices claim to support larger sense but fail when
725 * trying to request it. When a transport failure happens
726 * using US_FS_SANE_SENSE, we always retry with a standard
727 * (small) sense request. This fixes some USB GSM modems
728 */
729 if (temp_result == USB_STOR_TRANSPORT_FAILED &&
730 (us->fflags & US_FL_SANE_SENSE) &&
731 sense_size != US_SENSE_SIZE) {
732 US_DEBUGP("-- auto-sense failure, retry small sense\n");
733 sense_size = US_SENSE_SIZE;
734 goto Retry_Sense;
735 }
736
737 /* Other failures */
723 if (temp_result != USB_STOR_TRANSPORT_GOOD) { 738 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
724 US_DEBUGP("-- auto-sense failure\n"); 739 US_DEBUGP("-- auto-sense failure\n");
725 740
@@ -768,17 +783,32 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
768 /* set the result so the higher layers expect this data */ 783 /* set the result so the higher layers expect this data */
769 srb->result = SAM_STAT_CHECK_CONDITION; 784 srb->result = SAM_STAT_CHECK_CONDITION;
770 785
771 /* If things are really okay, then let's show that. Zero 786 /* We often get empty sense data. This could indicate that
772 * out the sense buffer so the higher layers won't realize 787 * everything worked or that there was an unspecified
773 * we did an unsolicited auto-sense. */ 788 * problem. We have to decide which.
774 if (result == USB_STOR_TRANSPORT_GOOD && 789 */
775 /* Filemark 0, ignore EOM, ILI 0, no sense */ 790 if ( /* Filemark 0, ignore EOM, ILI 0, no sense */
776 (srb->sense_buffer[2] & 0xaf) == 0 && 791 (srb->sense_buffer[2] & 0xaf) == 0 &&
777 /* No ASC or ASCQ */ 792 /* No ASC or ASCQ */
778 srb->sense_buffer[12] == 0 && 793 srb->sense_buffer[12] == 0 &&
779 srb->sense_buffer[13] == 0) { 794 srb->sense_buffer[13] == 0) {
780 srb->result = SAM_STAT_GOOD; 795
781 srb->sense_buffer[0] = 0x0; 796 /* If things are really okay, then let's show that.
797 * Zero out the sense buffer so the higher layers
798 * won't realize we did an unsolicited auto-sense.
799 */
800 if (result == USB_STOR_TRANSPORT_GOOD) {
801 srb->result = SAM_STAT_GOOD;
802 srb->sense_buffer[0] = 0x0;
803
804 /* If there was a problem, report an unspecified
805 * hardware error to prevent the higher layers from
806 * entering an infinite retry loop.
807 */
808 } else {
809 srb->result = DID_ERROR << 16;
810 srb->sense_buffer[2] = HARDWARE_ERROR;
811 }
782 } 812 }
783 } 813 }
784 814
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 079ae0f7bec1..d4f034ebaa8a 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1823,6 +1823,13 @@ UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
1823 US_SC_DEVICE, US_PR_DEVICE, NULL, 1823 US_SC_DEVICE, US_PR_DEVICE, NULL,
1824 US_FL_IGNORE_RESIDUE ), 1824 US_FL_IGNORE_RESIDUE ),
1825 1825
1826/* Reported by Sergey Pinaev <dfo@antex.ru> */
1827UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000,
1828 "iRiver",
1829 "P7K",
1830 US_SC_DEVICE, US_PR_DEVICE, NULL,
1831 US_FL_MAX_SECTORS_64 ),
1832
1826/* 1833/*
1827 * David Härdeman <david@2gen.com> 1834 * David Härdeman <david@2gen.com>
1828 * The key makes the SCSI stack print confusing (but harmless) messages 1835 * The key makes the SCSI stack print confusing (but harmless) messages
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index b2f149fedcc5..4516c36436e6 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -200,35 +200,40 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
200{ 200{
201 int result, bytes, secd_size; 201 int result, bytes, secd_size;
202 struct device *dev = &usb_dev->dev; 202 struct device *dev = &usb_dev->dev;
203 struct usb_security_descriptor secd; 203 struct usb_security_descriptor *secd;
204 const struct usb_encryption_descriptor *etd, *ccm1_etd = NULL; 204 const struct usb_encryption_descriptor *etd, *ccm1_etd = NULL;
205 void *secd_buf;
206 const void *itr, *top; 205 const void *itr, *top;
207 char buf[64]; 206 char buf[64];
208 207
208 secd = kmalloc(sizeof(struct usb_security_descriptor), GFP_KERNEL);
209 if (secd == NULL) {
210 result = -ENOMEM;
211 goto out;
212 }
213
209 result = usb_get_descriptor(usb_dev, USB_DT_SECURITY, 214 result = usb_get_descriptor(usb_dev, USB_DT_SECURITY,
210 0, &secd, sizeof(secd)); 215 0, secd, sizeof(struct usb_security_descriptor));
211 if (result < sizeof(secd)) { 216 if (result < sizeof(secd)) {
212 dev_err(dev, "Can't read security descriptor or " 217 dev_err(dev, "Can't read security descriptor or "
213 "not enough data: %d\n", result); 218 "not enough data: %d\n", result);
214 goto error_secd; 219 goto out;
215 } 220 }
216 secd_size = le16_to_cpu(secd.wTotalLength); 221 secd_size = le16_to_cpu(secd->wTotalLength);
217 secd_buf = kmalloc(secd_size, GFP_KERNEL); 222 secd = krealloc(secd, secd_size, GFP_KERNEL);
218 if (secd_buf == NULL) { 223 if (secd == NULL) {
219 dev_err(dev, "Can't allocate space for security descriptors\n"); 224 dev_err(dev, "Can't allocate space for security descriptors\n");
220 goto error_secd_alloc; 225 goto out;
221 } 226 }
222 result = usb_get_descriptor(usb_dev, USB_DT_SECURITY, 227 result = usb_get_descriptor(usb_dev, USB_DT_SECURITY,
223 0, secd_buf, secd_size); 228 0, secd, secd_size);
224 if (result < secd_size) { 229 if (result < secd_size) {
225 dev_err(dev, "Can't read security descriptor or " 230 dev_err(dev, "Can't read security descriptor or "
226 "not enough data: %d\n", result); 231 "not enough data: %d\n", result);
227 goto error_secd_all; 232 goto out;
228 } 233 }
229 bytes = 0; 234 bytes = 0;
230 itr = secd_buf + sizeof(secd); 235 itr = &secd[1];
231 top = secd_buf + result; 236 top = (void *)secd + result;
232 while (itr < top) { 237 while (itr < top) {
233 etd = itr; 238 etd = itr;
234 if (top - itr < sizeof(*etd)) { 239 if (top - itr < sizeof(*etd)) {
@@ -259,24 +264,16 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
259 dev_err(dev, "WUSB device doesn't support CCM1 encryption, " 264 dev_err(dev, "WUSB device doesn't support CCM1 encryption, "
260 "can't use!\n"); 265 "can't use!\n");
261 result = -EINVAL; 266 result = -EINVAL;
262 goto error_no_ccm1; 267 goto out;
263 } 268 }
264 wusb_dev->ccm1_etd = *ccm1_etd; 269 wusb_dev->ccm1_etd = *ccm1_etd;
265 dev_dbg(dev, "supported encryption: %s; using %s (0x%02x/%02x)\n", 270 dev_dbg(dev, "supported encryption: %s; using %s (0x%02x/%02x)\n",
266 buf, wusb_et_name(ccm1_etd->bEncryptionType), 271 buf, wusb_et_name(ccm1_etd->bEncryptionType),
267 ccm1_etd->bEncryptionValue, ccm1_etd->bAuthKeyIndex); 272 ccm1_etd->bEncryptionValue, ccm1_etd->bAuthKeyIndex);
268 result = 0; 273 result = 0;
269 kfree(secd_buf);
270out: 274out:
275 kfree(secd);
271 return result; 276 return result;
272
273
274error_no_ccm1:
275error_secd_all:
276 kfree(secd_buf);
277error_secd_alloc:
278error_secd:
279 goto out;
280} 277}
281 278
282void wusb_dev_sec_rm(struct wusb_dev *wusb_dev) 279void wusb_dev_sec_rm(struct wusb_dev *wusb_dev)