@@ -23,10 +23,8 @@ LOG_MODULE_REGISTER(mock_serial, CONFIG_LOG_DEFAULT_LEVEL);
2323
2424#define DT_DRV_COMPAT vnd_serial
2525struct serial_vnd_data {
26- #ifdef CONFIG_RING_BUFFER
2726 struct ring_buf * written ;
2827 struct ring_buf * read_queue ;
29- #endif
3028 serial_vnd_write_cb_t callback ;
3129 void * callback_data ;
3230#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@@ -49,14 +47,14 @@ static bool is_irq_rx_pending(const struct device *dev)
4947{
5048 struct serial_vnd_data * data = dev -> data ;
5149
52- return !ring_buf_is_empty (data -> read_queue );
50+ return !ring_buffer_empty (data -> read_queue );
5351}
5452
5553static bool is_irq_tx_pending (const struct device * dev )
5654{
5755 struct serial_vnd_data * data = dev -> data ;
5856
59- return ring_buf_space_get (data -> written ) != 0 ;
57+ return ring_buffer_space (data -> written ) != 0 ;
6058}
6159
6260static void irq_process (const struct device * dev )
@@ -105,7 +103,7 @@ static void irq_rx_disable(const struct device *dev)
105103static int irq_rx_ready (const struct device * dev )
106104{
107105 struct serial_vnd_data * data = dev -> data ;
108- bool ready = !ring_buf_is_empty (data -> read_queue );
106+ bool ready = !ring_buffer_empty (data -> read_queue );
109107
110108 LOG_DBG ("rx ready: %d" , ready );
111109 return ready ;
@@ -131,7 +129,7 @@ static void irq_tx_disable(const struct device *dev)
131129static int irq_tx_ready (const struct device * dev )
132130{
133131 struct serial_vnd_data * data = dev -> data ;
134- int available = ring_buf_space_get (data -> written );
132+ int available = ring_buffer_space (data -> written );
135133
136134 LOG_DBG ("tx ready: %d" , available );
137135 return available ;
@@ -163,7 +161,7 @@ static int irq_update(const struct device *dev)
163161static int fifo_fill (const struct device * dev , const uint8_t * tx_data , int size )
164162{
165163 struct serial_vnd_data * data = dev -> data ;
166- uint32_t write_len = ring_buf_put (data -> written , tx_data , size );
164+ uint32_t write_len = ring_buffer_write (data -> written , tx_data , size );
167165
168166 if (data -> callback ) {
169167 data -> callback (dev , data -> callback_data );
@@ -174,7 +172,7 @@ static int fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
174172static int fifo_read (const struct device * dev , uint8_t * rx_data , const int size )
175173{
176174 struct serial_vnd_data * data = dev -> data ;
177- int read_len = ring_buf_get (data -> read_queue , rx_data , size );
175+ int read_len = ring_buffer_read (data -> read_queue , rx_data , size );
178176
179177 LOG_HEXDUMP_DBG (rx_data , read_len , "" );
180178 return read_len ;
@@ -183,33 +181,29 @@ static int fifo_read(const struct device *dev, uint8_t *rx_data, const int size)
183181
184182static int serial_vnd_poll_in (const struct device * dev , unsigned char * c )
185183{
186- #ifdef CONFIG_RING_BUFFER
184+
187185 struct serial_vnd_data * data = dev -> data ;
188186 uint32_t bytes_read ;
189187
190188 if (data == NULL || data -> read_queue == NULL ) {
191189 return - ENOTSUP ;
192190 }
193- bytes_read = ring_buf_get (data -> read_queue , c , 1 );
191+ bytes_read = ring_buffer_read (data -> read_queue , c , 1 );
194192 if (bytes_read == 1 ) {
195193 return 0 ;
196194 }
197195 return -1 ;
198- #else
199- return - ENOTSUP ;
200- #endif
201196}
202197
203198static void serial_vnd_poll_out (const struct device * dev , unsigned char c )
204199{
205200 struct serial_vnd_data * data = dev -> data ;
206201
207- #ifdef CONFIG_RING_BUFFER
208202 if (data == NULL || data -> written == NULL ) {
209203 return ;
210204 }
211- ring_buf_put (data -> written , & c , 1 );
212- #endif
205+ ring_buffer_write (data -> written , & c , 1 );
206+
213207 if (data -> callback ) {
214208 data -> callback (dev , data -> callback_data );
215209 }
@@ -219,7 +213,6 @@ static void serial_vnd_poll_out(const struct device *dev, unsigned char c)
219213static void async_rx_run (const struct device * dev );
220214#endif
221215
222- #ifdef CONFIG_RING_BUFFER
223216int serial_vnd_queue_in_data (const struct device * dev , const unsigned char * c , uint32_t size )
224217{
225218 struct serial_vnd_data * data = dev -> data ;
@@ -228,7 +221,7 @@ int serial_vnd_queue_in_data(const struct device *dev, const unsigned char *c, u
228221 if (data == NULL || data -> read_queue == NULL ) {
229222 return - ENOTSUP ;
230223 }
231- write_size = ring_buf_put (data -> read_queue , c , size );
224+ write_size = ring_buffer_write (data -> read_queue , c , size );
232225
233226 LOG_DBG ("size %u write_size %u" , size , write_size );
234227 LOG_HEXDUMP_DBG (c , write_size , "" );
@@ -253,7 +246,7 @@ uint32_t serial_vnd_out_data_size_get(const struct device *dev)
253246 if (data == NULL || data -> written == NULL ) {
254247 return - ENOTSUP ;
255248 }
256- return ring_buf_size_get (data -> written );
249+ return ring_buffer_size (data -> written );
257250}
258251
259252uint32_t serial_vnd_read_out_data (const struct device * dev , unsigned char * out_data , uint32_t size )
@@ -263,7 +256,7 @@ uint32_t serial_vnd_read_out_data(const struct device *dev, unsigned char *out_d
263256 if (data == NULL || data -> written == NULL ) {
264257 return - ENOTSUP ;
265258 }
266- return ring_buf_get (data -> written , out_data , size );
259+ return ring_buffer_read (data -> written , out_data , size );
267260}
268261
269262uint32_t serial_vnd_peek_out_data (const struct device * dev , unsigned char * out_data , uint32_t size )
@@ -275,7 +268,7 @@ uint32_t serial_vnd_peek_out_data(const struct device *dev, unsigned char *out_d
275268 }
276269 return ring_buf_peek (data -> written , out_data , size );
277270}
278- #endif
271+
279272
280273void serial_vnd_set_callback (const struct device * dev , serial_vnd_write_cb_t callback ,
281274 void * user_data )
@@ -345,7 +338,7 @@ static int serial_vnd_api_tx(const struct device *dev, const uint8_t *tx_data, s
345338 return - EINVAL ;
346339 }
347340
348- write_len = ring_buf_put (data -> written , tx_data , len );
341+ write_len = ring_buffer_write (data -> written , tx_data , len );
349342 if (data -> callback ) {
350343 data -> callback (dev , data -> callback_data );
351344 }
@@ -377,7 +370,7 @@ static void async_rx_run(const struct device *dev)
377370
378371 read_remaining = data -> read_size - data -> read_position ;
379372
380- read_len = ring_buf_get (data -> read_queue , & data -> read_buf [data -> read_position ],
373+ read_len = ring_buffer_read (data -> read_queue , & data -> read_buf [data -> read_position ],
381374 read_remaining );
382375
383376 if (read_len != 0 ) {
@@ -456,8 +449,8 @@ static DEVICE_API(uart, serial_vnd_api) = {
456449};
457450
458451#define VND_SERIAL_DATA_BUFFER (n ) \
459- RING_BUF_DECLARE (written_data_##n, DT_INST_PROP(n, buffer_size)); \
460- RING_BUF_DECLARE (read_queue_##n, DT_INST_PROP(n, buffer_size)); \
452+ RING_BUFFER_DECLARE (written_data_##n, DT_INST_PROP(n, buffer_size)); \
453+ RING_BUFFER_DECLARE (read_queue_##n, DT_INST_PROP(n, buffer_size)); \
461454 static struct serial_vnd_data serial_vnd_data_##n = { \
462455 .written = &written_data_##n, \
463456 .read_queue = &read_queue_##n, \
0 commit comments