Skip to content

Commit f7f63c6

Browse files
joerchanjhedberg
authored andcommitted
Bluetooth: host: Check for device ready for whitelist API
The whitelist API uses the controller directly through HCI commands. Bluetooth device must have been initialized before sending HCI commands. Signed-off-by: Joakim Andersson <[email protected]>
1 parent e124c1c commit f7f63c6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5921,6 +5921,10 @@ int bt_le_whitelist_add(const bt_addr_le_t *addr)
59215921
struct net_buf *buf;
59225922
int err;
59235923

5924+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
5925+
return -EAGAIN;
5926+
}
5927+
59245928
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
59255929
if (!buf) {
59265930
return -ENOBUFS;
@@ -5945,6 +5949,10 @@ int bt_le_whitelist_rem(const bt_addr_le_t *addr)
59455949
struct net_buf *buf;
59465950
int err;
59475951

5952+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
5953+
return -EAGAIN;
5954+
}
5955+
59485956
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_WL, sizeof(*cp));
59495957
if (!buf) {
59505958
return -ENOBUFS;
@@ -5964,8 +5972,13 @@ int bt_le_whitelist_rem(const bt_addr_le_t *addr)
59645972

59655973
int bt_le_whitelist_clear(void)
59665974
{
5967-
int err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
5975+
int err;
5976+
5977+
if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
5978+
return -EAGAIN;
5979+
}
59685980

5981+
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
59695982
if (err) {
59705983
BT_ERR("Failed to clear whitelist");
59715984
return err;

0 commit comments

Comments
 (0)