drivers: udc: move transfer status to buffer info structure

This allows us to get the result of synchronous transfer without
any hacks, just from the net_buf structure.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2023-03-06 13:56:51 +01:00 committed by Carles Cufí
parent 39218112ab
commit ad81b3b797
4 changed files with 8 additions and 5 deletions

View File

@ -187,6 +187,7 @@ int udc_submit_ep_event(const struct device *dev,
struct net_buf *const buf,
const int err)
{
struct udc_buf_info *bi = udc_get_buf_info(buf);
struct udc_data *data = dev->data;
const struct udc_event drv_evt = {
.type = UDC_EVT_EP_REQUEST,
@ -199,6 +200,8 @@ int udc_submit_ep_event(const struct device *dev,
return -EPERM;
}
bi->err = err;
return data->event_cb(dev, &drv_evt);
}

View File

@ -191,6 +191,8 @@ struct udc_buf_info {
unsigned int queued : 1;
/** Transfer owner (usually pointer to a class instance) */
void *owner;
/** Transfer result, 0 on success, other values on error */
int err;
} __packed;
/**

View File

@ -43,11 +43,9 @@ static int event_handler_ep_request(struct usbd_contex *const uds_ctx,
bi = udc_get_buf_info(event->buf);
if (USB_EP_GET_IDX(bi->ep) == 0) {
ret = usbd_handle_ctrl_xfer(uds_ctx, event->buf,
event->status);
ret = usbd_handle_ctrl_xfer(uds_ctx, event->buf, bi->err);
} else {
ret = usbd_class_handle_xfer(uds_ctx, event->buf,
event->status);
ret = usbd_class_handle_xfer(uds_ctx, event->buf, bi->err);
}
if (ret) {

View File

@ -41,7 +41,7 @@ static void event_ep_request(const struct device *dev, struct udc_event event)
err = udc_ep_buf_free(dev, event.buf);
zassert_ok(err, "Failed to free request buffer");
if (event.status == -ECONNABORTED && bi->ep == last_used_ep) {
if (bi->err == -ECONNABORTED && bi->ep == last_used_ep) {
k_sem_give(&ep_queue_sem);
}
}