Bluetooth: Allow to call enable function only once

Currently enable procedure can be called only once regardles if it
failed or succeeded.

Change-Id: I3869e97442720860baba7bb1b7610738ca95561a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-05-30 14:20:42 +02:00 committed by Johan Hedberg
parent d2fa54d4a6
commit d1d0ee7b2d
4 changed files with 10 additions and 0 deletions

View file

@ -101,6 +101,10 @@ int bt_enable(bt_ready_cb_t cb)
return -EINVAL;
}
if (atomic_test_and_set_bit(&nble.flags, NBLE_FLAG_ENABLE)) {
return -EALREADY;
}
ret = nble_open();
if (ret) {
return ret;

View file

@ -584,6 +584,7 @@ void ble_gap_set_rssi_report(struct ble_rssi_report_params *par,
rssi_report_resp_t resp_cb, rssi_report_t evt_cb);
enum {
NBLE_FLAG_ENABLE,
NBLE_FLAG_KEEP_ADVERTISING,
};

View file

@ -3220,6 +3220,10 @@ int bt_enable(bt_ready_cb_t cb)
return -ENODEV;
}
if (atomic_test_and_set_bit(bt_dev.flags, BT_DEV_ENABLE)) {
return -EALREADY;
}
/* Initialize the buffer pools */
net_buf_pool_init(hci_cmd_pool);
#if defined(CONFIG_BLUETOOTH_HOST_BUFFERS)

View file

@ -26,6 +26,7 @@
/* bt_dev flags: the flags defined here represent BT controller state */
enum {
BT_DEV_ENABLE,
BT_DEV_READY,
BT_DEV_ID_STATIC_RANDOM,