Skip to content

Commit aab91dc

Browse files
nirav-agrawalnordicjm
authored andcommitted
[nrf fromtree] bluetooth: host: perform hci-reset in bt_disable()
- added HCI command to send hci-reset in bt_disable() func, and remove its call from the driver close() call. - remove rsp buf pass to 'hci_reset_complete()' func as status is already checked under 'bt_hci_cmd_send_sync()'. Signed-off-by: Nirav Agrawal <[email protected]> (cherry picked from commit 438701f)
1 parent b70ec03 commit aab91dc

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

drivers/bluetooth/hci/hci_nxp.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 NXP
2+
* Copyright 2023-2025 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -507,13 +507,7 @@ static int bt_nxp_close(const struct device *dev)
507507
{
508508
struct bt_nxp_data *hci = dev->data;
509509
int ret = 0;
510-
/* Reset the Controller */
511-
if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
512-
ret = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
513-
if (ret) {
514-
LOG_ERR("Failed to reset BLE controller");
515-
}
516-
}
510+
517511
hci->recv = NULL;
518512

519513
return ret;

drivers/bluetooth/hci/ipc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2019 Nordic Semiconductor ASA
3+
* Copyright 2025 NXP
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -372,14 +373,6 @@ static int bt_ipc_close(const struct device *dev)
372373
struct ipc_data *ipc = dev->data;
373374
int err;
374375

375-
if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
376-
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
377-
if (err) {
378-
LOG_ERR("Sending reset command failed with: %d", err);
379-
return err;
380-
}
381-
}
382-
383376
err = ipc_service_deregister_endpoint(&ipc->hci_ept);
384377
if (err) {
385378
LOG_ERR("Deregistering HCI endpoint failed with: %d", err);

subsys/bluetooth/host/hci_core.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/*
44
* Copyright (c) 2017-2025 Nordic Semiconductor ASA
55
* Copyright (c) 2015-2016 Intel Corporation
6+
* Copyright 2025 NXP
67
*
78
* SPDX-License-Identifier: Apache-2.0
89
*/
@@ -2389,17 +2390,10 @@ static void le_ltk_request(struct net_buf *buf)
23892390
}
23902391
#endif /* CONFIG_BT_SMP */
23912392

2392-
static void hci_reset_complete(struct net_buf *buf)
2393+
static void hci_reset_complete(void)
23932394
{
2394-
uint8_t status = buf->data[0];
23952395
atomic_t flags;
23962396

2397-
LOG_DBG("status 0x%02x %s", status, bt_hci_err_to_str(status));
2398-
2399-
if (status) {
2400-
return;
2401-
}
2402-
24032397
if (IS_ENABLED(CONFIG_BT_OBSERVER)) {
24042398
bt_scan_reset();
24052399
}
@@ -3255,12 +3249,12 @@ static int common_init(void)
32553249

32563250
if (!drv_quirk_no_reset()) {
32573251
/* Send HCI_RESET */
3258-
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, &rsp);
3252+
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
32593253
if (err) {
32603254
return err;
32613255
}
3262-
hci_reset_complete(rsp);
3263-
net_buf_unref(rsp);
3256+
3257+
hci_reset_complete();
32643258
}
32653259

32663260
/* Read Local Supported Features */
@@ -4384,6 +4378,18 @@ int bt_disable(void)
43844378
disconnected_handles_reset();
43854379
#endif /* CONFIG_BT_CONN */
43864380

4381+
/* Reset the Controller */
4382+
if (!drv_quirk_no_reset()) {
4383+
4384+
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
4385+
if (err) {
4386+
LOG_ERR("Failed to reset BLE controller");
4387+
return err;
4388+
}
4389+
4390+
hci_reset_complete();
4391+
}
4392+
43874393
err = bt_hci_close(bt_dev.hci);
43884394
if (err == -ENOSYS) {
43894395
atomic_clear_bit(bt_dev.flags, BT_DEV_DISABLE);

0 commit comments

Comments
 (0)