Bluetooth: host: Refactor HCI remove from resolving list command

Move HCI remove device from resolving list command out to it's own
function.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-03-23 12:23:20 +01:00 committed by Johan Hedberg
commit 8f8b163a93

View file

@ -3716,16 +3716,32 @@ static void keys_add_id(struct bt_keys *keys, void *data)
} }
} }
static int hci_id_del(const bt_addr_le_t *addr)
{
struct bt_hci_cp_le_rem_dev_from_rl *cp;
struct net_buf *buf;
BT_DBG("addr %s", bt_addr_le_str(addr));
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_RL, sizeof(*cp));
if (!buf) {
return -ENOBUFS;
}
cp = net_buf_add(buf, sizeof(*cp));
bt_addr_le_copy(&cp->peer_id_addr, addr);
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_RL, buf, NULL);
}
void bt_id_del(struct bt_keys *keys) void bt_id_del(struct bt_keys *keys)
{ {
struct bt_le_ext_adv *adv; struct bt_le_ext_adv *adv;
struct bt_hci_cp_le_rem_dev_from_rl *cp;
bool adv_enabled; bool adv_enabled;
#if defined(CONFIG_BT_OBSERVER) #if defined(CONFIG_BT_OBSERVER)
bool scan_enabled; bool scan_enabled;
#endif /* CONFIG_BT_OBSERVER */ #endif /* CONFIG_BT_OBSERVER */
struct bt_conn *conn; struct bt_conn *conn;
struct net_buf *buf;
int err; int err;
BT_DBG("addr %s", bt_addr_le_str(&keys->addr)); BT_DBG("addr %s", bt_addr_le_str(&keys->addr));
@ -3780,15 +3796,7 @@ void bt_id_del(struct bt_keys *keys)
goto done; goto done;
} }
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_RL, sizeof(*cp)); err = hci_id_del(&keys->addr);
if (!buf) {
goto done;
}
cp = net_buf_add(buf, sizeof(*cp));
bt_addr_le_copy(&cp->peer_id_addr, &keys->addr);
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_RL, buf, NULL);
if (err) { if (err) {
BT_ERR("Failed to remove IRK from controller"); BT_ERR("Failed to remove IRK from controller");
goto done; goto done;