Skip to content

Commit ffeee6c

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Update ull_disable with -EALREADY return
Update ull_disable implementation to return -EALREADY if LLL event is already disabled. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 179fe06 commit ffeee6c

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ int ull_ticker_stop_with_mark(uint8_t ticker_handle, void *param,
17021702
uint32_t volatile ret_cb;
17031703
uint32_t ret;
17041704
void *mark;
1705+
int err;
17051706

17061707
mark = ull_disable_mark(param);
17071708
if (mark != param) {
@@ -1722,16 +1723,17 @@ int ull_ticker_stop_with_mark(uint8_t ticker_handle, void *param,
17221723
return -EALREADY;
17231724
}
17241725

1725-
ret = ull_disable(lll_disable);
1726-
if (ret) {
1727-
return -EBUSY;
1728-
}
1726+
err = ull_disable(lll_disable);
17291727

17301728
mark = ull_disable_unmark(param);
17311729
if (mark != param) {
17321730
return -ENOLCK;
17331731
}
17341732

1733+
if (err && (err != -EALREADY)) {
1734+
return err;
1735+
}
1736+
17351737
return 0;
17361738
}
17371739

@@ -1761,8 +1763,8 @@ int ull_disable(void *lll)
17611763
uint32_t ret;
17621764

17631765
hdr = HDR_LLL2ULL(lll);
1764-
if (!hdr || !ull_ref_get(hdr)) {
1765-
return 0;
1766+
if (!ull_ref_get(hdr)) {
1767+
return -EALREADY;
17661768
}
17671769

17681770
k_sem_init(&sem, 0, 1);
@@ -1780,7 +1782,7 @@ int ull_disable(void *lll)
17801782
* care.
17811783
*/
17821784
if (!ull_ref_get(hdr)) {
1783-
return 0;
1785+
return -EALREADY;
17841786
}
17851787

17861788
mfy.param = lll;

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,8 +2523,9 @@ static inline uint8_t disable(uint8_t handle)
25232523
{
25242524
uint32_t volatile ret_cb;
25252525
struct ll_adv_set *adv;
2526-
void *mark;
25272526
uint32_t ret;
2527+
void *mark;
2528+
int err;
25282529

25292530
adv = ull_adv_is_enabled_get(handle);
25302531
if (!adv) {
@@ -2585,8 +2586,8 @@ static inline uint8_t disable(uint8_t handle)
25852586
return BT_HCI_ERR_CMD_DISALLOWED;
25862587
}
25872588

2588-
ret = ull_disable(&adv->lll);
2589-
LL_ASSERT(!ret);
2589+
err = ull_disable(&adv->lll);
2590+
LL_ASSERT(!err || (err == -EALREADY));
25902591

25912592
mark = ull_disable_unmark(adv);
25922593
LL_ASSERT(mark == adv);
@@ -2596,13 +2597,12 @@ static inline uint8_t disable(uint8_t handle)
25962597

25972598
if (lll_aux) {
25982599
struct ll_adv_aux_set *aux;
2599-
uint8_t err;
26002600

26012601
aux = HDR_LLL2ULL(lll_aux);
26022602

26032603
err = ull_adv_aux_stop(aux);
2604-
if (err) {
2605-
return err;
2604+
if (err && (err != -EALREADY)) {
2605+
return BT_HCI_ERR_CMD_DISALLOWED;
26062606
}
26072607
}
26082608
#endif /* CONFIG_BT_CTLR_ADV_EXT && (CONFIG_BT_CTLR_ADV_AUX_SET > 0) */

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor,
10731073
return ret;
10741074
}
10751075

1076-
uint8_t ull_adv_aux_stop(struct ll_adv_aux_set *aux)
1076+
int ull_adv_aux_stop(struct ll_adv_aux_set *aux)
10771077
{
10781078
uint8_t aux_handle;
10791079
int err;
@@ -1084,7 +1084,7 @@ uint8_t ull_adv_aux_stop(struct ll_adv_aux_set *aux)
10841084
aux, &aux->lll);
10851085
LL_ASSERT(err == 0 || err == -EALREADY);
10861086
if (err) {
1087-
return BT_HCI_ERR_CMD_DISALLOWED;
1087+
return err;
10881088
}
10891089

10901090
aux->is_started = 0U;

subsys/bluetooth/controller/ll_sw/ull_adv_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor,
8383
uint32_t ticks_slot_overhead);
8484

8585
/* helper function to stop auxiliary advertising */
86-
uint8_t ull_adv_aux_stop(struct ll_adv_aux_set *aux);
86+
int ull_adv_aux_stop(struct ll_adv_aux_set *aux);
8787

8888
/* helper function to acquire and initialize auxiliary advertising instance */
8989
struct ll_adv_aux_set *ull_adv_aux_acquire(struct lll_adv *lll);

0 commit comments

Comments
 (0)