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

Pull USB fixes from Greg KH:
"Let's try this again... Here are some USB fixes for 5.9-rc3.

This differs from the previous pull request for this release in that
the usb gadget patch now does not break some systems, and actually
does what it was intended to do. Many thanks to Marek Szyprowski for
quickly noticing and testing the patch from Andy Shevchenko to resolve
this issue.

Additionally, some more new USB quirks have been added to get some new
devices to work properly based on user reports.

Other than that, the patches are all here, and they contain:

- usb gadget driver fixes

- xhci driver fixes

- typec fixes

- new quirks and ids

- fixes for USB patches that went into 5.9-rc1.

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

* tag 'usb-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (33 commits)
usb: storage: Add unusual_uas entry for Sony PSZ drives
USB: Ignore UAS for JMicron JMS567 ATA/ATAPI Bridge
usb: host: ohci-exynos: Fix error handling in exynos_ohci_probe()
USB: gadget: u_f: Unbreak offset calculation in VLAs
USB: quirks: Ignore duplicate endpoint on Sound Devices MixPre-D
usb: typec: tcpm: Fix Fix source hard reset response for TDA 2.3.1.1 and TDA 2.3.1.2 failures
USB: PHY: JZ4770: Fix static checker warning.
USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()
USB: gadget: u_f: add overflow checks to VLA macros
xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed
xhci: Do warm-reset when both CAS and XDEV_RESUME are set
usb: host: xhci: fix ep context print mismatch in debugfs
usb: uas: Add quirk for PNY Pro Elite
tools: usb: move to tools buildsystem
USB: Fix device driver race
USB: Also match device drivers using the ->match vfunc
usb: host: xhci-tegra: fix tegra_xusb_get_phy()
usb: host: xhci-tegra: otg usb2/usb3 port init
usb: hcd: Fix use after free in usb_hcd_pci_remove()
usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port()
...

+423 -169
+10 -12
drivers/usb/class/cdc-acm.c
··· 378 378 if (current_size < expected_size) { 379 379 /* notification is transmitted fragmented, reassemble */ 380 380 if (acm->nb_size < expected_size) { 381 - if (acm->nb_size) { 382 - kfree(acm->notification_buffer); 383 - acm->nb_size = 0; 384 - } 381 + u8 *new_buffer; 385 382 alloc_size = roundup_pow_of_two(expected_size); 386 - /* 387 - * kmalloc ensures a valid notification_buffer after a 388 - * use of kfree in case the previous allocation was too 389 - * small. Final freeing is done on disconnect. 390 - */ 391 - acm->notification_buffer = 392 - kmalloc(alloc_size, GFP_ATOMIC); 393 - if (!acm->notification_buffer) 383 + /* Final freeing is done on disconnect. */ 384 + new_buffer = krealloc(acm->notification_buffer, 385 + alloc_size, GFP_ATOMIC); 386 + if (!new_buffer) { 387 + acm->nb_index = 0; 394 388 goto exit; 389 + } 390 + 391 + acm->notification_buffer = new_buffer; 395 392 acm->nb_size = alloc_size; 393 + dr = (struct usb_cdc_notification *)acm->notification_buffer; 396 394 } 397 395 398 396 copy_size = min(current_size,
+38 -2
drivers/usb/core/driver.c
··· 905 905 return 0; 906 906 } 907 907 908 + static bool is_dev_usb_generic_driver(struct device *dev) 909 + { 910 + struct usb_device_driver *udd = dev->driver ? 911 + to_usb_device_driver(dev->driver) : NULL; 912 + 913 + return udd == &usb_generic_driver; 914 + } 915 + 916 + static int __usb_bus_reprobe_drivers(struct device *dev, void *data) 917 + { 918 + struct usb_device_driver *new_udriver = data; 919 + struct usb_device *udev; 920 + int ret; 921 + 922 + if (!is_dev_usb_generic_driver(dev)) 923 + return 0; 924 + 925 + udev = to_usb_device(dev); 926 + if (usb_device_match_id(udev, new_udriver->id_table) == NULL && 927 + (!new_udriver->match || new_udriver->match(udev) != 0)) 928 + return 0; 929 + 930 + ret = device_reprobe(dev); 931 + if (ret && ret != -EPROBE_DEFER) 932 + dev_err(dev, "Failed to reprobe device (error %d)\n", ret); 933 + 934 + return 0; 935 + } 936 + 908 937 /** 909 938 * usb_register_device_driver - register a USB device (not interface) driver 910 939 * @new_udriver: USB operations for the device driver ··· 963 934 964 935 retval = driver_register(&new_udriver->drvwrap.driver); 965 936 966 - if (!retval) 937 + if (!retval) { 967 938 pr_info("%s: registered new device driver %s\n", 968 939 usbcore_name, new_udriver->name); 969 - else 940 + /* 941 + * Check whether any device could be better served with 942 + * this new driver 943 + */ 944 + bus_for_each_dev(&usb_bus_type, NULL, new_udriver, 945 + __usb_bus_reprobe_drivers); 946 + } else { 970 947 printk(KERN_ERR "%s: error %d registering device " 971 948 " driver %s\n", 972 949 usbcore_name, retval, new_udriver->name); 950 + } 973 951 974 952 return retval; 975 953 }
+3 -2
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 - 209 - return usb_device_match_id(udev, udrv->id_table) != NULL; 208 + if (usb_device_match_id(udev, udrv->id_table) != NULL) 209 + return 1; 210 + return (udrv->match && udrv->match(udev)); 210 211 } 211 212 212 213 static bool usb_generic_driver_match(struct usb_device *udev)
+4 -1
drivers/usb/core/hcd-pci.c
··· 315 315 void usb_hcd_pci_remove(struct pci_dev *dev) 316 316 { 317 317 struct usb_hcd *hcd; 318 + int hcd_driver_flags; 318 319 319 320 hcd = pci_get_drvdata(dev); 320 321 if (!hcd) 321 322 return; 323 + 324 + hcd_driver_flags = hcd->driver->flags; 322 325 323 326 if (pci_dev_run_wake(dev)) 324 327 pm_runtime_get_noresume(&dev->dev); ··· 350 347 up_read(&companions_rwsem); 351 348 } 352 349 usb_put_hcd(hcd); 353 - if ((hcd->driver->flags & HCD_MASK) < HCD_USB3) 350 + if ((hcd_driver_flags & HCD_MASK) < HCD_USB3) 354 351 pci_free_irq_vectors(dev); 355 352 pci_disable_device(dev); 356 353 }
+7
drivers/usb/core/quirks.c
··· 370 370 { USB_DEVICE(0x0926, 0x0202), .driver_info = 371 371 USB_QUIRK_ENDPOINT_IGNORE }, 372 372 373 + /* Sound Devices MixPre-D */ 374 + { USB_DEVICE(0x0926, 0x0208), .driver_info = 375 + USB_QUIRK_ENDPOINT_IGNORE }, 376 + 373 377 /* Keytouch QWERTY Panel keyboard */ 374 378 { USB_DEVICE(0x0926, 0x3333), .driver_info = 375 379 USB_QUIRK_CONFIG_INTF_STRINGS }, ··· 469 465 470 466 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, 471 467 468 + { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM }, 469 + 472 470 /* DJI CineSSD */ 473 471 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, 474 472 ··· 515 509 */ 516 510 static const struct usb_device_id usb_endpoint_ignore[] = { 517 511 { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 }, 512 + { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 }, 518 513 { } 519 514 }; 520 515
+89 -18
drivers/usb/dwc3/gadget.c
··· 1054 1054 * dwc3_prepare_one_trb - setup one TRB from one request 1055 1055 * @dep: endpoint for which this request is prepared 1056 1056 * @req: dwc3_request pointer 1057 + * @trb_length: buffer size of the TRB 1057 1058 * @chain: should this TRB be chained to the next? 1058 1059 * @node: only for isochronous endpoints. First TRB needs different type. 1059 1060 */ 1060 1061 static void dwc3_prepare_one_trb(struct dwc3_ep *dep, 1061 - struct dwc3_request *req, unsigned chain, unsigned node) 1062 + struct dwc3_request *req, unsigned int trb_length, 1063 + unsigned chain, unsigned node) 1062 1064 { 1063 1065 struct dwc3_trb *trb; 1064 - unsigned int length; 1065 1066 dma_addr_t dma; 1066 1067 unsigned stream_id = req->request.stream_id; 1067 1068 unsigned short_not_ok = req->request.short_not_ok; 1068 1069 unsigned no_interrupt = req->request.no_interrupt; 1069 1070 unsigned is_last = req->request.is_last; 1070 1071 1071 - if (req->request.num_sgs > 0) { 1072 - length = sg_dma_len(req->start_sg); 1072 + if (req->request.num_sgs > 0) 1073 1073 dma = sg_dma_address(req->start_sg); 1074 - } else { 1075 - length = req->request.length; 1074 + else 1076 1075 dma = req->request.dma; 1077 - } 1078 1076 1079 1077 trb = &dep->trb_pool[dep->trb_enqueue]; 1080 1078 ··· 1084 1086 1085 1087 req->num_trbs++; 1086 1088 1087 - __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node, 1089 + __dwc3_prepare_one_trb(dep, trb, dma, trb_length, chain, node, 1088 1090 stream_id, short_not_ok, no_interrupt, is_last); 1089 1091 } 1090 1092 ··· 1094 1096 struct scatterlist *sg = req->start_sg; 1095 1097 struct scatterlist *s; 1096 1098 int i; 1097 - 1099 + unsigned int length = req->request.length; 1098 1100 unsigned int remaining = req->request.num_mapped_sgs 1099 1101 - req->num_queued_sgs; 1100 1102 1103 + /* 1104 + * If we resume preparing the request, then get the remaining length of 1105 + * the request and resume where we left off. 1106 + */ 1107 + for_each_sg(req->request.sg, s, req->num_queued_sgs, i) 1108 + length -= sg_dma_len(s); 1109 + 1101 1110 for_each_sg(sg, s, remaining, i) { 1102 - unsigned int length = req->request.length; 1103 1111 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); 1104 1112 unsigned int rem = length % maxp; 1113 + unsigned int trb_length; 1105 1114 unsigned chain = true; 1115 + 1116 + trb_length = min_t(unsigned int, length, sg_dma_len(s)); 1117 + 1118 + length -= trb_length; 1106 1119 1107 1120 /* 1108 1121 * IOMMU driver is coalescing the list of sgs which shares a ··· 1122 1113 * sgs passed. So mark the chain bit to false if it isthe last 1123 1114 * mapped sg. 1124 1115 */ 1125 - if (i == remaining - 1) 1116 + if ((i == remaining - 1) || !length) 1126 1117 chain = false; 1127 1118 1128 1119 if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) { ··· 1132 1123 req->needs_extra_trb = true; 1133 1124 1134 1125 /* prepare normal TRB */ 1135 - dwc3_prepare_one_trb(dep, req, true, i); 1126 + dwc3_prepare_one_trb(dep, req, trb_length, true, i); 1136 1127 1137 1128 /* Now prepare one extra TRB to align transfer size */ 1138 1129 trb = &dep->trb_pool[dep->trb_enqueue]; ··· 1143 1134 req->request.short_not_ok, 1144 1135 req->request.no_interrupt, 1145 1136 req->request.is_last); 1137 + } else if (req->request.zero && req->request.length && 1138 + !usb_endpoint_xfer_isoc(dep->endpoint.desc) && 1139 + !rem && !chain) { 1140 + struct dwc3 *dwc = dep->dwc; 1141 + struct dwc3_trb *trb; 1142 + 1143 + req->needs_extra_trb = true; 1144 + 1145 + /* Prepare normal TRB */ 1146 + dwc3_prepare_one_trb(dep, req, trb_length, true, i); 1147 + 1148 + /* Prepare one extra TRB to handle ZLP */ 1149 + trb = &dep->trb_pool[dep->trb_enqueue]; 1150 + req->num_trbs++; 1151 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, 1152 + !req->direction, 1, 1153 + req->request.stream_id, 1154 + req->request.short_not_ok, 1155 + req->request.no_interrupt, 1156 + req->request.is_last); 1157 + 1158 + /* Prepare one more TRB to handle MPS alignment */ 1159 + if (!req->direction) { 1160 + trb = &dep->trb_pool[dep->trb_enqueue]; 1161 + req->num_trbs++; 1162 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp, 1163 + false, 1, req->request.stream_id, 1164 + req->request.short_not_ok, 1165 + req->request.no_interrupt, 1166 + req->request.is_last); 1167 + } 1146 1168 } else { 1147 - dwc3_prepare_one_trb(dep, req, chain, i); 1169 + dwc3_prepare_one_trb(dep, req, trb_length, chain, i); 1148 1170 } 1149 1171 1150 1172 /* ··· 1189 1149 req->start_sg = sg_next(s); 1190 1150 1191 1151 req->num_queued_sgs++; 1152 + 1153 + /* 1154 + * The number of pending SG entries may not correspond to the 1155 + * number of mapped SG entries. If all the data are queued, then 1156 + * don't include unused SG entries. 1157 + */ 1158 + if (length == 0) { 1159 + req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs; 1160 + break; 1161 + } 1192 1162 1193 1163 if (!dwc3_calc_trbs_left(dep)) 1194 1164 break; ··· 1219 1169 req->needs_extra_trb = true; 1220 1170 1221 1171 /* prepare normal TRB */ 1222 - dwc3_prepare_one_trb(dep, req, true, 0); 1172 + dwc3_prepare_one_trb(dep, req, length, true, 0); 1223 1173 1224 1174 /* Now prepare one extra TRB to align transfer size */ 1225 1175 trb = &dep->trb_pool[dep->trb_enqueue]; ··· 1230 1180 req->request.no_interrupt, 1231 1181 req->request.is_last); 1232 1182 } else if (req->request.zero && req->request.length && 1183 + !usb_endpoint_xfer_isoc(dep->endpoint.desc) && 1233 1184 (IS_ALIGNED(req->request.length, maxp))) { 1234 1185 struct dwc3 *dwc = dep->dwc; 1235 1186 struct dwc3_trb *trb; ··· 1238 1187 req->needs_extra_trb = true; 1239 1188 1240 1189 /* prepare normal TRB */ 1241 - dwc3_prepare_one_trb(dep, req, true, 0); 1190 + dwc3_prepare_one_trb(dep, req, length, true, 0); 1242 1191 1243 - /* Now prepare one extra TRB to handle ZLP */ 1192 + /* Prepare one extra TRB to handle ZLP */ 1244 1193 trb = &dep->trb_pool[dep->trb_enqueue]; 1245 1194 req->num_trbs++; 1246 1195 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, 1247 - false, 1, req->request.stream_id, 1196 + !req->direction, 1, req->request.stream_id, 1248 1197 req->request.short_not_ok, 1249 1198 req->request.no_interrupt, 1250 1199 req->request.is_last); 1200 + 1201 + /* Prepare one more TRB to handle MPS alignment for OUT */ 1202 + if (!req->direction) { 1203 + trb = &dep->trb_pool[dep->trb_enqueue]; 1204 + req->num_trbs++; 1205 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp, 1206 + false, 1, req->request.stream_id, 1207 + req->request.short_not_ok, 1208 + req->request.no_interrupt, 1209 + req->request.is_last); 1210 + } 1251 1211 } else { 1252 - dwc3_prepare_one_trb(dep, req, false, 0); 1212 + dwc3_prepare_one_trb(dep, req, length, false, 0); 1253 1213 } 1254 1214 } 1255 1215 ··· 2733 2671 status); 2734 2672 2735 2673 if (req->needs_extra_trb) { 2674 + unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); 2675 + 2736 2676 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, 2737 2677 status); 2678 + 2679 + /* Reclaim MPS padding TRB for ZLP */ 2680 + if (!req->direction && req->request.zero && req->request.length && 2681 + !usb_endpoint_xfer_isoc(dep->endpoint.desc) && 2682 + (IS_ALIGNED(req->request.length, maxp))) 2683 + ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); 2684 + 2738 2685 req->needs_extra_trb = false; 2739 2686 } 2740 2687
+69 -12
drivers/usb/gadget/function/f_ncm.c
··· 1181 1181 int ndp_index; 1182 1182 unsigned dg_len, dg_len2; 1183 1183 unsigned ndp_len; 1184 + unsigned block_len; 1184 1185 struct sk_buff *skb2; 1185 1186 int ret = -EINVAL; 1186 - unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize); 1187 + unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize); 1188 + unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize); 1187 1189 const struct ndp_parser_opts *opts = ncm->parser_opts; 1188 1190 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; 1189 1191 int dgram_counter; 1192 + bool ndp_after_header; 1190 1193 1191 1194 /* dwSignature */ 1192 1195 if (get_unaligned_le32(tmp) != opts->nth_sign) { ··· 1208 1205 } 1209 1206 tmp++; /* skip wSequence */ 1210 1207 1208 + block_len = get_ncm(&tmp, opts->block_length); 1211 1209 /* (d)wBlockLength */ 1212 - if (get_ncm(&tmp, opts->block_length) > max_size) { 1210 + if (block_len > ntb_max) { 1213 1211 INFO(port->func.config->cdev, "OUT size exceeded\n"); 1214 1212 goto err; 1215 1213 } 1216 1214 1217 1215 ndp_index = get_ncm(&tmp, opts->ndp_index); 1216 + ndp_after_header = false; 1218 1217 1219 1218 /* Run through all the NDP's in the NTB */ 1220 1219 do { 1221 - /* NCM 3.2 */ 1222 - if (((ndp_index % 4) != 0) && 1223 - (ndp_index < opts->nth_size)) { 1220 + /* 1221 + * NCM 3.2 1222 + * dwNdpIndex 1223 + */ 1224 + if (((ndp_index % 4) != 0) || 1225 + (ndp_index < opts->nth_size) || 1226 + (ndp_index > (block_len - 1227 + opts->ndp_size))) { 1224 1228 INFO(port->func.config->cdev, "Bad index: %#X\n", 1225 1229 ndp_index); 1226 1230 goto err; 1227 1231 } 1232 + if (ndp_index == opts->nth_size) 1233 + ndp_after_header = true; 1228 1234 1229 - /* walk through NDP */ 1235 + /* 1236 + * walk through NDP 1237 + * dwSignature 1238 + */ 1230 1239 tmp = (void *)(skb->data + ndp_index); 1231 1240 if (get_unaligned_le32(tmp) != ncm->ndp_sign) { 1232 1241 INFO(port->func.config->cdev, "Wrong NDP SIGN\n"); ··· 1249 1234 ndp_len = get_unaligned_le16(tmp++); 1250 1235 /* 1251 1236 * NCM 3.3.1 1237 + * wLength 1252 1238 * entry is 2 items 1253 1239 * item size is 16/32 bits, opts->dgram_item_len * 2 bytes 1254 1240 * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry 1255 1241 * Each entry is a dgram index and a dgram length. 1256 1242 */ 1257 1243 if ((ndp_len < opts->ndp_size 1258 - + 2 * 2 * (opts->dgram_item_len * 2)) 1259 - || (ndp_len % opts->ndplen_align != 0)) { 1244 + + 2 * 2 * (opts->dgram_item_len * 2)) || 1245 + (ndp_len % opts->ndplen_align != 0)) { 1260 1246 INFO(port->func.config->cdev, "Bad NDP length: %#X\n", 1261 1247 ndp_len); 1262 1248 goto err; ··· 1274 1258 1275 1259 do { 1276 1260 index = index2; 1261 + /* wDatagramIndex[0] */ 1262 + if ((index < opts->nth_size) || 1263 + (index > block_len - opts->dpe_size)) { 1264 + INFO(port->func.config->cdev, 1265 + "Bad index: %#X\n", index); 1266 + goto err; 1267 + } 1268 + 1277 1269 dg_len = dg_len2; 1278 - if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */ 1270 + /* 1271 + * wDatagramLength[0] 1272 + * ethernet hdr + crc or larger than max frame size 1273 + */ 1274 + if ((dg_len < 14 + crc_len) || 1275 + (dg_len > frame_max)) { 1279 1276 INFO(port->func.config->cdev, 1280 1277 "Bad dgram length: %#X\n", dg_len); 1281 1278 goto err; ··· 1312 1283 index2 = get_ncm(&tmp, opts->dgram_item_len); 1313 1284 dg_len2 = get_ncm(&tmp, opts->dgram_item_len); 1314 1285 1286 + if (index2 == 0 || dg_len2 == 0) 1287 + break; 1288 + 1289 + /* wDatagramIndex[1] */ 1290 + if (ndp_after_header) { 1291 + if (index2 < opts->nth_size + opts->ndp_size) { 1292 + INFO(port->func.config->cdev, 1293 + "Bad index: %#X\n", index2); 1294 + goto err; 1295 + } 1296 + } else { 1297 + if (index2 < opts->nth_size + opts->dpe_size) { 1298 + INFO(port->func.config->cdev, 1299 + "Bad index: %#X\n", index2); 1300 + goto err; 1301 + } 1302 + } 1303 + if (index2 > block_len - opts->dpe_size) { 1304 + INFO(port->func.config->cdev, 1305 + "Bad index: %#X\n", index2); 1306 + goto err; 1307 + } 1308 + 1309 + /* wDatagramLength[1] */ 1310 + if ((dg_len2 < 14 + crc_len) || 1311 + (dg_len2 > frame_max)) { 1312 + INFO(port->func.config->cdev, 1313 + "Bad dgram length: %#X\n", dg_len); 1314 + goto err; 1315 + } 1316 + 1315 1317 /* 1316 1318 * Copy the data into a new skb. 1317 1319 * This ensures the truesize is correct ··· 1359 1299 ndp_len -= 2 * (opts->dgram_item_len * 2); 1360 1300 1361 1301 dgram_counter++; 1362 - 1363 - if (index2 == 0 || dg_len2 == 0) 1364 - break; 1365 1302 } while (ndp_len > 2 * (opts->dgram_item_len * 2)); 1366 1303 } while (ndp_index); 1367 1304
+4 -3
drivers/usb/gadget/function/f_tcm.c
··· 753 753 goto err_sts; 754 754 755 755 return 0; 756 + 756 757 err_sts: 757 - usb_ep_free_request(fu->ep_status, stream->req_status); 758 - stream->req_status = NULL; 759 - err_out: 760 758 usb_ep_free_request(fu->ep_out, stream->req_out); 761 759 stream->req_out = NULL; 760 + err_out: 761 + usb_ep_free_request(fu->ep_in, stream->req_in); 762 + stream->req_in = NULL; 762 763 out: 763 764 return -ENOMEM; 764 765 }
+27 -11
drivers/usb/gadget/u_f.h
··· 14 14 #define __U_F_H__ 15 15 16 16 #include <linux/usb/gadget.h> 17 + #include <linux/overflow.h> 17 18 18 19 /* Variable Length Array Macros **********************************************/ 19 20 #define vla_group(groupname) size_t groupname##__next = 0 ··· 22 21 23 22 #define vla_item(groupname, type, name, n) \ 24 23 size_t groupname##_##name##__offset = ({ \ 25 - size_t align_mask = __alignof__(type) - 1; \ 26 - size_t offset = (groupname##__next + align_mask) & ~align_mask;\ 27 - size_t size = (n) * sizeof(type); \ 28 - groupname##__next = offset + size; \ 24 + size_t offset = 0; \ 25 + if (groupname##__next != SIZE_MAX) { \ 26 + size_t align_mask = __alignof__(type) - 1; \ 27 + size_t size = array_size(n, sizeof(type)); \ 28 + offset = (groupname##__next + align_mask) & \ 29 + ~align_mask; \ 30 + if (check_add_overflow(offset, size, \ 31 + &groupname##__next)) { \ 32 + groupname##__next = SIZE_MAX; \ 33 + offset = 0; \ 34 + } \ 35 + } \ 29 36 offset; \ 30 37 }) 31 38 32 39 #define vla_item_with_sz(groupname, type, name, n) \ 33 - size_t groupname##_##name##__sz = (n) * sizeof(type); \ 34 - size_t groupname##_##name##__offset = ({ \ 35 - size_t align_mask = __alignof__(type) - 1; \ 36 - size_t offset = (groupname##__next + align_mask) & ~align_mask;\ 37 - size_t size = groupname##_##name##__sz; \ 38 - groupname##__next = offset + size; \ 39 - offset; \ 40 + size_t groupname##_##name##__sz = array_size(n, sizeof(type)); \ 41 + size_t groupname##_##name##__offset = ({ \ 42 + size_t offset = 0; \ 43 + if (groupname##__next != SIZE_MAX) { \ 44 + size_t align_mask = __alignof__(type) - 1; \ 45 + offset = (groupname##__next + align_mask) & \ 46 + ~align_mask; \ 47 + if (check_add_overflow(offset, groupname##_##name##__sz,\ 48 + &groupname##__next)) { \ 49 + groupname##__next = SIZE_MAX; \ 50 + offset = 0; \ 51 + } \ 52 + } \ 53 + offset; \ 40 54 }) 41 55 42 56 #define vla_ptr(ptr, groupname, name) \
+2 -3
drivers/usb/host/ohci-exynos.c
··· 171 171 hcd->rsrc_len = resource_size(res); 172 172 173 173 irq = platform_get_irq(pdev, 0); 174 - if (!irq) { 175 - dev_err(&pdev->dev, "Failed to get IRQ\n"); 176 - err = -ENODEV; 174 + if (irq < 0) { 175 + err = irq; 177 176 goto fail_io; 178 177 } 179 178
+4 -4
drivers/usb/host/xhci-debugfs.c
··· 274 274 275 275 static int xhci_endpoint_context_show(struct seq_file *s, void *unused) 276 276 { 277 - int dci; 277 + int ep_index; 278 278 dma_addr_t dma; 279 279 struct xhci_hcd *xhci; 280 280 struct xhci_ep_ctx *ep_ctx; ··· 283 283 284 284 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus)); 285 285 286 - for (dci = 1; dci < 32; dci++) { 287 - ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci); 288 - dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params); 286 + for (ep_index = 0; ep_index < 31; ep_index++) { 287 + ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); 288 + dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params); 289 289 seq_printf(s, "%pad: %s\n", &dma, 290 290 xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info), 291 291 le32_to_cpu(ep_ctx->ep_info2),
+10 -9
drivers/usb/host/xhci-hub.c
··· 740 740 { 741 741 u32 pls = status_reg & PORT_PLS_MASK; 742 742 743 - /* resume state is a xHCI internal state. 744 - * Do not report it to usb core, instead, pretend to be U3, 745 - * thus usb core knows it's not ready for transfer 746 - */ 747 - if (pls == XDEV_RESUME) { 748 - *status |= USB_SS_PORT_LS_U3; 749 - return; 750 - } 751 - 752 743 /* When the CAS bit is set then warm reset 753 744 * should be performed on port 754 745 */ ··· 761 770 */ 762 771 pls |= USB_PORT_STAT_CONNECTION; 763 772 } else { 773 + /* 774 + * Resume state is an xHCI internal state. Do not report it to 775 + * usb core, instead, pretend to be U3, thus usb core knows 776 + * it's not ready for transfer. 777 + */ 778 + if (pls == XDEV_RESUME) { 779 + *status |= USB_SS_PORT_LS_U3; 780 + return; 781 + } 782 + 764 783 /* 765 784 * If CAS bit isn't set but the Port is already at 766 785 * Compliance Mode, fake a connection so the USB core
+1 -18
drivers/usb/host/xhci-pci-renesas.c
··· 50 50 #define RENESAS_RETRY 10000 51 51 #define RENESAS_DELAY 10 52 52 53 - #define ROM_VALID_01 0x2013 54 - #define ROM_VALID_02 0x2026 55 - 56 - static int renesas_verify_fw_version(struct pci_dev *pdev, u32 version) 57 - { 58 - switch (version) { 59 - case ROM_VALID_01: 60 - case ROM_VALID_02: 61 - return 0; 62 - } 63 - dev_err(&pdev->dev, "FW has invalid version :%d\n", version); 64 - return -EINVAL; 65 - } 66 - 67 53 static int renesas_fw_download_image(struct pci_dev *dev, 68 54 const u32 *fw, size_t step, bool rom) 69 55 { ··· 188 202 189 203 version &= RENESAS_FW_VERSION_FIELD; 190 204 version = version >> RENESAS_FW_VERSION_OFFSET; 191 - 192 - err = renesas_verify_fw_version(pdev, version); 193 - if (err) 194 - return err; 205 + dev_dbg(&pdev->dev, "Found ROM version: %x\n", version); 195 206 196 207 /* 197 208 * Test if ROM is present and loaded, if so we can skip everything
+3 -1
drivers/usb/host/xhci-tegra.c
··· 1136 1136 unsigned int i, phy_count = 0; 1137 1137 1138 1138 for (i = 0; i < tegra->soc->num_types; i++) { 1139 - if (!strncmp(tegra->soc->phy_types[i].name, "usb2", 1139 + if (!strncmp(tegra->soc->phy_types[i].name, name, 1140 1140 strlen(name))) 1141 1141 return tegra->phys[phy_count+port]; 1142 1142 ··· 1258 1258 1259 1259 INIT_WORK(&tegra->id_work, tegra_xhci_id_work); 1260 1260 tegra->id_nb.notifier_call = tegra_xhci_id_notify; 1261 + tegra->otg_usb2_port = -EINVAL; 1262 + tegra->otg_usb3_port = -EINVAL; 1261 1263 1262 1264 for (i = 0; i < tegra->num_usb_phys; i++) { 1263 1265 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
+2 -1
drivers/usb/host/xhci.c
··· 3236 3236 3237 3237 wait_for_completion(cfg_cmd->completion); 3238 3238 3239 - ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE; 3240 3239 xhci_free_command(xhci, cfg_cmd); 3241 3240 cleanup: 3242 3241 xhci_free_command(xhci, stop_cmd); 3242 + if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE) 3243 + ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE; 3243 3244 } 3244 3245 3245 3246 static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
+1 -1
drivers/usb/misc/lvstest.c
··· 426 426 USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT); 427 427 if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) { 428 428 dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret); 429 - return ret; 429 + return ret < 0 ? ret : -EINVAL; 430 430 } 431 431 432 432 /* submit urb to poll interrupt endpoint */
+1 -1
drivers/usb/misc/yurex.c
··· 492 492 prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE); 493 493 dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__, 494 494 dev->cntl_buffer[0]); 495 - retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL); 495 + retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC); 496 496 if (retval >= 0) 497 497 timeout = schedule_timeout(YUREX_WRITE_TIMEOUT); 498 498 finish_wait(&dev->waitq, &wait);
+1
drivers/usb/phy/phy-jz4770.c
··· 176 176 177 177 /* Wait for PHY to reset */ 178 178 usleep_range(30, 300); 179 + reg = readl(priv->base + REG_USBPCR_OFFSET); 179 180 writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET); 180 181 usleep_range(300, 1000); 181 182
+1 -1
drivers/usb/storage/unusual_devs.h
··· 2328 2328 "JMicron", 2329 2329 "USB to ATA/ATAPI Bridge", 2330 2330 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 2331 - US_FL_BROKEN_FUA ), 2331 + US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ), 2332 2332 2333 2333 /* Reported by Andrey Rahmatullin <wrar@altlinux.org> */ 2334 2334 UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
+14
drivers/usb/storage/unusual_uas.h
··· 28 28 * and don't forget to CC: the USB development list <linux-usb@vger.kernel.org> 29 29 */ 30 30 31 + /* Reported-by: Till Dörges <doerges@pre-sense.de> */ 32 + UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999, 33 + "Sony", 34 + "PSZ-HA*", 35 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 36 + US_FL_NO_REPORT_OPCODES), 37 + 31 38 /* Reported-by: Julian Groß <julian.g@posteo.de> */ 32 39 UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999, 33 40 "LaCie", ··· 86 79 "JMS567", 87 80 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 88 81 US_FL_BROKEN_FUA), 82 + 83 + /* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */ 84 + UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999, 85 + "PNY", 86 + "Pro Elite SSD", 87 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, 88 + US_FL_NO_ATA_1X), 89 89 90 90 /* Reported-by: Hans de Goede <hdegoede@redhat.com> */ 91 91 UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
+25 -3
drivers/usb/typec/tcpm/tcpm.c
··· 3372 3372 tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0); 3373 3373 break; 3374 3374 case SRC_HARD_RESET_VBUS_OFF: 3375 - tcpm_set_vconn(port, true); 3375 + /* 3376 + * 7.1.5 Response to Hard Resets 3377 + * Hard Reset Signaling indicates a communication failure has occurred and the 3378 + * Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin and Shall 3379 + * drive VBUS to vSafe0V as shown in Figure 7-9. 3380 + */ 3381 + tcpm_set_vconn(port, false); 3376 3382 tcpm_set_vbus(port, false); 3377 3383 tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE, 3378 3384 tcpm_data_role_for_source(port)); 3379 - tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); 3385 + /* 3386 + * If tcpc fails to notify vbus off, TCPM will wait for PD_T_SAFE_0V + 3387 + * PD_T_SRC_RECOVER before turning vbus back on. 3388 + * From Table 7-12 Sequence Description for a Source Initiated Hard Reset: 3389 + * 4. Policy Engine waits tPSHardReset after sending Hard Reset Signaling and then 3390 + * tells the Device Policy Manager to instruct the power supply to perform a 3391 + * Hard Reset. The transition to vSafe0V Shall occur within tSafe0V (t2). 3392 + * 5. After tSrcRecover the Source applies power to VBUS in an attempt to 3393 + * re-establish communication with the Sink and resume USB Default Operation. 3394 + * The transition to vSafe5V Shall occur within tSrcTurnOn(t4). 3395 + */ 3396 + tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SAFE_0V + PD_T_SRC_RECOVER); 3380 3397 break; 3381 3398 case SRC_HARD_RESET_VBUS_ON: 3399 + tcpm_set_vconn(port, true); 3382 3400 tcpm_set_vbus(port, true); 3383 3401 port->tcpc->set_pd_rx(port->tcpc, true); 3384 3402 tcpm_set_attached_state(port, true); ··· 3962 3944 tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0); 3963 3945 break; 3964 3946 case SRC_HARD_RESET_VBUS_OFF: 3965 - tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, 0); 3947 + /* 3948 + * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait 3949 + * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V. 3950 + */ 3951 + tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); 3966 3952 break; 3967 3953 case HARD_RESET_SEND: 3968 3954 break;
+1 -8
drivers/usb/typec/ucsi/displayport.c
··· 288 288 struct typec_altmode *alt; 289 289 struct ucsi_dp *dp; 290 290 291 - mutex_lock(&con->lock); 292 - 293 291 /* We can't rely on the firmware with the capabilities. */ 294 292 desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE; 295 293 ··· 296 298 desc->vdo |= all_assignments << 16; 297 299 298 300 alt = typec_port_register_altmode(con->port, desc); 299 - if (IS_ERR(alt)) { 300 - mutex_unlock(&con->lock); 301 + if (IS_ERR(alt)) 301 302 return alt; 302 - } 303 303 304 304 dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL); 305 305 if (!dp) { 306 306 typec_unregister_altmode(alt); 307 - mutex_unlock(&con->lock); 308 307 return ERR_PTR(-ENOMEM); 309 308 } 310 309 ··· 313 318 314 319 alt->ops = &ucsi_displayport_ops; 315 320 typec_altmode_set_drvdata(alt, dp); 316 - 317 - mutex_unlock(&con->lock); 318 321 319 322 return alt; 320 323 }
+53 -50
drivers/usb/typec/ucsi/ucsi.c
··· 146 146 return UCSI_CCI_LENGTH(cci); 147 147 } 148 148 149 - static int ucsi_run_command(struct ucsi *ucsi, u64 command, 150 - void *data, size_t size) 149 + int ucsi_send_command(struct ucsi *ucsi, u64 command, 150 + void *data, size_t size) 151 151 { 152 152 u8 length; 153 153 int ret; 154 154 155 + mutex_lock(&ucsi->ppm_lock); 156 + 155 157 ret = ucsi_exec_command(ucsi, command); 156 158 if (ret < 0) 157 - return ret; 159 + goto out; 158 160 159 161 length = ret; 160 162 161 163 if (data) { 162 164 ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size); 163 165 if (ret) 164 - return ret; 166 + goto out; 165 167 } 166 168 167 169 ret = ucsi_acknowledge_command(ucsi); 168 170 if (ret) 169 - return ret; 171 + goto out; 170 172 171 - return length; 172 - } 173 - 174 - int ucsi_send_command(struct ucsi *ucsi, u64 command, 175 - void *retval, size_t size) 176 - { 177 - int ret; 178 - 179 - mutex_lock(&ucsi->ppm_lock); 180 - ret = ucsi_run_command(ucsi, command, retval, size); 173 + ret = length; 174 + out: 181 175 mutex_unlock(&ucsi->ppm_lock); 182 - 183 176 return ret; 184 177 } 185 178 EXPORT_SYMBOL_GPL(ucsi_send_command); ··· 198 205 int i; 199 206 200 207 command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num); 201 - ret = ucsi_run_command(con->ucsi, command, &cur, sizeof(cur)); 208 + ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur)); 202 209 if (ret < 0) { 203 210 if (con->ucsi->version > 0x0100) { 204 211 dev_err(con->ucsi->dev, ··· 347 354 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient); 348 355 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num); 349 356 command |= UCSI_GET_ALTMODE_OFFSET(i); 350 - len = ucsi_run_command(con->ucsi, command, &alt, sizeof(alt)); 357 + len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt)); 351 358 /* 352 359 * We are collecting all altmodes first and then registering. 353 360 * Some type-C device will return zero length data beyond last ··· 424 431 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient); 425 432 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num); 426 433 command |= UCSI_GET_ALTMODE_OFFSET(i); 427 - len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt)); 434 + len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt)); 428 435 if (len <= 0) 429 436 return len; 430 437 ··· 495 502 command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner); 496 503 command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1); 497 504 command |= UCSI_GET_PDOS_SRC_PDOS; 498 - ret = ucsi_run_command(ucsi, command, con->src_pdos, 505 + ret = ucsi_send_command(ucsi, command, con->src_pdos, 499 506 sizeof(con->src_pdos)); 500 507 if (ret < 0) { 501 508 dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret); ··· 674 681 */ 675 682 command = UCSI_GET_CAM_SUPPORTED; 676 683 command |= UCSI_CONNECTOR_NUMBER(con->num); 677 - ucsi_run_command(con->ucsi, command, NULL, 0); 684 + ucsi_send_command(con->ucsi, command, NULL, 0); 678 685 } 679 686 680 687 if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE) ··· 729 736 u32 cci; 730 737 int ret; 731 738 739 + mutex_lock(&ucsi->ppm_lock); 740 + 732 741 ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command, 733 742 sizeof(command)); 734 743 if (ret < 0) 735 - return ret; 744 + goto out; 736 745 737 746 tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS); 738 747 739 748 do { 740 - if (time_is_before_jiffies(tmo)) 741 - return -ETIMEDOUT; 749 + if (time_is_before_jiffies(tmo)) { 750 + ret = -ETIMEDOUT; 751 + goto out; 752 + } 742 753 743 754 ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci)); 744 755 if (ret) 745 - return ret; 756 + goto out; 746 757 747 758 /* If the PPM is still doing something else, reset it again. */ 748 759 if (cci & ~UCSI_CCI_RESET_COMPLETE) { ··· 754 757 &command, 755 758 sizeof(command)); 756 759 if (ret < 0) 757 - return ret; 760 + goto out; 758 761 } 759 762 760 763 msleep(20); 761 764 } while (!(cci & UCSI_CCI_RESET_COMPLETE)); 762 765 763 - return 0; 766 + out: 767 + mutex_unlock(&ucsi->ppm_lock); 768 + return ret; 764 769 } 765 770 766 771 static int ucsi_role_cmd(struct ucsi_connector *con, u64 command) ··· 774 775 u64 c; 775 776 776 777 /* PPM most likely stopped responding. Resetting everything. */ 777 - mutex_lock(&con->ucsi->ppm_lock); 778 778 ucsi_reset_ppm(con->ucsi); 779 - mutex_unlock(&con->ucsi->ppm_lock); 780 779 781 780 c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy; 782 781 ucsi_send_command(con->ucsi, c, NULL, 0); ··· 898 901 con->num = index + 1; 899 902 con->ucsi = ucsi; 900 903 904 + /* Delay other interactions with the con until registration is complete */ 905 + mutex_lock(&con->lock); 906 + 901 907 /* Get connector capability */ 902 908 command = UCSI_GET_CONNECTOR_CAPABILITY; 903 909 command |= UCSI_CONNECTOR_NUMBER(con->num); 904 - ret = ucsi_run_command(ucsi, command, &con->cap, sizeof(con->cap)); 910 + ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap)); 905 911 if (ret < 0) 906 - return ret; 912 + goto out; 907 913 908 914 if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP) 909 915 cap->data = TYPEC_PORT_DRD; ··· 938 938 939 939 ret = ucsi_register_port_psy(con); 940 940 if (ret) 941 - return ret; 941 + goto out; 942 942 943 943 /* Register the connector */ 944 944 con->port = typec_register_port(ucsi->dev, cap); 945 - if (IS_ERR(con->port)) 946 - return PTR_ERR(con->port); 945 + if (IS_ERR(con->port)) { 946 + ret = PTR_ERR(con->port); 947 + goto out; 948 + } 947 949 948 950 /* Alternate modes */ 949 951 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON); 950 - if (ret) 952 + if (ret) { 951 953 dev_err(ucsi->dev, "con%d: failed to register alt modes\n", 952 954 con->num); 955 + goto out; 956 + } 953 957 954 958 /* Get the status */ 955 959 command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num); 956 - ret = ucsi_run_command(ucsi, command, &con->status, 957 - sizeof(con->status)); 960 + ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status)); 958 961 if (ret < 0) { 959 962 dev_err(ucsi->dev, "con%d: failed to get status\n", con->num); 960 - return 0; 963 + ret = 0; 964 + goto out; 961 965 } 966 + ret = 0; /* ucsi_send_command() returns length on success */ 962 967 963 968 switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) { 964 969 case UCSI_CONSTAT_PARTNER_TYPE_UFP: ··· 988 983 989 984 if (con->partner) { 990 985 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP); 991 - if (ret) 986 + if (ret) { 992 987 dev_err(ucsi->dev, 993 988 "con%d: failed to register alternate modes\n", 994 989 con->num); 995 - else 990 + ret = 0; 991 + } else { 996 992 ucsi_altmode_update_active(con); 993 + } 997 994 } 998 995 999 996 trace_ucsi_register_port(con->num, &con->status); 1000 997 1001 - return 0; 998 + out: 999 + mutex_unlock(&con->lock); 1000 + return ret; 1002 1001 } 1003 1002 1004 1003 /** ··· 1018 1009 int ret; 1019 1010 int i; 1020 1011 1021 - mutex_lock(&ucsi->ppm_lock); 1022 - 1023 1012 /* Reset the PPM */ 1024 1013 ret = ucsi_reset_ppm(ucsi); 1025 1014 if (ret) { ··· 1028 1021 /* Enable basic notifications */ 1029 1022 ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR; 1030 1023 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy; 1031 - ret = ucsi_run_command(ucsi, command, NULL, 0); 1024 + ret = ucsi_send_command(ucsi, command, NULL, 0); 1032 1025 if (ret < 0) 1033 1026 goto err_reset; 1034 1027 1035 1028 /* Get PPM capabilities */ 1036 1029 command = UCSI_GET_CAPABILITY; 1037 - ret = ucsi_run_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap)); 1030 + ret = ucsi_send_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap)); 1038 1031 if (ret < 0) 1039 1032 goto err_reset; 1040 1033 ··· 1061 1054 /* Enable all notifications */ 1062 1055 ucsi->ntfy = UCSI_ENABLE_NTFY_ALL; 1063 1056 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy; 1064 - ret = ucsi_run_command(ucsi, command, NULL, 0); 1057 + ret = ucsi_send_command(ucsi, command, NULL, 0); 1065 1058 if (ret < 0) 1066 1059 goto err_unregister; 1067 - 1068 - mutex_unlock(&ucsi->ppm_lock); 1069 1060 1070 1061 return 0; 1071 1062 ··· 1079 1074 err_reset: 1080 1075 ucsi_reset_ppm(ucsi); 1081 1076 err: 1082 - mutex_unlock(&ucsi->ppm_lock); 1083 - 1084 1077 return ret; 1085 1078 } 1086 1079
+6
drivers/usb/usbip/stub_dev.c
··· 461 461 return; 462 462 } 463 463 464 + static bool usbip_match(struct usb_device *udev) 465 + { 466 + return true; 467 + } 468 + 464 469 #ifdef CONFIG_PM 465 470 466 471 /* These functions need usb_port_suspend and usb_port_resume, ··· 491 486 .name = "usbip-host", 492 487 .probe = stub_probe, 493 488 .disconnect = stub_disconnect, 489 + .match = usbip_match, 494 490 #ifdef CONFIG_PM 495 491 .suspend = stub_suspend, 496 492 .resume = stub_resume,
+2
tools/usb/Build
··· 1 + testusb-y += testusb.o 2 + ffs-test-y += ffs-test.o
+45 -8
tools/usb/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for USB tools 3 + include ../scripts/Makefile.include 3 4 4 - PTHREAD_LIBS = -lpthread 5 - WARNINGS = -Wall -Wextra 6 - CFLAGS = $(WARNINGS) -g -I../include 7 - LDFLAGS = $(PTHREAD_LIBS) 5 + bindir ?= /usr/bin 8 6 9 - all: testusb ffs-test 10 - %: %.c 11 - $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 7 + ifeq ($(srctree),) 8 + srctree := $(patsubst %/,%,$(dir $(CURDIR))) 9 + srctree := $(patsubst %/,%,$(dir $(srctree))) 10 + endif 11 + 12 + # Do not use make's built-in rules 13 + # (this improves performance and avoids hard-to-debug behaviour); 14 + MAKEFLAGS += -r 15 + 16 + override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include 17 + override LDFLAGS += -lpthread 18 + 19 + ALL_TARGETS := testusb ffs-test 20 + ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) 21 + 22 + all: $(ALL_PROGRAMS) 23 + 24 + export srctree OUTPUT CC LD CFLAGS 25 + include $(srctree)/tools/build/Makefile.include 26 + 27 + TESTUSB_IN := $(OUTPUT)testusb-in.o 28 + $(TESTUSB_IN): FORCE 29 + $(Q)$(MAKE) $(build)=testusb 30 + $(OUTPUT)testusb: $(TESTUSB_IN) 31 + $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) 32 + 33 + FFS_TEST_IN := $(OUTPUT)ffs-test-in.o 34 + $(FFS_TEST_IN): FORCE 35 + $(Q)$(MAKE) $(build)=ffs-test 36 + $(OUTPUT)ffs-test: $(FFS_TEST_IN) 37 + $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) 12 38 13 39 clean: 14 - $(RM) testusb ffs-test 40 + rm -f $(ALL_PROGRAMS) 41 + find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete 42 + 43 + install: $(ALL_PROGRAMS) 44 + install -d -m 755 $(DESTDIR)$(bindir); \ 45 + for program in $(ALL_PROGRAMS); do \ 46 + install $$program $(DESTDIR)$(bindir); \ 47 + done 48 + 49 + FORCE: 50 + 51 + .PHONY: all install clean FORCE prepare