static void hci_uart_write_work(struct work_struct *work) { struct hci_uart *hu = container_of(work, struct hci_uart, write_work); struct serdev_device *serdev = hu->serdev; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; /* REVISIT: * should we cope with bad skbs or ->write() returning an error value? */ do { clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len; len = serdev_device_write_buf(serdev, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, hci_skb_pkt_type(skb)); kfree_skb(skb); } } while(test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)); clear_bit(HCI_UART_SENDING, &hu->tx_state); }
int hci_uart_tx_wakeup_sprd(struct hci_uart *hu, int is_queue_empty, bool is_data, bool send_by_timer) { struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; int skb_len, len; /* if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { BT_DBG("return 0"); set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } */ if(!is_data) { unsigned char data = 0xaa; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); if(NULL != hu->tx_skb) { goto restart; } if((1 == is_queue_empty) ||(send_by_timer == true)) { tty->ops->write(tty, &data, 1); BT_UART_DBG("sending 0xaa "); mod_timer(&timer_retransmit, jiffies + HZ / 100); } clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; } restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); skb_len = 0; len = 0; while ((skb = hci_uart_dequeue(hu))) { skb_len = skb->len; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; BT_UART_DBG("sk_data:type 0x%x len=%d skb_len %d data:0x%x 0x%x 0x%x",bt_cb(skb)->pkt_type, len, skb->len, skb->data[1], skb->data[2], skb->data[3]); skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } BT_DBG(""); restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); #if !defined(CONFIG_MT5931_MT6622) /*added by Barry,for broadcom 4325*/ #ifdef CONFIG_BT_AUTOSLEEP #ifdef CONFIG_RFKILL_RK extern int rfkill_rk_sleep_bt(bool bSleep); rfkill_rk_sleep_bt(false); #else //extern void bcm4325_sleep(unsigned long bSleep); //bcm4325_sleep(0); #endif #endif #endif while ((skb = hci_uart_dequeue(hu))) { int len; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); #if defined(CONFIG_MT5931_MT6622) /* Host can enter sleep after 5s no UART data */ wake_lock_timeout(&bt_wake_lock, WAKE_LOCK_TIMEOUT); #endif return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; #if defined(CONFIG_BT_CSR8811) if(hdev == NULL) return -1; #endif if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } BT_DBG(""); restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len; /* Samsung Bluetooth Feature.2012.01.19 * Add wake_peer uart operation which is called before starting UART TX */ #if !defined(CONFIG_BT_CSR8811) if (hdev->wake_peer) hdev->wake_peer(hdev); #endif set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; #endif if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } BT_DBG(""); #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) schedule_work(&hu->write_work); #else restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); #endif return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { cyg_io_handle_t serial = hu->tty; struct hci_dev *hdev = &hu->hdev; struct sk_buff *skb; if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } // BT_DBG(""); restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len = skb->len; int ret; //set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); //len = tty->driver.write(tty, 0, skb->data, skb->len);//UART write //diag_printf("write skb = %x\n",skb); //diag_printf("data[0] %x %x %x %x\n",skb->data[0],skb->data[1],skb->data[2],skb->data[3]); ret = (int)cyg_io_write(serial, skb->data, (cyg_uint32*)&len); if(ret != ENOERR) break; hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, skb->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } BT_DBG(""); restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len; if (hdev->wake_peer) hdev->wake_peer(hdev); set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; }
int hci_uart_tx_wakeup(struct hci_uart *hu) { struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); return 0; } BT_DBG(""); restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); /*added by Barry,for broadcom 4325*/ #ifdef CONFIG_BT_HCIBCM4325 bcm4325_sleep(0); #endif while ((skb = hci_uart_dequeue(hu))) { int len; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return 0; }
static void hci_uart_write_work(struct work_struct *work) { struct hci_uart *hu = container_of(work, struct hci_uart, write_work); struct tty_struct *tty = hu->tty; struct hci_dev *hdev = hu->hdev; struct sk_buff *skb; /* REVISIT: should we cope with bad skbs or ->write() returning * and error value ? */ restart: clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); while ((skb = hci_uart_dequeue(hu))) { int len; set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); len = tty->ops->write(tty, skb->data, skb->len); hdev->stat.byte_tx += len; skb_pull(skb, len); if (skb->len) { hu->tx_skb = skb; break; } hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); kfree_skb(skb); } if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) goto restart; clear_bit(HCI_UART_SENDING, &hu->tx_state); return; }