Page MenuHomeFreeBSD

usb: implement attach kernel driver
ClosedPublic

Authored by aokblast on Aug 22 2025, 2:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 15, 8:16 PM
Unknown Object (File)
Tue, Jun 2, 3:35 PM
Unknown Object (File)
May 17 2026, 2:38 PM
Unknown Object (File)
May 17 2026, 2:38 PM
Unknown Object (File)
May 17 2026, 1:13 PM
Unknown Object (File)
May 17 2026, 9:20 AM
Unknown Object (File)
May 17 2026, 9:13 AM
Unknown Object (File)
May 16 2026, 11:49 PM
Subscribers

Details

Summary

FreeBSD's USB framework supports detaching kernel drivers to allow
user space applications to exclusively claim USB interfaces. However,
it lacked support for reattaching the kernel driver afterward.

This commit adds the missing functionality, enabling user space
to return control of the device back to the kernel.

Sponsored by: The FreeBSD Foundation

Test Plan

Tested by usbconfig detach_kernel_driver a keyboard and reattach it.

Diff Detail

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

Event Timeline

I think we also need to update usbconfig(8).

lib/libusb/libusb10.c
1055
lib/libusb/libusb20_ugen20.c
728
sys/dev/usb/usb_ioctl.h
276–277
usr.sbin/usbconfig/usbconfig.c
505
lib/libusb/libusb20.h
249

Minor fixes and add usbcnfig document

sys/dev/usb/usb_device.h
315 ↗(On Diff #160875)

There seems no usb_attach_device() definition? Is the diff of usb_device.c forgot to upload?

sys/dev/usb/usb_device.h
315 ↗(On Diff #160875)

No attach actually, it is called usb_probe_and_attach. I will delete that later.

lib/libusb/libusb.h
211–212

or if you prefer, supports detching with libusb_detach_...() and attaching with libusb_attach_...().

This revision is now accepted and ready to land.Aug 27 2025, 1:26 PM

Oh, it would be better to have the subject like usb: Implement attach kernel driver function or feature or so.

This revision was automatically updated to reflect the committed changes.