Skip to content

usb.core.Device.detach_kernel_driver() could unbind TinyUSB class drivers #10620

@samblenny

Description

@samblenny

The current implementation of usb.core.Device.detach_kernel_driver() looks like this:

void common_hal_usb_core_device_detach_kernel_driver(usb_core_device_obj_t *self, mp_int_t interface) {
    #if CIRCUITPY_USB_KEYBOARD_WORKFLOW
    usb_keyboard_detach(self->device_address, interface);
    #endif
}

So, it's only aware of the possibility of the CircuitPython core having claimed keyboards.

For better compatibility with desktop PyUSB, the detach implementation could be extended to unbind TinyUSB class drivers. For more about TinyUSB class driver binding, check out the enum_parse_configuration_desc() implementation in tinyusb/src/host/usbh.c.

It's not clear to me at the moment whether TinyUSB provides a way to unbind drivers independently of removing a device. See process_removed_device() implementation in usbh.c for how undbinding works during device removal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions