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

Commit 4c8f06f9 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

gatt: Remove reduntant `in_use` flag

Now, when clcb is dynamic, there is no need to keep in_use flag, as it
is always true when clcb exist.

Bug: 249431973
Test: atest BluetoothInstrumentationTests
Test: manual GATT operation testing
Tag: #feature
Change-Id: I1bfb4c546c41ca590942feab718b597514f8a59e
parent e254b2fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1169,7 +1169,7 @@ void GATT_Deregister(tGATT_IF gatt_if) {

    for (auto clcb_it = gatt_cb.clcb_queue.begin();
         clcb_it != gatt_cb.clcb_queue.end();) {
      if (clcb_it->in_use && (clcb_it->p_reg->gatt_if == gatt_if) &&
      if ((clcb_it->p_reg->gatt_if == gatt_if) &&
          (clcb_it->p_tcb->tcb_idx == p_tcb->tcb_idx)) {
        alarm_cancel(clcb_it->gatt_rsp_timer_ent);
        gatt_clcb_invalidate(p_tcb, &(*clcb_it));
+6 −6
Original line number Diff line number Diff line
@@ -1205,6 +1205,12 @@ void gatt_client_handle_server_rsp(tGATT_TCB& tcb, uint16_t cid,

  uint8_t cmd_code = 0;
  tGATT_CLCB* p_clcb = gatt_cmd_dequeue(tcb, cid, &cmd_code);
  if (!p_clcb) {
    LOG_WARN("ATT - clcb already not in use, ignoring response");
    gatt_cl_send_next_cmd_inq(tcb);
    return;
  }

  uint8_t rsp_code = gatt_cmd_to_rsp_code(cmd_code);
  if (!p_clcb) {
    LOG_WARN("ATT - clcb already not in use, ignoring response");
@@ -1219,12 +1225,6 @@ void gatt_client_handle_server_rsp(tGATT_TCB& tcb, uint16_t cid,
    return;
  }

  if (!p_clcb->in_use) {
    LOG(WARNING) << "ATT - clcb already not in use, ignoring response";
    gatt_cl_send_next_cmd_inq(tcb);
    return;
  }

  gatt_stop_rsp_timer(p_clcb);
  p_clcb->retry_count = 0;

+0 −1
Original line number Diff line number Diff line
@@ -370,7 +370,6 @@ struct tGATT_CLCB {
  tGATT_STATUS status;     /* operation status */
  bool first_read_blob_after_read;
  tGATT_READ_INC_UUID128 read_uuid128;
  bool in_use;
  alarm_t* gatt_rsp_timer_ent; /* peer response timer */
  uint8_t retry_count;
  uint16_t read_req_current_mtu; /* This is the MTU value that the read was
+2 −3
Original line number Diff line number Diff line
@@ -983,7 +983,6 @@ tGATT_CLCB* gatt_clcb_alloc(uint16_t conn_id) {
  tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx);
  tGATT_REG* p_reg = gatt_get_regcb(gatt_if);

  clcb.in_use = true;
  clcb.conn_id = conn_id;
  clcb.p_reg = p_reg;
  clcb.p_tcb = p_tcb;
@@ -1137,7 +1136,7 @@ uint16_t gatt_tcb_get_payload_size_rx(tGATT_TCB& tcb, uint16_t cid) {
 *
 ******************************************************************************/
void gatt_clcb_dealloc(tGATT_CLCB* p_clcb) {
  if (p_clcb && p_clcb->in_use) {
  if (p_clcb) {
    alarm_free(p_clcb->gatt_rsp_timer_ent);
    for (auto clcb_it = gatt_cb.clcb_queue.begin();
         clcb_it != gatt_cb.clcb_queue.end(); clcb_it++) {
@@ -1232,7 +1231,7 @@ uint8_t gatt_num_clcb_by_bd_addr(const RawAddress& bda) {
  uint8_t num = 0;

  for (auto const& clcb : gatt_cb.clcb_queue) {
    if (clcb.in_use && clcb.p_tcb->peer_bda == bda) num++;
    if (clcb.p_tcb->peer_bda == bda) num++;
  }
  return num;
}