Skip to content

Commit 751463c

Browse files
committed
Bluetooth: hci_core: Fix tracking of periodic advertisement
Periodic advertising enabled flag cannot be tracked by the enabled flag since advertising and periodic advertising each can be enabled/disabled separately from one another causing the states to be inconsistent when for example an advertising set is disabled its enabled flag is set to false which is then used for periodic which has not being disabled. Fixes: eca0ae4 ("Bluetooth: Add initial implementation of BIS connections") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 857eb0f commit 751463c

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ struct adv_info {
244244
bool enabled;
245245
bool pending;
246246
bool periodic;
247+
bool periodic_enabled;
247248
__u8 mesh;
248249
__u8 instance;
249250
__u8 handle;

net/bluetooth/hci_event.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,
16071607

16081608
hci_dev_set_flag(hdev, HCI_LE_ADV);
16091609

1610-
if (adv && !adv->periodic)
1610+
if (adv)
16111611
adv->enabled = true;
16121612
else if (!set->handle)
16131613
hci_dev_set_flag(hdev, HCI_LE_ADV_0);
@@ -3963,8 +3963,11 @@ static u8 hci_cc_le_set_per_adv_enable(struct hci_dev *hdev, void *data,
39633963
hci_dev_set_flag(hdev, HCI_LE_PER_ADV);
39643964

39653965
if (adv)
3966-
adv->enabled = true;
3966+
adv->periodic_enabled = true;
39673967
} else {
3968+
if (adv)
3969+
adv->periodic_enabled = false;
3970+
39683971
/* If just one instance was disabled check if there are
39693972
* any other instance enabled before clearing HCI_LE_PER_ADV.
39703973
* The current periodic adv instance will be marked as

net/bluetooth/hci_sync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
16071607

16081608
/* If periodic advertising already disabled there is nothing to do. */
16091609
adv = hci_find_adv_instance(hdev, instance);
1610-
if (!adv || !adv->periodic || !adv->enabled)
1610+
if (!adv || !adv->periodic_enabled)
16111611
return 0;
16121612

16131613
memset(&cp, 0, sizeof(cp));
@@ -1672,7 +1672,7 @@ static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
16721672

16731673
/* If periodic advertising already enabled there is nothing to do. */
16741674
adv = hci_find_adv_instance(hdev, instance);
1675-
if (adv && adv->periodic && adv->enabled)
1675+
if (adv && adv->periodic_enabled)
16761676
return 0;
16771677

16781678
memset(&cp, 0, sizeof(cp));

0 commit comments

Comments
 (0)