Skip to content

Commit 8183433

Browse files
committed
fix compile with tud_vendor_control_xfer_cb() and check tud_descriptor_device_cb()
1 parent e92acf0 commit 8183433

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/device/usbd.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,6 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
708708

709709
// Vendor request
710710
if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR ) {
711-
TU_VERIFY(tud_vendor_control_xfer_cb);
712-
713711
usbd_control_set_complete_callback(tud_vendor_control_xfer_cb);
714712
return tud_vendor_control_xfer_cb(rhport, CONTROL_STAGE_SETUP, p_request);
715713
}
@@ -1060,25 +1058,23 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
10601058

10611059
switch(desc_type)
10621060
{
1063-
case TUSB_DESC_DEVICE:
1064-
{
1061+
case TUSB_DESC_DEVICE: {
10651062
TU_LOG_USBD(" Device\r\n");
10661063

10671064
void* desc_device = (void*) (uintptr_t) tud_descriptor_device_cb();
1065+
TU_ASSERT(desc_device);
10681066

10691067
// Only response with exactly 1 Packet if: not addressed and host requested more data than device descriptor has.
10701068
// This only happens with the very first get device descriptor and EP0 size = 8 or 16.
10711069
if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed &&
1072-
((tusb_control_request_t const*) p_request)->wLength > sizeof(tusb_desc_device_t))
1073-
{
1070+
((tusb_control_request_t const*) p_request)->wLength > sizeof(tusb_desc_device_t)) {
10741071
// Hack here: we modify the request length to prevent usbd_control response with zlp
10751072
// since we are responding with 1 packet & less data than wLength.
10761073
tusb_control_request_t mod_request = *p_request;
10771074
mod_request.wLength = CFG_TUD_ENDPOINT0_SIZE;
10781075

10791076
return tud_control_xfer(rhport, &mod_request, desc_device, CFG_TUD_ENDPOINT0_SIZE);
1080-
}else
1081-
{
1077+
}else {
10821078
return tud_control_xfer(rhport, p_request, desc_device, sizeof(tusb_desc_device_t));
10831079
}
10841080
}

0 commit comments

Comments
 (0)