Bluetooth: Controller: legacy: terminate condition to check role first

Refactor to revert back the terminate check condition to
check the connection role first.

Reverts legacy code changed in
commit 8b1d50b981 ("Bluetooth: controller: llcp: fix issue
 re. missing ack of terminate ind").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2022-07-23 08:52:00 +05:30 committed by Carles Cufí
commit 8191423950

View file

@ -1520,21 +1520,23 @@ void ull_conn_done(struct node_rx_event_done *done)
reason_final = conn->llcp_terminate.reason_final; reason_final = conn->llcp_terminate.reason_final;
if (reason_final && ( if (reason_final && (
#if defined(CONFIG_BT_LL_SW_LLCP_LEGACY) #if defined(CONFIG_BT_LL_SW_LLCP_LEGACY)
#if defined(CONFIG_BT_PERIPHERAL)
lll->role ||
#else /* CONFIG_BT_PERIPHERAL */
false ||
#endif /* CONFIG_BT_PERIPHERAL */
#if defined(CONFIG_BT_CENTRAL) #if defined(CONFIG_BT_CENTRAL)
(((conn->llcp_terminate.req - (((conn->llcp_terminate.req -
conn->llcp_terminate.ack) & 0xFF) == conn->llcp_terminate.ack) & 0xFF) ==
TERM_ACKED) || TERM_ACKED) ||
conn->central.terminate_ack || conn->central.terminate_ack ||
(reason_final == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL) || (reason_final == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL)
#endif /* CONFIG_BT_CENTRAL */ #else /* CONFIG_BT_CENTRAL */
#if defined(CONFIG_BT_PERIPHERAL)
lll->role
#else /* CONFIG_BT_PERIPHERAL */
false
#endif /* CONFIG_BT_PERIPHERAL */
#else /* defined(CONFIG_BT_LL_SW_LLCP_LEGACY) */
true true
#endif /* !defined(CONFIG_BT_LL_SW_LLCP_LEGACY) */ #endif /* CONFIG_BT_CENTRAL */
#else /* !CONFIG_BT_LL_SW_LLCP_LEGACY */
true
#endif /* !CONFIG_BT_LL_SW_LLCP_LEGACY */
)) { )) {
conn_cleanup(conn, reason_final); conn_cleanup(conn, reason_final);