From 014930dadcbd6249745437b4d6a15bfaa8b4e804 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Sun, 27 Sep 2020 00:12:49 -0700 Subject: [PATCH] L2cap: Simplify DisconnectRsp Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working & OPP Change-Id: I3c4c18bc6d55fe3aa8acda4db8d72f97781729ec --- stack/l2cap/l2c_api.cc | 31 ------------------------------- stack/l2cap/l2c_csm.cc | 8 ++++++-- stack/l2cap/l2c_int.h | 1 - 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/stack/l2cap/l2c_api.cc b/stack/l2cap/l2c_api.cc index 339355ac9..5bf7aefaf 100644 --- a/stack/l2cap/l2c_api.cc +++ b/stack/l2cap/l2c_api.cc @@ -791,37 +791,6 @@ bool L2CA_DisconnectReq(uint16_t cid) { return (true); } -/******************************************************************************* - * - * Function L2CA_DisconnectRsp - * - * Description Higher layers call this function to acknowledge the - * disconnection of a channel. - * - * Returns void - * - ******************************************************************************/ -bool L2CA_DisconnectRsp(uint16_t cid) { - if (bluetooth::shim::is_gd_shim_enabled()) { - return bluetooth::shim::L2CA_DisconnectRsp(cid); - } - - tL2C_CCB* p_ccb; - - L2CAP_TRACE_API("L2CA_DisconnectRsp() CID: 0x%04x", cid); - - /* Find the channel control block. We don't know the link it is on. */ - p_ccb = l2cu_find_ccb_by_cid(NULL, cid); - if (p_ccb == NULL) { - L2CAP_TRACE_WARNING("L2CAP - no CCB for L2CA_disc_rsp, CID: %d", cid); - return (false); - } - - l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_RSP, NULL); - - return (true); -} - bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { if (bluetooth::shim::is_gd_shim_enabled()) { return bluetooth::shim::L2CA_GetRemoteCid(lcid, rcid); diff --git a/stack/l2cap/l2c_csm.cc b/stack/l2cap/l2c_csm.cc index 344ce8849..39579da26 100644 --- a/stack/l2cap/l2c_csm.cc +++ b/stack/l2cap/l2c_csm.cc @@ -74,6 +74,10 @@ static void l2c_csm_send_config_rsp_ok(tL2C_CCB* p_ccb) { l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONFIG_RSP, &config); } +static void l2c_csm_send_disconnect_rsp(tL2C_CCB* p_ccb) { + l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_RSP, NULL); +} + /******************************************************************************* * * Function l2c_csm_execute @@ -854,7 +858,7 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { "L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x Conf Needed", p_ccb->local_cid); (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); - L2CA_DisconnectRsp(p_ccb->local_cid); + l2c_csm_send_disconnect_rsp(p_ccb); break; case L2CEVT_L2CA_CONFIG_REQ: /* Upper layer config req */ @@ -1034,7 +1038,7 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { "L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x Conf Needed", p_ccb->local_cid); (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); - L2CA_DisconnectRsp(p_ccb->local_cid); + l2c_csm_send_disconnect_rsp(p_ccb); break; case L2CEVT_L2CAP_DATA: /* Peer data packet rcvd */ diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h index 5c51c9c22..e6e73dcb0 100644 --- a/stack/l2cap/l2c_int.h +++ b/stack/l2cap/l2c_int.h @@ -623,7 +623,6 @@ extern bool l2cu_create_conn_le(tL2C_LCB* p_lcb); extern bool l2cu_create_conn_le(tL2C_LCB* p_lcb, uint8_t initiating_phys); extern void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb); extern void l2cu_adjust_out_mps(tL2C_CCB* p_ccb); -extern bool L2CA_DisconnectRsp(uint16_t cid); /* Functions provided by l2c_link.cc *********************************** -- 2.11.0