Merge pull request #3569 from hathach/revert-3565-driver-init

Revert "Make driver init() function optional"
This commit is contained in:
Ha Thach
2026-03-23 12:51:22 +07:00
committed by GitHub
3 changed files with 5 additions and 6 deletions

View File

@ -189,13 +189,13 @@ Class Driver Interface
See ``usbd.c``.
**Required Functions**:
- ``init()``: Initialize class driver
- ``reset()``: Reset class state
- ``open()``: Configure class endpoints
- ``control_xfer_cb()``: Handle control requests
- ``xfer_cb()``: Handle data transfer completion
**Optional Functions**:
- ``init()``: Initialize class driver
- ``close()``: Clean up class resources
- ``deinit()``: Deinitialize class driver
- ``sof()``: Start-of-frame processing

View File

@ -572,10 +572,9 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
// Init class drivers
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
usbd_class_driver_t const* driver = get_driver(i);
if (driver && driver->init) {
TU_LOG_USBD("%s init\r\n", driver->name);
driver->init();
}
TU_ASSERT(driver && driver->init);
TU_LOG_USBD("%s init\r\n", driver->name);
driver->init();
}
_usbd_rhport = rhport;

View File

@ -544,7 +544,7 @@ bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
// Class drivers
for (uint8_t drv_id = 0; drv_id < TOTAL_DRIVER_COUNT; drv_id++) {
usbh_class_driver_t const* driver = get_driver(drv_id);
if (driver && driver->init) {
if (driver != NULL) {
TU_LOG_USBH("%s init\r\n", driver->name);
driver->init();
}