Skip to content

Commit b79ffe3

Browse files
jfischer-nofabiobaltieri
authored andcommitted
usb: device: use irq_update in CDC ACM UART implementation
Move the TX/RX ready flag updates into irq_update() where they belong. Signed-off-by: Johann Fischer <[email protected]>
1 parent c5a31ae commit b79ffe3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

subsys/usb/device/class/cdc_acm.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,6 @@ static int cdc_acm_fifo_fill(const struct device *dev,
531531
irq_unlock(lock);
532532
LOG_DBG("Wrote %zu of %d bytes to TX ringbuffer", wrote, len);
533533

534-
if (!ring_buf_space_get(dev_data->tx_ringbuf)) {
535-
dev_data->tx_ready = false;
536-
}
537-
538534
if (wrote) {
539535
k_work_schedule_for_queue(&USB_WORK_Q, &dev_data->tx_work, K_NO_WAIT);
540536
}
@@ -563,10 +559,6 @@ static int cdc_acm_fifo_read(const struct device *dev, uint8_t *rx_data,
563559

564560
len = ring_buf_get(dev_data->rx_ringbuf, rx_data, size);
565561

566-
if (ring_buf_is_empty(dev_data->rx_ringbuf)) {
567-
dev_data->rx_ready = false;
568-
}
569-
570562
if (dev_data->rx_paused == true) {
571563
if (ring_buf_space_get(dev_data->rx_ringbuf) >= CDC_ACM_BUFFER_SIZE) {
572564
struct usb_cfg_data *cfg = (void *)dev->config;
@@ -698,7 +690,15 @@ static int cdc_acm_irq_is_pending(const struct device *dev)
698690
*/
699691
static int cdc_acm_irq_update(const struct device *dev)
700692
{
701-
ARG_UNUSED(dev);
693+
struct cdc_acm_dev_data_t * const dev_data = dev->data;
694+
695+
if (!ring_buf_space_get(dev_data->tx_ringbuf)) {
696+
dev_data->tx_ready = false;
697+
}
698+
699+
if (ring_buf_is_empty(dev_data->rx_ringbuf)) {
700+
dev_data->rx_ready = false;
701+
}
702702

703703
return 1;
704704
}

0 commit comments

Comments
 (0)