Lines Matching refs:hu
92 static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) in hci_uart_tx_complete() argument
94 struct hci_dev *hdev = hu->hdev; in hci_uart_tx_complete()
112 static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) in hci_uart_dequeue() argument
114 struct sk_buff *skb = hu->tx_skb; in hci_uart_dequeue()
117 skb = hu->proto->dequeue(hu); in hci_uart_dequeue()
119 hu->tx_skb = NULL; in hci_uart_dequeue()
124 int hci_uart_tx_wakeup(struct hci_uart *hu) in hci_uart_tx_wakeup() argument
126 if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { in hci_uart_tx_wakeup()
127 set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); in hci_uart_tx_wakeup()
133 schedule_work(&hu->write_work); in hci_uart_tx_wakeup()
140 struct hci_uart *hu = container_of(work, struct hci_uart, write_work); in hci_uart_write_work() local
141 struct tty_struct *tty = hu->tty; in hci_uart_write_work()
142 struct hci_dev *hdev = hu->hdev; in hci_uart_write_work()
150 clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); in hci_uart_write_work()
152 while ((skb = hci_uart_dequeue(hu))) { in hci_uart_write_work()
161 hu->tx_skb = skb; in hci_uart_write_work()
165 hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); in hci_uart_write_work()
169 if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) in hci_uart_write_work()
172 clear_bit(HCI_UART_SENDING, &hu->tx_state); in hci_uart_write_work()
177 struct hci_uart *hu = container_of(work, struct hci_uart, init_ready); in hci_uart_init_work() local
180 if (!test_and_clear_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_init_work()
183 err = hci_register_dev(hu->hdev); in hci_uart_init_work()
186 hci_free_dev(hu->hdev); in hci_uart_init_work()
187 hu->hdev = NULL; in hci_uart_init_work()
188 hu->proto->close(hu); in hci_uart_init_work()
191 set_bit(HCI_UART_REGISTERED, &hu->flags); in hci_uart_init_work()
194 int hci_uart_init_ready(struct hci_uart *hu) in hci_uart_init_ready() argument
196 if (!test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_init_ready()
199 schedule_work(&hu->init_ready); in hci_uart_init_ready()
217 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_flush() local
218 struct tty_struct *tty = hu->tty; in hci_uart_flush()
222 if (hu->tx_skb) { in hci_uart_flush()
223 kfree_skb(hu->tx_skb); hu->tx_skb = NULL; in hci_uart_flush()
230 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_flush()
231 hu->proto->flush(hu); in hci_uart_flush()
249 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_send_frame() local
253 hu->proto->enqueue(hu, skb); in hci_uart_send_frame()
255 hci_uart_tx_wakeup(hu); in hci_uart_send_frame()
261 void hci_uart_set_flow_control(struct hci_uart *hu, bool enable) in hci_uart_set_flow_control() argument
263 struct tty_struct *tty = hu->tty; in hci_uart_set_flow_control()
313 void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed, in hci_uart_set_speeds() argument
316 hu->init_speed = init_speed; in hci_uart_set_speeds()
317 hu->oper_speed = oper_speed; in hci_uart_set_speeds()
320 void hci_uart_init_tty(struct hci_uart *hu) in hci_uart_init_tty() argument
322 struct tty_struct *tty = hu->tty; in hci_uart_init_tty()
339 void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed) in hci_uart_set_baudrate() argument
341 struct tty_struct *tty = hu->tty; in hci_uart_set_baudrate()
351 BT_DBG("%s: New tty speeds: %d/%d", hu->hdev->name, in hci_uart_set_baudrate()
357 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_setup() local
364 if (hu->init_speed) in hci_uart_setup()
365 speed = hu->init_speed; in hci_uart_setup()
366 else if (hu->proto->init_speed) in hci_uart_setup()
367 speed = hu->proto->init_speed; in hci_uart_setup()
372 hci_uart_set_baudrate(hu, speed); in hci_uart_setup()
375 if (hu->oper_speed) in hci_uart_setup()
376 speed = hu->oper_speed; in hci_uart_setup()
377 else if (hu->proto->oper_speed) in hci_uart_setup()
378 speed = hu->proto->oper_speed; in hci_uart_setup()
382 if (hu->proto->set_baudrate && speed) { in hci_uart_setup()
383 err = hu->proto->set_baudrate(hu, speed); in hci_uart_setup()
385 hci_uart_set_baudrate(hu, speed); in hci_uart_setup()
388 if (hu->proto->setup) in hci_uart_setup()
389 return hu->proto->setup(hu); in hci_uart_setup()
391 if (!test_bit(HCI_UART_VND_DETECT, &hu->hdev_flags)) in hci_uart_setup()
442 struct hci_uart *hu; in hci_uart_tty_open() local
451 hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL); in hci_uart_tty_open()
452 if (!hu) { in hci_uart_tty_open()
457 tty->disc_data = hu; in hci_uart_tty_open()
458 hu->tty = tty; in hci_uart_tty_open()
461 INIT_WORK(&hu->init_ready, hci_uart_init_work); in hci_uart_tty_open()
462 INIT_WORK(&hu->write_work, hci_uart_write_work); in hci_uart_tty_open()
483 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_close() local
491 if (!hu) in hci_uart_tty_close()
494 hdev = hu->hdev; in hci_uart_tty_close()
498 cancel_work_sync(&hu->write_work); in hci_uart_tty_close()
500 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { in hci_uart_tty_close()
502 if (test_bit(HCI_UART_REGISTERED, &hu->flags)) in hci_uart_tty_close()
506 hu->proto->close(hu); in hci_uart_tty_close()
509 kfree(hu); in hci_uart_tty_close()
522 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_wakeup() local
526 if (!hu) in hci_uart_tty_wakeup()
531 if (tty != hu->tty) in hci_uart_tty_wakeup()
534 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_wakeup()
535 hci_uart_tx_wakeup(hu); in hci_uart_tty_wakeup()
553 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_receive() local
555 if (!hu || tty != hu->tty) in hci_uart_tty_receive()
558 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_receive()
564 hu->proto->recv(hu, data, count); in hci_uart_tty_receive()
566 if (hu->hdev) in hci_uart_tty_receive()
567 hu->hdev->stat.byte_rx += count; in hci_uart_tty_receive()
572 static int hci_uart_register_dev(struct hci_uart *hu) in hci_uart_register_dev() argument
585 hu->hdev = hdev; in hci_uart_register_dev()
588 hci_set_drvdata(hdev, hu); in hci_uart_register_dev()
594 if (hu->proto->setup) in hci_uart_register_dev()
595 hdev->manufacturer = hu->proto->manufacturer; in hci_uart_register_dev()
602 SET_HCIDEV_DEV(hdev, hu->tty->dev); in hci_uart_register_dev()
604 if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) in hci_uart_register_dev()
607 if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) in hci_uart_register_dev()
610 if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) in hci_uart_register_dev()
613 if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) in hci_uart_register_dev()
618 if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_register_dev()
627 set_bit(HCI_UART_REGISTERED, &hu->flags); in hci_uart_register_dev()
632 static int hci_uart_set_proto(struct hci_uart *hu, int id) in hci_uart_set_proto() argument
641 err = p->open(hu); in hci_uart_set_proto()
645 hu->proto = p; in hci_uart_set_proto()
647 err = hci_uart_register_dev(hu); in hci_uart_set_proto()
649 p->close(hu); in hci_uart_set_proto()
656 static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags) in hci_uart_set_flags() argument
668 hu->hdev_flags = flags; in hci_uart_set_flags()
689 struct hci_uart *hu = tty->disc_data; in hci_uart_tty_ioctl() local
695 if (!hu) in hci_uart_tty_ioctl()
700 if (!test_and_set_bit(HCI_UART_PROTO_SET, &hu->flags)) { in hci_uart_tty_ioctl()
701 err = hci_uart_set_proto(hu, arg); in hci_uart_tty_ioctl()
703 clear_bit(HCI_UART_PROTO_SET, &hu->flags); in hci_uart_tty_ioctl()
711 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_ioctl()
712 return hu->proto->id; in hci_uart_tty_ioctl()
716 if (test_bit(HCI_UART_REGISTERED, &hu->flags)) in hci_uart_tty_ioctl()
717 return hu->hdev->id; in hci_uart_tty_ioctl()
721 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) in hci_uart_tty_ioctl()
723 err = hci_uart_set_flags(hu, arg); in hci_uart_tty_ioctl()
729 return hu->hdev_flags; in hci_uart_tty_ioctl()