Page MenuHomeFreeBSD

usb: preserve error when doing request
ClosedPublic

Authored by aokblast on Aug 29 2025, 5:25 PM.
Tags
None
Referenced Files
F163763694: D52244.id179606.diff
Sat, Jul 25, 9:37 PM
F163719196: D52244.id161202.diff
Sat, Jul 25, 4:26 PM
F163703289: D52244.id179606.diff
Sat, Jul 25, 2:21 PM
F163696763: D52244.id161202.diff
Sat, Jul 25, 1:25 PM
Unknown Object (File)
Sat, Jul 25, 2:42 AM
Unknown Object (File)
Thu, Jul 23, 7:48 PM
Unknown Object (File)
Mon, Jul 20, 7:41 AM
Unknown Object (File)
Sat, Jul 18, 5:09 PM

Details

Summary

Currently, USB request not distinguished different error and always return EIO.
However, some error are recoverable or ignorable in userspace.
Therefore, we preserve the meaning of different error to userspace then
allow userspace to decide how to use the return error.

For example, when host required a vendor defined descriptor but the device refused to do so. According to the XHCI protocol. it should return USB_ERR_STALLED. And this kind of error is definitely ignorable.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans added inline comments.
lib/libusb/libusb10_io.c
539–540

This seems to have accidentally conflated error namespaces, which would have coincidentally worked since the values are the same here.

541

Not strictly necessary, but IMO nice to call it out as a reminder. I'd maybe pair it with an explanation at the final return down below of where you might expect err > 0 or an assertion if that just can't happen.

lib/libusb/libusb20_ugen20.c
792

style(9)

sys/dev/usb/usb_generic.c
896–905

Maybe paranoid, but I'd probably recommend:

MPASS(error < nitems(usb_error_to_errno);
adrian added inline comments.
lib/libusb/libusb10_io.c
539–540

are these supposed to be LIBUSB20_ERROR_* errors?

This revision is now accepted and ready to land.Jun 19 2026, 5:09 AM
lib/libusb/libusb10_io.c
539–540

What is it refers to?

This revision was automatically updated to reflect the committed changes.