/* Close protocol */ static int brcm_close(struct hci_uart *hu) { struct brcm_struct *brcm = hu->priv; BT_DBG("hu %p", hu); skb_queue_purge(&brcm->tx_wait_q); skb_queue_purge(&brcm->txq); brcm->hcibrcm_state = HCIBRCM_ASLEEP; del_timer(&sleep_timer); deassert_bt_wake(brcm->btwake_gpio, brcm->hostwake_gpio); __brcm_bcm_serial_clock_request_off(hu); if (brcm->rx_skb) kfree_skb(brcm->rx_skb); if (hw_struct) { bcm_bzhw_stop(hw_struct); hw_struct = NULL; kfree(hw_struct); } hu->priv = NULL; kfree(brcm); return 0; }
// // timeout handler // void sleep_timer_function(unsigned long data) { struct brcm_struct *lbrcm = (struct brcm_struct *)data; if (lbrcm->is_there_activity) { lbrcm->inactive_period = 0; lbrcm->is_there_activity = 0; } else { if (lbrcm->hcibrcm_state != HCIBRCM_ASLEEP) { lbrcm->inactive_period += TIMER_PERIOD; if (lbrcm->inactive_period >= HOST_CONTROLLER_IDLE_TSH) { // deassert BT_WAKE signal BT_DBG("Deassert wake signal, moves to ASLEEP"); lbrcm->hcibrcm_state = HCIBRCM_ASLEEP; lbrcm->inactive_period = 0; deassert_bt_wake(); } } } mod_timer(&sleep_timer, jiffies + TIMER_PERIOD*HZ/1000); }
/** * timeout handler */ void sleep_timer_function(unsigned long data) { struct brcm_struct *lbrcm = (struct brcm_struct *)data; if (lbrcm->is_there_activity) { lbrcm->inactive_period = 0; lbrcm->is_there_activity = 0; } else { /*if (lbrcm->hcibrcm_state != HCIBRCM_ASLEEP) {*/ lbrcm->inactive_period += TIMER_PERIOD; if (lbrcm->inactive_period >= HOST_CONTROLLER_IDLE_TSH) { /* deassert BT_WAKE signal*/ BT_DBG("Deassert wake signal, moves to ASLEEP"); lbrcm->hcibrcm_state = HCIBRCM_ASLEEP; lbrcm->inactive_period = 0; deassert_bt_wake(lbrcm->btwake_gpio, lbrcm->hostwake_gpio); } /*}*/ } if (lbrcm->hcibrcm_state != HCIBRCM_ASLEEP) { mod_timer(&sleep_timer, jiffies + msecs_to_jiffies(TIMER_PERIOD)); } }