From dc7964aa1ad7bd324d8b176d30e9fdcff01b68ef Mon Sep 17 00:00:00 2001 From: Wang Mengyang Date: Fri, 10 Jan 2025 12:45:37 +0800 Subject: [PATCH] change(bt): Remove unused state variable for (e)SCO disconnect reason in Bluedroid --- .../bt/host/bluedroid/stack/btm/btm_acl.c | 12 ++++---- .../bt/host/bluedroid/stack/btm/btm_sco.c | 30 ------------------- .../bluedroid/stack/btm/include/btm_int.h | 1 - .../bluedroid/stack/include/stack/btm_api.h | 18 ----------- 4 files changed, 6 insertions(+), 55 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_acl.c b/components/bt/host/bluedroid/stack/btm/btm_acl.c index 4b7e7eedce..93ca1062fa 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -335,7 +335,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L #if (CLASSIC_BT_INCLUDED == TRUE) const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); #endif ///CLASSIC_BT_INCLUDED == TRUE - /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ + /* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */ #if (SMP_INCLUDED == TRUE) btm_sec_set_peer_sec_caps(p, p_dev_rec); #endif ///SMP_INCLUDED == TRUE @@ -350,7 +350,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L return; } } else { - /* If remote features indicated secure connection (SC) mode, check the remote feautres again*/ + /* If remote features indicated secure connection (SC) mode, check the remote features again*/ /* this is to prevent from BIAS attack where attacker can downgrade SC mode*/ btm_read_remote_features (p->hci_handle); } @@ -474,7 +474,7 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport) BTM_TRACE_DEBUG("Bonded\n"); } } else { - BTM_TRACE_DEBUG("Bletooth link down\n"); + BTM_TRACE_DEBUG("Bluetooth link down\n"); p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED | BTM_SEC_ROLE_SWITCHED); } @@ -1016,7 +1016,7 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages) const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND); #if (SMP_INCLUDED == TRUE) - /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */ + /* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */ btm_sec_set_peer_sec_caps(p_acl_cb, p_dev_rec); #endif ///SMP_INCLUDED == TRUE BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend); @@ -1455,7 +1455,7 @@ void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset) ** ** Function btm_acl_role_changed ** -** Description This function is called whan a link's master/slave role change +** Description This function is called when a link's master/slave role change ** event or command status event (with error) is received. ** It updates the link control block, and calls ** the registered callback with status and role (if registered). @@ -2705,7 +2705,7 @@ void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mo l2c_link_hci_conn_comp(status, handle, bda); } #if BTM_SCO_INCLUDED == TRUE - else { + else if (link_type == HCI_LINK_TYPE_SCO) { memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA)); esco_data.link_type = HCI_LINK_TYPE_SCO; memcpy (esco_data.bd_addr, bda, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/stack/btm/btm_sco.c b/components/bt/host/bluedroid/stack/btm/btm_sco.c index 7dede5d4d3..ceb7830a4b 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_sco.c +++ b/components/bt/host/bluedroid/stack/btm/btm_sco.c @@ -117,8 +117,6 @@ void btm_sco_init (void) } #endif /* Initialize nonzero defaults */ - btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON; - btm_cb.sco_cb.def_esco_parms = btm_esco_defaults; /* Initialize with defaults */ btm_cb.sco_cb.desired_sco_mode = BTM_DEFAULT_SCO_MODE; } @@ -1048,7 +1046,6 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle, tBTM_CHG_ESCO_PARAMS parms; #endif - btm_cb.sco_cb.sco_disc_reason = hci_status; BTM_TRACE_API("%s, handle %x", __FUNCTION__, hci_handle); #if (BTM_MAX_SCO_LINKS>0) for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { @@ -1224,16 +1221,11 @@ void btm_sco_removed (UINT16 hci_handle, UINT8 reason) #if (BTM_MAX_SCO_LINKS>0) tSCO_CONN *p = &btm_cb.sco_cb.sco_db[0]; UINT16 xx; -#endif - btm_cb.sco_cb.sco_disc_reason = reason; - -#if (BTM_MAX_SCO_LINKS>0) p = &btm_cb.sco_cb.sco_db[0]; for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { if ((p->state != SCO_ST_UNUSED) && (p->state != SCO_ST_LISTENING) && (p->hci_handle == hci_handle)) { btm_sco_flush_sco_data(xx); - p->state = SCO_ST_UNUSED; #if BTM_SCO_HCI_INCLUDED == TRUE btm_cb.sco_cb.xmit_window_size += p->sent_not_acked; @@ -1375,24 +1367,6 @@ UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx) #endif } -/******************************************************************************* -** -** Function BTM_ReadScoDiscReason -** -** Description This function is returns the reason why an (e)SCO connection -** has been removed. It contains the value until read, or until -** another (e)SCO connection has disconnected. -** -** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set. -** -*******************************************************************************/ -UINT16 BTM_ReadScoDiscReason (void) -{ - UINT16 res = btm_cb.sco_cb.sco_disc_reason; - btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON; - return (res); -} - /******************************************************************************* ** ** Function BTM_ReadDeviceScoPacketTypes @@ -1894,10 +1868,6 @@ UINT8 *BTM_ReadScoBdAddr(UINT16 sco_inx) { return ((UINT8 *) NULL); } -UINT16 BTM_ReadScoDiscReason (void) -{ - return (BTM_INVALID_SCO_DISC_REASON); -} tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms) { return (BTM_MODE_UNSUPPORTED); diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 0674818774..e5e3df0d1b 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -468,7 +468,6 @@ typedef struct { tSCO_CONN sco_db[BTM_MAX_SCO_LINKS]; tBTM_ESCO_PARAMS def_esco_parms; BD_ADDR xfer_addr; - UINT16 sco_disc_reason; BOOLEAN esco_supported; /* TRUE if 1.2 cntlr AND supports eSCO links */ tBTM_SCO_TYPE desired_sco_mode; tBTM_SCO_TYPE xfer_sco_type; diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index 73c1ab70ee..6364e27d7b 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -1019,9 +1019,6 @@ typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc, #define BTM_INVALID_SCO_INDEX 0xFFFF #define BTM_INVALID_HCI_HANDLE 0xFFFF -/* Define an invalid SCO disconnect reason */ -#define BTM_INVALID_SCO_DISC_REASON 0xFFFF - /* Define first active SCO index */ #define BTM_FIRST_ACTIVE_SCO_INDEX BTM_MAX_SCO_LINKS @@ -3236,21 +3233,6 @@ UINT16 BTM_ReadScoHandle (UINT16 sco_inx); UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx); -/******************************************************************************* -** -** Function BTM_ReadScoDiscReason -** -** Description This function is returns the reason why an (e)SCO connection -** has been removed. It contains the value until read, or until -** another (e)SCO connection has disconnected. -** -** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set. -** -*******************************************************************************/ -//extern -UINT16 BTM_ReadScoDiscReason (void); - - /******************************************************************************* ** ** Function BTM_SetEScoMode