Skip to content

Commit ac1c826

Browse files
Bluetooth: Controller: Simplify aux flush
aux->rx_last cannot be NULL since it's always set after acquire to a valid node so the flow in flush() can be simplified. rx parameter is only used to update PDU chain, then it's overwritten, so we can instead update PDU chain in caller since there's only one place when this should happen. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 35a737b commit ac1c826

File tree

1 file changed

+17
-39
lines changed

1 file changed

+17
-39
lines changed

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static inline uint8_t aux_handle_get(struct ll_scan_aux_set *aux);
4646
static inline struct ll_sync_set *sync_create_get(struct ll_scan_set *scan);
4747
static void last_disabled_cb(void *param);
4848
static void done_disabled_cb(void *param);
49-
static void flush(struct ll_scan_aux_set *aux, struct node_rx_hdr *rx);
49+
static void flush(struct ll_scan_aux_set *aux);
5050
static void ticker_cb(uint32_t ticks_at_expire, uint32_t remainder,
5151
uint16_t lazy, uint8_t force, void *param);
5252
static void ticker_op_cb(uint32_t status, void *param);
@@ -481,6 +481,8 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
481481

482482
hdr = &aux->ull;
483483

484+
aux->rx_last->rx_ftr.extra = rx;
485+
484486
/* ref == 0
485487
* All PDUs were scheduled from LLL and there is no pending done
486488
* event, we can flush here.
@@ -492,11 +494,11 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
492494
*/
493495
LL_ASSERT(ull_ref_get(hdr) < 2);
494496
if (ull_ref_get(hdr) == 0) {
495-
flush(aux, rx);
497+
flush(aux);
496498
} else {
497499
LL_ASSERT(!hdr->disabled_cb);
498500

499-
hdr->disabled_param = rx;
501+
hdr->disabled_param = aux;
500502
hdr->disabled_cb = last_disabled_cb;
501503
}
502504

@@ -550,7 +552,7 @@ void ull_scan_aux_release(memq_link_t *link, struct node_rx_hdr *rx)
550552
lll_aux = lll->lll_aux;
551553
if (lll_aux) {
552554
aux = HDR_LLL2ULL(lll_aux);
553-
flush(aux, NULL);
555+
flush(aux);
554556
}
555557

556558
/* Mark for buffer for release */
@@ -597,49 +599,25 @@ static inline struct ll_sync_set *sync_create_get(struct ll_scan_set *scan)
597599

598600
static void last_disabled_cb(void *param)
599601
{
600-
struct ll_scan_aux_set *aux;
601-
struct node_rx_hdr *rx;
602-
603-
rx = param;
604-
605-
if (ull_scan_is_valid_get(HDR_LLL2ULL(rx->rx_ftr.param))) {
606-
struct lll_scan *lll;
607-
608-
lll = rx->rx_ftr.param;
609-
LL_ASSERT(lll->lll_aux);
610-
aux = HDR_LLL2ULL(lll->lll_aux);
611-
} else {
612-
aux = HDR_LLL2ULL(rx->rx_ftr.param);
613-
LL_ASSERT(ull_scan_aux_is_valid_get(aux));
614-
}
615-
616-
flush(aux, rx);
602+
flush(param);
617603
}
618604

619605
static void done_disabled_cb(void *param)
620606
{
621-
flush(param, NULL);
607+
flush(param);
622608
}
623609

624-
static void flush(struct ll_scan_aux_set *aux, struct node_rx_hdr *rx)
610+
static void flush(struct ll_scan_aux_set *aux)
625611
{
626-
if (aux->rx_last) {
627-
struct lll_scan *lll;
628-
629-
if (rx) {
630-
aux->rx_last->rx_ftr.extra = rx;
631-
}
612+
struct node_rx_hdr *rx;
613+
struct lll_scan *lll;
632614

633-
rx = aux->rx_head;
634-
lll = rx->rx_ftr.param;
635-
lll->lll_aux = NULL;
615+
rx = aux->rx_head;
616+
lll = rx->rx_ftr.param;
617+
lll->lll_aux = NULL;
636618

637-
ll_rx_put(rx->link, rx);
638-
ll_rx_sched();
639-
} else if (rx) {
640-
ll_rx_put(rx->link, rx);
641-
ll_rx_sched();
642-
}
619+
ll_rx_put(rx->link, rx);
620+
ll_rx_sched();
643621

644622
aux_release(aux);
645623
}
@@ -695,5 +673,5 @@ static void ticker_op_cb(uint32_t status, void *param)
695673

696674
static void ticker_op_aux_failure(void *param)
697675
{
698-
flush(param, NULL);
676+
flush(param);
699677
}

0 commit comments

Comments
 (0)