Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6:
USB: option.c: add support for D-Link DWM-162-U5
USB: usbmon: fix bug in mon_buff_area_shrink
USB: xhci: Fix scratchpad deallocation.
USB: xhci: Fix TRB physical to virtual address translation.
USB: xhci: Fix bug memory free after failed initialization.
USB: cdc_acm: Fix memory leak after hangup
USB: cdc_acm: Fix race condition when opening tty
USB: ohci: quirk AMD prefetch for USB 1.1 ISO transfer

+78 -22
+12 -6
drivers/usb/class/cdc-acm.c
··· 609 610 acm->throttle = 0; 611 612 - tasklet_schedule(&acm->urb_task); 613 set_bit(ASYNCB_INITIALIZED, &acm->port.flags); 614 rv = tty_port_block_til_ready(&acm->port, tty, filp); 615 done: 616 mutex_unlock(&acm->mutex); 617 err_out: ··· 686 687 /* Perform the closing process and see if we need to do the hardware 688 shutdown */ 689 - if (!acm || tty_port_close_start(&acm->port, tty, filp) == 0) 690 return; 691 acm_port_down(acm, 0); 692 tty_port_close_end(&acm->port, tty); 693 - mutex_lock(&open_mutex); 694 tty_port_tty_set(&acm->port, NULL); 695 - if (!acm->dev) 696 - acm_tty_unregister(acm); 697 - mutex_unlock(&open_mutex); 698 } 699 700 static int acm_tty_write(struct tty_struct *tty,
··· 609 610 acm->throttle = 0; 611 612 set_bit(ASYNCB_INITIALIZED, &acm->port.flags); 613 rv = tty_port_block_til_ready(&acm->port, tty, filp); 614 + tasklet_schedule(&acm->urb_task); 615 done: 616 mutex_unlock(&acm->mutex); 617 err_out: ··· 686 687 /* Perform the closing process and see if we need to do the hardware 688 shutdown */ 689 + if (!acm) 690 return; 691 + if (tty_port_close_start(&acm->port, tty, filp) == 0) { 692 + mutex_lock(&open_mutex); 693 + if (!acm->dev) { 694 + tty_port_tty_set(&acm->port, NULL); 695 + acm_tty_unregister(acm); 696 + tty->driver_data = NULL; 697 + } 698 + mutex_unlock(&open_mutex); 699 + return; 700 + } 701 acm_port_down(acm, 0); 702 tty_port_close_end(&acm->port, tty); 703 tty_port_tty_set(&acm->port, NULL); 704 } 705 706 static int acm_tty_write(struct tty_struct *tty,
+5
drivers/usb/host/ohci-hcd.c
··· 87 #ifdef CONFIG_PCI 88 static void quirk_amd_pll(int state); 89 static void amd_iso_dev_put(void); 90 #else 91 static inline void quirk_amd_pll(int state) 92 { 93 return; 94 } 95 static inline void amd_iso_dev_put(void) 96 { 97 return; 98 }
··· 87 #ifdef CONFIG_PCI 88 static void quirk_amd_pll(int state); 89 static void amd_iso_dev_put(void); 90 + static void sb800_prefetch(struct ohci_hcd *ohci, int on); 91 #else 92 static inline void quirk_amd_pll(int state) 93 { 94 return; 95 } 96 static inline void amd_iso_dev_put(void) 97 + { 98 + return; 99 + } 100 + static inline void sb800_prefetch(struct ohci_hcd *ohci, int on) 101 { 102 return; 103 }
+20
drivers/usb/host/ohci-pci.c
··· 177 return 0; 178 179 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev); 180 if ((rev > 0x3b) || (rev < 0x30)) { 181 pci_dev_put(amd_smbus_dev); 182 amd_smbus_dev = NULL; ··· 267 } 268 } 269 270 } 271 272 /* List of quirks for OHCI */
··· 177 return 0; 178 179 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev); 180 + 181 + /* SB800 needs pre-fetch fix */ 182 + if ((rev >= 0x40) && (rev <= 0x4f)) { 183 + ohci->flags |= OHCI_QUIRK_AMD_PREFETCH; 184 + ohci_dbg(ohci, "enabled AMD prefetch quirk\n"); 185 + } 186 + 187 if ((rev > 0x3b) || (rev < 0x30)) { 188 pci_dev_put(amd_smbus_dev); 189 amd_smbus_dev = NULL; ··· 260 } 261 } 262 263 + } 264 + 265 + static void sb800_prefetch(struct ohci_hcd *ohci, int on) 266 + { 267 + struct pci_dev *pdev; 268 + u16 misc; 269 + 270 + pdev = to_pci_dev(ohci_to_hcd(ohci)->self.controller); 271 + pci_read_config_word(pdev, 0x50, &misc); 272 + if (on == 0) 273 + pci_write_config_word(pdev, 0x50, misc & 0xfcff); 274 + else 275 + pci_write_config_word(pdev, 0x50, misc | 0x0300); 276 } 277 278 /* List of quirks for OHCI */
+12 -6
drivers/usb/host/ohci-q.c
··· 49 switch (usb_pipetype (urb->pipe)) { 50 case PIPE_ISOCHRONOUS: 51 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--; 52 - if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 53 - && quirk_amdiso(ohci)) 54 - quirk_amd_pll(1); 55 break; 56 case PIPE_INTERRUPT: 57 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--; ··· 683 data + urb->iso_frame_desc [cnt].offset, 684 urb->iso_frame_desc [cnt].length, urb, cnt); 685 } 686 - if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 687 - && quirk_amdiso(ohci)) 688 - quirk_amd_pll(0); 689 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 690 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; 691 break;
··· 49 switch (usb_pipetype (urb->pipe)) { 50 case PIPE_ISOCHRONOUS: 51 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--; 52 + if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { 53 + if (quirk_amdiso(ohci)) 54 + quirk_amd_pll(1); 55 + if (quirk_amdprefetch(ohci)) 56 + sb800_prefetch(ohci, 0); 57 + } 58 break; 59 case PIPE_INTERRUPT: 60 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--; ··· 680 data + urb->iso_frame_desc [cnt].offset, 681 urb->iso_frame_desc [cnt].length, urb, cnt); 682 } 683 + if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { 684 + if (quirk_amdiso(ohci)) 685 + quirk_amd_pll(0); 686 + if (quirk_amdprefetch(ohci)) 687 + sb800_prefetch(ohci, 1); 688 + } 689 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 690 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; 691 break;
+9
drivers/usb/host/ohci.h
··· 402 #define OHCI_QUIRK_FRAME_NO 0x80 /* no big endian frame_no shift */ 403 #define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ 404 #define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/ 405 // there are also chip quirks/bugs in init logic 406 407 struct work_struct nec_work; /* Worker for NEC quirk */ ··· 434 { 435 return ohci->flags & OHCI_QUIRK_AMD_ISO; 436 } 437 #else 438 static inline int quirk_nec(struct ohci_hcd *ohci) 439 { ··· 448 return 0; 449 } 450 static inline int quirk_amdiso(struct ohci_hcd *ohci) 451 { 452 return 0; 453 }
··· 402 #define OHCI_QUIRK_FRAME_NO 0x80 /* no big endian frame_no shift */ 403 #define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ 404 #define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/ 405 + #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */ 406 // there are also chip quirks/bugs in init logic 407 408 struct work_struct nec_work; /* Worker for NEC quirk */ ··· 433 { 434 return ohci->flags & OHCI_QUIRK_AMD_ISO; 435 } 436 + static inline int quirk_amdprefetch(struct ohci_hcd *ohci) 437 + { 438 + return ohci->flags & OHCI_QUIRK_AMD_PREFETCH; 439 + } 440 #else 441 static inline int quirk_nec(struct ohci_hcd *ohci) 442 { ··· 443 return 0; 444 } 445 static inline int quirk_amdiso(struct ohci_hcd *ohci) 446 + { 447 + return 0; 448 + } 449 + static inline int quirk_amdprefetch(struct ohci_hcd *ohci) 450 { 451 return 0; 452 }
+6 -4
drivers/usb/host/xhci-mem.c
··· 802 int i; 803 804 /* Free the Event Ring Segment Table and the actual Event Ring */ 805 - xhci_writel(xhci, 0, &xhci->ir_set->erst_size); 806 - xhci_write_64(xhci, 0, &xhci->ir_set->erst_base); 807 - xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue); 808 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 809 if (xhci->erst.entries) 810 pci_free_consistent(pdev, size, ··· 843 xhci->dcbaa, xhci->dcbaa->dma); 844 xhci->dcbaa = NULL; 845 846 xhci->page_size = 0; 847 xhci->page_shift = 0; 848 - scratchpad_free(xhci); 849 } 850 851 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
··· 802 int i; 803 804 /* Free the Event Ring Segment Table and the actual Event Ring */ 805 + if (xhci->ir_set) { 806 + xhci_writel(xhci, 0, &xhci->ir_set->erst_size); 807 + xhci_write_64(xhci, 0, &xhci->ir_set->erst_base); 808 + xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue); 809 + } 810 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 811 if (xhci->erst.entries) 812 pci_free_consistent(pdev, size, ··· 841 xhci->dcbaa, xhci->dcbaa->dma); 842 xhci->dcbaa = NULL; 843 844 + scratchpad_free(xhci); 845 xhci->page_size = 0; 846 xhci->page_shift = 0; 847 } 848 849 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
+5 -2
drivers/usb/host/xhci-ring.c
··· 864 cur_seg = start_seg; 865 866 do { 867 /* We may get an event for a Link TRB in the middle of a TD */ 868 end_seg_dma = xhci_trb_virt_to_dma(cur_seg, 869 - &start_seg->trbs[TRBS_PER_SEGMENT - 1]); 870 /* If the end TRB isn't in this segment, this is set to 0 */ 871 end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb); 872 ··· 895 } 896 cur_seg = cur_seg->next; 897 start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]); 898 - } while (1); 899 900 } 901 902 /*
··· 864 cur_seg = start_seg; 865 866 do { 867 + if (start_dma == 0) 868 + return 0; 869 /* We may get an event for a Link TRB in the middle of a TD */ 870 end_seg_dma = xhci_trb_virt_to_dma(cur_seg, 871 + &cur_seg->trbs[TRBS_PER_SEGMENT - 1]); 872 /* If the end TRB isn't in this segment, this is set to 0 */ 873 end_trb_dma = xhci_trb_virt_to_dma(cur_seg, end_trb); 874 ··· 893 } 894 cur_seg = cur_seg->next; 895 start_dma = xhci_trb_virt_to_dma(cur_seg, &cur_seg->trbs[0]); 896 + } while (cur_seg != start_seg); 897 898 + return 0; 899 } 900 901 /*
+7 -4
drivers/usb/mon/mon_bin.c
··· 348 349 /* 350 * Return a few (kilo-)bytes to the head of the buffer. 351 - * This is used if a DMA fetch fails. 352 */ 353 static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int size) 354 { 355 356 - size = (size + PKT_ALIGN-1) & ~(PKT_ALIGN-1); 357 rp->b_cnt -= size; 358 if (rp->b_in < size) 359 rp->b_in += rp->b_size; ··· 433 unsigned int urb_length; 434 unsigned int offset; 435 unsigned int length; 436 unsigned int ndesc, lendesc; 437 unsigned char dir; 438 struct mon_bin_hdr *ep; ··· 538 if (length != 0) { 539 ep->flag_data = mon_bin_get_data(rp, offset, urb, length); 540 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */ 541 - ep->len_cap = 0; 542 - mon_buff_area_shrink(rp, length); 543 } 544 } else { 545 ep->flag_data = data_tag;
··· 348 349 /* 350 * Return a few (kilo-)bytes to the head of the buffer. 351 + * This is used if a data fetch fails. 352 */ 353 static void mon_buff_area_shrink(struct mon_reader_bin *rp, unsigned int size) 354 { 355 356 + /* size &= ~(PKT_ALIGN-1); -- we're called with aligned size */ 357 rp->b_cnt -= size; 358 if (rp->b_in < size) 359 rp->b_in += rp->b_size; ··· 433 unsigned int urb_length; 434 unsigned int offset; 435 unsigned int length; 436 + unsigned int delta; 437 unsigned int ndesc, lendesc; 438 unsigned char dir; 439 struct mon_bin_hdr *ep; ··· 537 if (length != 0) { 538 ep->flag_data = mon_bin_get_data(rp, offset, urb, length); 539 if (ep->flag_data != 0) { /* Yes, it's 0x00, not '0' */ 540 + delta = (ep->len_cap + PKT_ALIGN-1) & ~(PKT_ALIGN-1); 541 + ep->len_cap -= length; 542 + delta -= (ep->len_cap + PKT_ALIGN-1) & ~(PKT_ALIGN-1); 543 + mon_buff_area_shrink(rp, delta); 544 } 545 } else { 546 ep->flag_data = data_tag;
+2
drivers/usb/serial/option.c
··· 308 309 #define DLINK_VENDOR_ID 0x1186 310 #define DLINK_PRODUCT_DWM_652 0x3e04 311 312 #define QISDA_VENDOR_ID 0x1da5 313 #define QISDA_PRODUCT_H21_4512 0x4512 ··· 587 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 588 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 589 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 590 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 591 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 592 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
··· 308 309 #define DLINK_VENDOR_ID 0x1186 310 #define DLINK_PRODUCT_DWM_652 0x3e04 311 + #define DLINK_PRODUCT_DWM_652_U5 0xce16 312 313 #define QISDA_VENDOR_ID 0x1da5 314 #define QISDA_PRODUCT_H21_4512 0x4512 ··· 586 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 587 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 588 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 589 + { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 590 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 591 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 592 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },