Skip to content

Commit 29ae143

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Refactor out initiator reset
Refactor out the initiator reset implementation into a function. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e937dde commit 29ae143

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -695,42 +695,6 @@ void ll_reset(void)
695695
#endif /* CONFIG_BT_CTLR_ADV_ISO */
696696

697697
#if defined(CONFIG_BT_CONN)
698-
#if defined(CONFIG_BT_CENTRAL)
699-
/* Reset initiator */
700-
{
701-
void *rx;
702-
703-
err = ll_connect_disable(&rx);
704-
if (!err) {
705-
struct ll_scan_set *scan;
706-
707-
scan = ull_scan_is_enabled_get(SCAN_HANDLE_1M);
708-
709-
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_EXT) &&
710-
IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
711-
struct ll_scan_set *scan_other;
712-
713-
scan_other = ull_scan_is_enabled_get(SCAN_HANDLE_PHY_CODED);
714-
if (scan_other) {
715-
if (scan) {
716-
scan->is_enabled = 0U;
717-
scan->lll.conn = NULL;
718-
}
719-
720-
scan = scan_other;
721-
}
722-
}
723-
724-
LL_ASSERT(scan);
725-
726-
scan->is_enabled = 0U;
727-
scan->lll.conn = NULL;
728-
}
729-
730-
ARG_UNUSED(rx);
731-
}
732-
#endif /* CONFIG_BT_CENTRAL */
733-
734698
/* Reset conn role */
735699
err = ull_conn_reset();
736700
LL_ASSERT(!err);

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@ int ull_conn_reset(void)
759759
uint16_t handle;
760760
int err;
761761

762+
#if defined(CONFIG_BT_CENTRAL)
763+
/* Reset initiator */
764+
(void)ull_master_reset();
765+
#endif /* CONFIG_BT_CENTRAL */
766+
762767
for (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
763768
disable(handle);
764769
}

subsys/bluetooth/controller/ll_sw/ull_master.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,44 @@ uint8_t ll_enc_req_send(uint16_t handle, uint8_t const *const rand,
641641
}
642642
#endif /* CONFIG_BT_CTLR_LE_ENC */
643643

644+
int ull_master_reset(void)
645+
{
646+
int err;
647+
void *rx;
648+
649+
err = ll_connect_disable(&rx);
650+
if (!err) {
651+
struct ll_scan_set *scan;
652+
653+
scan = ull_scan_is_enabled_get(SCAN_HANDLE_1M);
654+
655+
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_EXT) &&
656+
IS_ENABLED(CONFIG_BT_CTLR_PHY_CODED)) {
657+
struct ll_scan_set *scan_other;
658+
659+
scan_other =
660+
ull_scan_is_enabled_get(SCAN_HANDLE_PHY_CODED);
661+
if (scan_other) {
662+
if (scan) {
663+
scan->is_enabled = 0U;
664+
scan->lll.conn = NULL;
665+
}
666+
667+
scan = scan_other;
668+
}
669+
}
670+
671+
LL_ASSERT(scan);
672+
673+
scan->is_enabled = 0U;
674+
scan->lll.conn = NULL;
675+
}
676+
677+
ARG_UNUSED(rx);
678+
679+
return err;
680+
}
681+
644682
void ull_master_cleanup(struct node_rx_hdr *rx_free)
645683
{
646684
struct lll_conn *conn_lll;

subsys/bluetooth/controller/ll_sw/ull_master_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
int ull_master_reset(void);
78
void ull_master_cleanup(struct node_rx_hdr *rx_free);
89
void ull_master_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
910
struct lll_conn *lll);

0 commit comments

Comments
 (0)