aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/atm/usbatm.c5
-rw-r--r--drivers/usb/core/hcd.c3
-rw-r--r--drivers/usb/core/hub.c39
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c4
-rw-r--r--drivers/usb/host/ehci-hcd.c26
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c2
-rw-r--r--drivers/usb/host/ehci-sched.c32
-rw-r--r--drivers/usb/host/ehci.h138
-rw-r--r--drivers/usb/host/ohci-omap.c2
-rw-r--r--drivers/usb/host/ohci-pxa27x.c259
-rw-r--r--drivers/usb/host/sl811_cs.c133
-rw-r--r--drivers/usb/musb/Kconfig1
-rw-r--r--drivers/usb/musb/musb_core.c4
-rw-r--r--drivers/usb/musb/omap2430.c4
-rw-r--r--drivers/usb/musb/omap2430.h4
-rw-r--r--drivers/usb/serial/aircable.c15
-rw-r--r--drivers/usb/serial/belkin_sa.c3
-rw-r--r--drivers/usb/serial/console.c10
-rw-r--r--drivers/usb/serial/cp2101.c3
-rw-r--r--drivers/usb/serial/cyberjack.c3
-rw-r--r--drivers/usb/serial/cypress_m8.c5
-rw-r--r--drivers/usb/serial/digi_acceleport.c19
-rw-r--r--drivers/usb/serial/empeg.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c28
-rw-r--r--drivers/usb/serial/ftdi_sio.h5
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c43
-rw-r--r--drivers/usb/serial/io_ti.c26
-rw-r--r--drivers/usb/serial/ipaq.c3
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/ir-usb.c3
-rw-r--r--drivers/usb/serial/iuu_phoenix.c3
-rw-r--r--drivers/usb/serial/keyspan.c77
-rw-r--r--drivers/usb/serial/keyspan_pda.c16
-rw-r--r--drivers/usb/serial/kl5kusb105.c3
-rw-r--r--drivers/usb/serial/kobil_sct.c3
-rw-r--r--drivers/usb/serial/mct_u232.c6
-rw-r--r--drivers/usb/serial/mos7720.c36
-rw-r--r--drivers/usb/serial/mos7840.c7
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/omninet.c10
-rw-r--r--drivers/usb/serial/option.c20
-rw-r--r--drivers/usb/serial/oti6858.c7
-rw-r--r--drivers/usb/serial/pl2303.c15
-rw-r--r--drivers/usb/serial/safe_serial.c11
-rw-r--r--drivers/usb/serial/sierra.c28
-rw-r--r--drivers/usb/serial/spcp8x5.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c46
-rw-r--r--drivers/usb/serial/usb-serial.c28
-rw-r--r--drivers/usb/serial/visor.c18
-rw-r--r--drivers/usb/serial/whiteheat.c8
-rw-r--r--drivers/usb/storage/Kconfig12
-rw-r--r--drivers/usb/storage/Makefile3
-rw-r--r--drivers/usb/storage/unusual_devs.h30
-rw-r--r--drivers/usb/storage/usb.c2
58 files changed, 651 insertions, 587 deletions
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 07228721cafe..0da2c25bab3b 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -640,14 +640,13 @@ static void usbatm_cancel_send(struct usbatm_data *instance,
640 640
641 atm_dbg(instance, "%s entered\n", __func__); 641 atm_dbg(instance, "%s entered\n", __func__);
642 spin_lock_irq(&instance->sndqueue.lock); 642 spin_lock_irq(&instance->sndqueue.lock);
643 for (skb = instance->sndqueue.next, n = skb->next; 643 skb_queue_walk_safe(&instance->sndqueue, skb, n) {
644 skb != (struct sk_buff *)&instance->sndqueue;
645 skb = n, n = skb->next)
646 if (UDSL_SKB(skb)->atm.vcc == vcc) { 644 if (UDSL_SKB(skb)->atm.vcc == vcc) {
647 atm_dbg(instance, "%s: popping skb 0x%p\n", __func__, skb); 645 atm_dbg(instance, "%s: popping skb 0x%p\n", __func__, skb);
648 __skb_unlink(skb, &instance->sndqueue); 646 __skb_unlink(skb, &instance->sndqueue);
649 usbatm_pop(vcc, skb); 647 usbatm_pop(vcc, skb);
650 } 648 }
649 }
651 spin_unlock_irq(&instance->sndqueue.lock); 650 spin_unlock_irq(&instance->sndqueue.lock);
652 651
653 tasklet_disable(&instance->tx_channel.tasklet); 652 tasklet_disable(&instance->tx_channel.tasklet);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8abd4e59bf4a..8ab389dca2b9 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1876,7 +1876,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
1876 * with IRQF_SHARED. As usb_hcd_irq() will always disable 1876 * with IRQF_SHARED. As usb_hcd_irq() will always disable
1877 * interrupts we can remove it here. 1877 * interrupts we can remove it here.
1878 */ 1878 */
1879 irqflags &= ~IRQF_DISABLED; 1879 if (irqflags & IRQF_SHARED)
1880 irqflags &= ~IRQF_DISABLED;
1880 1881
1881 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 1882 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
1882 hcd->driver->description, hcd->self.busnum); 1883 hcd->driver->description, hcd->self.busnum);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6a5cb018383d..d99963873e37 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2683,35 +2683,17 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2683 USB_PORT_STAT_C_ENABLE); 2683 USB_PORT_STAT_C_ENABLE);
2684#endif 2684#endif
2685 2685
2686 /* Try to use the debounce delay for protection against
2687 * port-enable changes caused, for example, by EMI.
2688 */
2689 if (portchange & (USB_PORT_STAT_C_CONNECTION |
2690 USB_PORT_STAT_C_ENABLE)) {
2691 status = hub_port_debounce(hub, port1);
2692 if (status < 0) {
2693 if (printk_ratelimit())
2694 dev_err (hub_dev, "connect-debounce failed, "
2695 "port %d disabled\n", port1);
2696 portstatus &= ~USB_PORT_STAT_CONNECTION;
2697 } else {
2698 portstatus = status;
2699 }
2700 }
2701
2702 /* Try to resuscitate an existing device */ 2686 /* Try to resuscitate an existing device */
2703 udev = hdev->children[port1-1]; 2687 udev = hdev->children[port1-1];
2704 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && 2688 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
2705 udev->state != USB_STATE_NOTATTACHED) { 2689 udev->state != USB_STATE_NOTATTACHED) {
2706
2707 usb_lock_device(udev); 2690 usb_lock_device(udev);
2708 if (portstatus & USB_PORT_STAT_ENABLE) { 2691 if (portstatus & USB_PORT_STAT_ENABLE) {
2709 status = 0; /* Nothing to do */ 2692 status = 0; /* Nothing to do */
2710 } else if (!udev->persist_enabled) {
2711 status = -ENODEV; /* Mustn't resuscitate */
2712 2693
2713#ifdef CONFIG_USB_SUSPEND 2694#ifdef CONFIG_USB_SUSPEND
2714 } else if (udev->state == USB_STATE_SUSPENDED) { 2695 } else if (udev->state == USB_STATE_SUSPENDED &&
2696 udev->persist_enabled) {
2715 /* For a suspended device, treat this as a 2697 /* For a suspended device, treat this as a
2716 * remote wakeup event. 2698 * remote wakeup event.
2717 */ 2699 */
@@ -2726,7 +2708,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2726#endif 2708#endif
2727 2709
2728 } else { 2710 } else {
2729 status = usb_reset_device(udev); 2711 status = -ENODEV; /* Don't resuscitate */
2730 } 2712 }
2731 usb_unlock_device(udev); 2713 usb_unlock_device(udev);
2732 2714
@@ -2741,6 +2723,19 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2741 usb_disconnect(&hdev->children[port1-1]); 2723 usb_disconnect(&hdev->children[port1-1]);
2742 clear_bit(port1, hub->change_bits); 2724 clear_bit(port1, hub->change_bits);
2743 2725
2726 if (portchange & (USB_PORT_STAT_C_CONNECTION |
2727 USB_PORT_STAT_C_ENABLE)) {
2728 status = hub_port_debounce(hub, port1);
2729 if (status < 0) {
2730 if (printk_ratelimit())
2731 dev_err(hub_dev, "connect-debounce failed, "
2732 "port %d disabled\n", port1);
2733 portstatus &= ~USB_PORT_STAT_CONNECTION;
2734 } else {
2735 portstatus = status;
2736 }
2737 }
2738
2744 /* Return now if debouncing failed or nothing is connected */ 2739 /* Return now if debouncing failed or nothing is connected */
2745 if (!(portstatus & USB_PORT_STAT_CONNECTION)) { 2740 if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
2746 2741
@@ -2748,7 +2743,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2748 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 2743 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
2749 && !(portstatus & (1 << USB_PORT_FEAT_POWER))) 2744 && !(portstatus & (1 << USB_PORT_FEAT_POWER)))
2750 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 2745 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
2751 2746
2752 if (portstatus & USB_PORT_STAT_ENABLE) 2747 if (portstatus & USB_PORT_STAT_ENABLE)
2753 goto done; 2748 goto done;
2754 return; 2749 return;
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index db410e92c80d..77fa7a080801 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -97,7 +97,7 @@ enum {
97 Opt_err, 97 Opt_err,
98}; 98};
99 99
100static match_table_t tokens = { 100static const match_table_t tokens = {
101 {Opt_devuid, "devuid=%u"}, 101 {Opt_devuid, "devuid=%u"},
102 {Opt_devgid, "devgid=%u"}, 102 {Opt_devgid, "devgid=%u"},
103 {Opt_devmode, "devmode=%o"}, 103 {Opt_devmode, "devmode=%o"},
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 1cfccf102a2d..45ad556169f1 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -223,7 +223,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
223 fsl_writel(tmp, &dr_regs->endpointlistaddr); 223 fsl_writel(tmp, &dr_regs->endpointlistaddr);
224 224
225 VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x", 225 VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x",
226 (int)udc->ep_qh, (int)tmp, 226 udc->ep_qh, (int)tmp,
227 fsl_readl(&dr_regs->endpointlistaddr)); 227 fsl_readl(&dr_regs->endpointlistaddr));
228 228
229 /* Config PHY interface */ 229 /* Config PHY interface */
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 574c53831a05..bb54cca4c543 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -787,7 +787,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
787 omap_set_dma_dest_params(ep->lch, 787 omap_set_dma_dest_params(ep->lch,
788 OMAP_DMA_PORT_TIPB, 788 OMAP_DMA_PORT_TIPB,
789 OMAP_DMA_AMODE_CONSTANT, 789 OMAP_DMA_AMODE_CONSTANT,
790 (unsigned long) io_v2p(UDC_DATA_DMA), 790 UDC_DATA_DMA,
791 0, 0); 791 0, 0);
792 } 792 }
793 } else { 793 } else {
@@ -804,7 +804,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
804 omap_set_dma_src_params(ep->lch, 804 omap_set_dma_src_params(ep->lch,
805 OMAP_DMA_PORT_TIPB, 805 OMAP_DMA_PORT_TIPB,
806 OMAP_DMA_AMODE_CONSTANT, 806 OMAP_DMA_AMODE_CONSTANT,
807 (unsigned long) io_v2p(UDC_DATA_DMA), 807 UDC_DATA_DMA,
808 0, 0); 808 0, 0);
809 /* EMIFF or SDRC */ 809 /* EMIFF or SDRC */
810 omap_set_dma_dest_burst_mode(ep->lch, 810 omap_set_dma_dest_burst_mode(ep->lch,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d9d53f289caf..8409e0705d63 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -145,16 +145,6 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
145 return -ETIMEDOUT; 145 return -ETIMEDOUT;
146} 146}
147 147
148static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
149 u32 mask, u32 done, int usec)
150{
151 int error = handshake(ehci, ptr, mask, done, usec);
152 if (error)
153 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
154
155 return error;
156}
157
158/* force HC to halt state from unknown (EHCI spec section 2.3) */ 148/* force HC to halt state from unknown (EHCI spec section 2.3) */
159static int ehci_halt (struct ehci_hcd *ehci) 149static int ehci_halt (struct ehci_hcd *ehci)
160{ 150{
@@ -173,6 +163,22 @@ static int ehci_halt (struct ehci_hcd *ehci)
173 STS_HALT, STS_HALT, 16 * 125); 163 STS_HALT, STS_HALT, 16 * 125);
174} 164}
175 165
166static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
167 u32 mask, u32 done, int usec)
168{
169 int error;
170
171 error = handshake(ehci, ptr, mask, done, usec);
172 if (error) {
173 ehci_halt(ehci);
174 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
175 ehci_err(ehci, "force halt; handhake %p %08x %08x -> %d\n",
176 ptr, mask, done, error);
177 }
178
179 return error;
180}
181
176/* put TDI/ARC silicon into EHCI mode */ 182/* put TDI/ARC silicon into EHCI mode */
177static void tdi_reset (struct ehci_hcd *ehci) 183static void tdi_reset (struct ehci_hcd *ehci)
178{ 184{
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index f9575c409124..9c32063a0c2f 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * IXP4XX EHCI Host Controller Driver 2 * IXP4XX EHCI Host Controller Driver
3 * 3 *
4 * Author: Vladimir Barinov <vbarinov@ru.mvista.com> 4 * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
5 * 5 *
6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> 6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
7 * 7 *
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index b7853c8bac0f..4a0c5a78b2ed 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -437,6 +437,9 @@ static int enable_periodic (struct ehci_hcd *ehci)
437 u32 cmd; 437 u32 cmd;
438 int status; 438 int status;
439 439
440 if (ehci->periodic_sched++)
441 return 0;
442
440 /* did clearing PSE did take effect yet? 443 /* did clearing PSE did take effect yet?
441 * takes effect only at frame boundaries... 444 * takes effect only at frame boundaries...
442 */ 445 */
@@ -461,6 +464,9 @@ static int disable_periodic (struct ehci_hcd *ehci)
461 u32 cmd; 464 u32 cmd;
462 int status; 465 int status;
463 466
467 if (--ehci->periodic_sched)
468 return 0;
469
464 /* did setting PSE not take effect yet? 470 /* did setting PSE not take effect yet?
465 * takes effect only at frame boundaries... 471 * takes effect only at frame boundaries...
466 */ 472 */
@@ -544,13 +550,10 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
544 : (qh->usecs * 8); 550 : (qh->usecs * 8);
545 551
546 /* maybe enable periodic schedule processing */ 552 /* maybe enable periodic schedule processing */
547 if (!ehci->periodic_sched++) 553 return enable_periodic(ehci);
548 return enable_periodic (ehci);
549
550 return 0;
551} 554}
552 555
553static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) 556static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
554{ 557{
555 unsigned i; 558 unsigned i;
556 unsigned period; 559 unsigned period;
@@ -586,9 +589,7 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
586 qh_put (qh); 589 qh_put (qh);
587 590
588 /* maybe turn off periodic schedule */ 591 /* maybe turn off periodic schedule */
589 ehci->periodic_sched--; 592 return disable_periodic(ehci);
590 if (!ehci->periodic_sched)
591 (void) disable_periodic (ehci);
592} 593}
593 594
594static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) 595static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
@@ -1562,9 +1563,7 @@ itd_link_urb (
1562 urb->hcpriv = NULL; 1563 urb->hcpriv = NULL;
1563 1564
1564 timer_action (ehci, TIMER_IO_WATCHDOG); 1565 timer_action (ehci, TIMER_IO_WATCHDOG);
1565 if (unlikely (!ehci->periodic_sched++)) 1566 return enable_periodic(ehci);
1566 return enable_periodic (ehci);
1567 return 0;
1568} 1567}
1569 1568
1570#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) 1569#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR)
@@ -1642,7 +1641,7 @@ itd_complete (
1642 ehci_urb_done(ehci, urb, 0); 1641 ehci_urb_done(ehci, urb, 0);
1643 retval = true; 1642 retval = true;
1644 urb = NULL; 1643 urb = NULL;
1645 ehci->periodic_sched--; 1644 (void) disable_periodic(ehci);
1646 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 1645 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
1647 1646
1648 if (unlikely (list_empty (&stream->td_list))) { 1647 if (unlikely (list_empty (&stream->td_list))) {
@@ -1951,9 +1950,7 @@ sitd_link_urb (
1951 urb->hcpriv = NULL; 1950 urb->hcpriv = NULL;
1952 1951
1953 timer_action (ehci, TIMER_IO_WATCHDOG); 1952 timer_action (ehci, TIMER_IO_WATCHDOG);
1954 if (!ehci->periodic_sched++) 1953 return enable_periodic(ehci);
1955 return enable_periodic (ehci);
1956 return 0;
1957} 1954}
1958 1955
1959/*-------------------------------------------------------------------------*/ 1956/*-------------------------------------------------------------------------*/
@@ -2019,7 +2016,7 @@ sitd_complete (
2019 ehci_urb_done(ehci, urb, 0); 2016 ehci_urb_done(ehci, urb, 0);
2020 retval = true; 2017 retval = true;
2021 urb = NULL; 2018 urb = NULL;
2022 ehci->periodic_sched--; 2019 (void) disable_periodic(ehci);
2023 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 2020 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
2024 2021
2025 if (list_empty (&stream->td_list)) { 2022 if (list_empty (&stream->td_list)) {
@@ -2243,8 +2240,7 @@ restart:
2243 if (unlikely (modified)) { 2240 if (unlikely (modified)) {
2244 if (likely(ehci->periodic_sched > 0)) 2241 if (likely(ehci->periodic_sched > 0))
2245 goto restart; 2242 goto restart;
2246 /* maybe we can short-circuit this scan! */ 2243 /* short-circuit this scan */
2247 disable_periodic(ehci);
2248 now_uframe = clock; 2244 now_uframe = clock;
2249 break; 2245 break;
2250 } 2246 }
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 5799298364fb..b697a13364ec 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -210,143 +210,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
210 210
211/*-------------------------------------------------------------------------*/ 211/*-------------------------------------------------------------------------*/
212 212
213/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ 213#include <linux/usb/ehci_def.h>
214
215/* Section 2.2 Host Controller Capability Registers */
216struct ehci_caps {
217 /* these fields are specified as 8 and 16 bit registers,
218 * but some hosts can't perform 8 or 16 bit PCI accesses.
219 */
220 u32 hc_capbase;
221#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
222#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
223 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
224#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
225#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
226#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
227#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
228#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
229#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
230#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
231
232 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
233#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
234#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
235#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
236#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
237#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
238#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
239 u8 portroute [8]; /* nibbles for routing - offset 0xC */
240} __attribute__ ((packed));
241
242
243/* Section 2.3 Host Controller Operational Registers */
244struct ehci_regs {
245
246 /* USBCMD: offset 0x00 */
247 u32 command;
248/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
249#define CMD_PARK (1<<11) /* enable "park" on async qh */
250#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
251#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
252#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
253#define CMD_ASE (1<<5) /* async schedule enable */
254#define CMD_PSE (1<<4) /* periodic schedule enable */
255/* 3:2 is periodic frame list size */
256#define CMD_RESET (1<<1) /* reset HC not bus */
257#define CMD_RUN (1<<0) /* start/stop HC */
258
259 /* USBSTS: offset 0x04 */
260 u32 status;
261#define STS_ASS (1<<15) /* Async Schedule Status */
262#define STS_PSS (1<<14) /* Periodic Schedule Status */
263#define STS_RECL (1<<13) /* Reclamation */
264#define STS_HALT (1<<12) /* Not running (any reason) */
265/* some bits reserved */
266 /* these STS_* flags are also intr_enable bits (USBINTR) */
267#define STS_IAA (1<<5) /* Interrupted on async advance */
268#define STS_FATAL (1<<4) /* such as some PCI access errors */
269#define STS_FLR (1<<3) /* frame list rolled over */
270#define STS_PCD (1<<2) /* port change detect */
271#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
272#define STS_INT (1<<0) /* "normal" completion (short, ...) */
273
274 /* USBINTR: offset 0x08 */
275 u32 intr_enable;
276
277 /* FRINDEX: offset 0x0C */
278 u32 frame_index; /* current microframe number */
279 /* CTRLDSSEGMENT: offset 0x10 */
280 u32 segment; /* address bits 63:32 if needed */
281 /* PERIODICLISTBASE: offset 0x14 */
282 u32 frame_list; /* points to periodic list */
283 /* ASYNCLISTADDR: offset 0x18 */
284 u32 async_next; /* address of next async queue head */
285
286 u32 reserved [9];
287
288 /* CONFIGFLAG: offset 0x40 */
289 u32 configured_flag;
290#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
291
292 /* PORTSC: offset 0x44 */
293 u32 port_status [0]; /* up to N_PORTS */
294/* 31:23 reserved */
295#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
296#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
297#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
298/* 19:16 for port testing */
299#define PORT_LED_OFF (0<<14)
300#define PORT_LED_AMBER (1<<14)
301#define PORT_LED_GREEN (2<<14)
302#define PORT_LED_MASK (3<<14)
303#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
304#define PORT_POWER (1<<12) /* true: has power (see PPC) */
305#define PORT_USB11(x) (((x)&(3<<10))==(1<<10)) /* USB 1.1 device */
306/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
307/* 9 reserved */
308#define PORT_RESET (1<<8) /* reset port */
309#define PORT_SUSPEND (1<<7) /* suspend port */
310#define PORT_RESUME (1<<6) /* resume it */
311#define PORT_OCC (1<<5) /* over current change */
312#define PORT_OC (1<<4) /* over current active */
313#define PORT_PEC (1<<3) /* port enable change */
314#define PORT_PE (1<<2) /* port enable */
315#define PORT_CSC (1<<1) /* connect status change */
316#define PORT_CONNECT (1<<0) /* device connected */
317#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
318} __attribute__ ((packed));
319
320#define USBMODE 0x68 /* USB Device mode */
321#define USBMODE_SDIS (1<<3) /* Stream disable */
322#define USBMODE_BE (1<<2) /* BE/LE endianness select */
323#define USBMODE_CM_HC (3<<0) /* host controller mode */
324#define USBMODE_CM_IDLE (0<<0) /* idle state */
325
326/* Appendix C, Debug port ... intended for use with special "debug devices"
327 * that can help if there's no serial console. (nonstandard enumeration.)
328 */
329struct ehci_dbg_port {
330 u32 control;
331#define DBGP_OWNER (1<<30)
332#define DBGP_ENABLED (1<<28)
333#define DBGP_DONE (1<<16)
334#define DBGP_INUSE (1<<10)
335#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
336# define DBGP_ERR_BAD 1
337# define DBGP_ERR_SIGNAL 2
338#define DBGP_ERROR (1<<6)
339#define DBGP_GO (1<<5)
340#define DBGP_OUT (1<<4)
341#define DBGP_LEN(x) (((x)>>0)&0x0f)
342 u32 pids;
343#define DBGP_PID_GET(x) (((x)>>16)&0xff)
344#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
345 u32 data03;
346 u32 data47;
347 u32 address;
348#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep))
349} __attribute__ ((packed));
350 214
351/*-------------------------------------------------------------------------*/ 215/*-------------------------------------------------------------------------*/
352 216
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 1eb64d08b60a..95b3ec89c126 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -208,7 +208,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)
208 if (cpu_is_omap16xx()) 208 if (cpu_is_omap16xx())
209 ocpi_enable(); 209 ocpi_enable();
210 210
211#ifdef CONFIG_ARCH_OMAP_OTG 211#ifdef CONFIG_USB_OTG
212 if (need_transceiver) { 212 if (need_transceiver) {
213 ohci->transceiver = otg_get_transceiver(); 213 ohci->transceiver = otg_get_transceiver();
214 if (ohci->transceiver) { 214 if (ohci->transceiver) {
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 7f0f35c78185..e294d430733b 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -23,17 +23,90 @@
23#include <linux/signal.h> 23#include <linux/signal.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/clk.h> 25#include <linux/clk.h>
26
27#include <mach/hardware.h>
28#include <mach/pxa-regs.h>
29#include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */
30#include <mach/ohci.h> 26#include <mach/ohci.h>
31 27
28/*
29 * UHC: USB Host Controller (OHCI-like) register definitions
30 */
31#define UHCREV (0x0000) /* UHC HCI Spec Revision */
32#define UHCHCON (0x0004) /* UHC Host Control Register */
33#define UHCCOMS (0x0008) /* UHC Command Status Register */
34#define UHCINTS (0x000C) /* UHC Interrupt Status Register */
35#define UHCINTE (0x0010) /* UHC Interrupt Enable */
36#define UHCINTD (0x0014) /* UHC Interrupt Disable */
37#define UHCHCCA (0x0018) /* UHC Host Controller Comm. Area */
38#define UHCPCED (0x001C) /* UHC Period Current Endpt Descr */
39#define UHCCHED (0x0020) /* UHC Control Head Endpt Descr */
40#define UHCCCED (0x0024) /* UHC Control Current Endpt Descr */
41#define UHCBHED (0x0028) /* UHC Bulk Head Endpt Descr */
42#define UHCBCED (0x002C) /* UHC Bulk Current Endpt Descr */
43#define UHCDHEAD (0x0030) /* UHC Done Head */
44#define UHCFMI (0x0034) /* UHC Frame Interval */
45#define UHCFMR (0x0038) /* UHC Frame Remaining */
46#define UHCFMN (0x003C) /* UHC Frame Number */
47#define UHCPERS (0x0040) /* UHC Periodic Start */
48#define UHCLS (0x0044) /* UHC Low Speed Threshold */
49
50#define UHCRHDA (0x0048) /* UHC Root Hub Descriptor A */
51#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
52#define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */
53#define UHCRHDA_POTPGT(x) \
54 (((x) & 0xff) << 24) /* Power On To Power Good Time */
55
56#define UHCRHDB (0x004C) /* UHC Root Hub Descriptor B */
57#define UHCRHS (0x0050) /* UHC Root Hub Status */
58#define UHCRHPS1 (0x0054) /* UHC Root Hub Port 1 Status */
59#define UHCRHPS2 (0x0058) /* UHC Root Hub Port 2 Status */
60#define UHCRHPS3 (0x005C) /* UHC Root Hub Port 3 Status */
61
62#define UHCSTAT (0x0060) /* UHC Status Register */
63#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
64#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
65#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
66#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
67#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
68#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
69#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
70#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
71#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
72
73#define UHCHR (0x0064) /* UHC Reset Register */
74#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
75#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
76#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
77#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
78#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
79#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
80#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
81#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
82#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
83#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
84#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
85
86#define UHCHIE (0x0068) /* UHC Interrupt Enable Register*/
87#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
88#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
89#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
90#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
91#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
92 Interrupt Enable*/
93#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
94#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
95
96#define UHCHIT (0x006C) /* UHC Interrupt Test register */
97
32#define PXA_UHC_MAX_PORTNUM 3 98#define PXA_UHC_MAX_PORTNUM 3
33 99
34#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) 100struct pxa27x_ohci {
101 /* must be 1st member here for hcd_to_ohci() to work */
102 struct ohci_hcd ohci;
103
104 struct device *dev;
105 struct clk *clk;
106 void __iomem *mmio_base;
107};
35 108
36static struct clk *usb_clk; 109#define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)hcd_to_ohci(hcd)
37 110
38/* 111/*
39 PMM_NPS_MODE -- PMM Non-power switching mode 112 PMM_NPS_MODE -- PMM Non-power switching mode
@@ -45,30 +118,35 @@ static struct clk *usb_clk;
45 PMM_PERPORT_MODE -- PMM per port switching mode 118 PMM_PERPORT_MODE -- PMM per port switching mode
46 Ports are powered individually. 119 Ports are powered individually.
47 */ 120 */
48static int pxa27x_ohci_select_pmm( int mode ) 121static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode)
49{ 122{
50 switch ( mode ) { 123 uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA);
124 uint32_t uhcrhdb = __raw_readl(ohci->mmio_base + UHCRHDB);
125
126 switch (mode) {
51 case PMM_NPS_MODE: 127 case PMM_NPS_MODE:
52 UHCRHDA |= RH_A_NPS; 128 uhcrhda |= RH_A_NPS;
53 break; 129 break;
54 case PMM_GLOBAL_MODE: 130 case PMM_GLOBAL_MODE:
55 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); 131 uhcrhda &= ~(RH_A_NPS & RH_A_PSM);
56 break; 132 break;
57 case PMM_PERPORT_MODE: 133 case PMM_PERPORT_MODE:
58 UHCRHDA &= ~(RH_A_NPS); 134 uhcrhda &= ~(RH_A_NPS);
59 UHCRHDA |= RH_A_PSM; 135 uhcrhda |= RH_A_PSM;
60 136
61 /* Set port power control mask bits, only 3 ports. */ 137 /* Set port power control mask bits, only 3 ports. */
62 UHCRHDB |= (0x7<<17); 138 uhcrhdb |= (0x7<<17);
63 break; 139 break;
64 default: 140 default:
65 printk( KERN_ERR 141 printk( KERN_ERR
66 "Invalid mode %d, set to non-power switch mode.\n", 142 "Invalid mode %d, set to non-power switch mode.\n",
67 mode ); 143 mode );
68 144
69 UHCRHDA |= RH_A_NPS; 145 uhcrhda |= RH_A_NPS;
70 } 146 }
71 147
148 __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA);
149 __raw_writel(uhcrhdb, ohci->mmio_base + UHCRHDB);
72 return 0; 150 return 0;
73} 151}
74 152
@@ -76,57 +154,110 @@ extern int usb_disabled(void);
76 154
77/*-------------------------------------------------------------------------*/ 155/*-------------------------------------------------------------------------*/
78 156
79static int pxa27x_start_hc(struct device *dev) 157static inline void pxa27x_setup_hc(struct pxa27x_ohci *ohci,
158 struct pxaohci_platform_data *inf)
159{
160 uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR);
161 uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA);
162
163 if (inf->flags & ENABLE_PORT1)
164 uhchr &= ~UHCHR_SSEP1;
165
166 if (inf->flags & ENABLE_PORT2)
167 uhchr &= ~UHCHR_SSEP2;
168
169 if (inf->flags & ENABLE_PORT3)
170 uhchr &= ~UHCHR_SSEP3;
171
172 if (inf->flags & POWER_CONTROL_LOW)
173 uhchr |= UHCHR_PCPL;
174
175 if (inf->flags & POWER_SENSE_LOW)
176 uhchr |= UHCHR_PSPL;
177
178 if (inf->flags & NO_OC_PROTECTION)
179 uhcrhda |= UHCRHDA_NOCP;
180
181 if (inf->flags & OC_MODE_PERPORT)
182 uhcrhda |= UHCRHDA_OCPM;
183
184 if (inf->power_on_delay) {
185 uhcrhda &= ~UHCRHDA_POTPGT(0xff);
186 uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2);
187 }
188
189 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
190 __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA);
191}
192
193static inline void pxa27x_reset_hc(struct pxa27x_ohci *ohci)
194{
195 uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR);
196
197 __raw_writel(uhchr | UHCHR_FHR, ohci->mmio_base + UHCHR);
198 udelay(11);
199 __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR);
200}
201
202#ifdef CONFIG_CPU_PXA27x
203extern void pxa27x_clear_otgph(void);
204#else
205#define pxa27x_clear_otgph() do {} while (0)
206#endif
207
208static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev)
80{ 209{
81 int retval = 0; 210 int retval = 0;
82 struct pxaohci_platform_data *inf; 211 struct pxaohci_platform_data *inf;
212 uint32_t uhchr;
83 213
84 inf = dev->platform_data; 214 inf = dev->platform_data;
85 215
86 clk_enable(usb_clk); 216 clk_enable(ohci->clk);
87 217
88 UHCHR |= UHCHR_FHR; 218 pxa27x_reset_hc(ohci);
89 udelay(11); 219
90 UHCHR &= ~UHCHR_FHR; 220 uhchr = __raw_readl(ohci->mmio_base + UHCHR) | UHCHR_FSBIR;
221 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
91 222
92 UHCHR |= UHCHR_FSBIR; 223 while (__raw_readl(ohci->mmio_base + UHCHR) & UHCHR_FSBIR)
93 while (UHCHR & UHCHR_FSBIR)
94 cpu_relax(); 224 cpu_relax();
95 225
226 pxa27x_setup_hc(ohci, inf);
227
96 if (inf->init) 228 if (inf->init)
97 retval = inf->init(dev); 229 retval = inf->init(dev);
98 230
99 if (retval < 0) 231 if (retval < 0)
100 return retval; 232 return retval;
101 233
102 UHCHR &= ~UHCHR_SSE; 234 uhchr = __raw_readl(ohci->mmio_base + UHCHR) & ~UHCHR_SSE;
103 235 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
104 UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE); 236 __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, ohci->mmio_base + UHCHIE);
105 237
106 /* Clear any OTG Pin Hold */ 238 /* Clear any OTG Pin Hold */
107 if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH)) 239 pxa27x_clear_otgph();
108 PSSR |= PSSR_OTGPH;
109
110 return 0; 240 return 0;
111} 241}
112 242
113static void pxa27x_stop_hc(struct device *dev) 243static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev)
114{ 244{
115 struct pxaohci_platform_data *inf; 245 struct pxaohci_platform_data *inf;
246 uint32_t uhccoms;
116 247
117 inf = dev->platform_data; 248 inf = dev->platform_data;
118 249
119 if (inf->exit) 250 if (inf->exit)
120 inf->exit(dev); 251 inf->exit(dev);
121 252
122 UHCHR |= UHCHR_FHR; 253 pxa27x_reset_hc(ohci);
123 udelay(11);
124 UHCHR &= ~UHCHR_FHR;
125 254
126 UHCCOMS |= 1; 255 /* Host Controller Reset */
256 uhccoms = __raw_readl(ohci->mmio_base + UHCCOMS) | 0x01;
257 __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS);
127 udelay(10); 258 udelay(10);
128 259
129 clk_disable(usb_clk); 260 clk_disable(ohci->clk);
130} 261}
131 262
132 263
@@ -147,18 +278,22 @@ static void pxa27x_stop_hc(struct device *dev)
147 */ 278 */
148int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) 279int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
149{ 280{
150 int retval; 281 int retval, irq;
151 struct usb_hcd *hcd; 282 struct usb_hcd *hcd;
152 struct pxaohci_platform_data *inf; 283 struct pxaohci_platform_data *inf;
284 struct pxa27x_ohci *ohci;
285 struct resource *r;
286 struct clk *usb_clk;
153 287
154 inf = pdev->dev.platform_data; 288 inf = pdev->dev.platform_data;
155 289
156 if (!inf) 290 if (!inf)
157 return -ENODEV; 291 return -ENODEV;
158 292
159 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 293 irq = platform_get_irq(pdev, 0);
160 pr_debug ("resource[1] is not IORESOURCE_IRQ"); 294 if (irq < 0) {
161 return -ENOMEM; 295 pr_err("no resource of IORESOURCE_IRQ");
296 return -ENXIO;
162 } 297 }
163 298
164 usb_clk = clk_get(&pdev->dev, "USBCLK"); 299 usb_clk = clk_get(&pdev->dev, "USBCLK");
@@ -168,8 +303,16 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
168 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); 303 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
169 if (!hcd) 304 if (!hcd)
170 return -ENOMEM; 305 return -ENOMEM;
171 hcd->rsrc_start = pdev->resource[0].start; 306
172 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; 307 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
308 if (!r) {
309 pr_err("no resource of IORESOURCE_MEM");
310 retval = -ENXIO;
311 goto err1;
312 }
313
314 hcd->rsrc_start = r->start;
315 hcd->rsrc_len = resource_size(r);
173 316
174 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 317 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
175 pr_debug("request_mem_region failed"); 318 pr_debug("request_mem_region failed");
@@ -184,24 +327,30 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
184 goto err2; 327 goto err2;
185 } 328 }
186 329
187 if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { 330 /* initialize "struct pxa27x_ohci" */
331 ohci = (struct pxa27x_ohci *)hcd_to_ohci(hcd);
332 ohci->dev = &pdev->dev;
333 ohci->clk = usb_clk;
334 ohci->mmio_base = (void __iomem *)hcd->regs;
335
336 if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) {
188 pr_debug("pxa27x_start_hc failed"); 337 pr_debug("pxa27x_start_hc failed");
189 goto err3; 338 goto err3;
190 } 339 }
191 340
192 /* Select Power Management Mode */ 341 /* Select Power Management Mode */
193 pxa27x_ohci_select_pmm(inf->port_mode); 342 pxa27x_ohci_select_pmm(ohci, inf->port_mode);
194 343
195 if (inf->power_budget) 344 if (inf->power_budget)
196 hcd->power_budget = inf->power_budget; 345 hcd->power_budget = inf->power_budget;
197 346
198 ohci_hcd_init(hcd_to_ohci(hcd)); 347 ohci_hcd_init(hcd_to_ohci(hcd));
199 348
200 retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); 349 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
201 if (retval == 0) 350 if (retval == 0)
202 return retval; 351 return retval;
203 352
204 pxa27x_stop_hc(&pdev->dev); 353 pxa27x_stop_hc(ohci, &pdev->dev);
205 err3: 354 err3:
206 iounmap(hcd->regs); 355 iounmap(hcd->regs);
207 err2: 356 err2:
@@ -228,12 +377,14 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
228 */ 377 */
229void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) 378void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
230{ 379{
380 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
381
231 usb_remove_hcd(hcd); 382 usb_remove_hcd(hcd);
232 pxa27x_stop_hc(&pdev->dev); 383 pxa27x_stop_hc(ohci, &pdev->dev);
233 iounmap(hcd->regs); 384 iounmap(hcd->regs);
234 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 385 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
235 usb_put_hcd(hcd); 386 usb_put_hcd(hcd);
236 clk_put(usb_clk); 387 clk_put(ohci->clk);
237} 388}
238 389
239/*-------------------------------------------------------------------------*/ 390/*-------------------------------------------------------------------------*/
@@ -266,7 +417,7 @@ ohci_pxa27x_start (struct usb_hcd *hcd)
266static const struct hc_driver ohci_pxa27x_hc_driver = { 417static const struct hc_driver ohci_pxa27x_hc_driver = {
267 .description = hcd_name, 418 .description = hcd_name,
268 .product_desc = "PXA27x OHCI", 419 .product_desc = "PXA27x OHCI",
269 .hcd_priv_size = sizeof(struct ohci_hcd), 420 .hcd_priv_size = sizeof(struct pxa27x_ohci),
270 421
271 /* 422 /*
272 * generic hardware linkage 423 * generic hardware linkage
@@ -330,13 +481,13 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
330static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) 481static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state)
331{ 482{
332 struct usb_hcd *hcd = platform_get_drvdata(pdev); 483 struct usb_hcd *hcd = platform_get_drvdata(pdev);
333 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 484 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
334 485
335 if (time_before(jiffies, ohci->next_statechange)) 486 if (time_before(jiffies, ohci->ohci.next_statechange))
336 msleep(5); 487 msleep(5);
337 ohci->next_statechange = jiffies; 488 ohci->ohci.next_statechange = jiffies;
338 489
339 pxa27x_stop_hc(&pdev->dev); 490 pxa27x_stop_hc(ohci, &pdev->dev);
340 hcd->state = HC_STATE_SUSPENDED; 491 hcd->state = HC_STATE_SUSPENDED;
341 492
342 return 0; 493 return 0;
@@ -345,14 +496,14 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_
345static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) 496static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
346{ 497{
347 struct usb_hcd *hcd = platform_get_drvdata(pdev); 498 struct usb_hcd *hcd = platform_get_drvdata(pdev);
348 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 499 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
349 int status; 500 int status;
350 501
351 if (time_before(jiffies, ohci->next_statechange)) 502 if (time_before(jiffies, ohci->ohci.next_statechange))
352 msleep(5); 503 msleep(5);
353 ohci->next_statechange = jiffies; 504 ohci->ohci.next_statechange = jiffies;
354 505
355 if ((status = pxa27x_start_hc(&pdev->dev)) < 0) 506 if ((status = pxa27x_start_hc(ohci, &pdev->dev)) < 0)
356 return status; 507 return status;
357 508
358 ohci_finish_controller_resume(hcd); 509 ohci_finish_controller_resume(hcd);
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 5da63f535005..516848dd9b48 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -112,7 +112,8 @@ static struct platform_device platform_dev = {
112 .num_resources = ARRAY_SIZE(resources), 112 .num_resources = ARRAY_SIZE(resources),
113}; 113};
114 114
115static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) 115static int sl811_hc_init(struct device *parent, resource_size_t base_addr,
116 int irq)
116{ 117{
117 if (platform_dev.dev.parent) 118 if (platform_dev.dev.parent)
118 return -EBUSY; 119 return -EBUSY;
@@ -155,97 +156,72 @@ static void sl811_cs_release(struct pcmcia_device * link)
155 platform_device_unregister(&platform_dev); 156 platform_device_unregister(&platform_dev);
156} 157}
157 158
159static int sl811_cs_config_check(struct pcmcia_device *p_dev,
160 cistpl_cftable_entry_t *cfg,
161 cistpl_cftable_entry_t *dflt,
162 unsigned int vcc,
163 void *priv_data)
164{
165 if (cfg->index == 0)
166 return -ENODEV;
167
168 /* Use power settings for Vcc and Vpp if present */
169 /* Note that the CIS values need to be rescaled */
170 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
171 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
172 return -ENODEV;
173 } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
174 if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
175 return -ENODEV;
176 }
177
178 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
179 p_dev->conf.Vpp =
180 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
181 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
182 p_dev->conf.Vpp =
183 dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
184
185 /* we need an interrupt */
186 if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
187 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
188
189 /* IO window settings */
190 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
191 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
192 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
193
194 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
195 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
196 p_dev->io.BasePort1 = io->win[0].base;
197 p_dev->io.NumPorts1 = io->win[0].len;
198
199 return pcmcia_request_io(p_dev, &p_dev->io);
200 }
201 pcmcia_disable_device(p_dev);
202 return -ENODEV;
203}
204
205
158static int sl811_cs_config(struct pcmcia_device *link) 206static int sl811_cs_config(struct pcmcia_device *link)
159{ 207{
160 struct device *parent = &handle_to_dev(link); 208 struct device *parent = &handle_to_dev(link);
161 local_info_t *dev = link->priv; 209 local_info_t *dev = link->priv;
162 tuple_t tuple;
163 cisparse_t parse;
164 int last_fn, last_ret; 210 int last_fn, last_ret;
165 u_char buf[64];
166 config_info_t conf;
167 cistpl_cftable_entry_t dflt = { 0 };
168 211
169 DBG(0, "sl811_cs_config(0x%p)\n", link); 212 DBG(0, "sl811_cs_config(0x%p)\n", link);
170 213
171 /* Look up the current Vcc */ 214 if (pcmcia_loop_config(link, sl811_cs_config_check, NULL))
172 CS_CHECK(GetConfigurationInfo, 215 goto failed;
173 pcmcia_get_configuration_info(link, &conf));
174
175 tuple.Attributes = 0;
176 tuple.TupleData = buf;
177 tuple.TupleDataMax = sizeof(buf);
178 tuple.TupleOffset = 0;
179 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
180 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
181 while (1) {
182 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
183
184 if (pcmcia_get_tuple_data(link, &tuple) != 0
185 || pcmcia_parse_tuple(link, &tuple, &parse)
186 != 0)
187 goto next_entry;
188
189 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) {
190 dflt = *cfg;
191 }
192
193 if (cfg->index == 0)
194 goto next_entry;
195
196 link->conf.ConfigIndex = cfg->index;
197
198 /* Use power settings for Vcc and Vpp if present */
199 /* Note that the CIS values need to be rescaled */
200 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
201 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000
202 != conf.Vcc)
203 goto next_entry;
204 } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
205 if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000
206 != conf.Vcc)
207 goto next_entry;
208 }
209
210 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
211 link->conf.Vpp =
212 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
213 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
214 link->conf.Vpp =
215 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
216
217 /* we need an interrupt */
218 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
219 link->conf.Attributes |= CONF_ENABLE_IRQ;
220
221 /* IO window settings */
222 link->io.NumPorts1 = link->io.NumPorts2 = 0;
223 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
224 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
225
226 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
227 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
228 link->io.BasePort1 = io->win[0].base;
229 link->io.NumPorts1 = io->win[0].len;
230
231 if (pcmcia_request_io(link, &link->io) != 0)
232 goto next_entry;
233 }
234 break;
235
236next_entry:
237 pcmcia_disable_device(link);
238 last_ret = pcmcia_get_next_tuple(link, &tuple);
239 }
240 216
241 /* require an IRQ and two registers */ 217 /* require an IRQ and two registers */
242 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) 218 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
243 goto cs_failed; 219 goto failed;
244 if (link->conf.Attributes & CONF_ENABLE_IRQ) 220 if (link->conf.Attributes & CONF_ENABLE_IRQ)
245 CS_CHECK(RequestIRQ, 221 CS_CHECK(RequestIRQ,
246 pcmcia_request_irq(link, &link->irq)); 222 pcmcia_request_irq(link, &link->irq));
247 else 223 else
248 goto cs_failed; 224 goto failed;
249 225
250 CS_CHECK(RequestConfiguration, 226 CS_CHECK(RequestConfiguration,
251 pcmcia_request_configuration(link, &link->conf)); 227 pcmcia_request_configuration(link, &link->conf));
@@ -266,8 +242,9 @@ next_entry:
266 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) 242 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ)
267 < 0) { 243 < 0) {
268cs_failed: 244cs_failed:
269 printk("sl811_cs_config failed\n");
270 cs_error(link, last_fn, last_ret); 245 cs_error(link, last_fn, last_ret);
246failed:
247 printk(KERN_WARNING "sl811_cs_config failed\n");
271 sl811_cs_release(link); 248 sl811_cs_release(link);
272 return -ENODEV; 249 return -ENODEV;
273 } 250 }
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index a0017486ad4e..58b2b8fc9439 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -9,6 +9,7 @@ comment "Enable Host or Gadget support to see Inventra options"
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) && HAVE_CLK
12 depends on !SUPERH
12 select TWL4030_USB if MACH_OMAP_3430SDP 13 select TWL4030_USB if MACH_OMAP_3430SDP
13 tristate 'Inventra Highspeed Dual Role Controller (TI, ...)' 14 tristate 'Inventra Highspeed Dual Role Controller (TI, ...)'
14 help 15 help
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index c5b8f0296fcf..128e949db47c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -100,8 +100,8 @@
100#include <linux/io.h> 100#include <linux/io.h>
101 101
102#ifdef CONFIG_ARM 102#ifdef CONFIG_ARM
103#include <asm/arch/hardware.h> 103#include <mach/hardware.h>
104#include <asm/arch/memory.h> 104#include <mach/memory.h>
105#include <asm/mach-types.h> 105#include <asm/mach-types.h>
106#endif 106#endif
107 107
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 298b22e6ad0d..9d2dcb121c5e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -35,8 +35,8 @@
35#include <linux/io.h> 35#include <linux/io.h>
36 36
37#include <asm/mach-types.h> 37#include <asm/mach-types.h>
38#include <asm/arch/hardware.h> 38#include <mach/hardware.h>
39#include <asm/arch/mux.h> 39#include <mach/mux.h>
40 40
41#include "musb_core.h" 41#include "musb_core.h"
42#include "omap2430.h" 42#include "omap2430.h"
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index 786a62071f72..dc7670718cd2 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -11,8 +11,8 @@
11#define __MUSB_OMAP243X_H__ 11#define __MUSB_OMAP243X_H__
12 12
13#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) 13#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
14#include <asm/arch/hardware.h> 14#include <mach/hardware.h>
15#include <asm/arch/usb.h> 15#include <mach/usb.h>
16 16
17/* 17/*
18 * OMAP2430-specific definitions 18 * OMAP2430-specific definitions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 79ea98c66fa8..99fb7dc59c45 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work)
272 * 64 bytes, to ensure I do not get throttled. 272 * 64 bytes, to ensure I do not get throttled.
273 * Ask USB mailing list for better aproach. 273 * Ask USB mailing list for better aproach.
274 */ 274 */
275 tty = port->port.tty; 275 tty = tty_port_tty_get(&port->port);
276 276
277 if (!tty) { 277 if (!tty) {
278 schedule_work(&priv->rx_work); 278 schedule_work(&priv->rx_work);
@@ -283,12 +283,13 @@ static void aircable_read(struct work_struct *work)
283 count = min(64, serial_buf_data_avail(priv->rx_buf)); 283 count = min(64, serial_buf_data_avail(priv->rx_buf));
284 284
285 if (count <= 0) 285 if (count <= 0)
286 return; /* We have finished sending everything. */ 286 goto out; /* We have finished sending everything. */
287 287
288 tty_prepare_flip_string(tty, &data, count); 288 tty_prepare_flip_string(tty, &data, count);
289 if (!data) { 289 if (!data) {
290 err("%s- kzalloc(%d) failed.", __func__, count); 290 dev_err(&port->dev, "%s- kzalloc(%d) failed.",
291 return; 291 __func__, count);
292 goto out;
292 } 293 }
293 294
294 serial_buf_get(priv->rx_buf, data, count); 295 serial_buf_get(priv->rx_buf, data, count);
@@ -297,7 +298,8 @@ static void aircable_read(struct work_struct *work)
297 298
298 if (serial_buf_data_avail(priv->rx_buf)) 299 if (serial_buf_data_avail(priv->rx_buf))
299 schedule_work(&priv->rx_work); 300 schedule_work(&priv->rx_work);
300 301out:
302 tty_kref_put(tty);
301 return; 303 return;
302} 304}
303/* End of private methods */ 305/* End of private methods */
@@ -495,7 +497,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
495 usb_serial_debug_data(debug, &port->dev, __func__, 497 usb_serial_debug_data(debug, &port->dev, __func__,
496 urb->actual_length, urb->transfer_buffer); 498 urb->actual_length, urb->transfer_buffer);
497 499
498 tty = port->port.tty; 500 tty = tty_port_tty_get(&port->port);
499 if (tty && urb->actual_length) { 501 if (tty && urb->actual_length) {
500 if (urb->actual_length <= 2) { 502 if (urb->actual_length <= 2) {
501 /* This is an incomplete package */ 503 /* This is an incomplete package */
@@ -527,6 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
527 } 529 }
528 aircable_read(&priv->rx_work); 530 aircable_read(&priv->rx_work);
529 } 531 }
532 tty_kref_put(tty);
530 533
531 /* Schedule the next read _if_ we are still open */ 534 /* Schedule the next read _if_ we are still open */
532 if (port->port.count) { 535 if (port->port.count) {
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 2ebe06c3405a..1913bc7c5f0b 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -322,7 +322,7 @@ static void belkin_sa_read_int_callback(struct urb *urb)
322 * to look in to this before committing any code. 322 * to look in to this before committing any code.
323 */ 323 */
324 if (priv->last_lsr & BELKIN_SA_LSR_ERR) { 324 if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
325 tty = port->port.tty; 325 tty = tty_port_tty_get(&port->port);
326 /* Overrun Error */ 326 /* Overrun Error */
327 if (priv->last_lsr & BELKIN_SA_LSR_OE) { 327 if (priv->last_lsr & BELKIN_SA_LSR_OE) {
328 } 328 }
@@ -335,6 +335,7 @@ static void belkin_sa_read_int_callback(struct urb *urb)
335 /* Break Indicator */ 335 /* Break Indicator */
336 if (priv->last_lsr & BELKIN_SA_LSR_BI) { 336 if (priv->last_lsr & BELKIN_SA_LSR_BI) {
337 } 337 }
338 tty_kref_put(tty);
338 } 339 }
339#endif 340#endif
340 spin_unlock_irqrestore(&priv->lock, flags); 341 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 7b74238ad1c7..5b20de130e08 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -117,7 +117,7 @@ static int usb_console_setup(struct console *co, char *options)
117 } 117 }
118 118
119 port = serial->port[0]; 119 port = serial->port[0];
120 port->port.tty = NULL; 120 tty_port_tty_set(&port->port, NULL);
121 121
122 info->port = port; 122 info->port = port;
123 123
@@ -143,7 +143,7 @@ static int usb_console_setup(struct console *co, char *options)
143 } 143 }
144 memset(&dummy, 0, sizeof(struct ktermios)); 144 memset(&dummy, 0, sizeof(struct ktermios));
145 tty->termios = termios; 145 tty->termios = termios;
146 port->port.tty = tty; 146 tty_port_tty_set(&port->port, tty);
147 } 147 }
148 148
149 /* only call the device specific open if this 149 /* only call the device specific open if this
@@ -161,9 +161,9 @@ static int usb_console_setup(struct console *co, char *options)
161 if (serial->type->set_termios) { 161 if (serial->type->set_termios) {
162 termios->c_cflag = cflag; 162 termios->c_cflag = cflag;
163 tty_termios_encode_baud_rate(termios, baud, baud); 163 tty_termios_encode_baud_rate(termios, baud, baud);
164 serial->type->set_termios(NULL, port, &dummy); 164 serial->type->set_termios(tty, port, &dummy);
165 165
166 port->port.tty = NULL; 166 tty_port_tty_set(&port->port, NULL);
167 kfree(termios); 167 kfree(termios);
168 kfree(tty); 168 kfree(tty);
169 } 169 }
@@ -176,7 +176,7 @@ out:
176 return retval; 176 return retval;
177free_termios: 177free_termios:
178 kfree(termios); 178 kfree(termios);
179 port->port.tty = NULL; 179 tty_port_tty_set(&port->port, NULL);
180free_tty: 180free_tty:
181 kfree(tty); 181 kfree(tty);
182reset_open_count: 182reset_open_count:
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 442cba69cce5..1279553381e3 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -72,6 +72,7 @@ static struct usb_device_id id_table [] = {
72 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ 72 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
73 { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */ 73 { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */
74 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 74 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
75 { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */
75 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 76 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
76 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 77 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
77 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 78 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
@@ -83,6 +84,7 @@ static struct usb_device_id id_table [] = {
83 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 84 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
84 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 85 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
85 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 86 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
87 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
86 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 88 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
87 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 89 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
88 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 90 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
@@ -93,6 +95,7 @@ static struct usb_device_id id_table [] = {
93 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ 95 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */
94 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ 96 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */
95 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 97 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
98 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
96 { } /* Terminating Entry */ 99 { } /* Terminating Entry */
97}; 100};
98 101
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index b4d72351cb96..94ef36c4764b 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -384,7 +384,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
384 return; 384 return;
385 } 385 }
386 386
387 tty = port->port.tty; 387 tty = tty_port_tty_get(&port->port);
388 if (!tty) { 388 if (!tty) {
389 dbg("%s - ignoring since device not open\n", __func__); 389 dbg("%s - ignoring since device not open\n", __func__);
390 return; 390 return;
@@ -394,6 +394,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
394 tty_insert_flip_string(tty, data, urb->actual_length); 394 tty_insert_flip_string(tty, data, urb->actual_length);
395 tty_flip_buffer_push(tty); 395 tty_flip_buffer_push(tty);
396 } 396 }
397 tty_kref_put(tty);
397 398
398 spin_lock(&priv->lock); 399 spin_lock(&priv->lock);
399 400
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 22837a3f2f89..f3514a91f915 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1286,7 +1286,7 @@ static void cypress_read_int_callback(struct urb *urb)
1286 } 1286 }
1287 spin_unlock_irqrestore(&priv->lock, flags); 1287 spin_unlock_irqrestore(&priv->lock, flags);
1288 1288
1289 tty = port->port.tty; 1289 tty = tty_port_tty_get(&port->port);
1290 if (!tty) { 1290 if (!tty) {
1291 dbg("%s - bad tty pointer - exiting", __func__); 1291 dbg("%s - bad tty pointer - exiting", __func__);
1292 return; 1292 return;
@@ -1362,7 +1362,7 @@ static void cypress_read_int_callback(struct urb *urb)
1362 data[i]); 1362 data[i]);
1363 tty_insert_flip_char(tty, data[i], tty_flag); 1363 tty_insert_flip_char(tty, data[i], tty_flag);
1364 } 1364 }
1365 tty_flip_buffer_push(port->port.tty); 1365 tty_flip_buffer_push(tty);
1366 } 1366 }
1367 1367
1368 spin_lock_irqsave(&priv->lock, flags); 1368 spin_lock_irqsave(&priv->lock, flags);
@@ -1371,6 +1371,7 @@ static void cypress_read_int_callback(struct urb *urb)
1371 spin_unlock_irqrestore(&priv->lock, flags); 1371 spin_unlock_irqrestore(&priv->lock, flags);
1372 1372
1373continue_read: 1373continue_read:
1374 tty_kref_put(tty);
1374 1375
1375 /* Continue trying to always read... unless the port has closed. */ 1376 /* Continue trying to always read... unless the port has closed. */
1376 1377
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 240aad1acaab..5756ac6d6c92 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -604,7 +604,9 @@ static void digi_wakeup_write_lock(struct work_struct *work)
604 604
605static void digi_wakeup_write(struct usb_serial_port *port) 605static void digi_wakeup_write(struct usb_serial_port *port)
606{ 606{
607 tty_wakeup(port->port.tty); 607 struct tty_struct *tty = tty_port_tty_get(&port->port);
608 tty_wakeup(tty);
609 tty_kref_put(tty);
608} 610}
609 611
610 612
@@ -1668,7 +1670,7 @@ static int digi_read_inb_callback(struct urb *urb)
1668{ 1670{
1669 1671
1670 struct usb_serial_port *port = urb->context; 1672 struct usb_serial_port *port = urb->context;
1671 struct tty_struct *tty = port->port.tty; 1673 struct tty_struct *tty;
1672 struct digi_port *priv = usb_get_serial_port_data(port); 1674 struct digi_port *priv = usb_get_serial_port_data(port);
1673 int opcode = ((unsigned char *)urb->transfer_buffer)[0]; 1675 int opcode = ((unsigned char *)urb->transfer_buffer)[0];
1674 int len = ((unsigned char *)urb->transfer_buffer)[1]; 1676 int len = ((unsigned char *)urb->transfer_buffer)[1];
@@ -1692,6 +1694,7 @@ static int digi_read_inb_callback(struct urb *urb)
1692 return -1; 1694 return -1;
1693 } 1695 }
1694 1696
1697 tty = tty_port_tty_get(&port->port);
1695 spin_lock(&priv->dp_port_lock); 1698 spin_lock(&priv->dp_port_lock);
1696 1699
1697 /* check for throttle; if set, do not resubmit read urb */ 1700 /* check for throttle; if set, do not resubmit read urb */
@@ -1735,6 +1738,7 @@ static int digi_read_inb_callback(struct urb *urb)
1735 } 1738 }
1736 } 1739 }
1737 spin_unlock(&priv->dp_port_lock); 1740 spin_unlock(&priv->dp_port_lock);
1741 tty_kref_put(tty);
1738 1742
1739 if (opcode == DIGI_CMD_RECEIVE_DISABLE) 1743 if (opcode == DIGI_CMD_RECEIVE_DISABLE)
1740 dbg("%s: got RECEIVE_DISABLE", __func__); 1744 dbg("%s: got RECEIVE_DISABLE", __func__);
@@ -1760,6 +1764,7 @@ static int digi_read_oob_callback(struct urb *urb)
1760 1764
1761 struct usb_serial_port *port = urb->context; 1765 struct usb_serial_port *port = urb->context;
1762 struct usb_serial *serial = port->serial; 1766 struct usb_serial *serial = port->serial;
1767 struct tty_struct *tty;
1763 struct digi_port *priv = usb_get_serial_port_data(port); 1768 struct digi_port *priv = usb_get_serial_port_data(port);
1764 int opcode, line, status, val; 1769 int opcode, line, status, val;
1765 int i; 1770 int i;
@@ -1787,10 +1792,11 @@ static int digi_read_oob_callback(struct urb *urb)
1787 if (priv == NULL) 1792 if (priv == NULL)
1788 return -1; 1793 return -1;
1789 1794
1795 tty = tty_port_tty_get(&port->port);
1790 rts = 0; 1796 rts = 0;
1791 if (port->port.count) 1797 if (port->port.count)
1792 rts = port->port.tty->termios->c_cflag & CRTSCTS; 1798 rts = tty->termios->c_cflag & CRTSCTS;
1793 1799
1794 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { 1800 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
1795 spin_lock(&priv->dp_port_lock); 1801 spin_lock(&priv->dp_port_lock);
1796 /* convert from digi flags to termiox flags */ 1802 /* convert from digi flags to termiox flags */
@@ -1798,14 +1804,14 @@ static int digi_read_oob_callback(struct urb *urb)
1798 priv->dp_modem_signals |= TIOCM_CTS; 1804 priv->dp_modem_signals |= TIOCM_CTS;
1799 /* port must be open to use tty struct */ 1805 /* port must be open to use tty struct */
1800 if (rts) { 1806 if (rts) {
1801 port->port.tty->hw_stopped = 0; 1807 tty->hw_stopped = 0;
1802 digi_wakeup_write(port); 1808 digi_wakeup_write(port);
1803 } 1809 }
1804 } else { 1810 } else {
1805 priv->dp_modem_signals &= ~TIOCM_CTS; 1811 priv->dp_modem_signals &= ~TIOCM_CTS;
1806 /* port must be open to use tty struct */ 1812 /* port must be open to use tty struct */
1807 if (rts) 1813 if (rts)
1808 port->port.tty->hw_stopped = 1; 1814 tty->hw_stopped = 1;
1809 } 1815 }
1810 if (val & DIGI_READ_INPUT_SIGNALS_DSR) 1816 if (val & DIGI_READ_INPUT_SIGNALS_DSR)
1811 priv->dp_modem_signals |= TIOCM_DSR; 1817 priv->dp_modem_signals |= TIOCM_DSR;
@@ -1830,6 +1836,7 @@ static int digi_read_oob_callback(struct urb *urb)
1830 } else if (opcode == DIGI_CMD_IFLUSH_FIFO) { 1836 } else if (opcode == DIGI_CMD_IFLUSH_FIFO) {
1831 wake_up_interruptible(&priv->dp_flush_wait); 1837 wake_up_interruptible(&priv->dp_flush_wait);
1832 } 1838 }
1839 tty_kref_put(tty);
1833 } 1840 }
1834 return 0; 1841 return 0;
1835 1842
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index a6ab5b58d9ca..1072e847280f 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -33,9 +33,8 @@
33 * Moved MOD_DEC_USE_COUNT to end of empeg_close(). 33 * Moved MOD_DEC_USE_COUNT to end of empeg_close().
34 * 34 *
35 * (12/03/2000) gb 35 * (12/03/2000) gb
36 * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to 36 * Added tty->ldisc.set_termios(port, tty, NULL) to empeg_open().
37 * empeg_open(). This notifies the tty driver that the termios have 37 * This notifies the tty driver that the termios have changed.
38 * changed.
39 * 38 *
40 * (11/13/2000) gb 39 * (11/13/2000) gb
41 * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to 40 * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to
@@ -354,7 +353,7 @@ static void empeg_read_bulk_callback(struct urb *urb)
354 353
355 usb_serial_debug_data(debug, &port->dev, __func__, 354 usb_serial_debug_data(debug, &port->dev, __func__,
356 urb->actual_length, data); 355 urb->actual_length, data);
357 tty = port->port.tty; 356 tty = tty_port_tty_get(&port->port);
358 357
359 if (urb->actual_length) { 358 if (urb->actual_length) {
360 tty_buffer_request_room(tty, urb->actual_length); 359 tty_buffer_request_room(tty, urb->actual_length);
@@ -362,6 +361,7 @@ static void empeg_read_bulk_callback(struct urb *urb)
362 tty_flip_buffer_push(tty); 361 tty_flip_buffer_push(tty);
363 bytes_in += urb->actual_length; 362 bytes_in += urb->actual_length;
364 } 363 }
364 tty_kref_put(tty);
365 365
366 /* Continue trying to always read */ 366 /* Continue trying to always read */
367 usb_fill_bulk_urb( 367 usb_fill_bulk_urb(
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 984f6eff4c47..c2ac129557aa 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -654,6 +654,9 @@ static struct usb_device_id id_table_combined [] = {
654 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 654 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
655 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 655 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
656 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 656 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
657 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
658 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
659 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
657 { }, /* Optional parameter entry */ 660 { }, /* Optional parameter entry */
658 { } /* Terminating entry */ 661 { } /* Terminating entry */
659}; 662};
@@ -857,7 +860,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
857 860
858 kfree(buf); 861 kfree(buf);
859 if (rv < 0) { 862 if (rv < 0) {
860 err("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 863 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s",
861 __func__, 864 __func__,
862 (set & TIOCM_DTR) ? "HIGH" : 865 (set & TIOCM_DTR) ? "HIGH" :
863 (clear & TIOCM_DTR) ? "LOW" : "unchanged", 866 (clear & TIOCM_DTR) ? "LOW" : "unchanged",
@@ -1805,7 +1808,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1805 if (port->port.count <= 0) 1808 if (port->port.count <= 0)
1806 return; 1809 return;
1807 1810
1808 tty = port->port.tty; 1811 tty = tty_port_tty_get(&port->port);
1809 if (!tty) { 1812 if (!tty) {
1810 dbg("%s - bad tty pointer - exiting", __func__); 1813 dbg("%s - bad tty pointer - exiting", __func__);
1811 return; 1814 return;
@@ -1814,7 +1817,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1814 priv = usb_get_serial_port_data(port); 1817 priv = usb_get_serial_port_data(port);
1815 if (!priv) { 1818 if (!priv) {
1816 dbg("%s - bad port private data pointer - exiting", __func__); 1819 dbg("%s - bad port private data pointer - exiting", __func__);
1817 return; 1820 goto out;
1818 } 1821 }
1819 1822
1820 if (urb != port->read_urb) 1823 if (urb != port->read_urb)
@@ -1824,7 +1827,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1824 /* This will happen at close every time so it is a dbg not an 1827 /* This will happen at close every time so it is a dbg not an
1825 err */ 1828 err */
1826 dbg("(this is ok on close) nonzero read bulk status received: %d", status); 1829 dbg("(this is ok on close) nonzero read bulk status received: %d", status);
1827 return; 1830 goto out;
1828 } 1831 }
1829 1832
1830 /* count data bytes, but not status bytes */ 1833 /* count data bytes, but not status bytes */
@@ -1835,7 +1838,8 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1835 spin_unlock_irqrestore(&priv->rx_lock, flags); 1838 spin_unlock_irqrestore(&priv->rx_lock, flags);
1836 1839
1837 ftdi_process_read(&priv->rx_work.work); 1840 ftdi_process_read(&priv->rx_work.work);
1838 1841out:
1842 tty_kref_put(tty);
1839} /* ftdi_read_bulk_callback */ 1843} /* ftdi_read_bulk_callback */
1840 1844
1841 1845
@@ -1860,7 +1864,7 @@ static void ftdi_process_read(struct work_struct *work)
1860 if (port->port.count <= 0) 1864 if (port->port.count <= 0)
1861 return; 1865 return;
1862 1866
1863 tty = port->port.tty; 1867 tty = tty_port_tty_get(&port->port);
1864 if (!tty) { 1868 if (!tty) {
1865 dbg("%s - bad tty pointer - exiting", __func__); 1869 dbg("%s - bad tty pointer - exiting", __func__);
1866 return; 1870 return;
@@ -1869,13 +1873,13 @@ static void ftdi_process_read(struct work_struct *work)
1869 priv = usb_get_serial_port_data(port); 1873 priv = usb_get_serial_port_data(port);
1870 if (!priv) { 1874 if (!priv) {
1871 dbg("%s - bad port private data pointer - exiting", __func__); 1875 dbg("%s - bad port private data pointer - exiting", __func__);
1872 return; 1876 goto out;
1873 } 1877 }
1874 1878
1875 urb = port->read_urb; 1879 urb = port->read_urb;
1876 if (!urb) { 1880 if (!urb) {
1877 dbg("%s - bad read_urb pointer - exiting", __func__); 1881 dbg("%s - bad read_urb pointer - exiting", __func__);
1878 return; 1882 goto out;
1879 } 1883 }
1880 1884
1881 data = urb->transfer_buffer; 1885 data = urb->transfer_buffer;
@@ -2017,7 +2021,7 @@ static void ftdi_process_read(struct work_struct *work)
2017 schedule_delayed_work(&priv->rx_work, 1); 2021 schedule_delayed_work(&priv->rx_work, 1);
2018 else 2022 else
2019 dbg("%s - port is closed", __func__); 2023 dbg("%s - port is closed", __func__);
2020 return; 2024 goto out;
2021 } 2025 }
2022 2026
2023 /* urb is completely processed */ 2027 /* urb is completely processed */
@@ -2038,6 +2042,8 @@ static void ftdi_process_read(struct work_struct *work)
2038 err("%s - failed resubmitting read urb, error %d", 2042 err("%s - failed resubmitting read urb, error %d",
2039 __func__, result); 2043 __func__, result);
2040 } 2044 }
2045out:
2046 tty_kref_put(tty);
2041} /* ftdi_process_read */ 2047} /* ftdi_process_read */
2042 2048
2043 2049
@@ -2253,7 +2259,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2253 0, 0, 2259 0, 0,
2254 buf, 1, WDR_TIMEOUT); 2260 buf, 1, WDR_TIMEOUT);
2255 if (ret < 0) { 2261 if (ret < 0) {
2256 err("%s Could not get modem status of device - err: %d", __func__, 2262 dbg("%s Could not get modem status of device - err: %d", __func__,
2257 ret); 2263 ret);
2258 return ret; 2264 return ret;
2259 } 2265 }
@@ -2272,7 +2278,7 @@ static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2272 0, priv->interface, 2278 0, priv->interface,
2273 buf, 2, WDR_TIMEOUT); 2279 buf, 2, WDR_TIMEOUT);
2274 if (ret < 0) { 2280 if (ret < 0) {
2275 err("%s Could not get modem status of device - err: %d", __func__, 2281 dbg("%s Could not get modem status of device - err: %d", __func__,
2276 ret); 2282 ret);
2277 return ret; 2283 return ret;
2278 } 2284 }
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 382265bba969..8a5b6df3a976 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -750,6 +750,7 @@
750 750
751#define PAPOUCH_VID 0x5050 /* Vendor ID */ 751#define PAPOUCH_VID 0x5050 /* Vendor ID */
752#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ 752#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
753#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */
753 754
754/* 755/*
755 * ACG Identification Technologies GmbH products (http://www.acg.de/). 756 * ACG Identification Technologies GmbH products (http://www.acg.de/).
@@ -838,6 +839,10 @@
838/* Rig Expert Ukraine devices */ 839/* Rig Expert Ukraine devices */
839#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ 840#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */
840 841
842/* Domintell products http://www.domintell.com */
843#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
844#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
845
841/* Commands */ 846/* Commands */
842#define FTDI_SIO_RESET 0 /* Reset the port */ 847#define FTDI_SIO_RESET 0 /* Reset the port */
843#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 848#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index d95382088075..2ad0569bcf19 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -276,7 +276,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
276static void send_to_tty(struct usb_serial_port *port, 276static void send_to_tty(struct usb_serial_port *port,
277 char *data, unsigned int actual_length) 277 char *data, unsigned int actual_length)
278{ 278{
279 struct tty_struct *tty = port->port.tty; 279 struct tty_struct *tty = tty_port_tty_get(&port->port);
280 280
281 if (tty && actual_length) { 281 if (tty && actual_length) {
282 282
@@ -287,6 +287,7 @@ static void send_to_tty(struct usb_serial_port *port,
287 tty_insert_flip_string(tty, data, actual_length); 287 tty_insert_flip_string(tty, data, actual_length);
288 tty_flip_buffer_push(tty); 288 tty_flip_buffer_push(tty);
289 } 289 }
290 tty_kref_put(tty);
290} 291}
291 292
292 293
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index fe84c88ec20c..814909f1ee63 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -330,7 +330,7 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
330static void flush_and_resubmit_read_urb(struct usb_serial_port *port) 330static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
331{ 331{
332 struct urb *urb = port->read_urb; 332 struct urb *urb = port->read_urb;
333 struct tty_struct *tty = port->port.tty; 333 struct tty_struct *tty = tty_port_tty_get(&port->port);
334 int room; 334 int room;
335 335
336 /* Push data to tty */ 336 /* Push data to tty */
@@ -341,6 +341,7 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
341 tty_flip_buffer_push(tty); 341 tty_flip_buffer_push(tty);
342 } 342 }
343 } 343 }
344 tty_kref_put(tty);
344 345
345 resubmit_read_urb(port, GFP_ATOMIC); 346 resubmit_read_urb(port, GFP_ATOMIC);
346} 347}
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index bfa508ddb0fe..611f97fd62f1 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -600,6 +600,7 @@ static void edge_interrupt_callback(struct urb *urb)
600 struct edgeport_serial *edge_serial = urb->context; 600 struct edgeport_serial *edge_serial = urb->context;
601 struct edgeport_port *edge_port; 601 struct edgeport_port *edge_port;
602 struct usb_serial_port *port; 602 struct usb_serial_port *port;
603 struct tty_struct *tty;
603 unsigned char *data = urb->transfer_buffer; 604 unsigned char *data = urb->transfer_buffer;
604 int length = urb->actual_length; 605 int length = urb->actual_length;
605 int bytes_avail; 606 int bytes_avail;
@@ -675,9 +676,12 @@ static void edge_interrupt_callback(struct urb *urb)
675 676
676 /* tell the tty driver that something 677 /* tell the tty driver that something
677 has changed */ 678 has changed */
678 if (edge_port->port->port.tty) 679 tty = tty_port_tty_get(
679 tty_wakeup(edge_port->port->port.tty); 680 &edge_port->port->port);
680 681 if (tty) {
682 tty_wakeup(tty);
683 tty_kref_put(tty);
684 }
681 /* Since we have more credit, check 685 /* Since we have more credit, check
682 if more data can be sent */ 686 if more data can be sent */
683 send_more_port_data(edge_serial, 687 send_more_port_data(edge_serial,
@@ -778,13 +782,14 @@ static void edge_bulk_out_data_callback(struct urb *urb)
778 __func__, status); 782 __func__, status);
779 } 783 }
780 784
781 tty = edge_port->port->port.tty; 785 tty = tty_port_tty_get(&edge_port->port->port);
782 786
783 if (tty && edge_port->open) { 787 if (tty && edge_port->open) {
784 /* let the tty driver wakeup if it has a special 788 /* let the tty driver wakeup if it has a special
785 write_wakeup function */ 789 write_wakeup function */
786 tty_wakeup(tty); 790 tty_wakeup(tty);
787 } 791 }
792 tty_kref_put(tty);
788 793
789 /* Release the Write URB */ 794 /* Release the Write URB */
790 edge_port->write_in_progress = false; 795 edge_port->write_in_progress = false;
@@ -826,11 +831,12 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
826 } 831 }
827 832
828 /* Get pointer to tty */ 833 /* Get pointer to tty */
829 tty = edge_port->port->port.tty; 834 tty = tty_port_tty_get(&edge_port->port->port);
830 835
831 /* tell the tty driver that something has changed */ 836 /* tell the tty driver that something has changed */
832 if (tty && edge_port->open) 837 if (tty && edge_port->open)
833 tty_wakeup(tty); 838 tty_wakeup(tty);
839 tty_kref_put(tty);
834 840
835 /* we have completed the command */ 841 /* we have completed the command */
836 edge_port->commandPending = false; 842 edge_port->commandPending = false;
@@ -1932,11 +1938,13 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1932 edge_serial->rxPort]; 1938 edge_serial->rxPort];
1933 edge_port = usb_get_serial_port_data(port); 1939 edge_port = usb_get_serial_port_data(port);
1934 if (edge_port->open) { 1940 if (edge_port->open) {
1935 tty = edge_port->port->port.tty; 1941 tty = tty_port_tty_get(
1942 &edge_port->port->port);
1936 if (tty) { 1943 if (tty) {
1937 dbg("%s - Sending %d bytes to TTY for port %d", 1944 dbg("%s - Sending %d bytes to TTY for port %d",
1938 __func__, rxLen, edge_serial->rxPort); 1945 __func__, rxLen, edge_serial->rxPort);
1939 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); 1946 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
1947 tty_kref_put(tty);
1940 } 1948 }
1941 edge_port->icount.rx += rxLen; 1949 edge_port->icount.rx += rxLen;
1942 } 1950 }
@@ -1971,6 +1979,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
1971{ 1979{
1972 struct usb_serial_port *port; 1980 struct usb_serial_port *port;
1973 struct edgeport_port *edge_port; 1981 struct edgeport_port *edge_port;
1982 struct tty_struct *tty;
1974 __u8 code = edge_serial->rxStatusCode; 1983 __u8 code = edge_serial->rxStatusCode;
1975 1984
1976 /* switch the port pointer to the one being currently talked about */ 1985 /* switch the port pointer to the one being currently talked about */
@@ -2020,10 +2029,12 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2020 2029
2021 /* send the current line settings to the port so we are 2030 /* send the current line settings to the port so we are
2022 in sync with any further termios calls */ 2031 in sync with any further termios calls */
2023 /* FIXME: locking on tty */ 2032 tty = tty_port_tty_get(&edge_port->port->port);
2024 if (edge_port->port->port.tty) 2033 if (tty) {
2025 change_port_settings(edge_port->port->port.tty, 2034 change_port_settings(tty,
2026 edge_port, edge_port->port->port.tty->termios); 2035 edge_port, tty->termios);
2036 tty_kref_put(tty);
2037 }
2027 2038
2028 /* we have completed the open */ 2039 /* we have completed the open */
2029 edge_port->openPending = false; 2040 edge_port->openPending = false;
@@ -2163,10 +2174,14 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
2163 } 2174 }
2164 2175
2165 /* Place LSR data byte into Rx buffer */ 2176 /* Place LSR data byte into Rx buffer */
2166 if (lsrData && edge_port->port->port.tty) 2177 if (lsrData) {
2167 edge_tty_recv(&edge_port->port->dev, 2178 struct tty_struct *tty =
2168 edge_port->port->port.tty, &data, 1); 2179 tty_port_tty_get(&edge_port->port->port);
2169 2180 if (tty) {
2181 edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
2182 tty_kref_put(tty);
2183 }
2184 }
2170 /* update input line counters */ 2185 /* update input line counters */
2171 icount = &edge_port->icount; 2186 icount = &edge_port->icount;
2172 if (newLsr & LSR_BREAK) 2187 if (newLsr & LSR_BREAK)
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index cb4c54316cf5..541dd8e6e7a2 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
572 int flush) 572 int flush)
573{ 573{
574 int baud_rate; 574 int baud_rate;
575 struct tty_struct *tty = port->port->port.tty; 575 struct tty_struct *tty = tty_port_tty_get(&port->port->port);
576 wait_queue_t wait; 576 wait_queue_t wait;
577 unsigned long flags; 577 unsigned long flags;
578 578
@@ -599,6 +599,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
599 if (flush) 599 if (flush)
600 edge_buf_clear(port->ep_out_buf); 600 edge_buf_clear(port->ep_out_buf);
601 spin_unlock_irqrestore(&port->ep_lock, flags); 601 spin_unlock_irqrestore(&port->ep_lock, flags);
602 tty_kref_put(tty);
602 603
603 /* wait for data to drain from the device */ 604 /* wait for data to drain from the device */
604 timeout += jiffies; 605 timeout += jiffies;
@@ -1554,7 +1555,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1554 /* Save the new modem status */ 1555 /* Save the new modem status */
1555 edge_port->shadow_msr = msr & 0xf0; 1556 edge_port->shadow_msr = msr & 0xf0;
1556 1557
1557 tty = edge_port->port->port.tty; 1558 tty = tty_port_tty_get(&edge_port->port->port);
1558 /* handle CTS flow control */ 1559 /* handle CTS flow control */
1559 if (tty && C_CRTSCTS(tty)) { 1560 if (tty && C_CRTSCTS(tty)) {
1560 if (msr & EDGEPORT_MSR_CTS) { 1561 if (msr & EDGEPORT_MSR_CTS) {
@@ -1564,6 +1565,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1564 tty->hw_stopped = 1; 1565 tty->hw_stopped = 1;
1565 } 1566 }
1566 } 1567 }
1568 tty_kref_put(tty);
1567 1569
1568 return; 1570 return;
1569} 1571}
@@ -1574,6 +1576,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1574 struct async_icount *icount; 1576 struct async_icount *icount;
1575 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | 1577 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR |
1576 LSR_FRM_ERR | LSR_BREAK)); 1578 LSR_FRM_ERR | LSR_BREAK));
1579 struct tty_struct *tty;
1577 1580
1578 dbg("%s - %02x", __func__, new_lsr); 1581 dbg("%s - %02x", __func__, new_lsr);
1579 1582
@@ -1587,8 +1590,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1587 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1590 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
1588 1591
1589 /* Place LSR data byte into Rx buffer */ 1592 /* Place LSR data byte into Rx buffer */
1590 if (lsr_data && edge_port->port->port.tty) 1593 if (lsr_data) {
1591 edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1); 1594 tty = tty_port_tty_get(&edge_port->port->port);
1595 if (tty) {
1596 edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
1597 tty_kref_put(tty);
1598 }
1599 }
1592 1600
1593 /* update input line counters */ 1601 /* update input line counters */
1594 icount = &edge_port->icount; 1602 icount = &edge_port->icount;
@@ -1749,7 +1757,7 @@ static void edge_bulk_in_callback(struct urb *urb)
1749 ++data; 1757 ++data;
1750 } 1758 }
1751 1759
1752 tty = edge_port->port->port.tty; 1760 tty = tty_port_tty_get(&edge_port->port->port);
1753 if (tty && urb->actual_length) { 1761 if (tty && urb->actual_length) {
1754 usb_serial_debug_data(debug, &edge_port->port->dev, 1762 usb_serial_debug_data(debug, &edge_port->port->dev,
1755 __func__, urb->actual_length, data); 1763 __func__, urb->actual_length, data);
@@ -1761,6 +1769,7 @@ static void edge_bulk_in_callback(struct urb *urb)
1761 urb->actual_length); 1769 urb->actual_length);
1762 edge_port->icount.rx += urb->actual_length; 1770 edge_port->icount.rx += urb->actual_length;
1763 } 1771 }
1772 tty_kref_put(tty);
1764 1773
1765exit: 1774exit:
1766 /* continue read unless stopped */ 1775 /* continue read unless stopped */
@@ -1796,6 +1805,7 @@ static void edge_bulk_out_callback(struct urb *urb)
1796 struct usb_serial_port *port = urb->context; 1805 struct usb_serial_port *port = urb->context;
1797 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1806 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1798 int status = urb->status; 1807 int status = urb->status;
1808 struct tty_struct *tty;
1799 1809
1800 dbg("%s - port %d", __func__, port->number); 1810 dbg("%s - port %d", __func__, port->number);
1801 1811
@@ -1818,7 +1828,9 @@ static void edge_bulk_out_callback(struct urb *urb)
1818 } 1828 }
1819 1829
1820 /* send any buffered data */ 1830 /* send any buffered data */
1821 edge_send(port->port.tty); 1831 tty = tty_port_tty_get(&port->port);
1832 edge_send(tty);
1833 tty_kref_put(tty);
1822} 1834}
1823 1835
1824static int edge_open(struct tty_struct *tty, 1836static int edge_open(struct tty_struct *tty,
@@ -1876,7 +1888,7 @@ static int edge_open(struct tty_struct *tty,
1876 1888
1877 /* set up the port settings */ 1889 /* set up the port settings */
1878 if (tty) 1890 if (tty)
1879 edge_set_termios(tty, port, port->port.tty->termios); 1891 edge_set_termios(tty, port, tty->termios);
1880 1892
1881 /* open up the port */ 1893 /* open up the port */
1882 1894
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index cd9a2e138c8b..2affa9c118b2 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -764,13 +764,14 @@ static void ipaq_read_bulk_callback(struct urb *urb)
764 usb_serial_debug_data(debug, &port->dev, __func__, 764 usb_serial_debug_data(debug, &port->dev, __func__,
765 urb->actual_length, data); 765 urb->actual_length, data);
766 766
767 tty = port->port.tty; 767 tty = tty_port_tty_get(&port->port);
768 if (tty && urb->actual_length) { 768 if (tty && urb->actual_length) {
769 tty_buffer_request_room(tty, urb->actual_length); 769 tty_buffer_request_room(tty, urb->actual_length);
770 tty_insert_flip_string(tty, data, urb->actual_length); 770 tty_insert_flip_string(tty, data, urb->actual_length);
771 tty_flip_buffer_push(tty); 771 tty_flip_buffer_push(tty);
772 bytes_in += urb->actual_length; 772 bytes_in += urb->actual_length;
773 } 773 }
774 tty_kref_put(tty);
774 775
775 /* Continue trying to always read */ 776 /* Continue trying to always read */
776 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 777 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index a842025b9b57..480cac27d646 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -170,12 +170,13 @@ static void ipw_read_bulk_callback(struct urb *urb)
170 usb_serial_debug_data(debug, &port->dev, __func__, 170 usb_serial_debug_data(debug, &port->dev, __func__,
171 urb->actual_length, data); 171 urb->actual_length, data);
172 172
173 tty = port->port.tty; 173 tty = tty_port_tty_get(&port->port);
174 if (tty && urb->actual_length) { 174 if (tty && urb->actual_length) {
175 tty_buffer_request_room(tty, urb->actual_length); 175 tty_buffer_request_room(tty, urb->actual_length);
176 tty_insert_flip_string(tty, data, urb->actual_length); 176 tty_insert_flip_string(tty, data, urb->actual_length);
177 tty_flip_buffer_push(tty); 177 tty_flip_buffer_push(tty);
178 } 178 }
179 tty_kref_put(tty);
179 180
180 /* Continue trying to always read */ 181 /* Continue trying to always read */
181 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 182 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index e59155c6607d..45d4043e04ab 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -465,11 +465,12 @@ static void ir_read_bulk_callback(struct urb *urb)
465 ir_baud = *data & 0x0f; 465 ir_baud = *data & 0x0f;
466 usb_serial_debug_data(debug, &port->dev, __func__, 466 usb_serial_debug_data(debug, &port->dev, __func__,
467 urb->actual_length, data); 467 urb->actual_length, data);
468 tty = port->port.tty; 468 tty = tty_port_tty_get(&port->port);
469 if (tty_buffer_request_room(tty, urb->actual_length - 1)) { 469 if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
470 tty_insert_flip_string(tty, data+1, urb->actual_length - 1); 470 tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
471 tty_flip_buffer_push(tty); 471 tty_flip_buffer_push(tty);
472 } 472 }
473 tty_kref_put(tty);
473 474
474 /* 475 /*
475 * No break here. 476 * No break here.
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index ddff37fa6339..53710aa7eadd 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -629,13 +629,14 @@ static void read_buf_callback(struct urb *urb)
629 } 629 }
630 630
631 dbg("%s - %i chars to write", __func__, urb->actual_length); 631 dbg("%s - %i chars to write", __func__, urb->actual_length);
632 tty = port->port.tty; 632 tty = tty_port_tty_get(&port->port);
633 if (data == NULL) 633 if (data == NULL)
634 dbg("%s - data is NULL !!!", __func__); 634 dbg("%s - data is NULL !!!", __func__);
635 if (tty && urb->actual_length && data) { 635 if (tty && urb->actual_length && data) {
636 tty_insert_flip_string(tty, data, urb->actual_length); 636 tty_insert_flip_string(tty, data, urb->actual_length);
637 tty_flip_buffer_push(tty); 637 tty_flip_buffer_push(tty);
638 } 638 }
639 tty_kref_put(tty);
639 iuu_led_activity_on(urb); 640 iuu_led_activity_on(urb);
640} 641}
641 642
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 704716f6f6d3..15447af48691 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -430,7 +430,7 @@ static void usa26_indat_callback(struct urb *urb)
430 } 430 }
431 431
432 port = urb->context; 432 port = urb->context;
433 tty = port->port.tty; 433 tty = tty_port_tty_get(&port->port);
434 if (tty && urb->actual_length) { 434 if (tty && urb->actual_length) {
435 /* 0x80 bit is error flag */ 435 /* 0x80 bit is error flag */
436 if ((data[0] & 0x80) == 0) { 436 if ((data[0] & 0x80) == 0) {
@@ -459,6 +459,7 @@ static void usa26_indat_callback(struct urb *urb)
459 } 459 }
460 tty_flip_buffer_push(tty); 460 tty_flip_buffer_push(tty);
461 } 461 }
462 tty_kref_put(tty);
462 463
463 /* Resubmit urb so we continue receiving */ 464 /* Resubmit urb so we continue receiving */
464 urb->dev = port->serial->dev; 465 urb->dev = port->serial->dev;
@@ -513,6 +514,7 @@ static void usa26_instat_callback(struct urb *urb)
513 struct usb_serial *serial; 514 struct usb_serial *serial;
514 struct usb_serial_port *port; 515 struct usb_serial_port *port;
515 struct keyspan_port_private *p_priv; 516 struct keyspan_port_private *p_priv;
517 struct tty_struct *tty;
516 int old_dcd_state, err; 518 int old_dcd_state, err;
517 int status = urb->status; 519 int status = urb->status;
518 520
@@ -553,12 +555,11 @@ static void usa26_instat_callback(struct urb *urb)
553 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 555 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
554 p_priv->ri_state = ((msg->ri) ? 1 : 0); 556 p_priv->ri_state = ((msg->ri) ? 1 : 0);
555 557
556 if (port->port.tty && !C_CLOCAL(port->port.tty) 558 if (old_dcd_state != p_priv->dcd_state) {
557 && old_dcd_state != p_priv->dcd_state) { 559 tty = tty_port_tty_get(&port->port);
558 if (old_dcd_state) 560 if (tty && !C_CLOCAL(tty))
559 tty_hangup(port->port.tty); 561 tty_hangup(tty);
560 /* else */ 562 tty_kref_put(tty);
561 /* wake_up_interruptible(&p_priv->open_wait); */
562 } 563 }
563 564
564 /* Resubmit urb so we continue receiving */ 565 /* Resubmit urb so we continue receiving */
@@ -604,11 +605,12 @@ static void usa28_indat_callback(struct urb *urb)
604 p_priv = usb_get_serial_port_data(port); 605 p_priv = usb_get_serial_port_data(port);
605 data = urb->transfer_buffer; 606 data = urb->transfer_buffer;
606 607
607 tty = port->port.tty; 608 tty =tty_port_tty_get(&port->port);
608 if (urb->actual_length) { 609 if (tty && urb->actual_length) {
609 tty_insert_flip_string(tty, data, urb->actual_length); 610 tty_insert_flip_string(tty, data, urb->actual_length);
610 tty_flip_buffer_push(tty); 611 tty_flip_buffer_push(tty);
611 } 612 }
613 tty_kref_put(tty);
612 614
613 /* Resubmit urb so we continue receiving */ 615 /* Resubmit urb so we continue receiving */
614 urb->dev = port->serial->dev; 616 urb->dev = port->serial->dev;
@@ -652,6 +654,7 @@ static void usa28_instat_callback(struct urb *urb)
652 struct usb_serial *serial; 654 struct usb_serial *serial;
653 struct usb_serial_port *port; 655 struct usb_serial_port *port;
654 struct keyspan_port_private *p_priv; 656 struct keyspan_port_private *p_priv;
657 struct tty_struct *tty;
655 int old_dcd_state; 658 int old_dcd_state;
656 int status = urb->status; 659 int status = urb->status;
657 660
@@ -689,12 +692,11 @@ static void usa28_instat_callback(struct urb *urb)
689 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 692 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
690 p_priv->ri_state = ((msg->ri) ? 1 : 0); 693 p_priv->ri_state = ((msg->ri) ? 1 : 0);
691 694
692 if (port->port.tty && !C_CLOCAL(port->port.tty) 695 if( old_dcd_state != p_priv->dcd_state && old_dcd_state) {
693 && old_dcd_state != p_priv->dcd_state) { 696 tty = tty_port_tty_get(&port->port);
694 if (old_dcd_state) 697 if (tty && !C_CLOCAL(tty))
695 tty_hangup(port->port.tty); 698 tty_hangup(tty);
696 /* else */ 699 tty_kref_put(tty);
697 /* wake_up_interruptible(&p_priv->open_wait); */
698 } 700 }
699 701
700 /* Resubmit urb so we continue receiving */ 702 /* Resubmit urb so we continue receiving */
@@ -785,12 +787,11 @@ static void usa49_instat_callback(struct urb *urb)
785 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 787 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
786 p_priv->ri_state = ((msg->ri) ? 1 : 0); 788 p_priv->ri_state = ((msg->ri) ? 1 : 0);
787 789
788 if (port->port.tty && !C_CLOCAL(port->port.tty) 790 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) {
789 && old_dcd_state != p_priv->dcd_state) { 791 struct tty_struct *tty = tty_port_tty_get(&port->port);
790 if (old_dcd_state) 792 if (tty && !C_CLOCAL(tty))
791 tty_hangup(port->port.tty); 793 tty_hangup(tty);
792 /* else */ 794 tty_kref_put(tty);
793 /* wake_up_interruptible(&p_priv->open_wait); */
794 } 795 }
795 796
796 /* Resubmit urb so we continue receiving */ 797 /* Resubmit urb so we continue receiving */
@@ -827,7 +828,7 @@ static void usa49_indat_callback(struct urb *urb)
827 } 828 }
828 829
829 port = urb->context; 830 port = urb->context;
830 tty = port->port.tty; 831 tty = tty_port_tty_get(&port->port);
831 if (tty && urb->actual_length) { 832 if (tty && urb->actual_length) {
832 /* 0x80 bit is error flag */ 833 /* 0x80 bit is error flag */
833 if ((data[0] & 0x80) == 0) { 834 if ((data[0] & 0x80) == 0) {
@@ -850,6 +851,7 @@ static void usa49_indat_callback(struct urb *urb)
850 } 851 }
851 tty_flip_buffer_push(tty); 852 tty_flip_buffer_push(tty);
852 } 853 }
854 tty_kref_put(tty);
853 855
854 /* Resubmit urb so we continue receiving */ 856 /* Resubmit urb so we continue receiving */
855 urb->dev = port->serial->dev; 857 urb->dev = port->serial->dev;
@@ -893,7 +895,7 @@ static void usa49wg_indat_callback(struct urb *urb)
893 return; 895 return;
894 } 896 }
895 port = serial->port[data[i++]]; 897 port = serial->port[data[i++]];
896 tty = port->port.tty; 898 tty = tty_port_tty_get(&port->port);
897 len = data[i++]; 899 len = data[i++];
898 900
899 /* 0x80 bit is error flag */ 901 /* 0x80 bit is error flag */
@@ -927,6 +929,7 @@ static void usa49wg_indat_callback(struct urb *urb)
927 } 929 }
928 if (port->port.count) 930 if (port->port.count)
929 tty_flip_buffer_push(tty); 931 tty_flip_buffer_push(tty);
932 tty_kref_put(tty);
930 } 933 }
931 } 934 }
932 935
@@ -967,8 +970,8 @@ static void usa90_indat_callback(struct urb *urb)
967 port = urb->context; 970 port = urb->context;
968 p_priv = usb_get_serial_port_data(port); 971 p_priv = usb_get_serial_port_data(port);
969 972
970 tty = port->port.tty;
971 if (urb->actual_length) { 973 if (urb->actual_length) {
974 tty = tty_port_tty_get(&port->port);
972 /* if current mode is DMA, looks like usa28 format 975 /* if current mode is DMA, looks like usa28 format
973 otherwise looks like usa26 data format */ 976 otherwise looks like usa26 data format */
974 977
@@ -1004,6 +1007,7 @@ static void usa90_indat_callback(struct urb *urb)
1004 } 1007 }
1005 } 1008 }
1006 tty_flip_buffer_push(tty); 1009 tty_flip_buffer_push(tty);
1010 tty_kref_put(tty);
1007 } 1011 }
1008 1012
1009 /* Resubmit urb so we continue receiving */ 1013 /* Resubmit urb so we continue receiving */
@@ -1025,6 +1029,7 @@ static void usa90_instat_callback(struct urb *urb)
1025 struct usb_serial *serial; 1029 struct usb_serial *serial;
1026 struct usb_serial_port *port; 1030 struct usb_serial_port *port;
1027 struct keyspan_port_private *p_priv; 1031 struct keyspan_port_private *p_priv;
1032 struct tty_struct *tty;
1028 int old_dcd_state, err; 1033 int old_dcd_state, err;
1029 int status = urb->status; 1034 int status = urb->status;
1030 1035
@@ -1053,12 +1058,11 @@ static void usa90_instat_callback(struct urb *urb)
1053 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 1058 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
1054 p_priv->ri_state = ((msg->ri) ? 1 : 0); 1059 p_priv->ri_state = ((msg->ri) ? 1 : 0);
1055 1060
1056 if (port->port.tty && !C_CLOCAL(port->port.tty) 1061 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) {
1057 && old_dcd_state != p_priv->dcd_state) { 1062 tty = tty_port_tty_get(&port->port);
1058 if (old_dcd_state) 1063 if (tty && !C_CLOCAL(tty))
1059 tty_hangup(port->port.tty); 1064 tty_hangup(tty);
1060 /* else */ 1065 tty_kref_put(tty);
1061 /* wake_up_interruptible(&p_priv->open_wait); */
1062 } 1066 }
1063 1067
1064 /* Resubmit urb so we continue receiving */ 1068 /* Resubmit urb so we continue receiving */
@@ -1130,12 +1134,11 @@ static void usa67_instat_callback(struct urb *urb)
1130 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); 1134 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
1131 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 1135 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
1132 1136
1133 if (port->port.tty && !C_CLOCAL(port->port.tty) 1137 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) {
1134 && old_dcd_state != p_priv->dcd_state) { 1138 struct tty_struct *tty = tty_port_tty_get(&port->port);
1135 if (old_dcd_state) 1139 if (tty && !C_CLOCAL(tty))
1136 tty_hangup(port->port.tty); 1140 tty_hangup(tty);
1137 /* else */ 1141 tty_kref_put(tty);
1138 /* wake_up_interruptible(&p_priv->open_wait); */
1139 } 1142 }
1140 1143
1141 /* Resubmit urb so we continue receiving */ 1144 /* Resubmit urb so we continue receiving */
@@ -1332,7 +1335,7 @@ static void keyspan_close(struct tty_struct *tty,
1332 stop_urb(p_priv->out_urbs[i]); 1335 stop_urb(p_priv->out_urbs[i]);
1333 } 1336 }
1334 } 1337 }
1335 port->port.tty = NULL; 1338 tty_port_tty_set(&port->port, NULL);
1336} 1339}
1337 1340
1338/* download the firmware to a pre-renumeration device */ 1341/* download the firmware to a pre-renumeration device */
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 040040a267d9..99e9a14c5bf6 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -172,8 +172,9 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
172 struct keyspan_pda_private *priv = 172 struct keyspan_pda_private *priv =
173 container_of(work, struct keyspan_pda_private, wakeup_work); 173 container_of(work, struct keyspan_pda_private, wakeup_work);
174 struct usb_serial_port *port = priv->port; 174 struct usb_serial_port *port = priv->port;
175 175 struct tty_struct *tty = tty_port_tty_get(&port->port);
176 tty_wakeup(port->port.tty); 176 tty_wakeup(tty);
177 tty_kref_put(tty);
177} 178}
178 179
179static void keyspan_pda_request_unthrottle(struct work_struct *work) 180static void keyspan_pda_request_unthrottle(struct work_struct *work)
@@ -205,7 +206,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
205static void keyspan_pda_rx_interrupt(struct urb *urb) 206static void keyspan_pda_rx_interrupt(struct urb *urb)
206{ 207{
207 struct usb_serial_port *port = urb->context; 208 struct usb_serial_port *port = urb->context;
208 struct tty_struct *tty = port->port.tty; 209 struct tty_struct *tty = tty_port_tty_get(&port->port);
209 unsigned char *data = urb->transfer_buffer; 210 unsigned char *data = urb->transfer_buffer;
210 int retval; 211 int retval;
211 int status = urb->status; 212 int status = urb->status;
@@ -222,7 +223,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
222 /* this urb is terminated, clean up */ 223 /* this urb is terminated, clean up */
223 dbg("%s - urb shutting down with status: %d", 224 dbg("%s - urb shutting down with status: %d",
224 __func__, status); 225 __func__, status);
225 return; 226 goto out;
226 default: 227 default:
227 dbg("%s - nonzero urb status received: %d", 228 dbg("%s - nonzero urb status received: %d",
228 __func__, status); 229 __func__, status);
@@ -261,8 +262,11 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
261exit: 262exit:
262 retval = usb_submit_urb(urb, GFP_ATOMIC); 263 retval = usb_submit_urb(urb, GFP_ATOMIC);
263 if (retval) 264 if (retval)
264 err("%s - usb_submit_urb failed with result %d", 265 dev_err(&port->dev,
265 __func__, retval); 266 "%s - usb_submit_urb failed with result %d",
267 __func__, retval);
268out:
269 tty_kref_put(tty);
266} 270}
267 271
268 272
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index b84dddc71124..ff3a07f5102f 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -658,7 +658,7 @@ static void klsi_105_read_bulk_callback(struct urb *urb)
658 } else { 658 } else {
659 int bytes_sent = ((__u8 *) data)[0] + 659 int bytes_sent = ((__u8 *) data)[0] +
660 ((unsigned int) ((__u8 *) data)[1] << 8); 660 ((unsigned int) ((__u8 *) data)[1] << 8);
661 tty = port->port.tty; 661 tty = tty_port_tty_get(&port->port);
662 /* we should immediately resubmit the URB, before attempting 662 /* we should immediately resubmit the URB, before attempting
663 * to pass the data on to the tty layer. But that needs locking 663 * to pass the data on to the tty layer. But that needs locking
664 * against re-entry an then mixed-up data because of 664 * against re-entry an then mixed-up data because of
@@ -679,6 +679,7 @@ static void klsi_105_read_bulk_callback(struct urb *urb)
679 tty_buffer_request_room(tty, bytes_sent); 679 tty_buffer_request_room(tty, bytes_sent);
680 tty_insert_flip_string(tty, data + 2, bytes_sent); 680 tty_insert_flip_string(tty, data + 2, bytes_sent);
681 tty_flip_buffer_push(tty); 681 tty_flip_buffer_push(tty);
682 tty_kref_put(tty);
682 683
683 /* again lockless, but debug info only */ 684 /* again lockless, but debug info only */
684 priv->bytes_in += bytes_sent; 685 priv->bytes_in += bytes_sent;
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index deba28ec77e8..cfcf37c2b957 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -383,7 +383,7 @@ static void kobil_read_int_callback(struct urb *urb)
383 return; 383 return;
384 } 384 }
385 385
386 tty = port->port.tty; 386 tty = tty_port_tty_get(&port->port);
387 if (urb->actual_length) { 387 if (urb->actual_length) {
388 388
389 /* BEGIN DEBUG */ 389 /* BEGIN DEBUG */
@@ -405,6 +405,7 @@ static void kobil_read_int_callback(struct urb *urb)
405 tty_insert_flip_string(tty, data, urb->actual_length); 405 tty_insert_flip_string(tty, data, urb->actual_length);
406 tty_flip_buffer_push(tty); 406 tty_flip_buffer_push(tty);
407 } 407 }
408 tty_kref_put(tty);
408 /* someone sets the dev to 0 if the close method has been called */ 409 /* someone sets the dev to 0 if the close method has been called */
409 port->interrupt_in_urb->dev = port->serial->dev; 410 port->interrupt_in_urb->dev = port->serial->dev;
410 411
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 0ded8bd6ec85..9b2cef81cde0 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -563,10 +563,11 @@ static void mct_u232_read_int_callback(struct urb *urb)
563 * Work-a-round: handle the 'usual' bulk-in pipe here 563 * Work-a-round: handle the 'usual' bulk-in pipe here
564 */ 564 */
565 if (urb->transfer_buffer_length > 2) { 565 if (urb->transfer_buffer_length > 2) {
566 tty = port->port.tty; 566 tty = tty_port_tty_get(&port->port);
567 if (urb->actual_length) { 567 if (urb->actual_length) {
568 tty_insert_flip_string(tty, data, urb->actual_length); 568 tty_insert_flip_string(tty, data, urb->actual_length);
569 tty_flip_buffer_push(tty); 569 tty_flip_buffer_push(tty);
570 tty_kref_put(tty);
570 } 571 }
571 goto exit; 572 goto exit;
572 } 573 }
@@ -591,7 +592,7 @@ static void mct_u232_read_int_callback(struct urb *urb)
591 * to look in to this before committing any code. 592 * to look in to this before committing any code.
592 */ 593 */
593 if (priv->last_lsr & MCT_U232_LSR_ERR) { 594 if (priv->last_lsr & MCT_U232_LSR_ERR) {
594 tty = port->port.tty; 595 tty = tty_port_tty_get(&port->port);
595 /* Overrun Error */ 596 /* Overrun Error */
596 if (priv->last_lsr & MCT_U232_LSR_OE) { 597 if (priv->last_lsr & MCT_U232_LSR_OE) {
597 } 598 }
@@ -604,6 +605,7 @@ static void mct_u232_read_int_callback(struct urb *urb)
604 /* Break Indicator */ 605 /* Break Indicator */
605 if (priv->last_lsr & MCT_U232_LSR_BI) { 606 if (priv->last_lsr & MCT_U232_LSR_BI) {
606 } 607 }
608 tty_kref_put(tty);
607 } 609 }
608#endif 610#endif
609 spin_unlock_irqrestore(&priv->lock, flags); 611 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 7c4917d77c0a..7b538caec37f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -216,12 +216,13 @@ static void mos7720_bulk_in_callback(struct urb *urb)
216 216
217 data = urb->transfer_buffer; 217 data = urb->transfer_buffer;
218 218
219 tty = port->port.tty; 219 tty = tty_port_tty_get(&port->port);
220 if (tty && urb->actual_length) { 220 if (tty && urb->actual_length) {
221 tty_buffer_request_room(tty, urb->actual_length); 221 tty_buffer_request_room(tty, urb->actual_length);
222 tty_insert_flip_string(tty, data, urb->actual_length); 222 tty_insert_flip_string(tty, data, urb->actual_length);
223 tty_flip_buffer_push(tty); 223 tty_flip_buffer_push(tty);
224 } 224 }
225 tty_kref_put(tty);
225 226
226 if (!port->read_urb) { 227 if (!port->read_urb) {
227 dbg("URB KILLED !!!"); 228 dbg("URB KILLED !!!");
@@ -262,10 +263,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
262 263
263 dbg("Entering ........."); 264 dbg("Entering .........");
264 265
265 tty = mos7720_port->port->port.tty; 266 tty = tty_port_tty_get(&mos7720_port->port->port);
266 267
267 if (tty && mos7720_port->open) 268 if (tty && mos7720_port->open)
268 tty_wakeup(tty); 269 tty_wakeup(tty);
270 tty_kref_put(tty);
269} 271}
270 272
271/* 273/*
@@ -1267,29 +1269,6 @@ static int get_lsr_info(struct tty_struct *tty,
1267 return 0; 1269 return 0;
1268} 1270}
1269 1271
1270/*
1271 * get_number_bytes_avail - get number of bytes available
1272 *
1273 * Purpose: Let user call ioctl to get the count of number of bytes available.
1274 */
1275static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1276 unsigned int __user *value)
1277{
1278 unsigned int result = 0;
1279 struct tty_struct *tty = mos7720_port->port->port.tty;
1280
1281 if (!tty)
1282 return -ENOIOCTLCMD;
1283
1284 result = tty->read_cnt;
1285
1286 dbg("%s(%d) = %d", __func__, mos7720_port->port->number, result);
1287 if (copy_to_user(value, &result, sizeof(int)))
1288 return -EFAULT;
1289
1290 return -ENOIOCTLCMD;
1291}
1292
1293static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1272static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1294 unsigned int __user *value) 1273 unsigned int __user *value)
1295{ 1274{
@@ -1409,13 +1388,6 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
1409 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1388 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1410 1389
1411 switch (cmd) { 1390 switch (cmd) {
1412 case TIOCINQ:
1413 /* return number of bytes available */
1414 dbg("%s (%d) TIOCINQ", __func__, port->number);
1415 return get_number_bytes_avail(mos7720_port,
1416 (unsigned int __user *)arg);
1417 break;
1418
1419 case TIOCSERGETLSR: 1391 case TIOCSERGETLSR:
1420 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1392 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1421 return get_lsr_info(tty, mos7720_port, 1393 return get_lsr_info(tty, mos7720_port,
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 09d82062b973..60543d79ef56 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -709,12 +709,13 @@ static void mos7840_bulk_in_callback(struct urb *urb)
709 dbg("%s", "Entering ........... \n"); 709 dbg("%s", "Entering ........... \n");
710 710
711 if (urb->actual_length) { 711 if (urb->actual_length) {
712 tty = mos7840_port->port->port.tty; 712 tty = tty_port_tty_get(&mos7840_port->port->port);
713 if (tty) { 713 if (tty) {
714 tty_buffer_request_room(tty, urb->actual_length); 714 tty_buffer_request_room(tty, urb->actual_length);
715 tty_insert_flip_string(tty, data, urb->actual_length); 715 tty_insert_flip_string(tty, data, urb->actual_length);
716 dbg(" %s \n", data); 716 dbg(" %s \n", data);
717 tty_flip_buffer_push(tty); 717 tty_flip_buffer_push(tty);
718 tty_kref_put(tty);
718 } 719 }
719 mos7840_port->icount.rx += urb->actual_length; 720 mos7840_port->icount.rx += urb->actual_length;
720 smp_wmb(); 721 smp_wmb();
@@ -773,10 +774,10 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
773 774
774 dbg("%s \n", "Entering ........."); 775 dbg("%s \n", "Entering .........");
775 776
776 tty = mos7840_port->port->port.tty; 777 tty = tty_port_tty_get(&mos7840_port->port->port);
777
778 if (tty && mos7840_port->open) 778 if (tty && mos7840_port->open)
779 tty_wakeup(tty); 779 tty_wakeup(tty);
780 tty_kref_put(tty);
780 781
781} 782}
782 783
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index d6736531a0fa..bcdcbb822705 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -64,12 +64,13 @@ static void navman_read_int_callback(struct urb *urb)
64 usb_serial_debug_data(debug, &port->dev, __func__, 64 usb_serial_debug_data(debug, &port->dev, __func__,
65 urb->actual_length, data); 65 urb->actual_length, data);
66 66
67 tty = port->port.tty; 67 tty = tty_port_tty_get(&port->port);
68 if (tty && urb->actual_length) { 68 if (tty && urb->actual_length) {
69 tty_buffer_request_room(tty, urb->actual_length); 69 tty_buffer_request_room(tty, urb->actual_length);
70 tty_insert_flip_string(tty, data, urb->actual_length); 70 tty_insert_flip_string(tty, data, urb->actual_length);
71 tty_flip_buffer_push(tty); 71 tty_flip_buffer_push(tty);
72 } 72 }
73 tty_kref_put(tty);
73 74
74exit: 75exit:
75 result = usb_submit_urb(urb, GFP_ATOMIC); 76 result = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index ae8e227f3db2..c4d70b0f1e48 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -172,7 +172,7 @@ static int omninet_open(struct tty_struct *tty,
172 dbg("%s - port %d", __func__, port->number); 172 dbg("%s - port %d", __func__, port->number);
173 173
174 wport = serial->port[1]; 174 wport = serial->port[1];
175 wport->port.tty = tty; /* FIXME */ 175 tty_port_tty_set(&wport->port, tty);
176 176
177 /* Start reading from the device */ 177 /* Start reading from the device */
178 usb_fill_bulk_urb(port->read_urb, serial->dev, 178 usb_fill_bulk_urb(port->read_urb, serial->dev,
@@ -229,9 +229,11 @@ static void omninet_read_bulk_callback(struct urb *urb)
229 } 229 }
230 230
231 if (urb->actual_length && header->oh_len) { 231 if (urb->actual_length && header->oh_len) {
232 tty_insert_flip_string(port->port.tty, 232 struct tty_struct *tty = tty_port_tty_get(&port->port);
233 data + OMNINET_DATAOFFSET, header->oh_len); 233 tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET,
234 tty_flip_buffer_push(port->port.tty); 234 header->oh_len);
235 tty_flip_buffer_push(tty);
236 tty_kref_put(tty);
235 } 237 }
236 238
237 /* Continue trying to always read */ 239 /* Continue trying to always read */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 9f9cd36455f4..6b1727e751e3 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -218,6 +218,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
218/* ZTE PRODUCTS */ 218/* ZTE PRODUCTS */
219#define ZTE_VENDOR_ID 0x19d2 219#define ZTE_VENDOR_ID 0x19d2
220#define ZTE_PRODUCT_MF628 0x0015 220#define ZTE_PRODUCT_MF628 0x0015
221#define ZTE_PRODUCT_CDMA_TECH 0xfffe
221 222
222static struct usb_device_id option_ids[] = { 223static struct usb_device_id option_ids[] = {
223 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 224 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
@@ -347,6 +348,7 @@ static struct usb_device_id option_ids[] = {
347 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 348 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
348 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 349 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
349 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 350 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) },
351 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
350 { } /* Terminating entry */ 352 { } /* Terminating entry */
351}; 353};
352MODULE_DEVICE_TABLE(usb, option_ids); 354MODULE_DEVICE_TABLE(usb, option_ids);
@@ -569,14 +571,14 @@ static void option_indat_callback(struct urb *urb)
569 dbg("%s: nonzero status: %d on endpoint %02x.", 571 dbg("%s: nonzero status: %d on endpoint %02x.",
570 __func__, status, endpoint); 572 __func__, status, endpoint);
571 } else { 573 } else {
572 tty = port->port.tty; 574 tty = tty_port_tty_get(&port->port);
573 if (urb->actual_length) { 575 if (urb->actual_length) {
574 tty_buffer_request_room(tty, urb->actual_length); 576 tty_buffer_request_room(tty, urb->actual_length);
575 tty_insert_flip_string(tty, data, urb->actual_length); 577 tty_insert_flip_string(tty, data, urb->actual_length);
576 tty_flip_buffer_push(tty); 578 tty_flip_buffer_push(tty);
577 } else { 579 } else
578 dbg("%s: empty read urb received", __func__); 580 dbg("%s: empty read urb received", __func__);
579 } 581 tty_kref_put(tty);
580 582
581 /* Resubmit urb so we continue receiving */ 583 /* Resubmit urb so we continue receiving */
582 if (port->port.count && status != -ESHUTDOWN) { 584 if (port->port.count && status != -ESHUTDOWN) {
@@ -645,9 +647,13 @@ static void option_instat_callback(struct urb *urb)
645 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 647 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
646 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 648 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
647 649
648 if (port->port.tty && !C_CLOCAL(port->port.tty) && 650 if (old_dcd_state && !portdata->dcd_state) {
649 old_dcd_state && !portdata->dcd_state) 651 struct tty_struct *tty =
650 tty_hangup(port->port.tty); 652 tty_port_tty_get(&port->port);
653 if (tty && !C_CLOCAL(tty))
654 tty_hangup(tty);
655 tty_kref_put(tty);
656 }
651 } else { 657 } else {
652 dbg("%s: type %x req %x", __func__, 658 dbg("%s: type %x req %x", __func__,
653 req_pkt->bRequestType, req_pkt->bRequest); 659 req_pkt->bRequestType, req_pkt->bRequest);
@@ -791,7 +797,7 @@ static void option_close(struct tty_struct *tty,
791 for (i = 0; i < N_OUT_URB; i++) 797 for (i = 0; i < N_OUT_URB; i++)
792 usb_kill_urb(portdata->out_urbs[i]); 798 usb_kill_urb(portdata->out_urbs[i]);
793 } 799 }
794 port->port.tty = NULL; /* FIXME */ 800 tty_port_tty_set(&port->port, NULL);
795} 801}
796 802
797/* Helper functions used by option_setup_urbs */ 803/* Helper functions used by option_setup_urbs */
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 81db5715ee25..ba551f00f16f 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -224,10 +224,6 @@ struct oti6858_private {
224 struct usb_serial_port *port; /* USB port with which associated */ 224 struct usb_serial_port *port; /* USB port with which associated */
225}; 225};
226 226
227#undef dbg
228/* #define dbg(format, arg...) printk(KERN_INFO "%s: " format "\n", __FILE__, ## arg) */
229#define dbg(format, arg...) printk(KERN_INFO "" format "\n", ## arg)
230
231static void setup_line(struct work_struct *work) 227static void setup_line(struct work_struct *work)
232{ 228{
233 struct oti6858_private *priv = container_of(work, 229 struct oti6858_private *priv = container_of(work,
@@ -1002,11 +998,12 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1002 return; 998 return;
1003 } 999 }
1004 1000
1005 tty = port->port.tty; 1001 tty = tty_port_tty_get(&port->port);
1006 if (tty != NULL && urb->actual_length > 0) { 1002 if (tty != NULL && urb->actual_length > 0) {
1007 tty_insert_flip_string(tty, data, urb->actual_length); 1003 tty_insert_flip_string(tty, data, urb->actual_length);
1008 tty_flip_buffer_push(tty); 1004 tty_flip_buffer_push(tty);
1009 } 1005 }
1006 tty_kref_put(tty);
1010 1007
1011 /* schedule the interrupt urb if we are still open */ 1008 /* schedule the interrupt urb if we are still open */
1012 if (port->port.count != 0) { 1009 if (port->port.count != 0) {
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 1ede1441cb1b..908437847165 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -154,7 +154,6 @@ struct pl2303_private {
154 wait_queue_head_t delta_msr_wait; 154 wait_queue_head_t delta_msr_wait;
155 u8 line_control; 155 u8 line_control;
156 u8 line_status; 156 u8 line_status;
157 u8 termios_initialized;
158 enum pl2303_type type; 157 enum pl2303_type type;
159}; 158};
160 159
@@ -526,16 +525,6 @@ static void pl2303_set_termios(struct tty_struct *tty,
526 525
527 dbg("%s - port %d", __func__, port->number); 526 dbg("%s - port %d", __func__, port->number);
528 527
529 spin_lock_irqsave(&priv->lock, flags);
530 if (!priv->termios_initialized) {
531 *(tty->termios) = tty_std_termios;
532 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
533 tty->termios->c_ispeed = 9600;
534 tty->termios->c_ospeed = 9600;
535 priv->termios_initialized = 1;
536 }
537 spin_unlock_irqrestore(&priv->lock, flags);
538
539 /* The PL2303 is reported to lose bytes if you change 528 /* The PL2303 is reported to lose bytes if you change
540 serial settings even to the same values as before. Thus 529 serial settings even to the same values as before. Thus
541 we actually need to filter in this specific case */ 530 we actually need to filter in this specific case */
@@ -1057,7 +1046,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1057 tty_flag = TTY_FRAME; 1046 tty_flag = TTY_FRAME;
1058 dbg("%s - tty_flag = %d", __func__, tty_flag); 1047 dbg("%s - tty_flag = %d", __func__, tty_flag);
1059 1048
1060 tty = port->port.tty; 1049 tty = tty_port_tty_get(&port->port);
1061 if (tty && urb->actual_length) { 1050 if (tty && urb->actual_length) {
1062 tty_buffer_request_room(tty, urb->actual_length + 1); 1051 tty_buffer_request_room(tty, urb->actual_length + 1);
1063 /* overrun is special, not associated with a char */ 1052 /* overrun is special, not associated with a char */
@@ -1067,7 +1056,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1067 tty_insert_flip_char(tty, data[i], tty_flag); 1056 tty_insert_flip_char(tty, data[i], tty_flag);
1068 tty_flip_buffer_push(tty); 1057 tty_flip_buffer_push(tty);
1069 } 1058 }
1070 1059 tty_kref_put(tty);
1071 /* Schedule the next read _if_ we are still open */ 1060 /* Schedule the next read _if_ we are still open */
1072 if (port->port.count) { 1061 if (port->port.count) {
1073 urb->dev = port->serial->dev; 1062 urb->dev = port->serial->dev;
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index def52d07a4ea..72903ac9f5c0 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -217,6 +217,7 @@ static void safe_read_bulk_callback(struct urb *urb)
217 struct usb_serial_port *port = urb->context; 217 struct usb_serial_port *port = urb->context;
218 unsigned char *data = urb->transfer_buffer; 218 unsigned char *data = urb->transfer_buffer;
219 unsigned char length = urb->actual_length; 219 unsigned char length = urb->actual_length;
220 struct tty_struct *tty;
220 int result; 221 int result;
221 int status = urb->status; 222 int status = urb->status;
222 223
@@ -242,6 +243,7 @@ static void safe_read_bulk_callback(struct urb *urb)
242 printk("\n"); 243 printk("\n");
243 } 244 }
244#endif 245#endif
246 tty = tty_port_tty_get(&port->port);
245 if (safe) { 247 if (safe) {
246 __u16 fcs; 248 __u16 fcs;
247 fcs = fcs_compute10(data, length, CRC10_INITFCS); 249 fcs = fcs_compute10(data, length, CRC10_INITFCS);
@@ -250,9 +252,9 @@ static void safe_read_bulk_callback(struct urb *urb)
250 if (actual_length <= (length - 2)) { 252 if (actual_length <= (length - 2)) {
251 info("%s - actual: %d", __func__, 253 info("%s - actual: %d", __func__,
252 actual_length); 254 actual_length);
253 tty_insert_flip_string(port->port.tty, 255 tty_insert_flip_string(tty,
254 data, actual_length); 256 data, actual_length);
255 tty_flip_buffer_push(port->port.tty); 257 tty_flip_buffer_push(tty);
256 } else { 258 } else {
257 err("%s - inconsistent lengths %d:%d", 259 err("%s - inconsistent lengths %d:%d",
258 __func__, actual_length, length); 260 __func__, actual_length, length);
@@ -261,9 +263,10 @@ static void safe_read_bulk_callback(struct urb *urb)
261 err("%s - bad CRC %x", __func__, fcs); 263 err("%s - bad CRC %x", __func__, fcs);
262 } 264 }
263 } else { 265 } else {
264 tty_insert_flip_string(port->port.tty, data, length); 266 tty_insert_flip_string(tty, data, length);
265 tty_flip_buffer_push(port->port.tty); 267 tty_flip_buffer_push(tty);
266 } 268 }
269 tty_kref_put(tty);
267 270
268 /* Continue trying to always read */ 271 /* Continue trying to always read */
269 usb_fill_bulk_urb(urb, port->serial->dev, 272 usb_fill_bulk_urb(urb, port->serial->dev,
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 706033753adb..8b9eaf383679 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -14,7 +14,7 @@
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15*/ 15*/
16 16
17#define DRIVER_VERSION "v.1.2.13a" 17#define DRIVER_VERSION "v.1.3.2"
18#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" 18#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>"
19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
20 20
@@ -30,9 +30,6 @@
30 30
31#define SWIMS_USB_REQUEST_SetPower 0x00 31#define SWIMS_USB_REQUEST_SetPower 0x00
32#define SWIMS_USB_REQUEST_SetNmea 0x07 32#define SWIMS_USB_REQUEST_SetNmea 0x07
33#define SWIMS_USB_REQUEST_SetMode 0x0B
34#define SWIMS_USB_REQUEST_GetSwocInfo 0x0A
35#define SWIMS_SET_MODE_Modem 0x0001
36 33
37/* per port private data */ 34/* per port private data */
38#define N_IN_URB 4 35#define N_IN_URB 4
@@ -163,7 +160,7 @@ static struct usb_device_id id_table [] = {
163 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 160 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
164 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 161 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
165 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 162 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
166 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ 163 { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */
167 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 164 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
168 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ 165 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
169 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ 166 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
@@ -175,6 +172,8 @@ static struct usb_device_id id_table [] = {
175 /* Sierra Wireless Device */ 172 /* Sierra Wireless Device */
176 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, 173 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) },
177 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ 174 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */
175 { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */
176 { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */
178 177
179 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 178 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
180 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 179 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
@@ -187,6 +186,7 @@ static struct usb_device_id id_table [] = {
187 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ 186 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
188 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ 187 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */
189 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ 188 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */
189 { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */
190 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ 190 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */
191 { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ 191 { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */
192 { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ 192 { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */
@@ -204,6 +204,8 @@ static struct usb_device_id id_table [] = {
204 /* Sierra Wireless Device */ 204 /* Sierra Wireless Device */
205 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, 205 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)},
206 /* Sierra Wireless Device */ 206 /* Sierra Wireless Device */
207 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)},
208 /* Sierra Wireless Device */
207 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, 209 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
208 210
209 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ 211 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
@@ -438,14 +440,14 @@ static void sierra_indat_callback(struct urb *urb)
438 dbg("%s: nonzero status: %d on endpoint %02x.", 440 dbg("%s: nonzero status: %d on endpoint %02x.",
439 __func__, status, endpoint); 441 __func__, status, endpoint);
440 } else { 442 } else {
441 tty = port->port.tty;
442 if (urb->actual_length) { 443 if (urb->actual_length) {
444 tty = tty_port_tty_get(&port->port);
443 tty_buffer_request_room(tty, urb->actual_length); 445 tty_buffer_request_room(tty, urb->actual_length);
444 tty_insert_flip_string(tty, data, urb->actual_length); 446 tty_insert_flip_string(tty, data, urb->actual_length);
445 tty_flip_buffer_push(tty); 447 tty_flip_buffer_push(tty);
446 } else { 448 tty_kref_put(tty);
449 } else
447 dbg("%s: empty read urb received", __func__); 450 dbg("%s: empty read urb received", __func__);
448 }
449 451
450 /* Resubmit urb so we continue receiving */ 452 /* Resubmit urb so we continue receiving */
451 if (port->port.count && status != -ESHUTDOWN) { 453 if (port->port.count && status != -ESHUTDOWN) {
@@ -483,6 +485,7 @@ static void sierra_instat_callback(struct urb *urb)
483 unsigned char signals = *((unsigned char *) 485 unsigned char signals = *((unsigned char *)
484 urb->transfer_buffer + 486 urb->transfer_buffer +
485 sizeof(struct usb_ctrlrequest)); 487 sizeof(struct usb_ctrlrequest));
488 struct tty_struct *tty;
486 489
487 dbg("%s: signal x%x", __func__, signals); 490 dbg("%s: signal x%x", __func__, signals);
488 491
@@ -492,9 +495,11 @@ static void sierra_instat_callback(struct urb *urb)
492 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 495 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
493 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 496 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
494 497
495 if (port->port.tty && !C_CLOCAL(port->port.tty) && 498 tty = tty_port_tty_get(&port->port);
499 if (tty && !C_CLOCAL(tty) &&
496 old_dcd_state && !portdata->dcd_state) 500 old_dcd_state && !portdata->dcd_state)
497 tty_hangup(port->port.tty); 501 tty_hangup(tty);
502 tty_kref_put(tty);
498 } else { 503 } else {
499 dbg("%s: type %x req %x", __func__, 504 dbg("%s: type %x req %x", __func__,
500 req_pkt->bRequestType, req_pkt->bRequest); 505 req_pkt->bRequestType, req_pkt->bRequest);
@@ -614,8 +619,7 @@ static void sierra_close(struct tty_struct *tty,
614 } 619 }
615 620
616 usb_kill_urb(port->interrupt_in_urb); 621 usb_kill_urb(port->interrupt_in_urb);
617 622 tty_port_tty_set(&port->port, NULL);
618 port->port.tty = NULL; /* FIXME */
619} 623}
620 624
621static int sierra_startup(struct usb_serial *serial) 625static int sierra_startup(struct usb_serial *serial)
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 283cf6b36b2c..1533d6e12238 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -755,7 +755,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
755 tty_flag = TTY_FRAME; 755 tty_flag = TTY_FRAME;
756 dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); 756 dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag);
757 757
758 tty = port->port.tty; 758 tty = tty_port_tty_get(&port->port);
759 if (tty && urb->actual_length) { 759 if (tty && urb->actual_length) {
760 tty_buffer_request_room(tty, urb->actual_length + 1); 760 tty_buffer_request_room(tty, urb->actual_length + 1);
761 /* overrun is special, not associated with a char */ 761 /* overrun is special, not associated with a char */
@@ -765,6 +765,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
765 tty_insert_flip_char(tty, data[i], tty_flag); 765 tty_insert_flip_char(tty, data[i], tty_flag);
766 tty_flip_buffer_push(tty); 766 tty_flip_buffer_push(tty);
767 } 767 }
768 tty_kref_put(tty);
768 769
769 /* Schedule the next read _if_ we are still open */ 770 /* Schedule the next read _if_ we are still open */
770 if (port->port.count) { 771 if (port->port.count) {
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index e39c779e4160..c90237d48b0e 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -179,7 +179,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
179static int ti_get_lsr(struct ti_port *tport); 179static int ti_get_lsr(struct ti_port *tport);
180static int ti_get_serial_info(struct ti_port *tport, 180static int ti_get_serial_info(struct ti_port *tport,
181 struct serial_struct __user *ret_arg); 181 struct serial_struct __user *ret_arg);
182static int ti_set_serial_info(struct ti_port *tport, 182static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
183 struct serial_struct __user *new_arg); 183 struct serial_struct __user *new_arg);
184static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); 184static void ti_handle_new_msr(struct ti_port *tport, __u8 msr);
185 185
@@ -857,8 +857,8 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file,
857 (struct serial_struct __user *)arg); 857 (struct serial_struct __user *)arg);
858 case TIOCSSERIAL: 858 case TIOCSSERIAL:
859 dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); 859 dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
860 return ti_set_serial_info(tport, 860 return ti_set_serial_info(tty, tport,
861 (struct serial_struct __user *)arg); 861 (struct serial_struct __user *)arg);
862 case TIOCMIWAIT: 862 case TIOCMIWAIT:
863 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); 863 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
864 cprev = tport->tp_icount; 864 cprev = tport->tp_icount;
@@ -1211,6 +1211,7 @@ static void ti_bulk_in_callback(struct urb *urb)
1211 struct device *dev = &urb->dev->dev; 1211 struct device *dev = &urb->dev->dev;
1212 int status = urb->status; 1212 int status = urb->status;
1213 int retval = 0; 1213 int retval = 0;
1214 struct tty_struct *tty;
1214 1215
1215 dbg("%s", __func__); 1216 dbg("%s", __func__);
1216 1217
@@ -1239,20 +1240,22 @@ static void ti_bulk_in_callback(struct urb *urb)
1239 return; 1240 return;
1240 } 1241 }
1241 1242
1242 if (port->port.tty && urb->actual_length) { 1243 tty = tty_port_tty_get(&port->port);
1244 if (tty && urb->actual_length) {
1243 usb_serial_debug_data(debug, dev, __func__, 1245 usb_serial_debug_data(debug, dev, __func__,
1244 urb->actual_length, urb->transfer_buffer); 1246 urb->actual_length, urb->transfer_buffer);
1245 1247
1246 if (!tport->tp_is_open) 1248 if (!tport->tp_is_open)
1247 dbg("%s - port closed, dropping data", __func__); 1249 dbg("%s - port closed, dropping data", __func__);
1248 else 1250 else
1249 ti_recv(&urb->dev->dev, port->port.tty, 1251 ti_recv(&urb->dev->dev, tty,
1250 urb->transfer_buffer, 1252 urb->transfer_buffer,
1251 urb->actual_length); 1253 urb->actual_length);
1252 1254
1253 spin_lock(&tport->tp_lock); 1255 spin_lock(&tport->tp_lock);
1254 tport->tp_icount.rx += urb->actual_length; 1256 tport->tp_icount.rx += urb->actual_length;
1255 spin_unlock(&tport->tp_lock); 1257 spin_unlock(&tport->tp_lock);
1258 tty_kref_put(tty);
1256 } 1259 }
1257 1260
1258exit: 1261exit:
@@ -1330,7 +1333,7 @@ static void ti_send(struct ti_port *tport)
1330{ 1333{
1331 int count, result; 1334 int count, result;
1332 struct usb_serial_port *port = tport->tp_port; 1335 struct usb_serial_port *port = tport->tp_port;
1333 struct tty_struct *tty = port->port.tty; /* FIXME */ 1336 struct tty_struct *tty = tty_port_tty_get(&port->port); /* FIXME */
1334 unsigned long flags; 1337 unsigned long flags;
1335 1338
1336 1339
@@ -1338,19 +1341,15 @@ static void ti_send(struct ti_port *tport)
1338 1341
1339 spin_lock_irqsave(&tport->tp_lock, flags); 1342 spin_lock_irqsave(&tport->tp_lock, flags);
1340 1343
1341 if (tport->tp_write_urb_in_use) { 1344 if (tport->tp_write_urb_in_use)
1342 spin_unlock_irqrestore(&tport->tp_lock, flags); 1345 goto unlock;
1343 return;
1344 }
1345 1346
1346 count = ti_buf_get(tport->tp_write_buf, 1347 count = ti_buf_get(tport->tp_write_buf,
1347 port->write_urb->transfer_buffer, 1348 port->write_urb->transfer_buffer,
1348 port->bulk_out_size); 1349 port->bulk_out_size);
1349 1350
1350 if (count == 0) { 1351 if (count == 0)
1351 spin_unlock_irqrestore(&tport->tp_lock, flags); 1352 goto unlock;
1352 return;
1353 }
1354 1353
1355 tport->tp_write_urb_in_use = 1; 1354 tport->tp_write_urb_in_use = 1;
1356 1355
@@ -1380,7 +1379,13 @@ static void ti_send(struct ti_port *tport)
1380 /* more room in the buffer for new writes, wakeup */ 1379 /* more room in the buffer for new writes, wakeup */
1381 if (tty) 1380 if (tty)
1382 tty_wakeup(tty); 1381 tty_wakeup(tty);
1382 tty_kref_put(tty);
1383 wake_up_interruptible(&tport->tp_write_wait); 1383 wake_up_interruptible(&tport->tp_write_wait);
1384 return;
1385unlock:
1386 spin_unlock_irqrestore(&tport->tp_lock, flags);
1387 tty_kref_put(tty);
1388 return;
1384} 1389}
1385 1390
1386 1391
@@ -1464,20 +1469,16 @@ static int ti_get_serial_info(struct ti_port *tport,
1464} 1469}
1465 1470
1466 1471
1467static int ti_set_serial_info(struct ti_port *tport, 1472static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
1468 struct serial_struct __user *new_arg) 1473 struct serial_struct __user *new_arg)
1469{ 1474{
1470 struct usb_serial_port *port = tport->tp_port;
1471 struct serial_struct new_serial; 1475 struct serial_struct new_serial;
1472 1476
1473 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) 1477 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial)))
1474 return -EFAULT; 1478 return -EFAULT;
1475 1479
1476 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; 1480 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
1477 /* FIXME */ 1481 tty->low_latency = (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1478 if (port->port.tty)
1479 port->port.tty->low_latency =
1480 (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1481 tport->tp_closing_wait = new_serial.closing_wait; 1482 tport->tp_closing_wait = new_serial.closing_wait;
1482 1483
1483 return 0; 1484 return 0;
@@ -1510,7 +1511,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1510 tport->tp_msr = msr & TI_MSR_MASK; 1511 tport->tp_msr = msr & TI_MSR_MASK;
1511 1512
1512 /* handle CTS flow control */ 1513 /* handle CTS flow control */
1513 tty = tport->tp_port->port.tty; 1514 tty = tty_port_tty_get(&tport->tp_port->port);
1514 if (tty && C_CRTSCTS(tty)) { 1515 if (tty && C_CRTSCTS(tty)) {
1515 if (msr & TI_MSR_CTS) { 1516 if (msr & TI_MSR_CTS) {
1516 tty->hw_stopped = 0; 1517 tty->hw_stopped = 0;
@@ -1519,6 +1520,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1519 tty->hw_stopped = 1; 1520 tty->hw_stopped = 1;
1520 } 1521 }
1521 } 1522 }
1523 tty_kref_put(tty);
1522} 1524}
1523 1525
1524 1526
@@ -1744,7 +1746,7 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1744 if (buffer) { 1746 if (buffer) {
1745 memcpy(buffer, fw_p->data, fw_p->size); 1747 memcpy(buffer, fw_p->data, fw_p->size);
1746 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); 1748 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1747 ti_do_download(dev, pipe, buffer, fw_p->size); 1749 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1748 kfree(buffer); 1750 kfree(buffer);
1749 } 1751 }
1750 release_firmware(fw_p); 1752 release_firmware(fw_p);
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b157c48e8b78..e7d4246027b2 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -214,7 +214,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
214 /* set up our port structure making the tty driver 214 /* set up our port structure making the tty driver
215 * remember our port object, and us it */ 215 * remember our port object, and us it */
216 tty->driver_data = port; 216 tty->driver_data = port;
217 port->port.tty = tty; 217 tty_port_tty_set(&port->port, tty);
218 218
219 if (port->port.count == 1) { 219 if (port->port.count == 1) {
220 220
@@ -246,7 +246,7 @@ bailout_module_put:
246bailout_mutex_unlock: 246bailout_mutex_unlock:
247 port->port.count = 0; 247 port->port.count = 0;
248 tty->driver_data = NULL; 248 tty->driver_data = NULL;
249 port->port.tty = NULL; 249 tty_port_tty_set(&port->port, NULL);
250 mutex_unlock(&port->mutex); 250 mutex_unlock(&port->mutex);
251bailout_kref_put: 251bailout_kref_put:
252 usb_serial_put(serial); 252 usb_serial_put(serial);
@@ -276,10 +276,11 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
276 port->serial->type->close(tty, port, filp); 276 port->serial->type->close(tty, port, filp);
277 277
278 if (port->port.count == (port->console? 1 : 0)) { 278 if (port->port.count == (port->console? 1 : 0)) {
279 if (port->port.tty) { 279 struct tty_struct *tty = tty_port_tty_get(&port->port);
280 if (port->port.tty->driver_data) 280 if (tty) {
281 port->port.tty->driver_data = NULL; 281 if (tty->driver_data)
282 port->port.tty = NULL; 282 tty->driver_data = NULL;
283 tty_port_tty_set(&port->port, NULL);
283 } 284 }
284 } 285 }
285 286
@@ -508,11 +509,12 @@ static void usb_serial_port_work(struct work_struct *work)
508 if (!port) 509 if (!port)
509 return; 510 return;
510 511
511 tty = port->port.tty; 512 tty = tty_port_tty_get(&port->port);
512 if (!tty) 513 if (!tty)
513 return; 514 return;
514 515
515 tty_wakeup(tty); 516 tty_wakeup(tty);
517 tty_kref_put(tty);
516} 518}
517 519
518static void port_release(struct device *dev) 520static void port_release(struct device *dev)
@@ -733,7 +735,9 @@ int usb_serial_probe(struct usb_interface *interface,
733 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && 735 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) &&
734 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || 736 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) ||
735 ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && 737 ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) &&
736 (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) { 738 (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) ||
739 ((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) &&
740 (le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) {
737 if (interface != dev->actconfig->interface[0]) { 741 if (interface != dev->actconfig->interface[0]) {
738 /* check out the endpoints of the other interface*/ 742 /* check out the endpoints of the other interface*/
739 iface_desc = dev->actconfig->interface[0]->cur_altsetting; 743 iface_desc = dev->actconfig->interface[0]->cur_altsetting;
@@ -817,6 +821,7 @@ int usb_serial_probe(struct usb_interface *interface,
817 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 821 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
818 if (!port) 822 if (!port)
819 goto probe_error; 823 goto probe_error;
824 tty_port_init(&port->port);
820 port->serial = serial; 825 port->serial = serial;
821 spin_lock_init(&port->lock); 826 spin_lock_init(&port->lock);
822 mutex_init(&port->mutex); 827 mutex_init(&port->mutex);
@@ -1038,8 +1043,11 @@ void usb_serial_disconnect(struct usb_interface *interface)
1038 for (i = 0; i < serial->num_ports; ++i) { 1043 for (i = 0; i < serial->num_ports; ++i) {
1039 port = serial->port[i]; 1044 port = serial->port[i];
1040 if (port) { 1045 if (port) {
1041 if (port->port.tty) 1046 struct tty_struct *tty = tty_port_tty_get(&port->port);
1042 tty_hangup(port->port.tty); 1047 if (tty) {
1048 tty_hangup(tty);
1049 tty_kref_put(tty);
1050 }
1043 kill_traffic(port); 1051 kill_traffic(port);
1044 } 1052 }
1045 } 1053 }
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index cf8924f9a2cc..a6d1c75a1c89 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -499,7 +499,7 @@ static void visor_read_bulk_callback(struct urb *urb)
499 int status = urb->status; 499 int status = urb->status;
500 struct tty_struct *tty; 500 struct tty_struct *tty;
501 int result; 501 int result;
502 int available_room; 502 int available_room = 0;
503 503
504 dbg("%s - port %d", __func__, port->number); 504 dbg("%s - port %d", __func__, port->number);
505 505
@@ -512,13 +512,17 @@ static void visor_read_bulk_callback(struct urb *urb)
512 usb_serial_debug_data(debug, &port->dev, __func__, 512 usb_serial_debug_data(debug, &port->dev, __func__,
513 urb->actual_length, data); 513 urb->actual_length, data);
514 514
515 tty = port->port.tty; 515 if (urb->actual_length) {
516 if (tty && urb->actual_length) { 516 tty = tty_port_tty_get(&port->port);
517 available_room = tty_buffer_request_room(tty, 517 if (tty) {
518 available_room = tty_buffer_request_room(tty,
518 urb->actual_length); 519 urb->actual_length);
519 if (available_room) { 520 if (available_room) {
520 tty_insert_flip_string(tty, data, available_room); 521 tty_insert_flip_string(tty, data,
521 tty_flip_buffer_push(tty); 522 available_room);
523 tty_flip_buffer_push(tty);
524 }
525 tty_kref_put(tty);
522 } 526 }
523 spin_lock(&priv->lock); 527 spin_lock(&priv->lock);
524 priv->bytes_in += available_room; 528 priv->bytes_in += available_room;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 3a9d14384a43..11c8b97a5177 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -1481,7 +1481,7 @@ static void rx_data_softint(struct work_struct *work)
1481 struct whiteheat_private *info = 1481 struct whiteheat_private *info =
1482 container_of(work, struct whiteheat_private, rx_work); 1482 container_of(work, struct whiteheat_private, rx_work);
1483 struct usb_serial_port *port = info->port; 1483 struct usb_serial_port *port = info->port;
1484 struct tty_struct *tty = port->port.tty; 1484 struct tty_struct *tty = tty_port_tty_get(&port->port);
1485 struct whiteheat_urb_wrap *wrap; 1485 struct whiteheat_urb_wrap *wrap;
1486 struct urb *urb; 1486 struct urb *urb;
1487 unsigned long flags; 1487 unsigned long flags;
@@ -1493,7 +1493,7 @@ static void rx_data_softint(struct work_struct *work)
1493 spin_lock_irqsave(&info->lock, flags); 1493 spin_lock_irqsave(&info->lock, flags);
1494 if (info->flags & THROTTLED) { 1494 if (info->flags & THROTTLED) {
1495 spin_unlock_irqrestore(&info->lock, flags); 1495 spin_unlock_irqrestore(&info->lock, flags);
1496 return; 1496 goto out;
1497 } 1497 }
1498 1498
1499 list_for_each_safe(tmp, tmp2, &info->rx_urb_q) { 1499 list_for_each_safe(tmp, tmp2, &info->rx_urb_q) {
@@ -1513,7 +1513,7 @@ static void rx_data_softint(struct work_struct *work)
1513 spin_unlock_irqrestore(&info->lock, flags); 1513 spin_unlock_irqrestore(&info->lock, flags);
1514 tty_flip_buffer_push(tty); 1514 tty_flip_buffer_push(tty);
1515 schedule_work(&info->rx_work); 1515 schedule_work(&info->rx_work);
1516 return; 1516 goto out;
1517 } 1517 }
1518 tty_insert_flip_string(tty, urb->transfer_buffer, len); 1518 tty_insert_flip_string(tty, urb->transfer_buffer, len);
1519 sent += len; 1519 sent += len;
@@ -1536,6 +1536,8 @@ static void rx_data_softint(struct work_struct *work)
1536 1536
1537 if (sent) 1537 if (sent)
1538 tty_flip_buffer_push(tty); 1538 tty_flip_buffer_push(tty);
1539out:
1540 tty_kref_put(tty);
1539} 1541}
1540 1542
1541 1543
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index c76034672c18..3d9249632ae1 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -146,18 +146,6 @@ config USB_STORAGE_KARMA
146 on the resulting scsi device node returns the Karma to normal 146 on the resulting scsi device node returns the Karma to normal
147 operation. 147 operation.
148 148
149config USB_STORAGE_SIERRA
150 bool "Sierra Wireless TRU-Install Feature Support"
151 depends on USB_STORAGE
152 help
153 Say Y here to include additional code to support Sierra Wireless
154 products with the TRU-Install feature (e.g., AC597E, AC881U).
155
156 This code switches the Sierra Wireless device from being in
157 Mass Storage mode to Modem mode. It also has the ability to
158 support host software upgrades should full Linux support be added
159 to TRU-Install.
160
161config USB_STORAGE_CYPRESS_ATACB 149config USB_STORAGE_CYPRESS_ATACB
162 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" 150 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
163 depends on USB_STORAGE 151 depends on USB_STORAGE
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index bc3415b475c9..7f8beb5366ae 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -21,11 +21,10 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o 21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o 23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
24usb-storage-obj-$(CONFIG_USB_STORAGE_SIERRA) += sierra_ms.o
25usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o 24usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
26 25
27usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 26usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
28 initializers.o $(usb-storage-obj-y) 27 initializers.o sierra_ms.o $(usb-storage-obj-y)
29 28
30ifneq ($(CONFIG_USB_LIBUSUAL),) 29ifneq ($(CONFIG_USB_LIBUSUAL),)
31 obj-$(CONFIG_USB) += libusual.o 30 obj-$(CONFIG_USB) += libusual.o
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index ba412e68d474..cd155475cb6e 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -160,6 +160,13 @@ UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0592,
160 US_SC_DEVICE, US_PR_DEVICE, NULL, 160 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_MAX_SECTORS_64 ), 161 US_FL_MAX_SECTORS_64 ),
162 162
163/* Reported by Filip Joelsson <filip@blueturtle.nu> */
164UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
165 "Nokia",
166 "Nokia 3110c",
167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ),
169
163/* Reported by Mario Rettig <mariorettig@web.de> */ 170/* Reported by Mario Rettig <mariorettig@web.de> */
164UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 171UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
165 "Nokia", 172 "Nokia",
@@ -232,6 +239,20 @@ UNUSUAL_DEV( 0x0421, 0x04b9, 0x0551, 0x0551,
232 US_SC_DEVICE, US_PR_DEVICE, NULL, 239 US_SC_DEVICE, US_PR_DEVICE, NULL,
233 US_FL_FIX_CAPACITY ), 240 US_FL_FIX_CAPACITY ),
234 241
242/* Reported by Richard Nauber <RichardNauber@web.de> */
243UNUSUAL_DEV( 0x0421, 0x04fa, 0x0601, 0x0601,
244 "Nokia",
245 "6300",
246 US_SC_DEVICE, US_PR_DEVICE, NULL,
247 US_FL_FIX_CAPACITY ),
248
249/* Patch for Nokia 5310 capacity */
250UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
251 "Nokia",
252 "5310",
253 US_SC_DEVICE, US_PR_DEVICE, NULL,
254 US_FL_FIX_CAPACITY ),
255
235/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 256/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
236UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 257UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
237 "SMSC", 258 "SMSC",
@@ -987,6 +1008,13 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
987 US_SC_DEVICE, US_PR_DEVICE, NULL, 1008 US_SC_DEVICE, US_PR_DEVICE, NULL,
988 US_FL_FIX_CAPACITY ), 1009 US_FL_FIX_CAPACITY ),
989 1010
1011/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
1012UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
1013 "RockChip",
1014 "MP3",
1015 US_SC_DEVICE, US_PR_DEVICE, NULL,
1016 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
1017
990/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> 1018/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
991 * This USB MP3/AVI player device fails and disconnects if more than 128 1019 * This USB MP3/AVI player device fails and disconnects if more than 128
992 * sectors (64kB) are read/written in a single command, and may be present 1020 * sectors (64kB) are read/written in a single command, and may be present
@@ -1576,7 +1604,6 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
1576 US_SC_DEVICE, US_PR_DEVICE, NULL, 1604 US_SC_DEVICE, US_PR_DEVICE, NULL,
1577 0), 1605 0),
1578 1606
1579#ifdef CONFIG_USB_STORAGE_SIERRA
1580/* Reported by Kevin Lloyd <linux@sierrawireless.com> 1607/* Reported by Kevin Lloyd <linux@sierrawireless.com>
1581 * Entry is needed for the initializer function override, 1608 * Entry is needed for the initializer function override,
1582 * which instructs the device to load as a modem 1609 * which instructs the device to load as a modem
@@ -1587,7 +1614,6 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
1587 "USB MMC Storage", 1614 "USB MMC Storage",
1588 US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, 1615 US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init,
1589 0), 1616 0),
1590#endif
1591 1617
1592/* Reported by Jaco Kroon <jaco@kroon.co.za> 1618/* Reported by Jaco Kroon <jaco@kroon.co.za>
1593 * The usb-storage module found on the Digitech GNX4 (and supposedly other 1619 * The usb-storage module found on the Digitech GNX4 (and supposedly other
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 73679aa506de..27016fd2cad1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -102,9 +102,7 @@
102#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB 102#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
103#include "cypress_atacb.h" 103#include "cypress_atacb.h"
104#endif 104#endif
105#ifdef CONFIG_USB_STORAGE_SIERRA
106#include "sierra_ms.h" 105#include "sierra_ms.h"
107#endif
108 106
109/* Some informational data */ 107/* Some informational data */
110MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 108MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");