diff options
| author | Ha Thach <[email protected]> | 2026-03-23 12:51:22 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-23 12:51:22 +0700 |
| commit | 096458defffe3ca183169f9e2116c322074f4b1e (patch) | |
| tree | 849234944fd5861e255400bdf3882b0b2cb35bed | |
| parent | 434947495ca2ff418aa2ad2db889fb34294defb2 (diff) | |
| parent | d8994a3018118136837e18895955e6ddbb89a5ec (diff) | |
Merge pull request #3569 from hathach/revert-3565-driver-init
Revert "Make driver init() function optional"
| -rw-r--r-- | docs/reference/architecture.rst | 2 | ||||
| -rw-r--r-- | src/device/usbd.c | 7 | ||||
| -rw-r--r-- | src/host/usbh.c | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/docs/reference/architecture.rst b/docs/reference/architecture.rst index 523e1d615..70ea17ed4 100644 --- a/docs/reference/architecture.rst +++ b/docs/reference/architecture.rst @@ -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 diff --git a/src/device/usbd.c b/src/device/usbd.c index c7f511eac..42903576c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -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; diff --git a/src/host/usbh.c b/src/host/usbh.c index f65a3a427..75df6bf60 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -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(); } |
