Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a small clump of USB fixes for 4.16-rc6.

Nothing major, just a number of fixes in lots of different drivers, as
well as a PHY driver fix that snuck into this tree. Full details are
in the shortlog.

All of these have been in linux-next with no reported issues"

* tag 'usb-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (22 commits)
usb: musb: Fix external abort in musb_remove on omap2430
phy: qcom-ufs: add MODULE_LICENSE tag
usb: typec: tcpm: fusb302: Do not log an error on -EPROBE_DEFER
USB: OHCI: Fix NULL dereference in HCDs using HCD_LOCAL_MEM
usbip: vudc: fix null pointer dereference on udc->lock
xhci: Fix front USB ports on ASUS PRIME B350M-A
usb: host: xhci-plat: revert "usb: host: xhci-plat: enable clk in resume timing"
usb: usbmon: Read text within supplied buffer size
usb: host: xhci-rcar: add support for r8a77965
USB: storage: Add JMicron bridge 152d:2567 to unusual_devs.h
usb: xhci: dbc: Fix lockdep warning
xhci: fix endpoint context tracer output
Revert "typec: tcpm: Only request matching pdos"
usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers
usb: quirks: add control message delay for 1b1c:1b20
uas: fix comparison for error code
usb: gadget: udc: renesas_usb3: add binging for r8a77965
usb: renesas_usbhs: add binding for r8a77965
usb: dwc2: fix STM32F7 USB OTG HS compatible
dt-bindings: usb: fix the STM32F7 DWC2 OTG HS core binding
...

+217 -224
+1 -1
Documentation/devicetree/bindings/usb/dwc2.txt
··· 19 19 configured in FS mode; 20 20 - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs 21 21 configured in HS mode; 22 - - "st,stm32f7xx-hsotg": The DWC2 USB HS controller instance in STM32F7xx SoCs 22 + - "st,stm32f7-hsotg": The DWC2 USB HS controller instance in STM32F7 SoCs 23 23 configured in HS mode; 24 24 - reg : Should contain 1 register range (address and length) 25 25 - interrupts : Should contain 1 interrupt
+1
Documentation/devicetree/bindings/usb/renesas_usb3.txt
··· 4 4 - compatible: Must contain one of the following: 5 5 - "renesas,r8a7795-usb3-peri" 6 6 - "renesas,r8a7796-usb3-peri" 7 + - "renesas,r8a77965-usb3-peri" 7 8 - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 compatible 8 9 device 9 10
+1
Documentation/devicetree/bindings/usb/renesas_usbhs.txt
··· 12 12 - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device 13 13 - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device 14 14 - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device 15 + - "renesas,usbhs-r8a77965" for r8a77965 (R-Car M3-N) compatible device 15 16 - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device 16 17 - "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device 17 18 - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices
+1
Documentation/devicetree/bindings/usb/usb-xhci.txt
··· 13 13 - "renesas,xhci-r8a7793" for r8a7793 SoC 14 14 - "renesas,xhci-r8a7795" for r8a7795 SoC 15 15 - "renesas,xhci-r8a7796" for r8a7796 SoC 16 + - "renesas,xhci-r8a77965" for r8a77965 SoC 16 17 - "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible 17 18 device 18 19 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 compatible device
+5
drivers/phy/qualcomm/phy-qcom-ufs.c
··· 675 675 return 0; 676 676 } 677 677 EXPORT_SYMBOL_GPL(ufs_qcom_phy_power_off); 678 + 679 + MODULE_AUTHOR("Yaniv Gardi <ygardi@codeaurora.org>"); 680 + MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 681 + MODULE_DESCRIPTION("Universal Flash Storage (UFS) QCOM PHY"); 682 + MODULE_LICENSE("GPL v2");
+4
drivers/usb/core/message.c
··· 151 151 152 152 ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); 153 153 154 + /* Linger a bit, prior to the next control message. */ 155 + if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG) 156 + msleep(200); 157 + 154 158 kfree(dr); 155 159 156 160 return ret;
+2 -1
drivers/usb/core/quirks.c
··· 230 230 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, 231 231 232 232 /* Corsair Strafe RGB */ 233 - { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, 233 + { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | 234 + USB_QUIRK_DELAY_CTRL_MSG }, 234 235 235 236 /* Corsair K70 LUX */ 236 237 { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
+3 -3
drivers/usb/dwc2/params.c
··· 137 137 p->activate_stm_fs_transceiver = true; 138 138 } 139 139 140 - static void dwc2_set_stm32f7xx_hsotg_params(struct dwc2_hsotg *hsotg) 140 + static void dwc2_set_stm32f7_hsotg_params(struct dwc2_hsotg *hsotg) 141 141 { 142 142 struct dwc2_core_params *p = &hsotg->params; 143 143 ··· 164 164 { .compatible = "st,stm32f4x9-fsotg", 165 165 .data = dwc2_set_stm32f4x9_fsotg_params }, 166 166 { .compatible = "st,stm32f4x9-hsotg" }, 167 - { .compatible = "st,stm32f7xx-hsotg", 168 - .data = dwc2_set_stm32f7xx_hsotg_params }, 167 + { .compatible = "st,stm32f7-hsotg", 168 + .data = dwc2_set_stm32f7_hsotg_params }, 169 169 {}, 170 170 }; 171 171 MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
+1 -1
drivers/usb/dwc3/core.c
··· 175 175 dwc->desired_dr_role = mode; 176 176 spin_unlock_irqrestore(&dwc->lock, flags); 177 177 178 - queue_work(system_power_efficient_wq, &dwc->drd_work); 178 + queue_work(system_freezable_wq, &dwc->drd_work); 179 179 } 180 180 181 181 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
-1
drivers/usb/gadget/function/f_fs.c
··· 1538 1538 if (sb->s_fs_info) { 1539 1539 ffs_release_dev(sb->s_fs_info); 1540 1540 ffs_data_closed(sb->s_fs_info); 1541 - ffs_data_put(sb->s_fs_info); 1542 1541 } 1543 1542 } 1544 1543
+2 -1
drivers/usb/host/ohci-hcd.c
··· 447 447 struct usb_hcd *hcd = ohci_to_hcd(ohci); 448 448 449 449 /* Accept arbitrarily long scatter-gather lists */ 450 - hcd->self.sg_tablesize = ~0; 450 + if (!(hcd->driver->flags & HCD_LOCAL_MEM)) 451 + hcd->self.sg_tablesize = ~0; 451 452 452 453 if (distrust_firmware) 453 454 ohci->flags |= OHCI_QUIRK_HUB_POWER;
+12 -8
drivers/usb/host/xhci-dbgcap.c
··· 328 328 int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, 329 329 gfp_t gfp_flags) 330 330 { 331 + unsigned long flags; 331 332 struct xhci_dbc *dbc = dep->dbc; 332 333 int ret = -ESHUTDOWN; 333 334 334 - spin_lock(&dbc->lock); 335 + spin_lock_irqsave(&dbc->lock, flags); 335 336 if (dbc->state == DS_CONFIGURED) 336 337 ret = dbc_ep_do_queue(dep, req); 337 - spin_unlock(&dbc->lock); 338 + spin_unlock_irqrestore(&dbc->lock, flags); 338 339 339 340 mod_delayed_work(system_wq, &dbc->event_work, 0); 340 341 ··· 522 521 static int xhci_dbc_start(struct xhci_hcd *xhci) 523 522 { 524 523 int ret; 524 + unsigned long flags; 525 525 struct xhci_dbc *dbc = xhci->dbc; 526 526 527 527 WARN_ON(!dbc); 528 528 529 529 pm_runtime_get_sync(xhci_to_hcd(xhci)->self.controller); 530 530 531 - spin_lock(&dbc->lock); 531 + spin_lock_irqsave(&dbc->lock, flags); 532 532 ret = xhci_do_dbc_start(xhci); 533 - spin_unlock(&dbc->lock); 533 + spin_unlock_irqrestore(&dbc->lock, flags); 534 534 535 535 if (ret) { 536 536 pm_runtime_put(xhci_to_hcd(xhci)->self.controller); ··· 543 541 544 542 static void xhci_dbc_stop(struct xhci_hcd *xhci) 545 543 { 544 + unsigned long flags; 546 545 struct xhci_dbc *dbc = xhci->dbc; 547 546 struct dbc_port *port = &dbc->port; 548 547 ··· 554 551 if (port->registered) 555 552 xhci_dbc_tty_unregister_device(xhci); 556 553 557 - spin_lock(&dbc->lock); 554 + spin_lock_irqsave(&dbc->lock, flags); 558 555 xhci_do_dbc_stop(xhci); 559 - spin_unlock(&dbc->lock); 556 + spin_unlock_irqrestore(&dbc->lock, flags); 560 557 561 558 pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); 562 559 } ··· 782 779 int ret; 783 780 enum evtreturn evtr; 784 781 struct xhci_dbc *dbc; 782 + unsigned long flags; 785 783 struct xhci_hcd *xhci; 786 784 787 785 dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work); 788 786 xhci = dbc->xhci; 789 787 790 - spin_lock(&dbc->lock); 788 + spin_lock_irqsave(&dbc->lock, flags); 791 789 evtr = xhci_dbc_do_handle_events(dbc); 792 - spin_unlock(&dbc->lock); 790 + spin_unlock_irqrestore(&dbc->lock, flags); 793 791 794 792 switch (evtr) { 795 793 case EVT_GSER:
+12 -8
drivers/usb/host/xhci-dbgtty.c
··· 92 92 static void 93 93 dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req) 94 94 { 95 + unsigned long flags; 95 96 struct xhci_dbc *dbc = xhci->dbc; 96 97 struct dbc_port *port = &dbc->port; 97 98 98 - spin_lock(&port->port_lock); 99 + spin_lock_irqsave(&port->port_lock, flags); 99 100 list_add_tail(&req->list_pool, &port->read_queue); 100 101 tasklet_schedule(&port->push); 101 - spin_unlock(&port->port_lock); 102 + spin_unlock_irqrestore(&port->port_lock, flags); 102 103 } 103 104 104 105 static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) 105 106 { 107 + unsigned long flags; 106 108 struct xhci_dbc *dbc = xhci->dbc; 107 109 struct dbc_port *port = &dbc->port; 108 110 109 - spin_lock(&port->port_lock); 111 + spin_lock_irqsave(&port->port_lock, flags); 110 112 list_add(&req->list_pool, &port->write_pool); 111 113 switch (req->status) { 112 114 case 0: ··· 121 119 req->status); 122 120 break; 123 121 } 124 - spin_unlock(&port->port_lock); 122 + spin_unlock_irqrestore(&port->port_lock, flags); 125 123 } 126 124 127 125 static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) ··· 329 327 { 330 328 struct dbc_request *req; 331 329 struct tty_struct *tty; 330 + unsigned long flags; 332 331 bool do_push = false; 333 332 bool disconnect = false; 334 333 struct dbc_port *port = (void *)_port; 335 334 struct list_head *queue = &port->read_queue; 336 335 337 - spin_lock_irq(&port->port_lock); 336 + spin_lock_irqsave(&port->port_lock, flags); 338 337 tty = port->port.tty; 339 338 while (!list_empty(queue)) { 340 339 req = list_first_entry(queue, struct dbc_request, list_pool); ··· 395 392 if (!disconnect) 396 393 dbc_start_rx(port); 397 394 398 - spin_unlock_irq(&port->port_lock); 395 + spin_unlock_irqrestore(&port->port_lock, flags); 399 396 } 400 397 401 398 static int dbc_port_activate(struct tty_port *_port, struct tty_struct *tty) 402 399 { 400 + unsigned long flags; 403 401 struct dbc_port *port = container_of(_port, struct dbc_port, port); 404 402 405 - spin_lock_irq(&port->port_lock); 403 + spin_lock_irqsave(&port->port_lock, flags); 406 404 dbc_start_rx(port); 407 - spin_unlock_irq(&port->port_lock); 405 + spin_unlock_irqrestore(&port->port_lock, flags); 408 406 409 407 return 0; 410 408 }
+3
drivers/usb/host/xhci-pci.c
··· 126 126 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 127 127 xhci->quirks |= XHCI_AMD_PLL_FIX; 128 128 129 + if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43bb) 130 + xhci->quirks |= XHCI_SUSPEND_DELAY; 131 + 129 132 if (pdev->vendor == PCI_VENDOR_ID_AMD) 130 133 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 131 134
+1 -10
drivers/usb/host/xhci-plat.c
··· 360 360 { 361 361 struct usb_hcd *hcd = dev_get_drvdata(dev); 362 362 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 363 - int ret; 364 363 365 364 /* 366 365 * xhci_suspend() needs `do_wakeup` to know whether host is allowed ··· 369 370 * reconsider this when xhci_plat_suspend enlarges its scope, e.g., 370 371 * also applies to runtime suspend. 371 372 */ 372 - ret = xhci_suspend(xhci, device_may_wakeup(dev)); 373 - 374 - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) 375 - clk_disable_unprepare(xhci->clk); 376 - 377 - return ret; 373 + return xhci_suspend(xhci, device_may_wakeup(dev)); 378 374 } 379 375 380 376 static int __maybe_unused xhci_plat_resume(struct device *dev) ··· 377 383 struct usb_hcd *hcd = dev_get_drvdata(dev); 378 384 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 379 385 int ret; 380 - 381 - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) 382 - clk_prepare_enable(xhci->clk); 383 386 384 387 ret = xhci_priv_resume_quirk(hcd); 385 388 if (ret)
+4
drivers/usb/host/xhci-rcar.c
··· 83 83 .soc_id = "r8a7796", 84 84 .data = (void *)RCAR_XHCI_FIRMWARE_V3, 85 85 }, 86 + { 87 + .soc_id = "r8a77965", 88 + .data = (void *)RCAR_XHCI_FIRMWARE_V3, 89 + }, 86 90 { /* sentinel */ }, 87 91 }; 88 92
+3
drivers/usb/host/xhci.c
··· 877 877 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 878 878 del_timer_sync(&xhci->shared_hcd->rh_timer); 879 879 880 + if (xhci->quirks & XHCI_SUSPEND_DELAY) 881 + usleep_range(1000, 1500); 882 + 880 883 spin_lock_irq(&xhci->lock); 881 884 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 882 885 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
+13 -10
drivers/usb/host/xhci.h
··· 718 718 /* bits 10:14 are Max Primary Streams */ 719 719 /* bit 15 is Linear Stream Array */ 720 720 /* Interval - period between requests to an endpoint - 125u increments. */ 721 - #define EP_INTERVAL(p) (((p) & 0xff) << 16) 722 - #define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 723 - #define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff) 724 - #define EP_MAXPSTREAMS_MASK (0x1f << 10) 725 - #define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) 721 + #define EP_INTERVAL(p) (((p) & 0xff) << 16) 722 + #define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 723 + #define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff) 724 + #define EP_MAXPSTREAMS_MASK (0x1f << 10) 725 + #define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) 726 + #define CTX_TO_EP_MAXPSTREAMS(p) (((p) & EP_MAXPSTREAMS_MASK) >> 10) 726 727 /* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */ 727 728 #define EP_HAS_LSA (1 << 15) 728 729 /* hosts with LEC=1 use bits 31:24 as ESIT high bits. */ ··· 1826 1825 #define XHCI_U2_DISABLE_WAKE (1 << 27) 1827 1826 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) 1828 1827 #define XHCI_HW_LPM_DISABLE (1 << 29) 1828 + #define XHCI_SUSPEND_DELAY (1 << 30) 1829 1829 1830 1830 unsigned int num_active_eps; 1831 1831 unsigned int limit_active_eps; ··· 2551 2549 u8 burst; 2552 2550 u8 cerr; 2553 2551 u8 mult; 2554 - u8 lsa; 2555 - u8 hid; 2552 + 2553 + bool lsa; 2554 + bool hid; 2556 2555 2557 2556 esit = CTX_TO_MAX_ESIT_PAYLOAD_HI(info) << 16 | 2558 2557 CTX_TO_MAX_ESIT_PAYLOAD(tx_info); 2559 2558 2560 2559 ep_state = info & EP_STATE_MASK; 2561 - max_pstr = info & EP_MAXPSTREAMS_MASK; 2560 + max_pstr = CTX_TO_EP_MAXPSTREAMS(info); 2562 2561 interval = CTX_TO_EP_INTERVAL(info); 2563 2562 mult = CTX_TO_EP_MULT(info) + 1; 2564 - lsa = info & EP_HAS_LSA; 2563 + lsa = !!(info & EP_HAS_LSA); 2565 2564 2566 2565 cerr = (info2 & (3 << 1)) >> 1; 2567 2566 ep_type = CTX_TO_EP_TYPE(info2); 2568 - hid = info2 & (1 << 7); 2567 + hid = !!(info2 & (1 << 7)); 2569 2568 burst = CTX_TO_MAX_BURST(info2); 2570 2569 maxp = MAX_PACKET_DECODED(info2); 2571 2570
+84 -54
drivers/usb/mon/mon_text.c
··· 85 85 86 86 wait_queue_head_t wait; 87 87 int printf_size; 88 + size_t printf_offset; 89 + size_t printf_togo; 88 90 char *printf_buf; 89 91 struct mutex printf_lock; 90 92 ··· 378 376 return rc; 379 377 } 380 378 381 - /* 382 - * For simplicity, we read one record in one system call and throw out 383 - * what does not fit. This means that the following does not work: 384 - * dd if=/dbg/usbmon/0t bs=10 385 - * Also, we do not allow seeks and do not bother advancing the offset. 386 - */ 387 - static ssize_t mon_text_read_t(struct file *file, char __user *buf, 388 - size_t nbytes, loff_t *ppos) 379 + static ssize_t mon_text_copy_to_user(struct mon_reader_text *rp, 380 + char __user * const buf, const size_t nbytes) 389 381 { 390 - struct mon_reader_text *rp = file->private_data; 391 - struct mon_event_text *ep; 392 - struct mon_text_ptr ptr; 382 + const size_t togo = min(nbytes, rp->printf_togo); 393 383 394 - ep = mon_text_read_wait(rp, file); 395 - if (IS_ERR(ep)) 396 - return PTR_ERR(ep); 397 - mutex_lock(&rp->printf_lock); 398 - ptr.cnt = 0; 399 - ptr.pbuf = rp->printf_buf; 400 - ptr.limit = rp->printf_size; 401 - 402 - mon_text_read_head_t(rp, &ptr, ep); 403 - mon_text_read_statset(rp, &ptr, ep); 404 - ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, 405 - " %d", ep->length); 406 - mon_text_read_data(rp, &ptr, ep); 407 - 408 - if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) 409 - ptr.cnt = -EFAULT; 410 - mutex_unlock(&rp->printf_lock); 411 - kmem_cache_free(rp->e_slab, ep); 412 - return ptr.cnt; 384 + if (copy_to_user(buf, &rp->printf_buf[rp->printf_offset], togo)) 385 + return -EFAULT; 386 + rp->printf_togo -= togo; 387 + rp->printf_offset += togo; 388 + return togo; 413 389 } 414 390 415 - static ssize_t mon_text_read_u(struct file *file, char __user *buf, 416 - size_t nbytes, loff_t *ppos) 391 + /* ppos is not advanced since the llseek operation is not permitted. */ 392 + static ssize_t mon_text_read_t(struct file *file, char __user *buf, 393 + size_t nbytes, loff_t *ppos) 417 394 { 418 395 struct mon_reader_text *rp = file->private_data; 419 396 struct mon_event_text *ep; 420 397 struct mon_text_ptr ptr; 398 + ssize_t ret; 421 399 422 - ep = mon_text_read_wait(rp, file); 423 - if (IS_ERR(ep)) 424 - return PTR_ERR(ep); 425 400 mutex_lock(&rp->printf_lock); 426 - ptr.cnt = 0; 427 - ptr.pbuf = rp->printf_buf; 428 - ptr.limit = rp->printf_size; 429 401 430 - mon_text_read_head_u(rp, &ptr, ep); 431 - if (ep->type == 'E') { 402 + if (rp->printf_togo == 0) { 403 + 404 + ep = mon_text_read_wait(rp, file); 405 + if (IS_ERR(ep)) { 406 + mutex_unlock(&rp->printf_lock); 407 + return PTR_ERR(ep); 408 + } 409 + ptr.cnt = 0; 410 + ptr.pbuf = rp->printf_buf; 411 + ptr.limit = rp->printf_size; 412 + 413 + mon_text_read_head_t(rp, &ptr, ep); 432 414 mon_text_read_statset(rp, &ptr, ep); 433 - } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) { 434 - mon_text_read_isostat(rp, &ptr, ep); 435 - mon_text_read_isodesc(rp, &ptr, ep); 436 - } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) { 437 - mon_text_read_intstat(rp, &ptr, ep); 438 - } else { 439 - mon_text_read_statset(rp, &ptr, ep); 415 + ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, 416 + " %d", ep->length); 417 + mon_text_read_data(rp, &ptr, ep); 418 + 419 + rp->printf_togo = ptr.cnt; 420 + rp->printf_offset = 0; 421 + 422 + kmem_cache_free(rp->e_slab, ep); 440 423 } 441 - ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, 442 - " %d", ep->length); 443 - mon_text_read_data(rp, &ptr, ep); 444 424 445 - if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) 446 - ptr.cnt = -EFAULT; 425 + ret = mon_text_copy_to_user(rp, buf, nbytes); 447 426 mutex_unlock(&rp->printf_lock); 448 - kmem_cache_free(rp->e_slab, ep); 449 - return ptr.cnt; 427 + return ret; 428 + } 429 + 430 + /* ppos is not advanced since the llseek operation is not permitted. */ 431 + static ssize_t mon_text_read_u(struct file *file, char __user *buf, 432 + size_t nbytes, loff_t *ppos) 433 + { 434 + struct mon_reader_text *rp = file->private_data; 435 + struct mon_event_text *ep; 436 + struct mon_text_ptr ptr; 437 + ssize_t ret; 438 + 439 + mutex_lock(&rp->printf_lock); 440 + 441 + if (rp->printf_togo == 0) { 442 + 443 + ep = mon_text_read_wait(rp, file); 444 + if (IS_ERR(ep)) { 445 + mutex_unlock(&rp->printf_lock); 446 + return PTR_ERR(ep); 447 + } 448 + ptr.cnt = 0; 449 + ptr.pbuf = rp->printf_buf; 450 + ptr.limit = rp->printf_size; 451 + 452 + mon_text_read_head_u(rp, &ptr, ep); 453 + if (ep->type == 'E') { 454 + mon_text_read_statset(rp, &ptr, ep); 455 + } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) { 456 + mon_text_read_isostat(rp, &ptr, ep); 457 + mon_text_read_isodesc(rp, &ptr, ep); 458 + } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) { 459 + mon_text_read_intstat(rp, &ptr, ep); 460 + } else { 461 + mon_text_read_statset(rp, &ptr, ep); 462 + } 463 + ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, 464 + " %d", ep->length); 465 + mon_text_read_data(rp, &ptr, ep); 466 + 467 + rp->printf_togo = ptr.cnt; 468 + rp->printf_offset = 0; 469 + 470 + kmem_cache_free(rp->e_slab, ep); 471 + } 472 + 473 + ret = mon_text_copy_to_user(rp, buf, nbytes); 474 + mutex_unlock(&rp->printf_lock); 475 + return ret; 450 476 } 451 477 452 478 static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp,
+3 -1
drivers/usb/musb/musb_core.c
··· 1756 1756 int vbus; 1757 1757 u8 devctl; 1758 1758 1759 + pm_runtime_get_sync(dev); 1759 1760 spin_lock_irqsave(&musb->lock, flags); 1760 1761 val = musb->a_wait_bcon; 1761 1762 vbus = musb_platform_get_vbus_status(musb); ··· 1770 1769 vbus = 0; 1771 1770 } 1772 1771 spin_unlock_irqrestore(&musb->lock, flags); 1772 + pm_runtime_put_sync(dev); 1773 1773 1774 1774 return sprintf(buf, "Vbus %s, timeout %lu msec\n", 1775 1775 vbus ? "on" : "off", val); ··· 2473 2471 musb_disable_interrupts(musb); 2474 2472 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2475 2473 spin_unlock_irqrestore(&musb->lock, flags); 2474 + musb_platform_exit(musb); 2476 2475 2477 2476 pm_runtime_dont_use_autosuspend(musb->controller); 2478 2477 pm_runtime_put_sync(musb->controller); 2479 2478 pm_runtime_disable(musb->controller); 2480 - musb_platform_exit(musb); 2481 2479 musb_phy_callback = NULL; 2482 2480 if (musb->dma_controller) 2483 2481 musb_dma_controller_destroy(musb->dma_controller);
+1 -1
drivers/usb/storage/uas.c
··· 1076 1076 return 0; 1077 1077 1078 1078 err = uas_configure_endpoints(devinfo); 1079 - if (err && err != ENODEV) 1079 + if (err && err != -ENODEV) 1080 1080 shost_printk(KERN_ERR, shost, 1081 1081 "%s: alloc streams error %d after reset", 1082 1082 __func__, err);
+7
drivers/usb/storage/unusual_devs.h
··· 2118 2118 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2119 2119 US_FL_BROKEN_FUA ), 2120 2120 2121 + /* Reported by Teijo Kinnunen <teijo.kinnunen@code-q.fi> */ 2122 + UNUSUAL_DEV( 0x152d, 0x2567, 0x0117, 0x0117, 2123 + "JMicron", 2124 + "USB to ATA/ATAPI Bridge", 2125 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2126 + US_FL_BROKEN_FUA ), 2127 + 2121 2128 /* Reported-by George Cherian <george.cherian@cavium.com> */ 2122 2129 UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, 2123 2130 "JMicron",
+2 -1
drivers/usb/typec/fusb302/fusb302.c
··· 1857 1857 chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev); 1858 1858 if (IS_ERR(chip->tcpm_port)) { 1859 1859 ret = PTR_ERR(chip->tcpm_port); 1860 - dev_err(dev, "cannot register tcpm port, ret=%d", ret); 1860 + if (ret != -EPROBE_DEFER) 1861 + dev_err(dev, "cannot register tcpm port, ret=%d", ret); 1861 1862 goto destroy_workqueue; 1862 1863 } 1863 1864
+42 -121
drivers/usb/typec/tcpm.c
··· 252 252 unsigned int nr_src_pdo; 253 253 u32 snk_pdo[PDO_MAX_OBJECTS]; 254 254 unsigned int nr_snk_pdo; 255 - unsigned int nr_fixed; /* number of fixed sink PDOs */ 256 - unsigned int nr_var; /* number of variable sink PDOs */ 257 - unsigned int nr_batt; /* number of battery sink PDOs */ 258 255 u32 snk_vdo[VDO_MAX_OBJECTS]; 259 256 unsigned int nr_snk_vdo; 260 257 ··· 1767 1770 return 0; 1768 1771 } 1769 1772 1770 - #define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) 1771 - #define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) 1772 - 1773 - static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, 1774 - int *src_pdo) 1773 + static int tcpm_pd_select_pdo(struct tcpm_port *port) 1775 1774 { 1776 - unsigned int i, j, max_mw = 0, max_mv = 0, mw = 0, mv = 0, ma = 0; 1775 + unsigned int i, max_mw = 0, max_mv = 0; 1777 1776 int ret = -EINVAL; 1778 1777 1779 1778 /* 1780 - * Select the source PDO providing the most power which has a 1781 - * matchig sink cap. 1779 + * Select the source PDO providing the most power while staying within 1780 + * the board's voltage limits. Prefer PDO providing exp 1782 1781 */ 1783 1782 for (i = 0; i < port->nr_source_caps; i++) { 1784 1783 u32 pdo = port->source_caps[i]; 1785 1784 enum pd_pdo_type type = pdo_type(pdo); 1785 + unsigned int mv, ma, mw; 1786 1786 1787 - if (type == PDO_TYPE_FIXED) { 1788 - for (j = 0; j < port->nr_fixed; j++) { 1789 - if (pdo_fixed_voltage(pdo) == 1790 - pdo_fixed_voltage(port->snk_pdo[j])) { 1791 - ma = min_current(pdo, port->snk_pdo[j]); 1792 - mv = pdo_fixed_voltage(pdo); 1793 - mw = ma * mv / 1000; 1794 - if (mw > max_mw || 1795 - (mw == max_mw && mv > max_mv)) { 1796 - ret = 0; 1797 - *src_pdo = i; 1798 - *sink_pdo = j; 1799 - max_mw = mw; 1800 - max_mv = mv; 1801 - } 1802 - /* There could only be one fixed pdo 1803 - * at a specific voltage level. 1804 - * So breaking here. 1805 - */ 1806 - break; 1807 - } 1808 - } 1809 - } else if (type == PDO_TYPE_BATT) { 1810 - for (j = port->nr_fixed; 1811 - j < port->nr_fixed + 1812 - port->nr_batt; 1813 - j++) { 1814 - if (pdo_min_voltage(pdo) >= 1815 - pdo_min_voltage(port->snk_pdo[j]) && 1816 - pdo_max_voltage(pdo) <= 1817 - pdo_max_voltage(port->snk_pdo[j])) { 1818 - mw = min_power(pdo, port->snk_pdo[j]); 1819 - mv = pdo_min_voltage(pdo); 1820 - if (mw > max_mw || 1821 - (mw == max_mw && mv > max_mv)) { 1822 - ret = 0; 1823 - *src_pdo = i; 1824 - *sink_pdo = j; 1825 - max_mw = mw; 1826 - max_mv = mv; 1827 - } 1828 - } 1829 - } 1830 - } else if (type == PDO_TYPE_VAR) { 1831 - for (j = port->nr_fixed + 1832 - port->nr_batt; 1833 - j < port->nr_fixed + 1834 - port->nr_batt + 1835 - port->nr_var; 1836 - j++) { 1837 - if (pdo_min_voltage(pdo) >= 1838 - pdo_min_voltage(port->snk_pdo[j]) && 1839 - pdo_max_voltage(pdo) <= 1840 - pdo_max_voltage(port->snk_pdo[j])) { 1841 - ma = min_current(pdo, port->snk_pdo[j]); 1842 - mv = pdo_min_voltage(pdo); 1843 - mw = ma * mv / 1000; 1844 - if (mw > max_mw || 1845 - (mw == max_mw && mv > max_mv)) { 1846 - ret = 0; 1847 - *src_pdo = i; 1848 - *sink_pdo = j; 1849 - max_mw = mw; 1850 - max_mv = mv; 1851 - } 1852 - } 1853 - } 1787 + if (type == PDO_TYPE_FIXED) 1788 + mv = pdo_fixed_voltage(pdo); 1789 + else 1790 + mv = pdo_min_voltage(pdo); 1791 + 1792 + if (type == PDO_TYPE_BATT) { 1793 + mw = pdo_max_power(pdo); 1794 + } else { 1795 + ma = min(pdo_max_current(pdo), 1796 + port->max_snk_ma); 1797 + mw = ma * mv / 1000; 1798 + } 1799 + 1800 + /* Perfer higher voltages if available */ 1801 + if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && 1802 + mv <= port->max_snk_mv) { 1803 + ret = i; 1804 + max_mw = mw; 1805 + max_mv = mv; 1854 1806 } 1855 1807 } 1856 1808 ··· 1811 1865 unsigned int mv, ma, mw, flags; 1812 1866 unsigned int max_ma, max_mw; 1813 1867 enum pd_pdo_type type; 1814 - int src_pdo_index, snk_pdo_index; 1815 - u32 pdo, matching_snk_pdo; 1868 + int index; 1869 + u32 pdo; 1816 1870 1817 - if (tcpm_pd_select_pdo(port, &snk_pdo_index, &src_pdo_index) < 0) 1871 + index = tcpm_pd_select_pdo(port); 1872 + if (index < 0) 1818 1873 return -EINVAL; 1819 - 1820 - pdo = port->source_caps[src_pdo_index]; 1821 - matching_snk_pdo = port->snk_pdo[snk_pdo_index]; 1874 + pdo = port->source_caps[index]; 1822 1875 type = pdo_type(pdo); 1823 1876 1824 1877 if (type == PDO_TYPE_FIXED) ··· 1825 1880 else 1826 1881 mv = pdo_min_voltage(pdo); 1827 1882 1828 - /* Select maximum available current within the sink pdo's limit */ 1883 + /* Select maximum available current within the board's power limit */ 1829 1884 if (type == PDO_TYPE_BATT) { 1830 - mw = min_power(pdo, matching_snk_pdo); 1831 - ma = 1000 * mw / mv; 1885 + mw = pdo_max_power(pdo); 1886 + ma = 1000 * min(mw, port->max_snk_mw) / mv; 1832 1887 } else { 1833 - ma = min_current(pdo, matching_snk_pdo); 1834 - mw = ma * mv / 1000; 1888 + ma = min(pdo_max_current(pdo), 1889 + 1000 * port->max_snk_mw / mv); 1835 1890 } 1891 + ma = min(ma, port->max_snk_ma); 1836 1892 1837 1893 flags = RDO_USB_COMM | RDO_NO_SUSPEND; 1838 1894 1839 1895 /* Set mismatch bit if offered power is less than operating power */ 1896 + mw = ma * mv / 1000; 1840 1897 max_ma = ma; 1841 1898 max_mw = mw; 1842 1899 if (mw < port->operating_snk_mw) { 1843 1900 flags |= RDO_CAP_MISMATCH; 1844 - if (type == PDO_TYPE_BATT && 1845 - (pdo_max_power(matching_snk_pdo) > pdo_max_power(pdo))) 1846 - max_mw = pdo_max_power(matching_snk_pdo); 1847 - else if (pdo_max_current(matching_snk_pdo) > 1848 - pdo_max_current(pdo)) 1849 - max_ma = pdo_max_current(matching_snk_pdo); 1901 + max_mw = port->operating_snk_mw; 1902 + max_ma = max_mw * 1000 / mv; 1850 1903 } 1851 1904 1852 1905 tcpm_log(port, "cc=%d cc1=%d cc2=%d vbus=%d vconn=%s polarity=%d", ··· 1853 1910 port->polarity); 1854 1911 1855 1912 if (type == PDO_TYPE_BATT) { 1856 - *rdo = RDO_BATT(src_pdo_index + 1, mw, max_mw, flags); 1913 + *rdo = RDO_BATT(index + 1, mw, max_mw, flags); 1857 1914 1858 1915 tcpm_log(port, "Requesting PDO %d: %u mV, %u mW%s", 1859 - src_pdo_index, mv, mw, 1916 + index, mv, mw, 1860 1917 flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); 1861 1918 } else { 1862 - *rdo = RDO_FIXED(src_pdo_index + 1, ma, max_ma, flags); 1919 + *rdo = RDO_FIXED(index + 1, ma, max_ma, flags); 1863 1920 1864 1921 tcpm_log(port, "Requesting PDO %d: %u mV, %u mA%s", 1865 - src_pdo_index, mv, ma, 1922 + index, mv, ma, 1866 1923 flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); 1867 1924 } 1868 1925 ··· 3593 3650 } 3594 3651 EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); 3595 3652 3596 - static int nr_type_pdos(const u32 *pdo, unsigned int nr_pdo, 3597 - enum pd_pdo_type type) 3598 - { 3599 - int count = 0; 3600 - int i; 3601 - 3602 - for (i = 0; i < nr_pdo; i++) { 3603 - if (pdo_type(pdo[i]) == type) 3604 - count++; 3605 - } 3606 - return count; 3607 - } 3608 - 3609 3653 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) 3610 3654 { 3611 3655 struct tcpm_port *port; ··· 3638 3708 tcpc->config->nr_src_pdo); 3639 3709 port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, 3640 3710 tcpc->config->nr_snk_pdo); 3641 - port->nr_fixed = nr_type_pdos(port->snk_pdo, 3642 - port->nr_snk_pdo, 3643 - PDO_TYPE_FIXED); 3644 - port->nr_var = nr_type_pdos(port->snk_pdo, 3645 - port->nr_snk_pdo, 3646 - PDO_TYPE_VAR); 3647 - port->nr_batt = nr_type_pdos(port->snk_pdo, 3648 - port->nr_snk_pdo, 3649 - PDO_TYPE_BATT); 3650 3711 port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, 3651 3712 tcpc->config->nr_snk_vdo); 3652 3713
+6 -2
drivers/usb/usbip/vudc_sysfs.c
··· 105 105 if (rv != 0) 106 106 return -EINVAL; 107 107 108 + if (!udc) { 109 + dev_err(dev, "no device"); 110 + return -ENODEV; 111 + } 108 112 spin_lock_irqsave(&udc->lock, flags); 109 113 /* Don't export what we don't have */ 110 - if (!udc || !udc->driver || !udc->pullup) { 111 - dev_err(dev, "no device or gadget not bound"); 114 + if (!udc->driver || !udc->pullup) { 115 + dev_err(dev, "gadget not bound"); 112 116 ret = -ENODEV; 113 117 goto unlock; 114 118 }
+3
include/linux/usb/quirks.h
··· 63 63 */ 64 64 #define USB_QUIRK_DISCONNECT_SUSPEND BIT(12) 65 65 66 + /* Device needs a pause after every control message. */ 67 + #define USB_QUIRK_DELAY_CTRL_MSG BIT(13) 68 + 66 69 #endif /* __LINUX_USB_QUIRKS_H */