Skip to content

Commit 096458d

Browse files
authored
Merge pull request #3569 from hathach/revert-3565-driver-init
Revert "Make driver init() function optional"
2 parents 4349474 + d8994a3 commit 096458d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

docs/reference/architecture.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ Class Driver Interface
189189
See ``usbd.c``.
190190

191191
**Required Functions**:
192+
- ``init()``: Initialize class driver
192193
- ``reset()``: Reset class state
193194
- ``open()``: Configure class endpoints
194195
- ``control_xfer_cb()``: Handle control requests
195196
- ``xfer_cb()``: Handle data transfer completion
196197

197198
**Optional Functions**:
198-
- ``init()``: Initialize class driver
199199
- ``close()``: Clean up class resources
200200
- ``deinit()``: Deinitialize class driver
201201
- ``sof()``: Start-of-frame processing

src/device/usbd.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,9 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
572572
// Init class drivers
573573
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
574574
usbd_class_driver_t const* driver = get_driver(i);
575-
if (driver && driver->init) {
576-
TU_LOG_USBD("%s init\r\n", driver->name);
577-
driver->init();
578-
}
575+
TU_ASSERT(driver && driver->init);
576+
TU_LOG_USBD("%s init\r\n", driver->name);
577+
driver->init();
579578
}
580579

581580
_usbd_rhport = rhport;

src/host/usbh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
544544
// Class drivers
545545
for (uint8_t drv_id = 0; drv_id < TOTAL_DRIVER_COUNT; drv_id++) {
546546
usbh_class_driver_t const* driver = get_driver(drv_id);
547-
if (driver && driver->init) {
547+
if (driver != NULL) {
548548
TU_LOG_USBH("%s init\r\n", driver->name);
549549
driver->init();
550550
}

0 commit comments

Comments
 (0)