diff --git a/fm_hci/fm_hci.c b/fm_hci/fm_hci.c index c48edd5f55cbbcae6242092df18eb170c2bfd32c..378e0c909ca0c782f2c622f2afb72a548be17086 100644 --- a/fm_hci/fm_hci.c +++ b/fm_hci/fm_hci.c @@ -677,6 +677,12 @@ void fm_hci_close(void *arg) { return; } event_notification(hci, HC_EVENT_EXIT); + pthread_mutex_lock(&hci->event_lock); +again: + pthread_cond_wait(&hci->event_cond, &hci->event_lock); + if (!(ready_events & HC_EVENT_EXIT_DONE)) + goto again; + pthread_mutex_unlock(&hci->event_lock); } int fm_hci_init(fm_hci_hal_t *hci_hal) @@ -785,6 +791,7 @@ static void fm_hci_exit(void *arg) vendor_close(hci); pthread_cond_broadcast(&hci->event_cond); pthread_cond_broadcast(&hci->cmd_credits_cond); + event_notification(hci, HC_EVENT_EXIT_DONE); stop_rx_thread(hci); stop_tx_thread(hci); ALOGD("Tx, Rx Threads join done"); diff --git a/fm_hci/fm_hci.h b/fm_hci/fm_hci.h index 8818068e834201e01553eea38c6b23fe1574920e..2cfb30eaaeeb529d18af20c8527b289be785f459 100644 --- a/fm_hci/fm_hci.h +++ b/fm_hci/fm_hci.h @@ -46,6 +46,7 @@ #define HC_EVENT_LPM_IDLE_TIMEOUT 0x0100 #define HC_EVENT_EXIT 0x0200 #define HC_EVENT_EPILOG 0x0400 +#define HC_EVENT_EXIT_DONE 0x8000 #define MAX_FM_CMD_CNT 100 #define FM_CMD 0x11