OSDN Git Service

L2cap: Simplify DisconnectRsp
authorHansong Zhang <hsz@google.com>
Sun, 27 Sep 2020 07:12:49 +0000 (00:12 -0700)
committerHansong Zhang <hsz@google.com>
Mon, 28 Sep 2020 06:38:08 +0000 (23:38 -0700)
Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working & OPP
Change-Id: I3c4c18bc6d55fe3aa8acda4db8d72f97781729ec

stack/l2cap/l2c_api.cc
stack/l2cap/l2c_csm.cc
stack/l2cap/l2c_int.h

index 339355a..5bf7aef 100644 (file)
@@ -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);
index 344ce88..39579da 100644 (file)
@@ -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    */
index 5c51c9c..e6e73dc 100644 (file)
@@ -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
  ***********************************