drivers: usb_dc_nrfx: Add pre-transfer checks if endpoint is enabled
The shim didn't check if a given endpoint was enabled before requesting the nrfx_usbd driver to perform a read or write operation on it. In certain circumstances this led to nrfx_usbd driver being stuck in a loop waiting for the associated DMA transfer to complete. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
1b3514a07e
commit
6e75d644de
1 changed files with 14 additions and 0 deletions
|
@ -1640,6 +1640,10 @@ int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!ep_ctx->cfg.en) {
|
||||
LOG_ERR("Endpoint 0x%02x is not enabled", ep);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
|
||||
|
||||
|
@ -1723,6 +1727,11 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!ep_ctx->cfg.en) {
|
||||
LOG_ERR("Endpoint 0x%02x is not enabled", ep);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
|
||||
|
||||
bytes_to_copy = MIN(max_data_len, ep_ctx->buf.len);
|
||||
|
@ -1765,6 +1774,11 @@ int usb_dc_ep_read_continue(u8_t ep)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!ep_ctx->cfg.en) {
|
||||
LOG_ERR("Endpoint 0x%02x is not enabled", ep);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
|
||||
if (!ep_ctx->buf.len) {
|
||||
ep_ctx->buf.curr = ep_ctx->buf.data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue