Skip to content

Commit 16bcaed

Browse files
jfischer-norlubos
authored andcommitted
[nrf fromtree] drivers: udc_nrf: fix enqueue of control IN transfer with length 0
If the direction of the last setup packet is not to the device but to the host, then the transfer is not a status stage and should be queued. This is not checked and prevents a zero length control IN transfer to the host, e.g. used by the DFU class to indicate the end of the upload process. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit 973f914)
1 parent a2b2330 commit 16bcaed

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/usb/udc/udc_nrf.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ static void udc_nrf_power_handler(nrfx_power_usb_evt_t pwr_evt)
561561
}
562562
}
563563

564-
static void udc_nrf_fake_status_in(const struct device *dev)
564+
static bool udc_nrf_fake_status_in(const struct device *dev)
565565
{
566566
struct udc_nrf_evt evt = {
567567
.type = UDC_NRF_EVT_STATUS_IN,
@@ -572,7 +572,10 @@ static void udc_nrf_fake_status_in(const struct device *dev)
572572
udc_nrf_fake_setup) {
573573
/* Let controller perform status IN stage */
574574
k_msgq_put(&drv_msgq, &evt, K_NO_WAIT);
575+
return true;
575576
}
577+
578+
return false;
576579
}
577580

578581
static int udc_nrf_ep_enqueue(const struct device *dev,
@@ -587,8 +590,9 @@ static int udc_nrf_ep_enqueue(const struct device *dev,
587590
udc_buf_put(cfg, buf);
588591

589592
if (cfg->addr == USB_CONTROL_EP_IN && buf->len == 0) {
590-
udc_nrf_fake_status_in(dev);
591-
return 0;
593+
if (udc_nrf_fake_status_in(dev)) {
594+
return 0;
595+
}
592596
}
593597

594598
k_msgq_put(&drv_msgq, &evt, K_NO_WAIT);

0 commit comments

Comments
 (0)