Lines Matching refs:hu
91 static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) in hci_uart_tx_complete() argument
93 struct hci_dev *hdev = hu->hdev; in hci_uart_tx_complete()
111 static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) in hci_uart_dequeue() argument
113 struct sk_buff *skb = hu->tx_skb; in hci_uart_dequeue()
116 skb = hu->proto->dequeue(hu); in hci_uart_dequeue()
118 hu->tx_skb = NULL; in hci_uart_dequeue()
123 int hci_uart_tx_wakeup(struct hci_uart *hu) in hci_uart_tx_wakeup() argument
125 if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { in hci_uart_tx_wakeup()
126 set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); in hci_uart_tx_wakeup()
132 schedule_work(&hu->write_work); in hci_uart_tx_wakeup()
139 struct hci_uart *hu = container_of(work, struct hci_uart, write_work); in hci_uart_write_work() local
140 struct tty_struct *tty = hu->tty; in hci_uart_write_work()
141 struct hci_dev *hdev = hu->hdev; in hci_uart_write_work()
149 clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); in hci_uart_write_work()
151 while ((skb = hci_uart_dequeue(hu))) { in hci_uart_write_work()
160 hu->tx_skb = skb; in hci_uart_write_work()
164 hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); in hci_uart_write_work()
168 if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) in hci_uart_write_work()
171 clear_bit(HCI_UART_SENDING, &hu->tx_state); in hci_uart_write_work()
176 struct hci_uart *hu = container_of(work, struct hci_uart, init_ready); in hci_uart_init_work() local
179 if (!test_and_clear_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_init_work()
182 err = hci_register_dev(hu->hdev); in hci_uart_init_work()
185 hci_free_dev(hu->hdev); in hci_uart_init_work()
186 hu->hdev = NULL; in hci_uart_init_work()
187 hu->proto->close(hu); in hci_uart_init_work()
190 set_bit(HCI_UART_REGISTERED, &hu->flags); in hci_uart_init_work()
193 int hci_uart_init_ready(struct hci_uart *hu) in hci_uart_init_ready() argument
195 if (!test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_init_ready()
198 schedule_work(&hu->init_ready); in hci_uart_init_ready()
219 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_flush() local
220 struct tty_struct *tty = hu->tty; in hci_uart_flush()
224 if (hu->tx_skb) { in hci_uart_flush()
225 kfree_skb(hu->tx_skb); hu->tx_skb = NULL; in hci_uart_flush()
232 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_flush()
233 hu->proto->flush(hu); in hci_uart_flush()
254 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_send_frame() local
261 hu->proto->enqueue(hu, skb); in hci_uart_send_frame()
263 hci_uart_tx_wakeup(hu); in hci_uart_send_frame()
270 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_setup() local
274 if (hu->proto->setup) in hci_uart_setup()
275 return hu->proto->setup(hu); in hci_uart_setup()
277 if (!test_bit(HCI_UART_VND_DETECT, &hu->hdev_flags)) in hci_uart_setup()
328 struct hci_uart *hu; in hci_uart_tty_open() local
337 hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL); in hci_uart_tty_open()
338 if (!hu) { in hci_uart_tty_open()
343 tty->disc_data = hu; in hci_uart_tty_open()
344 hu->tty = tty; in hci_uart_tty_open()
347 INIT_WORK(&hu->init_ready, hci_uart_init_work); in hci_uart_tty_open()
348 INIT_WORK(&hu->write_work, hci_uart_write_work); in hci_uart_tty_open()
350 spin_lock_init(&hu->rx_lock); in hci_uart_tty_open()
371 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_close() local
379 if (!hu) in hci_uart_tty_close()
382 hdev = hu->hdev; in hci_uart_tty_close()
386 cancel_work_sync(&hu->write_work); in hci_uart_tty_close()
388 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { in hci_uart_tty_close()
390 if (test_bit(HCI_UART_REGISTERED, &hu->flags)) in hci_uart_tty_close()
394 hu->proto->close(hu); in hci_uart_tty_close()
397 kfree(hu); in hci_uart_tty_close()
410 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_wakeup() local
414 if (!hu) in hci_uart_tty_wakeup()
419 if (tty != hu->tty) in hci_uart_tty_wakeup()
422 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_wakeup()
423 hci_uart_tx_wakeup(hu); in hci_uart_tty_wakeup()
441 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_receive() local
443 if (!hu || tty != hu->tty) in hci_uart_tty_receive()
446 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_receive()
449 spin_lock(&hu->rx_lock); in hci_uart_tty_receive()
450 hu->proto->recv(hu, data, count); in hci_uart_tty_receive()
452 if (hu->hdev) in hci_uart_tty_receive()
453 hu->hdev->stat.byte_rx += count; in hci_uart_tty_receive()
455 spin_unlock(&hu->rx_lock); in hci_uart_tty_receive()
460 static int hci_uart_register_dev(struct hci_uart *hu) in hci_uart_register_dev() argument
473 hu->hdev = hdev; in hci_uart_register_dev()
476 hci_set_drvdata(hdev, hu); in hci_uart_register_dev()
483 SET_HCIDEV_DEV(hdev, hu->tty->dev); in hci_uart_register_dev()
485 if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) in hci_uart_register_dev()
488 if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) in hci_uart_register_dev()
491 if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) in hci_uart_register_dev()
494 if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) in hci_uart_register_dev()
499 if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_register_dev()
508 set_bit(HCI_UART_REGISTERED, &hu->flags); in hci_uart_register_dev()
513 static int hci_uart_set_proto(struct hci_uart *hu, int id) in hci_uart_set_proto() argument
522 err = p->open(hu); in hci_uart_set_proto()
526 hu->proto = p; in hci_uart_set_proto()
528 err = hci_uart_register_dev(hu); in hci_uart_set_proto()
530 p->close(hu); in hci_uart_set_proto()
537 static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags) in hci_uart_set_flags() argument
549 hu->hdev_flags = flags; in hci_uart_set_flags()
570 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_ioctl() local
576 if (!hu) in hci_uart_tty_ioctl()
581 if (!test_and_set_bit(HCI_UART_PROTO_SET, &hu->flags)) { in hci_uart_tty_ioctl()
582 err = hci_uart_set_proto(hu, arg); in hci_uart_tty_ioctl()
584 clear_bit(HCI_UART_PROTO_SET, &hu->flags); in hci_uart_tty_ioctl()
592 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_ioctl()
593 return hu->proto->id; in hci_uart_tty_ioctl()
597 if (test_bit(HCI_UART_REGISTERED, &hu->flags)) in hci_uart_tty_ioctl()
598 return hu->hdev->id; in hci_uart_tty_ioctl()
602 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_ioctl()
604 err = hci_uart_set_flags(hu, arg); in hci_uart_tty_ioctl()
610 return hu->hdev_flags; in hci_uart_tty_ioctl()