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-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB driver fixes from Greg KH:
"Here are a number of small bugfixes for reported issues in some USB
drivers. They include:

- typec bugfixes

- xhci bugfixes and lockdep warning fixes

- cdc-acm driver regression fix

- kernel doc fixes

- cdns3 driver bugfixes for a bunch of reported issues

- other tiny USB driver fixes

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

* tag 'usb-5.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: cdns3: gadget: own the lock wrongly at the suspend routine
usb: cdns3: Fix on-chip memory overflow issue
usb: cdns3: gadget: suspicious implicit sign extension
xhci: Don't create stream debugfs files with spinlock held.
usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
xhci: Fix sizeof() mismatch
usb: typec: stusb160x: fix signedness comparison issue with enum variables
usb: typec: add missing MODULE_DEVICE_TABLE() to stusb160x
USB: apple-mfi-fastcharge: don't probe unhandled devices
usbcore: Check both id_table and match() when both available
usb: host: ehci-tegra: Fix error handling in tegra_ehci_probe()
usb: typec: stusb160x: fix an IS_ERR() vs NULL check in probe
usb: typec: tcpm: reset hard_reset_count for any disconnect
usb: cdc-acm: fix cooldown mechanism
usb: host: fsl-mph-dr-of: check return of dma_set_mask()
usb: fix kernel-doc markups
usb: typec: stusb160x: fix some signedness bugs
usb: cdns3: Variable 'length' set but not used

+195 -138
+35 -30
drivers/usb/cdns3/ep0.c
··· 137 137 struct usb_ctrlrequest *ctrl_req) 138 138 { 139 139 enum usb_device_state device_state = priv_dev->gadget.state; 140 - struct cdns3_endpoint *priv_ep; 141 140 u32 config = le16_to_cpu(ctrl_req->wValue); 142 141 int result = 0; 143 - int i; 144 142 145 143 switch (device_state) { 146 144 case USB_STATE_ADDRESS: 147 - /* Configure non-control EPs */ 148 - for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) { 149 - priv_ep = priv_dev->eps[i]; 150 - if (!priv_ep) 151 - continue; 152 - 153 - if (priv_ep->flags & EP_CLAIMED) 154 - cdns3_ep_config(priv_ep); 155 - } 156 - 157 145 result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); 158 146 159 - if (result) 160 - return result; 161 - 162 - if (!config) { 163 - cdns3_hw_reset_eps_config(priv_dev); 164 - usb_gadget_set_state(&priv_dev->gadget, 165 - USB_STATE_ADDRESS); 166 - } 147 + if (result || !config) 148 + goto reset_config; 167 149 168 150 break; 169 151 case USB_STATE_CONFIGURED: 170 152 result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); 153 + if (!config && !result) 154 + goto reset_config; 171 155 172 - if (!config && !result) { 173 - cdns3_hw_reset_eps_config(priv_dev); 174 - usb_gadget_set_state(&priv_dev->gadget, 175 - USB_STATE_ADDRESS); 176 - } 177 156 break; 178 157 default: 179 - result = -EINVAL; 158 + return -EINVAL; 180 159 } 160 + 161 + return 0; 162 + 163 + reset_config: 164 + if (result != USB_GADGET_DELAYED_STATUS) 165 + cdns3_hw_reset_eps_config(priv_dev); 166 + 167 + usb_gadget_set_state(&priv_dev->gadget, 168 + USB_STATE_ADDRESS); 181 169 182 170 return result; 183 171 } ··· 693 705 unsigned long flags; 694 706 int ret = 0; 695 707 u8 zlp = 0; 708 + int i; 696 709 697 710 spin_lock_irqsave(&priv_dev->lock, flags); 698 711 trace_cdns3_ep0_queue(priv_dev, request); ··· 709 720 u32 val; 710 721 711 722 cdns3_select_ep(priv_dev, 0x00); 723 + 724 + /* 725 + * Configure all non-control EPs which are not enabled by class driver 726 + */ 727 + for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) { 728 + priv_ep = priv_dev->eps[i]; 729 + if (priv_ep && priv_ep->flags & EP_CLAIMED && 730 + !(priv_ep->flags & EP_ENABLED)) 731 + cdns3_ep_config(priv_ep, 0); 732 + } 733 + 712 734 cdns3_set_hw_configuration(priv_dev); 713 735 cdns3_ep0_complete_setup(priv_dev, 0, 1); 714 736 /* wait until configuration set */ ··· 811 811 struct cdns3_usb_regs __iomem *regs; 812 812 struct cdns3_endpoint *priv_ep; 813 813 u32 max_packet_size = 64; 814 + u32 ep_cfg; 814 815 815 816 regs = priv_dev->regs; 816 817 ··· 843 842 BIT(0) | BIT(16)); 844 843 } 845 844 846 - writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size), 847 - &regs->ep_cfg); 845 + ep_cfg = EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size); 846 + 847 + if (!(priv_ep->flags & EP_CONFIGURED)) 848 + writel(ep_cfg, &regs->ep_cfg); 848 849 849 850 writel(EP_STS_EN_SETUPEN | EP_STS_EN_DESCMISEN | EP_STS_EN_TRBERREN, 850 851 &regs->ep_sts_en); ··· 854 851 /* init ep in */ 855 852 cdns3_select_ep(priv_dev, USB_DIR_IN); 856 853 857 - writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size), 858 - &regs->ep_cfg); 854 + if (!(priv_ep->flags & EP_CONFIGURED)) 855 + writel(ep_cfg, &regs->ep_cfg); 856 + 857 + priv_ep->flags |= EP_CONFIGURED; 859 858 860 859 writel(EP_STS_EN_SETUPEN | EP_STS_EN_TRBERREN, &regs->ep_sts_en); 861 860
+64 -51
drivers/usb/cdns3/gadget.c
··· 296 296 */ 297 297 void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev) 298 298 { 299 + int i; 300 + 299 301 writel(USB_CONF_CFGRST, &priv_dev->regs->usb_conf); 300 302 301 303 cdns3_allow_enable_l1(priv_dev, 0); ··· 306 304 priv_dev->out_mem_is_allocated = 0; 307 305 priv_dev->wait_for_setup = 0; 308 306 priv_dev->using_streams = 0; 307 + 308 + for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) 309 + if (priv_dev->eps[i]) 310 + priv_dev->eps[i]->flags &= ~EP_CONFIGURED; 309 311 } 310 312 311 313 /** ··· 512 506 513 507 while (!list_empty(&priv_ep->wa2_descmiss_req_list)) { 514 508 int chunk_end; 515 - int length; 516 509 517 510 descmiss_priv_req = 518 511 cdns3_next_priv_request(&priv_ep->wa2_descmiss_req_list); ··· 522 517 break; 523 518 524 519 chunk_end = descmiss_priv_req->flags & REQUEST_INTERNAL_CH; 525 - length = request->actual + descmiss_req->actual; 526 520 request->status = descmiss_req->status; 527 521 __cdns3_descmiss_copy_data(request, descmiss_req); 528 522 list_del_init(&descmiss_priv_req->list); ··· 1750 1746 1751 1747 static void cdns3_disconnect_gadget(struct cdns3_device *priv_dev) 1752 1748 { 1753 - if (priv_dev->gadget_driver && priv_dev->gadget_driver->disconnect) { 1754 - spin_unlock(&priv_dev->lock); 1749 + if (priv_dev->gadget_driver && priv_dev->gadget_driver->disconnect) 1755 1750 priv_dev->gadget_driver->disconnect(&priv_dev->gadget); 1756 - spin_lock(&priv_dev->lock); 1757 - } 1758 1751 } 1759 1752 1760 1753 /** ··· 1762 1761 */ 1763 1762 static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev, 1764 1763 u32 usb_ists) 1764 + __must_hold(&priv_dev->lock) 1765 1765 { 1766 1766 int speed = 0; 1767 1767 ··· 1787 1785 1788 1786 /* Disconnection detected */ 1789 1787 if (usb_ists & (USB_ISTS_DIS2I | USB_ISTS_DISI)) { 1788 + spin_unlock(&priv_dev->lock); 1790 1789 cdns3_disconnect_gadget(priv_dev); 1790 + spin_lock(&priv_dev->lock); 1791 1791 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; 1792 1792 usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED); 1793 1793 cdns3_hw_reset_eps_config(priv_dev); ··· 1983 1979 return 0; 1984 1980 } 1985 1981 1986 - static void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev, 1987 - struct cdns3_endpoint *priv_ep) 1988 - { 1989 - if (!priv_ep->use_streams || priv_dev->gadget.speed < USB_SPEED_SUPER) 1990 - return; 1991 - 1992 - if (priv_dev->dev_ver >= DEV_VER_V3) { 1993 - u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0)); 1994 - 1995 - /* 1996 - * Stream capable endpoints are handled by using ep_tdl 1997 - * register. Other endpoints use TDL from TRB feature. 1998 - */ 1999 - cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, mask); 2000 - } 2001 - 2002 - /* Enable Stream Bit TDL chk and SID chk */ 2003 - cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_STREAM_EN | 2004 - EP_CFG_TDL_CHK | EP_CFG_SID_CHK); 2005 - } 2006 - 2007 1982 static void cdns3_configure_dmult(struct cdns3_device *priv_dev, 2008 1983 struct cdns3_endpoint *priv_ep) 2009 1984 { ··· 2020 2037 /** 2021 2038 * cdns3_ep_config Configure hardware endpoint 2022 2039 * @priv_ep: extended endpoint object 2040 + * @enable: set EP_CFG_ENABLE bit in ep_cfg register. 2023 2041 */ 2024 - void cdns3_ep_config(struct cdns3_endpoint *priv_ep) 2042 + int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable) 2025 2043 { 2026 2044 bool is_iso_ep = (priv_ep->type == USB_ENDPOINT_XFER_ISOC); 2027 2045 struct cdns3_device *priv_dev = priv_ep->cdns3_dev; ··· 2083 2099 break; 2084 2100 default: 2085 2101 /* all other speed are not supported */ 2086 - return; 2102 + return -EINVAL; 2087 2103 } 2088 2104 2089 2105 if (max_packet_size == 1024) ··· 2093 2109 else 2094 2110 priv_ep->trb_burst_size = 16; 2095 2111 2096 - ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1, 2097 - !!priv_ep->dir); 2098 - if (ret) { 2099 - dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n"); 2100 - return; 2112 + /* onchip buffer is only allocated before configuration */ 2113 + if (!priv_dev->hw_configured_flag) { 2114 + ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1, 2115 + !!priv_ep->dir); 2116 + if (ret) { 2117 + dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n"); 2118 + return ret; 2119 + } 2120 + } 2121 + 2122 + if (enable) 2123 + ep_cfg |= EP_CFG_ENABLE; 2124 + 2125 + if (priv_ep->use_streams && priv_dev->gadget.speed >= USB_SPEED_SUPER) { 2126 + if (priv_dev->dev_ver >= DEV_VER_V3) { 2127 + u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0)); 2128 + 2129 + /* 2130 + * Stream capable endpoints are handled by using ep_tdl 2131 + * register. Other endpoints use TDL from TRB feature. 2132 + */ 2133 + cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, 2134 + mask); 2135 + } 2136 + 2137 + /* Enable Stream Bit TDL chk and SID chk */ 2138 + ep_cfg |= EP_CFG_STREAM_EN | EP_CFG_TDL_CHK | EP_CFG_SID_CHK; 2101 2139 } 2102 2140 2103 2141 ep_cfg |= EP_CFG_MAXPKTSIZE(max_packet_size) | ··· 2129 2123 2130 2124 cdns3_select_ep(priv_dev, bEndpointAddress); 2131 2125 writel(ep_cfg, &priv_dev->regs->ep_cfg); 2126 + priv_ep->flags |= EP_CONFIGURED; 2132 2127 2133 2128 dev_dbg(priv_dev->dev, "Configure %s: with val %08x\n", 2134 2129 priv_ep->name, ep_cfg); 2130 + 2131 + return 0; 2135 2132 } 2136 2133 2137 2134 /* Find correct direction for HW endpoint according to description */ ··· 2275 2266 u32 bEndpointAddress; 2276 2267 unsigned long flags; 2277 2268 int enable = 1; 2278 - int ret; 2269 + int ret = 0; 2279 2270 int val; 2280 2271 2281 2272 priv_ep = ep_to_cdns3_ep(ep); ··· 2314 2305 bEndpointAddress = priv_ep->num | priv_ep->dir; 2315 2306 cdns3_select_ep(priv_dev, bEndpointAddress); 2316 2307 2308 + /* 2309 + * For some versions of controller at some point during ISO OUT traffic 2310 + * DMA reads Transfer Ring for the EP which has never got doorbell. 2311 + * This issue was detected only on simulation, but to avoid this issue 2312 + * driver add protection against it. To fix it driver enable ISO OUT 2313 + * endpoint before setting DRBL. This special treatment of ISO OUT 2314 + * endpoints are recommended by controller specification. 2315 + */ 2316 + if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) 2317 + enable = 0; 2318 + 2317 2319 if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) { 2318 2320 /* 2319 2321 * Enable stream support (SS mode) related interrupts ··· 2335 2315 EP_STS_EN_SIDERREN | EP_STS_EN_MD_EXITEN | 2336 2316 EP_STS_EN_STREAMREN; 2337 2317 priv_ep->use_streams = true; 2338 - cdns3_stream_ep_reconfig(priv_dev, priv_ep); 2318 + ret = cdns3_ep_config(priv_ep, enable); 2339 2319 priv_dev->using_streams |= true; 2340 2320 } 2321 + } else { 2322 + ret = cdns3_ep_config(priv_ep, enable); 2341 2323 } 2342 2324 2343 - ret = cdns3_allocate_trb_pool(priv_ep); 2325 + if (ret) 2326 + goto exit; 2344 2327 2328 + ret = cdns3_allocate_trb_pool(priv_ep); 2345 2329 if (ret) 2346 2330 goto exit; 2347 2331 ··· 2374 2350 cdns3_wa2_enable_detection(priv_dev, priv_ep, reg); 2375 2351 2376 2352 writel(reg, &priv_dev->regs->ep_sts_en); 2377 - 2378 - /* 2379 - * For some versions of controller at some point during ISO OUT traffic 2380 - * DMA reads Transfer Ring for the EP which has never got doorbell. 2381 - * This issue was detected only on simulation, but to avoid this issue 2382 - * driver add protection against it. To fix it driver enable ISO OUT 2383 - * endpoint before setting DRBL. This special treatment of ISO OUT 2384 - * endpoints are recommended by controller specification. 2385 - */ 2386 - if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) 2387 - enable = 0; 2388 - 2389 - if (enable) 2390 - cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_ENABLE); 2391 2353 2392 2354 ep->desc = desc; 2393 2355 priv_ep->flags &= ~(EP_PENDING_REQUEST | EP_STALLED | EP_STALL_PENDING | ··· 3275 3265 } 3276 3266 3277 3267 static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup) 3268 + __must_hold(&cdns->lock) 3278 3269 { 3279 3270 struct cdns3_device *priv_dev = cdns->gadget_dev; 3280 3271 3272 + spin_unlock(&cdns->lock); 3281 3273 cdns3_disconnect_gadget(priv_dev); 3274 + spin_lock(&cdns->lock); 3282 3275 3283 3276 priv_dev->gadget.speed = USB_SPEED_UNKNOWN; 3284 3277 usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED);
+3 -2
drivers/usb/cdns3/gadget.h
··· 1072 1072 #define TRB_TDL_SS_SIZE_GET(p) (((p) & GENMASK(23, 17)) >> 17) 1073 1073 1074 1074 /* transfer_len bitmasks - bits 31:24 */ 1075 - #define TRB_BURST_LEN(p) (((p) << 24) & GENMASK(31, 24)) 1075 + #define TRB_BURST_LEN(p) ((unsigned int)((p) << 24) & GENMASK(31, 24)) 1076 1076 #define TRB_BURST_LEN_GET(p) (((p) & GENMASK(31, 24)) >> 24) 1077 1077 1078 1078 /* Data buffer pointer bitmasks*/ ··· 1159 1159 #define EP_QUIRK_EXTRA_BUF_DET BIT(12) 1160 1160 #define EP_QUIRK_EXTRA_BUF_EN BIT(13) 1161 1161 #define EP_TDLCHK_EN BIT(15) 1162 + #define EP_CONFIGURED BIT(16) 1162 1163 u32 flags; 1163 1164 1164 1165 struct cdns3_request *descmis_req; ··· 1361 1360 int cdns3_init_ep0(struct cdns3_device *priv_dev, 1362 1361 struct cdns3_endpoint *priv_ep); 1363 1362 void cdns3_ep0_config(struct cdns3_device *priv_dev); 1364 - void cdns3_ep_config(struct cdns3_endpoint *priv_ep); 1363 + int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable); 1365 1364 void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir); 1366 1365 int __cdns3_gadget_wakeup(struct cdns3_device *priv_dev); 1367 1366
+5 -7
drivers/usb/class/cdc-acm.c
··· 508 508 "%s - cooling babbling device\n", __func__); 509 509 usb_mark_last_busy(acm->dev); 510 510 set_bit(rb->index, &acm->urbs_in_error_delay); 511 + set_bit(ACM_ERROR_DELAY, &acm->flags); 511 512 cooldown = true; 512 513 break; 513 514 default: ··· 534 533 535 534 if (stopped || stalled || cooldown) { 536 535 if (stalled) 537 - schedule_work(&acm->work); 536 + schedule_delayed_work(&acm->dwork, 0); 538 537 else if (cooldown) 539 538 schedule_delayed_work(&acm->dwork, HZ / 2); 540 539 return; ··· 564 563 acm_write_done(acm, wb); 565 564 spin_unlock_irqrestore(&acm->write_lock, flags); 566 565 set_bit(EVENT_TTY_WAKEUP, &acm->flags); 567 - schedule_work(&acm->work); 566 + schedule_delayed_work(&acm->dwork, 0); 568 567 } 569 568 570 569 static void acm_softint(struct work_struct *work) 571 570 { 572 571 int i; 573 - struct acm *acm = container_of(work, struct acm, work); 572 + struct acm *acm = container_of(work, struct acm, dwork.work); 574 573 575 574 if (test_bit(EVENT_RX_STALL, &acm->flags)) { 576 575 smp_mb(); /* against acm_suspend() */ ··· 586 585 if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) { 587 586 for (i = 0; i < acm->rx_buflimit; i++) 588 587 if (test_and_clear_bit(i, &acm->urbs_in_error_delay)) 589 - acm_submit_read_urb(acm, i, GFP_NOIO); 588 + acm_submit_read_urb(acm, i, GFP_KERNEL); 590 589 } 591 590 592 591 if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags)) ··· 1352 1351 acm->ctrlsize = ctrlsize; 1353 1352 acm->readsize = readsize; 1354 1353 acm->rx_buflimit = num_rx_buf; 1355 - INIT_WORK(&acm->work, acm_softint); 1356 1354 INIT_DELAYED_WORK(&acm->dwork, acm_softint); 1357 1355 init_waitqueue_head(&acm->wioctl); 1358 1356 spin_lock_init(&acm->write_lock); ··· 1561 1561 } 1562 1562 1563 1563 acm_kill_urbs(acm); 1564 - cancel_work_sync(&acm->work); 1565 1564 cancel_delayed_work_sync(&acm->dwork); 1566 1565 1567 1566 tty_unregister_device(acm_tty_driver, acm->minor); ··· 1603 1604 return 0; 1604 1605 1605 1606 acm_kill_urbs(acm); 1606 - cancel_work_sync(&acm->work); 1607 1607 cancel_delayed_work_sync(&acm->dwork); 1608 1608 acm->urbs_in_error_delay = 0; 1609 1609
+1 -2
drivers/usb/class/cdc-acm.h
··· 112 112 # define ACM_ERROR_DELAY 3 113 113 unsigned long urbs_in_error_delay; /* these need to be restarted after a delay */ 114 114 struct usb_cdc_line_coding line; /* bits, stop, parity */ 115 - struct work_struct work; /* work queue entry for various purposes*/ 116 - struct delayed_work dwork; /* for cool downs needed in error recovery */ 115 + struct delayed_work dwork; /* work queue entry for various purposes */ 117 116 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ 118 117 unsigned int ctrlout; /* output control lines (DTR, RTS) */ 119 118 struct async_icount iocount; /* counters for control line changes */
+21 -9
drivers/usb/core/driver.c
··· 839 839 return NULL; 840 840 } 841 841 842 + bool usb_driver_applicable(struct usb_device *udev, 843 + struct usb_device_driver *udrv) 844 + { 845 + if (udrv->id_table && udrv->match) 846 + return usb_device_match_id(udev, udrv->id_table) != NULL && 847 + udrv->match(udev); 848 + 849 + if (udrv->id_table) 850 + return usb_device_match_id(udev, udrv->id_table) != NULL; 851 + 852 + if (udrv->match) 853 + return udrv->match(udev); 854 + 855 + return false; 856 + } 857 + 842 858 static int usb_device_match(struct device *dev, struct device_driver *drv) 843 859 { 844 860 /* devices and interfaces are handled separately */ ··· 869 853 udev = to_usb_device(dev); 870 854 udrv = to_usb_device_driver(drv); 871 855 872 - if (udrv->id_table) 873 - return usb_device_match_id(udev, udrv->id_table) != NULL; 874 - 875 - if (udrv->match) 876 - return udrv->match(udev); 877 - 878 856 /* If the device driver under consideration does not have a 879 857 * id_table or a match function, then let the driver's probe 880 858 * function decide. 881 859 */ 882 - return 1; 860 + if (!udrv->id_table && !udrv->match) 861 + return 1; 862 + 863 + return usb_driver_applicable(udev, udrv); 883 864 884 865 } else if (is_usb_interface(dev)) { 885 866 struct usb_interface *intf; ··· 954 941 return 0; 955 942 956 943 udev = to_usb_device(dev); 957 - if (usb_device_match_id(udev, new_udriver->id_table) == NULL && 958 - (!new_udriver->match || new_udriver->match(udev) == 0)) 944 + if (!usb_driver_applicable(udev, new_udriver)) 959 945 return 0; 960 946 961 947 ret = device_reprobe(dev);
+1 -3
drivers/usb/core/generic.c
··· 205 205 udrv = to_usb_device_driver(drv); 206 206 if (udrv == &usb_generic_driver) 207 207 return 0; 208 - if (usb_device_match_id(udev, udrv->id_table) != NULL) 209 - return 1; 210 - return (udrv->match && udrv->match(udev)); 208 + return usb_driver_applicable(udev, udrv); 211 209 } 212 210 213 211 static bool usb_generic_driver_match(struct usb_device *udev)
+2
drivers/usb/core/usb.h
··· 74 74 const struct usb_device_id *id); 75 75 extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev, 76 76 const struct usb_device_id *id); 77 + extern bool usb_driver_applicable(struct usb_device *udev, 78 + struct usb_device_driver *udrv); 77 79 extern void usb_forced_unbind_intf(struct usb_interface *intf); 78 80 extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev); 79 81
+1 -1
drivers/usb/dwc3/core.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - /** 2 + /* 3 3 * core.c - DesignWare USB3 DRD Controller Core file 4 4 * 5 5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
+1 -1
drivers/usb/dwc3/core.h
··· 1277 1277 #define DWC3_DEPEVT_EPCMDCMPLT 0x07 1278 1278 1279 1279 /** 1280 - * struct dwc3_event_depvt - Device Endpoint Events 1280 + * struct dwc3_event_depevt - Device Endpoint Events 1281 1281 * @one_bit: indicates this is an endpoint event (not used) 1282 1282 * @endpoint_number: number of the endpoint 1283 1283 * @endpoint_event: The event we have:
+1 -1
drivers/usb/gadget/composite.c
··· 1245 1245 EXPORT_SYMBOL_GPL(usb_string_id); 1246 1246 1247 1247 /** 1248 - * usb_string_ids() - allocate unused string IDs in batch 1248 + * usb_string_ids_tab() - allocate unused string IDs in batch 1249 1249 * @cdev: the device whose string descriptor IDs are being allocated 1250 1250 * @str: an array of usb_string objects to assign numbers to 1251 1251 * Context: single threaded during gadget setup
+2 -2
drivers/usb/host/ehci-tegra.c
··· 479 479 u_phy->otg->host = hcd_to_bus(hcd); 480 480 481 481 irq = platform_get_irq(pdev, 0); 482 - if (!irq) { 483 - err = -ENODEV; 482 + if (irq < 0) { 483 + err = irq; 484 484 goto cleanup_phy; 485 485 } 486 486
+6 -3
drivers/usb/host/fsl-mph-dr-of.c
··· 94 94 95 95 pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; 96 96 97 - if (!pdev->dev.dma_mask) 97 + if (!pdev->dev.dma_mask) { 98 98 pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask; 99 - else 100 - dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 99 + } else { 100 + retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 101 + if (retval) 102 + goto error; 103 + } 101 104 102 105 retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); 103 106 if (retval)
+2 -2
drivers/usb/host/xhci-mem.c
··· 2252 2252 2253 2253 if (!rhub->num_ports) 2254 2254 return; 2255 - rhub->ports = kcalloc_node(rhub->num_ports, sizeof(rhub->ports), flags, 2256 - dev_to_node(dev)); 2255 + rhub->ports = kcalloc_node(rhub->num_ports, sizeof(*rhub->ports), 2256 + flags, dev_to_node(dev)); 2257 2257 for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { 2258 2258 if (xhci->hw_ports[i].rhub != rhub || 2259 2259 xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY)
+17
drivers/usb/host/xhci-pci.c
··· 23 23 #define SSIC_PORT_CFG2_OFFSET 0x30 24 24 #define PROG_DONE (1 << 30) 25 25 #define SSIC_PORT_UNUSED (1 << 31) 26 + #define SPARSE_DISABLE_BIT 17 27 + #define SPARSE_CNTL_ENABLE 0xC12C 26 28 27 29 /* Device for a quirk */ 28 30 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 ··· 162 160 if (pdev->vendor == PCI_VENDOR_ID_AMD && 163 161 (pdev->device == 0x15e0 || pdev->device == 0x15e1)) 164 162 xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND; 163 + 164 + if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5) 165 + xhci->quirks |= XHCI_DISABLE_SPARSE; 165 166 166 167 if (pdev->vendor == PCI_VENDOR_ID_AMD) 167 168 xhci->quirks |= XHCI_TRUST_TX_LENGTH; ··· 503 498 readl(reg); 504 499 } 505 500 501 + static void xhci_sparse_control_quirk(struct usb_hcd *hcd) 502 + { 503 + u32 reg; 504 + 505 + reg = readl(hcd->regs + SPARSE_CNTL_ENABLE); 506 + reg &= ~BIT(SPARSE_DISABLE_BIT); 507 + writel(reg, hcd->regs + SPARSE_CNTL_ENABLE); 508 + } 509 + 506 510 static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) 507 511 { 508 512 struct xhci_hcd *xhci = hcd_to_xhci(hcd); ··· 530 516 531 517 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) 532 518 xhci_ssic_port_unused_quirk(hcd, true); 519 + 520 + if (xhci->quirks & XHCI_DISABLE_SPARSE) 521 + xhci_sparse_control_quirk(hcd); 533 522 534 523 ret = xhci_suspend(xhci, do_wakeup); 535 524 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
+4 -1
drivers/usb/host/xhci.c
··· 3533 3533 xhci_dbg(xhci, "Slot %u ep ctx %u now has streams.\n", 3534 3534 udev->slot_id, ep_index); 3535 3535 vdev->eps[ep_index].ep_state |= EP_HAS_STREAMS; 3536 - xhci_debugfs_create_stream_files(xhci, vdev, ep_index); 3537 3536 } 3538 3537 xhci_free_command(xhci, config_cmd); 3539 3538 spin_unlock_irqrestore(&xhci->lock, flags); 3540 3539 3540 + for (i = 0; i < num_eps; i++) { 3541 + ep_index = xhci_get_endpoint_index(&eps[i]->desc); 3542 + xhci_debugfs_create_stream_files(xhci, vdev, ep_index); 3543 + } 3541 3544 /* Subtract 1 for stream 0, which drivers can't use */ 3542 3545 return num_streams - 1; 3543 3546
+1
drivers/usb/host/xhci.h
··· 1877 1877 #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) 1878 1878 #define XHCI_RENESAS_FW_QUIRK BIT_ULL(36) 1879 1879 #define XHCI_SKIP_PHY_INIT BIT_ULL(37) 1880 + #define XHCI_DISABLE_SPARSE BIT_ULL(38) 1880 1881 1881 1882 unsigned int num_active_eps; 1882 1883 unsigned int limit_active_eps;
+12 -5
drivers/usb/misc/apple-mfi-fastcharge.c
··· 163 163 .property_is_writeable = apple_mfi_fc_property_is_writeable 164 164 }; 165 165 166 + static bool mfi_fc_match(struct usb_device *udev) 167 + { 168 + int idProduct; 169 + 170 + idProduct = le16_to_cpu(udev->descriptor.idProduct); 171 + /* See comment above mfi_fc_id_table[] */ 172 + return (idProduct >= 0x1200 && idProduct <= 0x12ff); 173 + } 174 + 166 175 static int mfi_fc_probe(struct usb_device *udev) 167 176 { 168 177 struct power_supply_config battery_cfg = {}; 169 178 struct mfi_device *mfi = NULL; 170 - int err, idProduct; 179 + int err; 171 180 172 - idProduct = le16_to_cpu(udev->descriptor.idProduct); 173 - /* See comment above mfi_fc_id_table[] */ 174 - if (idProduct < 0x1200 || idProduct > 0x12ff) { 181 + if (!mfi_fc_match(udev)) 175 182 return -ENODEV; 176 - } 177 183 178 184 mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL); 179 185 if (!mfi) { ··· 226 220 .probe = mfi_fc_probe, 227 221 .disconnect = mfi_fc_disconnect, 228 222 .id_table = mfi_fc_id_table, 223 + .match = mfi_fc_match, 229 224 .generic_subclass = 1, 230 225 }; 231 226
+1 -1
drivers/usb/typec/mux.c
··· 71 71 EXPORT_SYMBOL_GPL(fwnode_typec_switch_get); 72 72 73 73 /** 74 - * typec_put_switch - Release USB Type-C orientation switch 74 + * typec_switch_put - Release USB Type-C orientation switch 75 75 * @sw: USB Type-C orientation switch 76 76 * 77 77 * Decrement reference count for @sw.
+11 -13
drivers/usb/typec/stusb160x.c
··· 544 544 */ 545 545 ret = fwnode_property_read_string(fwnode, "power-role", &cap_str); 546 546 if (!ret) { 547 - chip->port_type = typec_find_port_power_role(cap_str); 548 - if (chip->port_type < 0) { 549 - ret = chip->port_type; 547 + ret = typec_find_port_power_role(cap_str); 548 + if (ret < 0) 550 549 return ret; 551 - } 550 + chip->port_type = ret; 552 551 } 553 552 chip->capability.type = chip->port_type; 554 553 ··· 564 565 */ 565 566 ret = fwnode_property_read_string(fwnode, "power-opmode", &cap_str); 566 567 if (!ret) { 567 - chip->pwr_opmode = typec_find_pwr_opmode(cap_str); 568 + ret = typec_find_pwr_opmode(cap_str); 568 569 /* Power delivery not yet supported */ 569 - if (chip->pwr_opmode < 0 || 570 - chip->pwr_opmode == TYPEC_PWR_MODE_PD) { 571 - ret = chip->pwr_opmode < 0 ? chip->pwr_opmode : -EINVAL; 572 - dev_err(chip->dev, "bad power operation mode: %d\n", 573 - chip->pwr_opmode); 574 - return ret; 570 + if (ret < 0 || ret == TYPEC_PWR_MODE_PD) { 571 + dev_err(chip->dev, "bad power operation mode: %d\n", ret); 572 + return -EINVAL; 575 573 } 574 + chip->pwr_opmode = ret; 576 575 } 577 576 578 577 return 0; ··· 629 632 { .compatible = "st,stusb1600", .data = &stusb1600_regmap_config}, 630 633 {}, 631 634 }; 635 + MODULE_DEVICE_TABLE(of, stusb160x_of_match); 632 636 633 637 static int stusb160x_probe(struct i2c_client *client) 634 638 { ··· 727 729 } 728 730 729 731 chip->port = typec_register_port(chip->dev, &chip->capability); 730 - if (!chip->port) { 731 - ret = -ENODEV; 732 + if (IS_ERR(chip->port)) { 733 + ret = PTR_ERR(chip->port); 732 734 goto all_reg_disable; 733 735 } 734 736
+3 -3
drivers/usb/typec/tcpm/tcpm.c
··· 2890 2890 2891 2891 static void tcpm_detach(struct tcpm_port *port) 2892 2892 { 2893 + if (tcpm_port_is_disconnected(port)) 2894 + port->hard_reset_count = 0; 2895 + 2893 2896 if (!port->attached) 2894 2897 return; 2895 2898 ··· 2900 2897 tcpm_log(port, "disable BIST MODE TESTDATA"); 2901 2898 port->tcpc->set_bist_data(port->tcpc, false); 2902 2899 } 2903 - 2904 - if (tcpm_port_is_disconnected(port)) 2905 - port->hard_reset_count = 0; 2906 2900 2907 2901 tcpm_reset_port(port); 2908 2902 }
+1 -1
include/linux/usb/composite.h
··· 437 437 #define OS_STRING_IDX 0xEE 438 438 439 439 /** 440 - * struct usb_composite_device - represents one composite usb gadget 440 + * struct usb_composite_dev - represents one composite usb gadget 441 441 * @gadget: read-only, abstracts the gadget's usb peripheral controller 442 442 * @req: used for control responses; buffer is pre-allocated 443 443 * @os_desc_req: used for OS descriptors responses; buffer is pre-allocated