Skip to content

Commit a64b617

Browse files
committed
Bluetooth: Host: Expose bt_workq for global Host use
There are other places in the Host that would make sense to run on bt_workq. This change exposes `bt_workq_chosen` in `hci_core.h` for use in other parts of the Host. `bt_workq_chosen` is set according to the `BT_RECV_CONTEXT` choice. Signed-off-by: Aleksander Wasaznik <[email protected]>
1 parent c8d9103 commit a64b617

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ static struct k_work_q bt_workq;
124124
static K_KERNEL_STACK_DEFINE(rx_thread_stack, CONFIG_BT_RX_STACK_SIZE);
125125
#endif /* CONFIG_BT_RECV_WORKQ_BT */
126126

127+
struct k_work_q *const bt_workq_chosen =
128+
COND_CODE_1(CONFIG_BT_RECV_WORKQ_BT, (&bt_workq), (&k_sys_work_q));
129+
127130
static void init_work(struct k_work *work);
128131

129132
struct bt_dev bt_dev = {
@@ -4350,13 +4353,11 @@ static void hci_event_prio(struct net_buf *buf)
43504353

43514354
static void rx_queue_put(struct net_buf *buf)
43524355
{
4356+
int err;
4357+
43534358
net_buf_slist_put(&bt_dev.rx_queue, buf);
43544359

4355-
#if defined(CONFIG_BT_RECV_WORKQ_SYS)
4356-
const int err = k_work_submit(&rx_work);
4357-
#elif defined(CONFIG_BT_RECV_WORKQ_BT)
4358-
const int err = k_work_submit_to_queue(&bt_workq, &rx_work);
4359-
#endif /* CONFIG_BT_RECV_WORKQ_SYS */
4360+
err = k_work_submit_to_queue(bt_workq_chosen, &rx_work);
43604361
if (err < 0) {
43614362
LOG_ERR("Could not submit rx_work: %d", err);
43624363
}

subsys/bluetooth/host/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ struct bt_dev {
442442
#endif
443443
};
444444

445+
extern struct k_work_q *const bt_workq_chosen;
445446
extern struct bt_dev bt_dev;
446447
extern const struct bt_conn_auth_cb *bt_auth;
447448
extern sys_slist_t bt_auth_info_cbs;

0 commit comments

Comments
 (0)