Skip to content

Commit 7b4f5d4

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 4b18e65 commit 7b4f5d4

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
@@ -125,6 +125,9 @@ static struct k_work_q bt_workq;
125125
static K_KERNEL_STACK_DEFINE(rx_thread_stack, CONFIG_BT_RX_STACK_SIZE);
126126
#endif /* CONFIG_BT_RECV_WORKQ_BT */
127127

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

130133
struct bt_dev bt_dev = {
@@ -4322,13 +4325,11 @@ static void hci_event_prio(struct net_buf *buf)
43224325

43234326
static void rx_queue_put(struct net_buf *buf)
43244327
{
4328+
int err;
4329+
43254330
net_buf_slist_put(&bt_dev.rx_queue, buf);
43264331

4327-
#if defined(CONFIG_BT_RECV_WORKQ_SYS)
4328-
const int err = k_work_submit(&rx_work);
4329-
#elif defined(CONFIG_BT_RECV_WORKQ_BT)
4330-
const int err = k_work_submit_to_queue(&bt_workq, &rx_work);
4331-
#endif /* CONFIG_BT_RECV_WORKQ_SYS */
4332+
err = k_work_submit_to_queue(bt_workq_chosen, &rx_work);
43324333
if (err < 0) {
43334334
LOG_ERR("Could not submit rx_work: %d", err);
43344335
}

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)