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 <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-06-29 14:10:10 +03:00 committed by Johan Hedberg
commit 3cb4d295d0

View file

@ -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;