Skip to content

Commit 355835d

Browse files
committed
subsys/*: update to new ring_buffer api
Update various subsystems to use the new ring_buffer API. Signed-off-by: Måns Ansgariusson <[email protected]>
1 parent f046ab3 commit 355835d

File tree

8 files changed

+23
-27
lines changed

8 files changed

+23
-27
lines changed

subsys/bluetooth/audio/shell/bap_usb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void usb_data_request(const struct device *dev)
118118
}
119119

120120
/* This may fail without causing issues since usb_audio_data is 0-initialized */
121-
size = ring_buf_get(&usb_in_ring_buf, pcm_buf, USB_STEREO_FRAME_SIZE);
121+
size = ring_buffer_read(&usb_in_ring_buf, pcm_buf, USB_STEREO_FRAME_SIZE);
122122
if (size != USB_STEREO_FRAME_SIZE) {
123123
/* If we could not fill the buffer, zero-fill the rest (possibly all) */
124124
memset(((uint8_t *)pcm_buf) + size, 0, USB_STEREO_FRAME_SIZE - size);
@@ -181,7 +181,7 @@ static void bap_usb_send_frames_to_usb(void)
181181
uint32_t rb_size;
182182

183183
/* Not enough space to store data */
184-
if (ring_buf_space_get(&usb_in_ring_buf) < sizeof(stereo_frame)) {
184+
if (ring_buffer_space(&usb_in_ring_buf) < sizeof(stereo_frame)) {
185185
if ((fail_cnt % bap_get_stats_interval()) == 0U) {
186186
LOG_WRN("[%zu] Could not send more than %zu frames to USB",
187187
fail_cnt, i);
@@ -219,7 +219,7 @@ static void bap_usb_send_frames_to_usb(void)
219219
}
220220
}
221221

222-
rb_size = ring_buf_put(&usb_in_ring_buf, (uint8_t *)stereo_frame,
222+
rb_size = ring_buffer_write(&usb_in_ring_buf, (uint8_t *)stereo_frame,
223223
sizeof(stereo_frame));
224224
if (rb_size != sizeof(stereo_frame)) {
225225
LOG_WRN("Failed to put frame on USB ring buf");

subsys/gnss/rtk/serial/serial.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static uint8_t process_buf[2048];
2424
static void gnss_rtk_process_work_handler(struct k_work *work)
2525
{
2626
static uint8_t work_buf[2048];
27-
uint32_t len = ring_buf_get(&process_ringbuf, work_buf, sizeof(work_buf));
27+
uint32_t len = ring_buffer_read(&process_ringbuf, work_buf, sizeof(work_buf));
2828
uint32_t offset = 0;
2929

3030
ARG_UNUSED(work);
@@ -70,7 +70,7 @@ static void rtk_uart_isr_callback(const struct device *dev, void *user_data)
7070

7171
ret = uart_fifo_read(dev, &c, 1);
7272
if (ret > 0) {
73-
ret = ring_buf_put(&process_ringbuf, &c, 1);
73+
ret = ring_buffer_write(&process_ringbuf, &c, 1);
7474
}
7575
} while (ret > 0);
7676

@@ -86,7 +86,7 @@ static int rtk_serial_client_init(void)
8686
{
8787
int err;
8888

89-
ring_buf_init(&process_ringbuf, ARRAY_SIZE(process_buf), process_buf);
89+
ring_buffer_init(&process_ringbuf, process_buf, ARRAY_SIZE(process_buf));
9090

9191
err = uart_irq_callback_user_data_set(rtk_serial_dev, rtk_uart_isr_callback, NULL);
9292
if (err < 0) {

subsys/mgmt/osdp/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
menuconfig OSDP
88
bool "Open Supervised Device Protocol (OSDP) driver"
9-
select RING_BUFFER
109
imply SERIAL_SUPPORT_INTERRUPT
1110
imply UART_INTERRUPT_DRIVEN
1211
imply UART_USE_RUNTIME_CONFIGURE

subsys/mgmt/osdp/src/osdp.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ static void osdp_handle_in_byte(struct osdp_device *p, uint8_t *buf, int len)
5252
/* Check for new packet beginning with [FF,53,...] sequence */
5353
if (p->last_byte == 0xFF && buf[0] == 0x53) {
5454
buf[0] = 0xFF;
55-
ring_buf_put(&p->rx_buf, buf, 1); /* put last byte */
55+
ring_buffer_write(&p->rx_buf, buf, 1); /* put last byte */
5656
buf[0] = 0x53;
57-
ring_buf_put(&p->rx_buf, buf, len); /* put rest */
57+
ring_buffer_write(&p->rx_buf, buf, len); /* put rest */
5858
p->wait_for_mark = 0; /* Mark found. Clear flag */
5959
}
6060
p->last_byte = buf[0];
6161
return;
6262
}
63-
ring_buf_put(&p->rx_buf, buf, len);
63+
ring_buffer_write(&p->rx_buf, buf, len);
6464
}
6565

6666
static void osdp_uart_isr(const struct device *dev, void *user_data)
@@ -79,7 +79,7 @@ static void osdp_uart_isr(const struct device *dev, void *user_data)
7979
}
8080

8181
if (uart_irq_tx_ready(dev)) {
82-
len = ring_buf_get(&p->tx_buf, buf, 1);
82+
len = ring_buffer_read(&p->tx_buf, buf, 1);
8383
if (!len) {
8484
uart_irq_tx_disable(dev);
8585
} else {
@@ -99,15 +99,15 @@ static int osdp_uart_receive(void *data, uint8_t *buf, int len)
9999
{
100100
struct osdp_device *p = data;
101101

102-
return (int)ring_buf_get(&p->rx_buf, buf, len);
102+
return (int)ring_buffer_read(&p->rx_buf, buf, len);
103103
}
104104

105105
static int osdp_uart_send(void *data, uint8_t *buf, int len)
106106
{
107107
int sent = 0;
108108
struct osdp_device *p = data;
109109

110-
sent = (int)ring_buf_put(&p->tx_buf, buf, len);
110+
sent = (int)ring_buffer_write(&p->tx_buf, buf, len);
111111
uart_irq_tx_enable(p->dev);
112112
return sent;
113113
}
@@ -117,8 +117,8 @@ static void osdp_uart_flush(void *data)
117117
struct osdp_device *p = data;
118118

119119
p->wait_for_mark = 1;
120-
ring_buf_reset(&p->tx_buf);
121-
ring_buf_reset(&p->rx_buf);
120+
ring_buffer_reset(&p->tx_buf);
121+
ring_buffer_reset(&p->rx_buf);
122122
}
123123

124124
struct osdp *osdp_get_ctx()
@@ -193,8 +193,8 @@ static int osdp_init(void)
193193
k_fifo_init(&p->rx_event_fifo);
194194
#endif
195195

196-
ring_buf_init(&p->rx_buf, sizeof(p->rx_fbuf), p->rx_fbuf);
197-
ring_buf_init(&p->tx_buf, sizeof(p->tx_fbuf), p->tx_fbuf);
196+
ring_buffer_init(&p->rx_buf, p->rx_fbuf, sizeof(p->rx_fbuf));
197+
ring_buffer_init(&p->tx_buf, p->tx_fbuf, sizeof(p->tx_fbuf));
198198

199199
/* init OSDP uart device */
200200
p->dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_osdp_uart));

subsys/testsuite/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ config TEST_BUSY_SIM
201201
bool "Busy simulator"
202202
depends on TEST
203203
select ENTROPY_GENERATOR
204-
select RING_BUFFER if !XOSHIRO_RANDOM_GENERATOR
205204
select COUNTER
206205
help
207206
It simulates cpu load by using counter device to generate interrupts

subsys/testsuite/busy_sim/busy_sim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static uint32_t get_timeout(bool idle, bool use_rand)
8484
if (use_rand) {
8585
sys_rand_get(&rand_val, sizeof(rand_val));
8686
} else {
87-
len = ring_buf_get(&rnd_rbuf,
87+
len = ring_buffer_read(&rnd_rbuf,
8888
(uint8_t *)&rand_val,
8989
sizeof(rand_val));
9090
if (len < sizeof(rand_val)) {
@@ -198,7 +198,7 @@ static int busy_sim_init(const struct device *dev)
198198

199199
if (config->entropy) {
200200
k_work_init(&sim_work, rng_pool_work_handler);
201-
ring_buf_init(&rnd_rbuf, BUFFER_SIZE, rnd_buf);
201+
ring_buffer_init(&rnd_rbuf, rnd_buf, BUFFER_SIZE);
202202
}
203203

204204
data->us_tick = freq / 1000000;

subsys/tracing/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ choice TRACING_METHOD_CHOICE
8080

8181
config TRACING_SYNC
8282
bool "Synchronous Tracing"
83-
select RING_BUFFER
8483
help
8584
Enable synchronous tracing. This requires the backend to be
8685
very low-latency.
8786

8887
config TRACING_ASYNC
8988
bool "Asynchronous Tracing"
90-
select RING_BUFFER
9189
help
9290
Enable asynchronous tracing. This will buffer all the tracing
9391
packets to the ring buffer first, tracing thread will try to

subsys/tracing/tracing_buffer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int tracing_buffer_put_finish(uint32_t size)
2929

3030
uint32_t tracing_buffer_put(uint8_t *data, uint32_t size)
3131
{
32-
return ring_buf_put(&tracing_ring_buf, data, size);
32+
return ring_buffer_write(&tracing_ring_buf, data, size);
3333
}
3434

3535
uint32_t tracing_buffer_get_claim(uint8_t **data, uint32_t size)
@@ -44,18 +44,18 @@ int tracing_buffer_get_finish(uint32_t size)
4444

4545
uint32_t tracing_buffer_get(uint8_t *data, uint32_t size)
4646
{
47-
return ring_buf_get(&tracing_ring_buf, data, size);
47+
return ring_buffer_read(&tracing_ring_buf, data, size);
4848
}
4949

5050
void tracing_buffer_init(void)
5151
{
52-
ring_buf_init(&tracing_ring_buf,
52+
ring_buffer_init(&tracing_ring_buf,
5353
sizeof(tracing_buffer), tracing_buffer);
5454
}
5555

5656
bool tracing_buffer_is_empty(void)
5757
{
58-
return ring_buf_is_empty(&tracing_ring_buf);
58+
return ring_buffer_empty(&tracing_ring_buf);
5959
}
6060

6161
uint32_t tracing_buffer_capacity_get(void)
@@ -65,5 +65,5 @@ uint32_t tracing_buffer_capacity_get(void)
6565

6666
uint32_t tracing_buffer_space_get(void)
6767
{
68-
return ring_buf_space_get(&tracing_ring_buf);
68+
return ring_buffer_space(&tracing_ring_buf);
6969
}

0 commit comments

Comments
 (0)