@@ -49,7 +49,7 @@ LOG_MODULE_REGISTER(usbd_cdc_acm, CONFIG_USBD_CDC_ACM_LOG_LEVEL);
4949#define CDC_ACM_TX_FIFO_BUSY 5
5050
5151struct cdc_acm_uart_fifo {
52- struct ring_buf * rb ;
52+ struct ring_buffer * rb ;
5353 bool irq ;
5454 bool altered ;
5555};
@@ -309,7 +309,7 @@ static int usbd_cdc_acm_request(struct usbd_class_data *const c_data,
309309 size_t done ;
310310
311311 LOG_HEXDUMP_INF (buf -> data , buf -> len , "" );
312- done = ring_buf_put (data -> rx_fifo .rb , buf -> data , buf -> len );
312+ done = ring_buffer_write (data -> rx_fifo .rb , buf -> data , buf -> len );
313313 if (done && data -> cb ) {
314314 cdc_acm_work_submit (& data -> irq_cb_work );
315315 }
@@ -326,7 +326,7 @@ static int usbd_cdc_acm_request(struct usbd_class_data *const c_data,
326326
327327 atomic_clear_bit (& data -> state , CDC_ACM_TX_FIFO_BUSY );
328328
329- if (!ring_buf_is_empty (data -> tx_fifo .rb )) {
329+ if (!ring_buffer_empty (data -> tx_fifo .rb )) {
330330 /* Queue pending TX data on IN endpoint */
331331 cdc_acm_work_schedule (& data -> tx_fifo_work , K_NO_WAIT );
332332 }
@@ -361,7 +361,7 @@ static void usbd_cdc_acm_enable(struct usbd_class_data *const c_data)
361361 }
362362
363363 if (atomic_test_bit (& data -> state , CDC_ACM_IRQ_TX_ENABLED )) {
364- if (ring_buf_space_get (data -> tx_fifo .rb )) {
364+ if (ring_buffer_space (data -> tx_fifo .rb )) {
365365 /* Raise TX ready interrupt */
366366 cdc_acm_work_submit (& data -> irq_cb_work );
367367 } else {
@@ -658,7 +658,7 @@ static void cdc_acm_tx_fifo_handler(struct k_work *work)
658658 return ;
659659 }
660660
661- len = ring_buf_get (data -> tx_fifo .rb , buf -> data , buf -> size );
661+ len = ring_buffer_read (data -> tx_fifo .rb , buf -> data , buf -> size );
662662 net_buf_add (buf , len );
663663
664664 data -> zlp_needed = len != 0 && len % cdc_acm_get_bulk_mps (c_data ) == 0 ;
@@ -697,7 +697,7 @@ static void cdc_acm_rx_fifo_handler(struct k_work *work)
697697 return ;
698698 }
699699
700- if (ring_buf_space_get (data -> rx_fifo .rb ) < cdc_acm_get_bulk_mps (c_data )) {
700+ if (ring_buffer_space (data -> rx_fifo .rb ) < cdc_acm_get_bulk_mps (c_data )) {
701701 LOG_INF ("RX buffer to small, throttle" );
702702 return ;
703703 }
@@ -729,7 +729,7 @@ static void cdc_acm_irq_tx_enable(const struct device *dev)
729729
730730 atomic_set_bit (& data -> state , CDC_ACM_IRQ_TX_ENABLED );
731731
732- if (ring_buf_space_get (data -> tx_fifo .rb )) {
732+ if (ring_buffer_space (data -> tx_fifo .rb )) {
733733 LOG_INF ("tx_en: trigger irq_cb_work" );
734734 cdc_acm_work_submit (& data -> irq_cb_work );
735735 }
@@ -749,7 +749,7 @@ static void cdc_acm_irq_rx_enable(const struct device *dev)
749749 atomic_set_bit (& data -> state , CDC_ACM_IRQ_RX_ENABLED );
750750
751751 /* Permit buffer to be drained regardless of USB state */
752- if (!ring_buf_is_empty (data -> rx_fifo .rb )) {
752+ if (!ring_buffer_empty (data -> rx_fifo .rb )) {
753753 LOG_INF ("rx_en: trigger irq_cb_work" );
754754 cdc_acm_work_submit (& data -> irq_cb_work );
755755 }
@@ -782,14 +782,14 @@ static int cdc_acm_fifo_fill(const struct device *dev,
782782 }
783783
784784 key = k_spin_lock (& data -> lock );
785- done = ring_buf_put (data -> tx_fifo .rb , tx_data , len );
785+ done = ring_buffer_write (data -> tx_fifo .rb , tx_data , len );
786786 k_spin_unlock (& data -> lock , key );
787787 if (done ) {
788788 data -> tx_fifo .altered = true;
789789 }
790790
791791 LOG_INF ("UART dev %p, len %d, remaining space %u" ,
792- dev , len , ring_buf_space_get (data -> tx_fifo .rb ));
792+ dev , len , ring_buffer_space (data -> tx_fifo .rb ));
793793
794794 return done ;
795795}
@@ -802,15 +802,15 @@ static int cdc_acm_fifo_read(const struct device *dev,
802802 uint32_t len ;
803803
804804 LOG_INF ("UART dev %p size %d length %u" ,
805- dev , size , ring_buf_size_get (data -> rx_fifo .rb ));
805+ dev , size , ring_buffer_size (data -> rx_fifo .rb ));
806806
807807 if (!check_wq_ctx (dev )) {
808808 LOG_WRN ("Invoked by inappropriate context" );
809809 __ASSERT_NO_MSG (false);
810810 return 0 ;
811811 }
812812
813- len = ring_buf_get (data -> rx_fifo .rb , rx_data , size );
813+ len = ring_buffer_read (data -> rx_fifo .rb , rx_data , size );
814814 if (len ) {
815815 data -> rx_fifo .altered = true;
816816 }
@@ -824,7 +824,7 @@ static int cdc_acm_irq_tx_ready(const struct device *dev)
824824
825825 if (check_wq_ctx (dev )) {
826826 if (data -> tx_fifo .irq ) {
827- return ring_buf_space_get (data -> tx_fifo .rb );
827+ return ring_buffer_space (data -> tx_fifo .rb );
828828 }
829829 } else {
830830 LOG_WRN ("Invoked by inappropriate context" );
@@ -878,14 +878,14 @@ static int cdc_acm_irq_update(const struct device *dev)
878878 }
879879
880880 if (atomic_test_bit (& data -> state , CDC_ACM_IRQ_RX_ENABLED ) &&
881- !ring_buf_is_empty (data -> rx_fifo .rb )) {
881+ !ring_buffer_empty (data -> rx_fifo .rb )) {
882882 data -> rx_fifo .irq = true;
883883 } else {
884884 data -> rx_fifo .irq = false;
885885 }
886886
887887 if (atomic_test_bit (& data -> state , CDC_ACM_IRQ_TX_ENABLED ) &&
888- ring_buf_space_get (data -> tx_fifo .rb )) {
888+ ring_buffer_space (data -> tx_fifo .rb )) {
889889 data -> tx_fifo .irq = true;
890890 } else {
891891 data -> tx_fifo .irq = false;
@@ -947,13 +947,13 @@ static void cdc_acm_irq_cb_handler(struct k_work *work)
947947 }
948948
949949 if (atomic_test_bit (& data -> state , CDC_ACM_IRQ_RX_ENABLED ) &&
950- !ring_buf_is_empty (data -> rx_fifo .rb )) {
950+ !ring_buffer_empty (data -> rx_fifo .rb )) {
951951 LOG_DBG ("rx irq pending, submit irq_cb_work" );
952952 cdc_acm_work_submit (& data -> irq_cb_work );
953953 }
954954
955955 if (atomic_test_bit (& data -> state , CDC_ACM_IRQ_TX_ENABLED ) &&
956- ring_buf_space_get (data -> tx_fifo .rb )) {
956+ ring_buffer_space (data -> tx_fifo .rb )) {
957957 LOG_DBG ("tx irq pending, submit irq_cb_work" );
958958 cdc_acm_work_submit (& data -> irq_cb_work );
959959 }
@@ -975,11 +975,11 @@ static int cdc_acm_poll_in(const struct device *dev, unsigned char *const c)
975975 uint32_t len ;
976976 int ret = -1 ;
977977
978- if (ring_buf_is_empty (data -> rx_fifo .rb )) {
978+ if (ring_buffer_empty (data -> rx_fifo .rb )) {
979979 return ret ;
980980 }
981981
982- len = ring_buf_get (data -> rx_fifo .rb , c , 1 );
982+ len = ring_buffer_read (data -> rx_fifo .rb , c , 1 );
983983 if (len ) {
984984 cdc_acm_work_submit (& data -> rx_fifo_work );
985985 ret = 0 ;
@@ -996,7 +996,7 @@ static void cdc_acm_poll_out(const struct device *dev, const unsigned char c)
996996
997997 while (true) {
998998 key = k_spin_lock (& data -> lock );
999- wrote = ring_buf_put (data -> tx_fifo .rb , & c , 1 );
999+ wrote = ring_buffer_write (data -> tx_fifo .rb , & c , 1 );
10001000 k_spin_unlock (& data -> lock , key );
10011001
10021002 if (wrote == 1 ) {
@@ -1119,8 +1119,8 @@ static int usbd_cdc_acm_preinit(const struct device *dev)
11191119{
11201120 struct cdc_acm_uart_data * const data = dev -> data ;
11211121
1122- ring_buf_reset (data -> tx_fifo .rb );
1123- ring_buf_reset (data -> rx_fifo .rb );
1122+ ring_buffer_reset (data -> tx_fifo .rb );
1123+ ring_buffer_reset (data -> rx_fifo .rb );
11241124
11251125 k_work_init_delayable (& data -> tx_fifo_work , cdc_acm_tx_fifo_handler );
11261126 k_work_init (& data -> rx_fifo_work , cdc_acm_rx_fifo_handler );
@@ -1350,8 +1350,8 @@ const static struct usb_desc_header *cdc_acm_hs_desc_##n[] = { \
13501350 USBD_DUT_STRING_INTERFACE); \
13511351 )) \
13521352 \
1353- RING_BUF_DECLARE (cdc_acm_rb_rx_##n, DT_INST_PROP(n, rx_fifo_size)); \
1354- RING_BUF_DECLARE (cdc_acm_rb_tx_##n, DT_INST_PROP(n, tx_fifo_size)); \
1353+ RING_BUFFER_DECLARE (cdc_acm_rb_rx_##n, DT_INST_PROP(n, rx_fifo_size)); \
1354+ RING_BUFFER_DECLARE (cdc_acm_rb_tx_##n, DT_INST_PROP(n, tx_fifo_size)); \
13551355 \
13561356 static const struct cdc_acm_uart_config uart_config_##n = { \
13571357 .c_data = &cdc_acm_##n, \
0 commit comments