From 3cb4d295d065896f7bfb22b02d2b77142b75c943 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 29 Jun 2017 14:10:10 +0300 Subject: [PATCH] Bluetooth: Fix KEEP_ADVERTISING flag treatment in bt_le_adv_stop() The BT_DEV_ADVERTISING flag already does a suffient job with tracking the actual advertising state, so there's no need for bt_le_adv_stop() to return an error if KEEP_ADVERTISING is set. We still need to clear KEEP_ADVERTISING, but it should not be considered an error if it was not set. Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/hci_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 5c9e460693f..74ff938a80f 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -4284,15 +4284,10 @@ int bt_le_adv_stop(void) { int err; - /* Advertise disable may fail if slave connections are established, - * and advertising is not kept ON as the controller does not support - * simultaneous slave connections and connectable advertising state. - * Hence, we test and clear BT_DEV_KEEP_ADVERTISING flag before trying - * to disable advertising if BT_DEV_ADVERTISING is set. + /* Make sure advertising is not re-enabled later even if it's not + * currently enabled (i.e. BT_DEV_ADVERTISING is not set). */ - if (!atomic_test_and_clear_bit(bt_dev.flags, BT_DEV_KEEP_ADVERTISING)) { - return -EALREADY; - } + atomic_clear_bit(bt_dev.flags, BT_DEV_KEEP_ADVERTISING); if (!atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) { return 0;