Bluetooth: controller: Add interface to get ULL ref count

Add a static inline interface to get ULL context reference
count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2020-09-09 15:57:34 +05:30 committed by Ioannis Glaropoulos
commit 35c0b77304
4 changed files with 12 additions and 5 deletions

View file

@ -111,7 +111,9 @@ struct evt_hdr {
};
struct ull_hdr {
uint8_t ref; /* Number of ongoing (between Prepare and Done) events */
uint8_t volatile ref; /* Number of ongoing (between Prepare and Done)
* events
*/
void (*disabled_cb)(void *param);
void *disabled_param;
};

View file

@ -1133,7 +1133,7 @@ int ull_disable(void *lll)
hdr->disabled_param = &sem;
hdr->disabled_cb = disabled_cb;
if (!hdr->ref) {
if (!ull_ref_get(hdr)) {
return ULL_STATUS_SUCCESS;
}
@ -1857,11 +1857,11 @@ static inline void rx_demux_event_done(memq_link_t *link,
}
/* Decrement prepare reference */
LL_ASSERT(ull_hdr->ref);
LL_ASSERT(ull_ref_get(ull_hdr));
ull_ref_dec(ull_hdr);
/* If disable initiated, signal the semaphore */
if (!ull_hdr->ref && ull_hdr->disabled_cb) {
if (!ull_ref_get(ull_hdr) && ull_hdr->disabled_cb) {
ull_hdr->disabled_cb(ull_hdr->disabled_param);
}
}

View file

@ -1675,7 +1675,7 @@ static void ticker_op_stop_cb(uint32_t status, void *param)
adv = param;
hdr = &adv->ull;
mfy.param = &adv->lll;
if (hdr->ref) {
if (ull_ref_get(hdr)) {
LL_ASSERT(!hdr->disabled_cb);
hdr->disabled_param = mfy.param;
hdr->disabled_cb = disabled_cb;

View file

@ -4,6 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
static inline uint8_t ull_ref_get(struct ull_hdr *hdr)
{
return hdr->ref;
}
static inline uint8_t ull_ref_inc(struct ull_hdr *hdr)
{
return ++hdr->ref;