From 3b703288ae2c4bbc0393bbf2dc232c86594f10f8 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Tue, 6 Jun 2017 16:35:34 +0200 Subject: [PATCH] Bluetooth: controller: Handle reset atomic properly In order to reuse code, the reset() function is used both to handle the reset HCI command but also to initialize the internal HCI variables when bringing up the system. In the latter case, avoid setting the reset bit in the state atomic and signalling the polling API, since that is not required during initialization. Signed-off-by: Carles Cufi --- subsys/bluetooth/controller/hci/hci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index 60085b271e4..51ddce131ac 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -189,8 +189,10 @@ static void reset(struct net_buf *buf, struct net_buf **evt) hci_hbuf_sent = 0; hci_hbuf_acked = 0; conn_count = 0; - atomic_set_bit(&hci_state_mask, HCI_STATE_BIT_RESET); - k_poll_signal(hbuf_signal, 0x0); + if (buf) { + atomic_set_bit(&hci_state_mask, HCI_STATE_BIT_RESET); + k_poll_signal(hbuf_signal, 0x0); + } #endif }