Skip to content

Commit 00adb2a

Browse files
jfischer-nocarlescufi
authored andcommitted
drivers: udc: remove no more required pending state flag
Pending state flag was only used by the UDC nRF USBD driver. With the introduction of busy state flag it is no longer needed and can be removed. Signed-off-by: Johann Fischer <[email protected]>
1 parent a033784 commit 00adb2a

File tree

5 files changed

+17
-47
lines changed

5 files changed

+17
-47
lines changed

drivers/usb/udc/udc_common.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,16 @@ int udc_register_ep(const struct device *dev, struct udc_ep_config *const cfg)
8383
return 0;
8484
}
8585

86-
struct net_buf *udc_buf_get(const struct device *dev, const uint8_t ep,
87-
const bool pending)
86+
struct net_buf *udc_buf_get(const struct device *dev, const uint8_t ep)
8887
{
8988
struct udc_ep_config *ep_cfg;
90-
struct net_buf *buf;
9189

9290
ep_cfg = udc_get_ep_cfg(dev, ep);
9391
if (ep_cfg == NULL) {
9492
return NULL;
9593
}
9694

97-
buf = net_buf_get(&ep_cfg->fifo, K_NO_WAIT);
98-
if (buf != NULL) {
99-
ep_cfg->stat.pending = 0;
100-
} else {
101-
if (pending) {
102-
ep_cfg->stat.pending = 1;
103-
}
104-
}
105-
106-
return buf;
95+
return net_buf_get(&ep_cfg->fifo, K_NO_WAIT);
10796
}
10897

10998
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)
133122
return buf;
134123
}
135124

136-
struct net_buf *udc_buf_peek(const struct device *dev, const uint8_t ep,
137-
const bool pending)
125+
struct net_buf *udc_buf_peek(const struct device *dev, const uint8_t ep)
138126
{
139127
struct udc_ep_config *ep_cfg;
140-
struct net_buf *buf = NULL;
141128

142129
ep_cfg = udc_get_ep_cfg(dev, ep);
143130
if (ep_cfg == NULL) {
144131
return NULL;
145132
}
146133

147-
buf = k_fifo_peek_head(&ep_cfg->fifo);
148-
if (buf == NULL && pending) {
149-
ep_cfg->stat.pending = 1;
150-
}
151-
152-
if (buf != NULL) {
153-
ep_cfg->stat.pending = 0;
154-
}
155-
156-
157-
return buf;
134+
return k_fifo_peek_head(&ep_cfg->fifo);
158135
}
159136

160137
void udc_buf_put(struct udc_ep_config *const ep_cfg,
@@ -361,7 +338,6 @@ int udc_ep_enable_internal(const struct device *dev,
361338

362339
cfg->stat.odd = 0;
363340
cfg->stat.halted = 0;
364-
cfg->stat.pending = 0;
365341
cfg->stat.data1 = false;
366342
ret = api->ep_enable(dev, cfg);
367343
cfg->stat.enabled = ret ? false : true;

drivers/usb/udc/udc_common.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ void udc_ep_set_busy(const struct device *dev, const uint8_t ep,
8787
*
8888
* @param[in] dev Pointer to device struct of the driver instance
8989
* @param[in] ep Endpoint representation structure
90-
* @param[in] pending Mark endpoint pending if there is no request in the FIFO
9190
*
9291
* @return pointer to UDC request or NULL on error.
9392
*/
9493
struct net_buf *udc_buf_get(const struct device *dev,
95-
const uint8_t ep,
96-
const bool pending);
94+
const uint8_t ep);
9795

9896
/**
9997
* @brief Get all UDC request from endpoint FIFO.
@@ -118,13 +116,11 @@ struct net_buf *udc_buf_get_all(const struct device *dev,
118116
*
119117
* @param[in] dev Pointer to device struct of the driver instance
120118
* @param[in] ep Endpoint representation structure
121-
* @param[in] pending Mark endpoint pending if there is no request in the FIFO
122119
*
123120
* @return pointer to request or NULL on error.
124121
*/
125122
struct net_buf *udc_buf_peek(const struct device *dev,
126-
const uint8_t ep,
127-
const bool pending);
123+
const uint8_t ep);
128124

129125
/**
130126
* @brief Put request at the tail of endpoint FIFO.

drivers/usb/udc/udc_kinetis.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int usbfsotg_xfer_start(const struct device *dev,
181181
uint8_t *data_ptr;
182182
size_t len;
183183

184-
buf = udc_buf_peek(dev, cfg->addr, true);
184+
buf = udc_buf_peek(dev, cfg->addr);
185185
if (buf == NULL) {
186186
return -ENODATA;
187187
}
@@ -301,7 +301,7 @@ static inline int work_handler_setup(const struct device *dev)
301301
struct net_buf *buf;
302302
int err;
303303

304-
buf = udc_buf_get(dev, USB_CONTROL_EP_OUT, true);
304+
buf = udc_buf_get(dev, USB_CONTROL_EP_OUT);
305305
if (buf == NULL) {
306306
return -ENODATA;
307307
}
@@ -354,7 +354,7 @@ static inline int work_handler_out(const struct device *dev,
354354
struct net_buf *buf;
355355
int err = 0;
356356

357-
buf = udc_buf_get(dev, ep, true);
357+
buf = udc_buf_get(dev, ep);
358358
if (buf == NULL) {
359359
return -ENODATA;
360360
}
@@ -392,7 +392,7 @@ static inline int work_handler_in(const struct device *dev,
392392
{
393393
struct net_buf *buf;
394394

395-
buf = udc_buf_get(dev, ep, true);
395+
buf = udc_buf_get(dev, ep);
396396
if (buf == NULL) {
397397
return -ENODATA;
398398
}
@@ -562,7 +562,7 @@ static ALWAYS_INLINE void isr_handle_xfer_done(const struct device *dev,
562562
priv->busy[odd] = false;
563563
priv->out_buf[odd] = NULL;
564564
} else {
565-
buf = udc_buf_peek(dev, ep_cfg->addr, true);
565+
buf = udc_buf_peek(dev, ep_cfg->addr);
566566
}
567567

568568
if (buf == NULL) {
@@ -591,7 +591,7 @@ static ALWAYS_INLINE void isr_handle_xfer_done(const struct device *dev,
591591
ep_cfg->stat.odd = !odd;
592592
ep_cfg->stat.data1 = !data1;
593593

594-
buf = udc_buf_peek(dev, ep_cfg->addr, true);
594+
buf = udc_buf_peek(dev, ep_cfg->addr);
595595
if (buf == NULL) {
596596
LOG_ERR("No buffer for ep 0x%02x", ep);
597597
udc_submit_event(dev, UDC_EVT_ERROR, -ENOBUFS, NULL);

drivers/usb/udc/udc_nrf.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void udc_event_xfer_in_next(const struct device *dev, const uint8_t ep)
9292
return;
9393
}
9494

95-
buf = udc_buf_peek(dev, ep, false);
95+
buf = udc_buf_peek(dev, ep);
9696
if (buf != NULL) {
9797
nrfx_usbd_transfer_t xfer = {
9898
.p_data = {.tx = buf->data},
@@ -142,7 +142,7 @@ static void udc_event_fake_status_in(const struct device *dev)
142142
{
143143
struct net_buf *buf;
144144

145-
buf = udc_buf_get(dev, USB_CONTROL_EP_IN, true);
145+
buf = udc_buf_get(dev, USB_CONTROL_EP_IN);
146146
if (unlikely(buf == NULL)) {
147147
LOG_DBG("ep 0x%02x queue is empty", USB_CONTROL_EP_IN);
148148
return;
@@ -160,7 +160,7 @@ static void udc_event_xfer_in(const struct device *dev,
160160

161161
switch (event->data.eptransfer.status) {
162162
case NRFX_USBD_EP_OK:
163-
buf = udc_buf_get(dev, ep, true);
163+
buf = udc_buf_get(dev, ep);
164164
if (buf == NULL) {
165165
LOG_ERR("ep 0x%02x queue is empty", ep);
166166
__ASSERT_NO_MSG(false);
@@ -221,7 +221,7 @@ static void udc_event_xfer_out_next(const struct device *dev, const uint8_t ep)
221221
return;
222222
}
223223

224-
buf = udc_buf_peek(dev, ep, true);
224+
buf = udc_buf_peek(dev, ep);
225225
if (buf != NULL) {
226226
nrfx_usbd_transfer_t xfer = {
227227
.p_data = {.rx = buf->data},
@@ -266,7 +266,7 @@ static void udc_event_xfer_out(const struct device *dev,
266266
LOG_ERR("OUT transfer failed %d", err_code);
267267
}
268268

269-
buf = udc_buf_get(dev, ep, true);
269+
buf = udc_buf_get(dev, ep);
270270
if (buf == NULL) {
271271
LOG_ERR("ep 0x%02x ok, queue is empty", ep);
272272
return;

include/zephyr/drivers/usb/udc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ struct udc_ep_stat {
7474
uint32_t enabled : 1;
7575
/** Endpoint is halted (returning STALL PID) */
7676
uint32_t halted : 1;
77-
/** Endpoint transfer (usually OUT) is pending for a request */
78-
uint32_t pending : 1;
7977
/** Last submitted PID is DATA1 */
8078
uint32_t data1 : 1;
8179
/** If double buffering is supported, last used buffer is odd */

0 commit comments

Comments
 (0)