فهرست منبع

btfmcodec: cancel workqueue

This change will cancel workqueue when bearer indication
is received.

Change-Id: Ib16849e684d6c2fb2ded817baff7ab31b5cbd6db
Signed-off-by: Balakrishna Godavarthi <[email protected]>
Balakrishna Godavarthi 1 سال پیش
والد
کامیت
d9dbe6c5bd
2فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 8 0
      btfmcodec/btfm_codec.c
  2. 1 2
      btfmcodec/btfm_codec_btadv_interface.c

+ 8 - 0
btfmcodec/btfm_codec.c

@@ -141,6 +141,7 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
 	uint32_t len;
 	uint8_t status;
 	int idx;
+	uint8_t *bearer_switch_ind;
 
 	BTFMCODEC_DBG("start");
 	while ((skb = skb_dequeue(&btfmcodec_dev->rxq))) {
@@ -163,6 +164,10 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
 				  wake_up_interruptible(&btfmcodec_dev->rsp_wait_q[BTM_PKT_TYPE_BEARER_SWITCH_IND]);
 				}
 				btfmcodec_dev->status[idx] = skb->data[0];
+				/* Reset bearer switch ind flag */
+				bearer_switch_ind =
+					&btfmcodec_dev->status[BTM_PKT_TYPE_BEARER_SWITCH_IND];
+				*bearer_switch_ind = BTM_WAITING_RSP;
 				queue_work(btfmcodec_dev->workqueue, &btfmcodec_dev->wq_prepare_bearer);
 			} else {
 				BTFMCODEC_ERR("wrong packet format with len:%d", len);
@@ -215,6 +220,9 @@ static void btfmcodec_dev_rxwork(struct work_struct *work)
 			BTFMCODEC_INFO("Rx BTM_BTFMCODEC_CTRL_MASTER_SHUTDOWN_RSP status:%d",
 				status);
 			wake_up_interruptible(&btfmcodec_dev->rsp_wait_q[idx]);
+			BTFMCODEC_INFO("%s: waiting to cancel prepare bearer wq", __func__);
+			cancel_work_sync(&btfmcodec_dev->wq_prepare_bearer);
+			BTFMCODEC_INFO("%s: prepare bearer wq canceled", __func__);
 			break;
 		case BTM_BTFMCODEC_BEARER_SWITCH_IND:
 			idx = BTM_PKT_TYPE_BEARER_SWITCH_IND;

+ 1 - 2
btfmcodec/btfm_codec_btadv_interface.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 202333 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include "btfm_codec.h"
@@ -123,7 +123,6 @@ int btfmcodec_wait_for_bearer_ind(struct btfmcodec_char_device *btfmcodec_dev)
 	int ret;
 	uint8_t *status = &btfmcodec_dev->status[BTM_PKT_TYPE_BEARER_SWITCH_IND];
 
-	*status = BTM_WAITING_RSP;
 	ret = wait_event_interruptible_timeout(*rsp_wait_q,
 		*status != BTM_WAITING_RSP,
 		msecs_to_jiffies(BTM_MASTER_CONFIG_RSP_TIMEOUT));