.. | .. |
---|
298 | 298 | goto skip_to_next_endpoint_or_interface_descriptor; |
---|
299 | 299 | } |
---|
300 | 300 | |
---|
301 | | - /* Ignore blacklisted endpoints */ |
---|
302 | | - if (udev->quirks & USB_QUIRK_ENDPOINT_BLACKLIST) { |
---|
303 | | - if (usb_endpoint_is_blacklisted(udev, ifp, d)) { |
---|
304 | | - dev_warn(ddev, "config %d interface %d altsetting %d has a blacklisted endpoint with address 0x%X, skipping\n", |
---|
| 301 | + /* Ignore some endpoints */ |
---|
| 302 | + if (udev->quirks & USB_QUIRK_ENDPOINT_IGNORE) { |
---|
| 303 | + if (usb_endpoint_is_ignored(udev, ifp, d)) { |
---|
| 304 | + dev_warn(ddev, "config %d interface %d altsetting %d has an ignored endpoint with address 0x%X, skipping\n", |
---|
305 | 305 | cfgno, inum, asnum, |
---|
306 | 306 | d->bEndpointAddress); |
---|
307 | 307 | goto skip_to_next_endpoint_or_interface_descriptor; |
---|
.. | .. |
---|
322 | 322 | j = 255; |
---|
323 | 323 | if (usb_endpoint_xfer_int(d)) { |
---|
324 | 324 | i = 1; |
---|
325 | | - switch (to_usb_device(ddev)->speed) { |
---|
| 325 | + switch (udev->speed) { |
---|
326 | 326 | case USB_SPEED_SUPER_PLUS: |
---|
327 | 327 | case USB_SPEED_SUPER: |
---|
328 | 328 | case USB_SPEED_HIGH: |
---|
.. | .. |
---|
343 | 343 | /* |
---|
344 | 344 | * This quirk fixes bIntervals reported in ms. |
---|
345 | 345 | */ |
---|
346 | | - if (to_usb_device(ddev)->quirks & |
---|
347 | | - USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) { |
---|
| 346 | + if (udev->quirks & USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL) { |
---|
348 | 347 | n = clamp(fls(d->bInterval) + 3, i, j); |
---|
349 | 348 | i = j = n; |
---|
350 | 349 | } |
---|
.. | .. |
---|
352 | 351 | * This quirk fixes bIntervals reported in |
---|
353 | 352 | * linear microframes. |
---|
354 | 353 | */ |
---|
355 | | - if (to_usb_device(ddev)->quirks & |
---|
356 | | - USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) { |
---|
| 354 | + if (udev->quirks & USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) { |
---|
357 | 355 | n = clamp(fls(d->bInterval), i, j); |
---|
358 | 356 | i = j = n; |
---|
359 | 357 | } |
---|
.. | .. |
---|
370 | 368 | } else if (usb_endpoint_xfer_isoc(d)) { |
---|
371 | 369 | i = 1; |
---|
372 | 370 | j = 16; |
---|
373 | | - switch (to_usb_device(ddev)->speed) { |
---|
| 371 | + switch (udev->speed) { |
---|
374 | 372 | case USB_SPEED_HIGH: |
---|
375 | 373 | n = 7; /* 8 ms = 2^(7-1) uframes */ |
---|
376 | 374 | break; |
---|
.. | .. |
---|
392 | 390 | * explicitly forbidden by the USB spec. In an attempt to make |
---|
393 | 391 | * them usable, we will try treating them as Interrupt endpoints. |
---|
394 | 392 | */ |
---|
395 | | - if (to_usb_device(ddev)->speed == USB_SPEED_LOW && |
---|
396 | | - usb_endpoint_xfer_bulk(d)) { |
---|
| 393 | + if (udev->speed == USB_SPEED_LOW && usb_endpoint_xfer_bulk(d)) { |
---|
397 | 394 | dev_warn(ddev, "config %d interface %d altsetting %d " |
---|
398 | 395 | "endpoint 0x%X is Bulk; changing to Interrupt\n", |
---|
399 | 396 | cfgno, inum, asnum, d->bEndpointAddress); |
---|
.. | .. |
---|
417 | 414 | |
---|
418 | 415 | /* Find the highest legal maxpacket size for this endpoint */ |
---|
419 | 416 | i = 0; /* additional transactions per microframe */ |
---|
420 | | - switch (to_usb_device(ddev)->speed) { |
---|
| 417 | + switch (udev->speed) { |
---|
421 | 418 | case USB_SPEED_LOW: |
---|
422 | 419 | maxpacket_maxes = low_speed_maxpacket_maxes; |
---|
423 | 420 | break; |
---|
.. | .. |
---|
430 | 427 | i = maxp & USB_EP_MAXP_MULT_MASK; |
---|
431 | 428 | maxp &= ~i; |
---|
432 | 429 | } |
---|
433 | | - /* fallthrough */ |
---|
| 430 | + fallthrough; |
---|
434 | 431 | default: |
---|
435 | 432 | maxpacket_maxes = high_speed_maxpacket_maxes; |
---|
436 | 433 | break; |
---|
.. | .. |
---|
453 | 450 | * maxpacket sizes other than 512. High speed HCDs may not |
---|
454 | 451 | * be able to handle that particular bug, so let's warn... |
---|
455 | 452 | */ |
---|
456 | | - if (to_usb_device(ddev)->speed == USB_SPEED_HIGH |
---|
457 | | - && usb_endpoint_xfer_bulk(d)) { |
---|
| 453 | + if (udev->speed == USB_SPEED_HIGH && usb_endpoint_xfer_bulk(d)) { |
---|
458 | 454 | if (maxp != 512) |
---|
459 | 455 | dev_warn(ddev, "config %d interface %d altsetting %d " |
---|
460 | 456 | "bulk endpoint 0x%X has invalid maxpacket %d\n", |
---|
.. | .. |
---|
463 | 459 | } |
---|
464 | 460 | |
---|
465 | 461 | /* Parse a possible SuperSpeed endpoint companion descriptor */ |
---|
466 | | - if (to_usb_device(ddev)->speed >= USB_SPEED_SUPER) |
---|
| 462 | + if (udev->speed >= USB_SPEED_SUPER) |
---|
467 | 463 | usb_parse_ss_endpoint_companion(ddev, cfgno, |
---|
468 | 464 | inum, asnum, endpoint, buffer, size); |
---|
469 | 465 | |
---|
.. | .. |
---|
618 | 614 | unsigned char *buffer2; |
---|
619 | 615 | int size2; |
---|
620 | 616 | struct usb_descriptor_header *header; |
---|
621 | | - int len, retval; |
---|
| 617 | + int retval; |
---|
622 | 618 | u8 inums[USB_MAXINTERFACES], nalts[USB_MAXINTERFACES]; |
---|
623 | 619 | unsigned iad_num = 0; |
---|
624 | 620 | |
---|
.. | .. |
---|
773 | 769 | nalts[i] = j = USB_MAXALTSETTING; |
---|
774 | 770 | } |
---|
775 | 771 | |
---|
776 | | - len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j; |
---|
777 | | - config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL); |
---|
| 772 | + intfc = kzalloc(struct_size(intfc, altsetting, j), GFP_KERNEL); |
---|
| 773 | + config->intf_cache[i] = intfc; |
---|
778 | 774 | if (!intfc) |
---|
779 | 775 | return -ENOMEM; |
---|
780 | 776 | kref_init(&intfc->ref); |
---|
.. | .. |
---|
866 | 862 | { |
---|
867 | 863 | struct device *ddev = &dev->dev; |
---|
868 | 864 | int ncfg = dev->descriptor.bNumConfigurations; |
---|
869 | | - int result = 0; |
---|
870 | 865 | unsigned int cfgno, length; |
---|
871 | 866 | unsigned char *bigbuffer; |
---|
872 | 867 | struct usb_config_descriptor *desc; |
---|
| 868 | + int result; |
---|
873 | 869 | |
---|
874 | | - cfgno = 0; |
---|
875 | | - result = -ENOMEM; |
---|
876 | 870 | if (ncfg > USB_MAXCONFIG) { |
---|
877 | 871 | dev_warn(ddev, "too many configurations: %d, " |
---|
878 | 872 | "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG); |
---|
.. | .. |
---|
887 | 881 | length = ncfg * sizeof(struct usb_host_config); |
---|
888 | 882 | dev->config = kzalloc(length, GFP_KERNEL); |
---|
889 | 883 | if (!dev->config) |
---|
890 | | - goto err2; |
---|
| 884 | + return -ENOMEM; |
---|
891 | 885 | |
---|
892 | 886 | length = ncfg * sizeof(char *); |
---|
893 | 887 | dev->rawdescriptors = kzalloc(length, GFP_KERNEL); |
---|
894 | 888 | if (!dev->rawdescriptors) |
---|
895 | | - goto err2; |
---|
| 889 | + return -ENOMEM; |
---|
896 | 890 | |
---|
897 | 891 | desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); |
---|
898 | 892 | if (!desc) |
---|
899 | | - goto err2; |
---|
| 893 | + return -ENOMEM; |
---|
900 | 894 | |
---|
901 | | - result = 0; |
---|
902 | | - for (; cfgno < ncfg; cfgno++) { |
---|
| 895 | + for (cfgno = 0; cfgno < ncfg; cfgno++) { |
---|
903 | 896 | /* We grab just the first descriptor so we know how long |
---|
904 | 897 | * the whole configuration is */ |
---|
905 | 898 | result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, |
---|
.. | .. |
---|
955 | 948 | goto err; |
---|
956 | 949 | } |
---|
957 | 950 | } |
---|
958 | | - result = 0; |
---|
959 | 951 | |
---|
960 | 952 | err: |
---|
961 | 953 | kfree(desc); |
---|
962 | 954 | dev->descriptor.bNumConfigurations = cfgno; |
---|
963 | | -err2: |
---|
964 | | - if (result == -ENOMEM) |
---|
965 | | - dev_err(ddev, "out of memory\n"); |
---|
| 955 | + |
---|
966 | 956 | return result; |
---|
967 | 957 | } |
---|
968 | 958 | |
---|
.. | .. |
---|
1086 | 1076 | case USB_PTM_CAP_TYPE: |
---|
1087 | 1077 | dev->bos->ptm_cap = |
---|
1088 | 1078 | (struct usb_ptm_cap_descriptor *)buffer; |
---|
1089 | | - break; |
---|
1090 | | - case USB_CAP_TYPE_CONFIG_SUMMARY: |
---|
1091 | | - /* one such desc per function */ |
---|
1092 | | - if (!dev->bos->num_config_summary_desc) |
---|
1093 | | - dev->bos->config_summary = |
---|
1094 | | - (struct usb_config_summary_descriptor *)buffer; |
---|
1095 | | - |
---|
1096 | | - dev->bos->num_config_summary_desc++; |
---|
1097 | | - break; |
---|
1098 | 1079 | default: |
---|
1099 | 1080 | break; |
---|
1100 | 1081 | } |
---|