From 8a089978e208b9111e224acb5ee1d0a27d308bd1 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sat, 22 Oct 2022 16:11:05 +0300 Subject: [PATCH] KINETIS/LLD/USBHSv1: Fix `USB_USE_WAIT` support The USBHSv1 LLD for KINETIS was checking `epc->in_cb` and `epc->out_cb` to be non-NULL before calling `_usb_isr_invoke_in_cb()` and `_usb_isr_invoke_out_cb()`. This is not correct, because if the `USB_USE_WAIT` option is enabled, those ChibiOS macros do more than just invoking the callback - they also resume the thread that may be waiting for the transfer completion, and omitting the call results in that thread never getting resumed. The macros also perform the same pointer check internally before invoking the callback. Remove the unneeded checks to make the driver work properly with any APIs enabled by `USB_USE_WAIT`. --- os/hal/ports/KINETIS/LLD/USBHSv1/hal_usb_lld.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/os/hal/ports/KINETIS/LLD/USBHSv1/hal_usb_lld.c b/os/hal/ports/KINETIS/LLD/USBHSv1/hal_usb_lld.c index e8838c164c..0fe261c5d0 100644 --- a/os/hal/ports/KINETIS/LLD/USBHSv1/hal_usb_lld.c +++ b/os/hal/ports/KINETIS/LLD/USBHSv1/hal_usb_lld.c @@ -278,8 +278,7 @@ OSAL_IRQ_HANDLER(KINETIS_USB_IRQ_VECTOR) { } else { - if(epc->in_cb != NULL) - _usb_isr_invoke_in_cb(usbp,ep); + _usb_isr_invoke_in_cb(usbp,ep); } } break; case BDT_PID_OUT: // OUT @@ -304,8 +303,7 @@ OSAL_IRQ_HANDLER(KINETIS_USB_IRQ_VECTOR) { has been received or the current packet is a short packet.*/ if ((rxed < epc->out_maxsize) || (epc->out_state->rxpkts == 0)) { - if(epc->out_cb != NULL) - _usb_isr_invoke_out_cb(usbp, ep); + _usb_isr_invoke_out_cb(usbp, ep); } } } break;