Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e728bbda authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap: Simplify DisconnectRsp

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working & OPP
Change-Id: I3c4c18bc6d55fe3aa8acda4db8d72f97781729ec
parent 5ea67bfb
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
@@ -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);
+6 −2
Original line number Diff line number Diff line
@@ -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    */
+0 −1
Original line number Diff line number Diff line
@@ -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
 ***********************************