Skip to content

Commit 5d4ed8e

Browse files
andrzej-kaczmarekcvinayak
authored andcommitted
Bluetooth: controller: Optimize lll_adv_pdu_and_extra_data_alloc
This function is the same as lll_adv_pdu_alloc except it also allocates extra data at the end - it can just use lll_adv_pdu_alloc call to avoid extensive c&p. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 3b63792 commit 5d4ed8e

File tree

1 file changed

+3
-28
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+3
-28
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -410,38 +410,13 @@ struct pdu_adv *lll_adv_pdu_and_extra_data_alloc(struct lll_adv_pdu *pdu,
410410
void **extra_data,
411411
uint8_t *idx)
412412
{
413-
uint8_t first, last;
414413
struct pdu_adv *p;
415-
416-
first = pdu->first;
417-
last = pdu->last;
418-
if (first == last) {
419-
last++;
420-
if (last == DOUBLE_BUFFER_SIZE) {
421-
last = 0U;
422-
}
423-
} else {
424-
uint8_t first_latest;
425-
426-
pdu->last = first;
427-
cpu_dmb();
428-
first_latest = pdu->first;
429-
if (first_latest != first) {
430-
last++;
431-
if (last == DOUBLE_BUFFER_SIZE) {
432-
last = 0U;
433-
}
434-
}
435-
}
436-
437-
*idx = last;
438-
439-
p = adv_pdu_allocate(pdu, last);
414+
p = lll_adv_pdu_alloc(pdu, idx);
440415

441416
if (extra_data) {
442-
*extra_data = adv_extra_data_allocate(pdu, last);
417+
*extra_data = adv_extra_data_allocate(pdu, *idx);
443418
} else {
444-
if (adv_extra_data_free(pdu, last)) {
419+
if (adv_extra_data_free(pdu, *idx)) {
445420
/* There is no release of memory allocated by
446421
* adv_pdu_allocate because there is no memory leak.
447422
* If caller can recover from this error and subsequent

0 commit comments

Comments
 (0)