Skip to content

Commit 1027931

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: HCI: Add proper tracking for enable status of adv instances
This adds a field to track if advertising instances are enabled or not and only clear HCI_LE_ADV flag if there is no instance left advertising. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 654e6f7 commit 1027931

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct oob_data {
221221

222222
struct adv_info {
223223
struct list_head list;
224+
bool enabled;
224225
bool pending;
225226
__u8 instance;
226227
__u32 flags;

net/bluetooth/hci_event.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,9 @@ static void hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev,
12771277
struct sk_buff *skb)
12781278
{
12791279
struct hci_cp_le_set_ext_adv_enable *cp;
1280+
struct hci_cp_ext_adv_set *set;
12801281
__u8 status = *((__u8 *) skb->data);
1282+
struct adv_info *adv = NULL, *n;
12811283

12821284
BT_DBG("%s status 0x%2.2x", hdev->name, status);
12831285

@@ -1288,22 +1290,48 @@ static void hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev,
12881290
if (!cp)
12891291
return;
12901292

1293+
set = (void *)cp->data;
1294+
12911295
hci_dev_lock(hdev);
12921296

1297+
if (cp->num_of_sets)
1298+
adv = hci_find_adv_instance(hdev, set->handle);
1299+
12931300
if (cp->enable) {
12941301
struct hci_conn *conn;
12951302

12961303
hci_dev_set_flag(hdev, HCI_LE_ADV);
12971304

1305+
if (adv)
1306+
adv->enabled = true;
1307+
12981308
conn = hci_lookup_le_connect(hdev);
12991309
if (conn)
13001310
queue_delayed_work(hdev->workqueue,
13011311
&conn->le_conn_timeout,
13021312
conn->conn_timeout);
13031313
} else {
1314+
if (adv) {
1315+
adv->enabled = false;
1316+
/* If just one instance was disabled check if there are
1317+
* any other instance enabled before clearing HCI_LE_ADV
1318+
*/
1319+
list_for_each_entry_safe(adv, n, &hdev->adv_instances,
1320+
list) {
1321+
if (adv->enabled)
1322+
goto unlock;
1323+
}
1324+
} else {
1325+
/* All instances shall be considered disabled */
1326+
list_for_each_entry_safe(adv, n, &hdev->adv_instances,
1327+
list)
1328+
adv->enabled = false;
1329+
}
1330+
13041331
hci_dev_clear_flag(hdev, HCI_LE_ADV);
13051332
}
13061333

1334+
unlock:
13071335
hci_dev_unlock(hdev);
13081336
}
13091337

0 commit comments

Comments
 (0)