diff --git a/drivers/usb/udc/udc_common.c b/drivers/usb/udc/udc_common.c index 9ecaa8b99be..6147167baee 100644 --- a/drivers/usb/udc/udc_common.c +++ b/drivers/usb/udc/udc_common.c @@ -83,27 +83,16 @@ int udc_register_ep(const struct device *dev, struct udc_ep_config *const cfg) return 0; } -struct net_buf *udc_buf_get(const struct device *dev, const uint8_t ep, - const bool pending) +struct net_buf *udc_buf_get(const struct device *dev, const uint8_t ep) { struct udc_ep_config *ep_cfg; - struct net_buf *buf; ep_cfg = udc_get_ep_cfg(dev, ep); if (ep_cfg == NULL) { return NULL; } - buf = net_buf_get(&ep_cfg->fifo, K_NO_WAIT); - if (buf != NULL) { - ep_cfg->stat.pending = 0; - } else { - if (pending) { - ep_cfg->stat.pending = 1; - } - } - - return buf; + return net_buf_get(&ep_cfg->fifo, K_NO_WAIT); } struct net_buf *udc_buf_get_all(const struct device *dev, const uint8_t ep) @@ -133,28 +122,16 @@ struct net_buf *udc_buf_get_all(const struct device *dev, const uint8_t ep) return buf; } -struct net_buf *udc_buf_peek(const struct device *dev, const uint8_t ep, - const bool pending) +struct net_buf *udc_buf_peek(const struct device *dev, const uint8_t ep) { struct udc_ep_config *ep_cfg; - struct net_buf *buf = NULL; ep_cfg = udc_get_ep_cfg(dev, ep); if (ep_cfg == NULL) { return NULL; } - buf = k_fifo_peek_head(&ep_cfg->fifo); - if (buf == NULL && pending) { - ep_cfg->stat.pending = 1; - } - - if (buf != NULL) { - ep_cfg->stat.pending = 0; - } - - - return buf; + return k_fifo_peek_head(&ep_cfg->fifo); } void udc_buf_put(struct udc_ep_config *const ep_cfg, @@ -361,7 +338,6 @@ int udc_ep_enable_internal(const struct device *dev, cfg->stat.odd = 0; cfg->stat.halted = 0; - cfg->stat.pending = 0; cfg->stat.data1 = false; ret = api->ep_enable(dev, cfg); cfg->stat.enabled = ret ? false : true; diff --git a/drivers/usb/udc/udc_common.h b/drivers/usb/udc/udc_common.h index 2807e60250d..5f0a20a8cd1 100644 --- a/drivers/usb/udc/udc_common.h +++ b/drivers/usb/udc/udc_common.h @@ -87,13 +87,11 @@ void udc_ep_set_busy(const struct device *dev, const uint8_t ep, * * @param[in] dev Pointer to device struct of the driver instance * @param[in] ep Endpoint representation structure - * @param[in] pending Mark endpoint pending if there is no request in the FIFO * * @return pointer to UDC request or NULL on error. */ struct net_buf *udc_buf_get(const struct device *dev, - const uint8_t ep, - const bool pending); + const uint8_t ep); /** * @brief Get all UDC request from endpoint FIFO. @@ -118,13 +116,11 @@ struct net_buf *udc_buf_get_all(const struct device *dev, * * @param[in] dev Pointer to device struct of the driver instance * @param[in] ep Endpoint representation structure - * @param[in] pending Mark endpoint pending if there is no request in the FIFO * * @return pointer to request or NULL on error. */ struct net_buf *udc_buf_peek(const struct device *dev, - const uint8_t ep, - const bool pending); + const uint8_t ep); /** * @brief Put request at the tail of endpoint FIFO. diff --git a/drivers/usb/udc/udc_kinetis.c b/drivers/usb/udc/udc_kinetis.c index b1d9bbdd6c9..aa94222e387 100644 --- a/drivers/usb/udc/udc_kinetis.c +++ b/drivers/usb/udc/udc_kinetis.c @@ -181,7 +181,7 @@ static int usbfsotg_xfer_start(const struct device *dev, uint8_t *data_ptr; size_t len; - buf = udc_buf_peek(dev, cfg->addr, true); + buf = udc_buf_peek(dev, cfg->addr); if (buf == NULL) { return -ENODATA; } @@ -301,7 +301,7 @@ static inline int work_handler_setup(const struct device *dev) struct net_buf *buf; int err; - buf = udc_buf_get(dev, USB_CONTROL_EP_OUT, true); + buf = udc_buf_get(dev, USB_CONTROL_EP_OUT); if (buf == NULL) { return -ENODATA; } @@ -354,7 +354,7 @@ static inline int work_handler_out(const struct device *dev, struct net_buf *buf; int err = 0; - buf = udc_buf_get(dev, ep, true); + buf = udc_buf_get(dev, ep); if (buf == NULL) { return -ENODATA; } @@ -392,7 +392,7 @@ static inline int work_handler_in(const struct device *dev, { struct net_buf *buf; - buf = udc_buf_get(dev, ep, true); + buf = udc_buf_get(dev, ep); if (buf == NULL) { return -ENODATA; } @@ -562,7 +562,7 @@ static ALWAYS_INLINE void isr_handle_xfer_done(const struct device *dev, priv->busy[odd] = false; priv->out_buf[odd] = NULL; } else { - buf = udc_buf_peek(dev, ep_cfg->addr, true); + buf = udc_buf_peek(dev, ep_cfg->addr); } if (buf == NULL) { @@ -591,7 +591,7 @@ static ALWAYS_INLINE void isr_handle_xfer_done(const struct device *dev, ep_cfg->stat.odd = !odd; ep_cfg->stat.data1 = !data1; - buf = udc_buf_peek(dev, ep_cfg->addr, true); + buf = udc_buf_peek(dev, ep_cfg->addr); if (buf == NULL) { LOG_ERR("No buffer for ep 0x%02x", ep); udc_submit_event(dev, UDC_EVT_ERROR, -ENOBUFS, NULL); diff --git a/drivers/usb/udc/udc_nrf.c b/drivers/usb/udc/udc_nrf.c index cb9e8f841e3..e39dfd1a72d 100644 --- a/drivers/usb/udc/udc_nrf.c +++ b/drivers/usb/udc/udc_nrf.c @@ -92,7 +92,7 @@ static void udc_event_xfer_in_next(const struct device *dev, const uint8_t ep) return; } - buf = udc_buf_peek(dev, ep, false); + buf = udc_buf_peek(dev, ep); if (buf != NULL) { nrfx_usbd_transfer_t xfer = { .p_data = {.tx = buf->data}, @@ -142,7 +142,7 @@ static void udc_event_fake_status_in(const struct device *dev) { struct net_buf *buf; - buf = udc_buf_get(dev, USB_CONTROL_EP_IN, true); + buf = udc_buf_get(dev, USB_CONTROL_EP_IN); if (unlikely(buf == NULL)) { LOG_DBG("ep 0x%02x queue is empty", USB_CONTROL_EP_IN); return; @@ -160,7 +160,7 @@ static void udc_event_xfer_in(const struct device *dev, switch (event->data.eptransfer.status) { case NRFX_USBD_EP_OK: - buf = udc_buf_get(dev, ep, true); + buf = udc_buf_get(dev, ep); if (buf == NULL) { LOG_ERR("ep 0x%02x queue is empty", ep); __ASSERT_NO_MSG(false); @@ -221,7 +221,7 @@ static void udc_event_xfer_out_next(const struct device *dev, const uint8_t ep) return; } - buf = udc_buf_peek(dev, ep, true); + buf = udc_buf_peek(dev, ep); if (buf != NULL) { nrfx_usbd_transfer_t xfer = { .p_data = {.rx = buf->data}, @@ -266,7 +266,7 @@ static void udc_event_xfer_out(const struct device *dev, LOG_ERR("OUT transfer failed %d", err_code); } - buf = udc_buf_get(dev, ep, true); + buf = udc_buf_get(dev, ep); if (buf == NULL) { LOG_ERR("ep 0x%02x ok, queue is empty", ep); return; diff --git a/include/zephyr/drivers/usb/udc.h b/include/zephyr/drivers/usb/udc.h index 0f87f357748..3de0689de9e 100644 --- a/include/zephyr/drivers/usb/udc.h +++ b/include/zephyr/drivers/usb/udc.h @@ -74,8 +74,6 @@ struct udc_ep_stat { uint32_t enabled : 1; /** Endpoint is halted (returning STALL PID) */ uint32_t halted : 1; - /** Endpoint transfer (usually OUT) is pending for a request */ - uint32_t pending : 1; /** Last submitted PID is DATA1 */ uint32_t data1 : 1; /** If double buffering is supported, last used buffer is odd */