Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions drivers/usb/device/usb_dc_numaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static void numaker_usbd_setup_fifo_copy_to_user(const struct device *dev, uint8
*
* size_p holds size to copy/copied on input/output
*/
static int numaker_usbd_ep_fifo_copy_to_user(struct numaker_usbd_ep *ep_cur, uint8_t *usrbuf,
static void numaker_usbd_ep_fifo_copy_to_user(struct numaker_usbd_ep *ep_cur, uint8_t *usrbuf,
uint32_t *size_p)
{
const struct device *dev = ep_cur->dev;
Expand All @@ -528,15 +528,13 @@ static int numaker_usbd_ep_fifo_copy_to_user(struct numaker_usbd_ep *ep_cur, uin
if (ep_cur->read_fifo_used == 0) {
ep_cur->read_fifo_pos = ep_cur->dmabuf_base;
}

return 0;
}

/* Copy data from user buffer to EP FIFO
*
* size_p holds size to copy/copied on input/output
*/
static int numaker_usbd_ep_fifo_copy_from_user(struct numaker_usbd_ep *ep_cur,
static void numaker_usbd_ep_fifo_copy_from_user(struct numaker_usbd_ep *ep_cur,
const uint8_t *usrbuf, uint32_t *size_p)
{
const struct device *dev = ep_cur->dev;
Expand All @@ -562,8 +560,6 @@ static int numaker_usbd_ep_fifo_copy_from_user(struct numaker_usbd_ep *ep_cur,
if (ep_cur->write_fifo_free == 0) {
ep_cur->write_fifo_pos = ep_cur->dmabuf_base;
}

return 0;
}

/* Update EP read/write FIFO on DATA OUT/IN completed */
Expand Down Expand Up @@ -1701,11 +1697,7 @@ int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data_buf, const uint3
/* NOTE: Null data or zero data length are valid, used for ZLP */
if (data_buf && data_len) {
data_len_act = data_len;
rc = numaker_usbd_ep_fifo_copy_from_user(ep_cur, data_buf, &data_len_act);
if (rc < 0) {
LOG_ERR("Copy to FIFO from user buffer");
goto cleanup;
}
numaker_usbd_ep_fifo_copy_from_user(ep_cur, data_buf, &data_len_act);
} else {
data_len_act = 0;
}
Expand Down Expand Up @@ -1813,12 +1805,7 @@ int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data_buf, uint32_t max_data_len, ui
*/
if (data_buf) {
data_len_act = max_data_len;
rc = numaker_usbd_ep_fifo_copy_to_user(ep_cur, data_buf, &data_len_act);
if (rc < 0) {
LOG_ERR("Copy from FIFO to user buffer");
goto cleanup;
}

numaker_usbd_ep_fifo_copy_to_user(ep_cur, data_buf, &data_len_act);
if (read_bytes) {
*read_bytes = data_len_act;
}
Expand Down