summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_subr.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* remove unused usbd_get_device_string()jsg2021-02-241-21/+1
| | | | ok mpi@
* Align the mixed naming for the variables used to reference tomglocker2021-02-011-14/+14
| | | | | | | | | bInterfaceNumber and bAlternateSetting as following: ifaceidx -> ifaceno altidx -> altno Suggested and ok mpi@
* The usb configuration descriptor parameter providing the number ofmglocker2021-01-271-5/+5
| | | | | | available device interfaces is called 'bNumInterfaces'. ok phessler@, thfr@ (who provided the man page diff)
* usbd_get_cdesc() returns usb_config_descriptor_t *. Therefore returnmglocker2020-08-271-3/+3
| | | | | | 'NULL' instead of '0'. ok deraadt@
* Nuke all occurrences of usbd_abort_pipe() if it gets called rightmglocker2020-07-311-4/+2
| | | | | | | | | | before usbd_close_pipe(), since usbd_close_pipe() already takes care about aborting non-empty pipes. As investigated by gerhard@ usbdi.c rev. 1.57 did add usbd_abort_pipe() to usbd_close_pipe(), but the drivers didn't get cleaned up afterwards. ok gerhard@
* tsleep(9) to tsleep_nsec(9) conversions.mpi2019-10-061-4/+3
| | | | ok visa@, kn@, cheloha@
* Don't retry to get the usb descriptor in usbd_new_device() if the callclaudio2019-06-241-1/+6
| | | | | | | | timed out. If usbd_get_desc() returns USBD_TIMEOUT the chance is high that the next call will do the same and it slows down attachement of devices a lot. Makes reattaching USB at resume a lot faster with my umb(4) card (which likes to time out). "move fast and fix things" deraadt@
* Publish new attached device once it is fully initialized.mpi2019-02-171-2/+3
| | | | | | | | Should prevent a race seen by florian@ where userland emits an USB_DEVICEINFO ioctl(2) for a device whose product/vendor names haven't yet been filled. ok florian@
* Remove unused variable.mpi2019-01-221-3/+2
|
* Free sizes for the subdevs array.mpi2018-11-271-4/+7
| | | | ok anton@, visa@
* Revert free sizes for `subdevs' array, it is incorrect.mpi2018-11-201-7/+4
| | | | Reported by anton@ and Natasha Kerensikova
* More uses of __func__ in debug printfs.mpi2018-11-181-27/+24
|
* Use "%s", __func__ in DPRINTF() to reduce grep noise.mpi2018-11-181-14/+14
|
* free(9) size for USB subdevs array.mpi2018-11-171-4/+7
| | | | ok ratchov@, visa@
* free(9) sizes for array of interfaces.mpi2018-11-161-5/+5
| | | | ok visa@
* free(9) sizes for configuration descriptors.mpi2018-11-141-3/+3
| | | | ok tedu@, visa@
* free(9) sizes for endpoints array.mpi2018-11-101-3/+5
| | | | ok okan@, tedu@, visa@
* Reuse implicit padding to export the port number of a USB device inmpi2018-07-191-1/+2
| | | | | | | | USB_DEVICEINFO. devel/libusb1 requires this piece of information. ok jcs@, mikeb@, jasper@, sthen@
* Change USB_DEVICEINFO to report USB port status/changes as currentlympi2018-07-101-16/+4
| | | | | | | | | seen by the stack. This will allows us to debug port status changes without relying on external tools, like lsusb(1), that generate I/O. While here correct USB3 LS port defines.
* Simplify/refactor the way vendor/product/serial informations arelandry2018-05-011-67/+63
| | | | | | | | | | | | | | | | | | gathered from usb devices. Cache them early in usbd_new_device() instead of querying the device several times (the content wont change anyway) and uselessly generating usb traffic (which could conflict with other access..) The heuristic stays the same, first look in the device descriptor, then try to match against usb_known_vendors/usb_known_products, then fallback to use the idVendor/idProduct codes. Remove the now useless 'usedev' parameter from usbd_fill_deviceinfo(). Tested from bsd & bsd.rd. suggested by and ok mpi@
* Fill the 'card' member of v4l2_capability struct with the usb productlandry2018-04-241-3/+1
| | | | | | | | name coming from usbd_devinfo_vp() instead of the dummy "Generic USB video class device" string, makes it easier to differentiate multiple webcams in firefox's webrtc permission dialog. ok/help mpi@
* A pile of sizes to free(9). In test for a few days in snapshots.deraadt2017-04-081-12/+13
| | | | | Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
* 3 more mallocarray() usesderaadt2017-04-051-3/+3
|
* Add sizes to various free(9) calls. Fixing the simpler ones first.deraadt2017-03-261-3/+3
| | | | ok natano visa
* Correctly check for valid maximum packet size.mpi2016-09-191-2/+2
| | | | from jsg@
* ``bMaxPacketSize'' is reported as a power of 2 for super speed devicesmpi2016-09-191-3/+7
| | | | | | | | as per section 4.8.2.1 of xHCI specification. Note that we never got this correctly. Spotted by and ok jsg@
* Ensure that the device descriptor ``bMaxPacketSize'' value is usablempi2016-09-181-26/+41
| | | | | | | | | | | | | before using it as the ``wMaxPacketSize'' of the default endpoint. This prevents host controller drivers from using incorrect value, in particular 0, that makes ehci(4) crash. While here do the 0xff -> 512 conversion for super speed devices. Crash found with a facedancer21. ok deraadt@
* Split usbd_fill_iface_data() in two and introduce usbd_parse_idesc() ampi2016-09-121-34/+39
| | | | | | | function for parsing and checking endpoint descriptors. More checks will be added later to prevent malformed descriptors of being used.
* Pass M_ZERO when allocating memory for "struct usbd_endpoint".mpi2016-09-021-2/+2
| | | | | | These descriptors are filled with value parsed from untrusted USB descriptors and we don't want to left memory unitialized if an error occurs during the parsing.
* Cleanup usbd_fill_iface_data() to make it easier to check for badmpi2016-09-021-17/+19
| | | | | | descriptors. No functionnal change.
* Do not free the configuration descriptor without setting ``dev->cdesc''mpi2016-09-021-6/+3
| | | | | | | | to NULL. Prevent a use after free triggerable with invalid interface descriptor. Found with umap2 and a facedancer21.
* Prevent a NULL dereference, triggerable with a crafted configurationmpi2016-09-021-2/+4
| | | | | | descriptor with a bad type. Found with umap2 and a facedancer21.
* Get rid of usbd_get_device_strings() because we use it only once.mpi2016-05-231-24/+20
| | | | | | Return a char * rather using a void function for usbd_get_device_string() ok patrick@
* Free the cache if the string cannot be retrieved. This allows thepatrick2016-05-211-3/+7
| | | | | | | fallback method to actually do its work and look up the strings via the vendor and product id. Regression noticed and ok tb@, ok mpi@
* Cache vendor, product and serial info for each usb device. This allowspatrick2016-05-181-4/+46
| | | | | | | | | | | ioctl(USB_DEVICEINFO) not to issue any further requests to gather information. Thus reducing stress on connected usb devices. This fixes an issue where usbdevs called in a loop causes a USB mass storage device to halt operation. Adapted from a similar commit in NetBSD. ok mpi@
* Convert uiomovei to uiomove. Fixes a few integer truncations along thestefan2016-03-031-5/+5
| | | | | | way. ok natano@
* Prevent a NULL dereference when detaching a USB device with ugen(4)mpi2016-01-141-3/+5
| | | | | | | | disabled or if allocating memory during the attachment process failed. Problem reported by and original diff from James Hastings on bugs@. ok deraadt@
* Wait a short while between setting a USB device's address and reloadingstsp2015-10-241-1/+4
| | | | | | its descriptor. Fixes flaky attach of USB devices (most importantly the detachable keyboard) on the Thinkpad Helix 2, and perhaps elsewhere. Problem diagnosed by mpi; ok mpi@
* Return an error if getting the config descriptor failed.jsg2015-03-231-1/+3
| | | | | | Avoids a NULL dereference encountered with a device I have. ok mpi@
* Always clear a port reset feature after setting it, or at least try to.mpi2014-12-211-18/+17
| | | | | | Otherwise we might leave a port in an unwanted state. Found while investigating timeout issues on xhci(4).
* yet more mallocarray() changes.doug2014-12-131-4/+5
| | | | ok tedu@ deraadt@
* More malloc() -> mallocarray() in the kernel.doug2014-12-091-4/+4
| | | | ok deraadt@ tedu@
* Remove USB locators. They are currently unused and this wont change duempi2014-11-101-45/+4
| | | | to the way USB buses are discovered.
* Remove the port status argument from usbd_reset_port(). We don't dompi2014-11-011-21/+18
| | | | | anything with it and it simplifies this mess in order to implement warm reset.
* Use usbd_set_port_feature() instead of rerolling it.mpi2014-11-011-15/+3
|
* Do not re-establish the default pipe twice for every controller. Movempi2014-10-051-24/+4
| | | | | | this hack in the drivers that need it. Tested by many, thanks! ok pirofti@, kettenis@
* Check that the speed of a new device does not exceed its parent's speedmpi2014-10-011-12/+1
| | | | | | | | | prior to calling usbd_new_device(). This will let us set the specified default Max Packet Size before opening the control pipe and reduces spaghetti! ok stsp@
* Do not allocate space for the whole structure when we just want to storempi2014-08-101-3/+2
| | | | a pointer, found by clang.
* Do not store the whole USB hub descriptor in the "struct usbd_hub"mpi2014-08-091-5/+4
| | | | to help integrating super speed hubs that use a different descriptor.
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-17/+17
| | | | after discussions with beck deraadt kettenis.