Lines Matching refs:hu

24 static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type)  in hci_uart_tx_complete()  argument
26 struct hci_dev *hdev = hu->hdev; in hci_uart_tx_complete()
44 static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) in hci_uart_dequeue() argument
46 struct sk_buff *skb = hu->tx_skb; in hci_uart_dequeue()
49 if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) in hci_uart_dequeue()
50 skb = hu->proto->dequeue(hu); in hci_uart_dequeue()
52 hu->tx_skb = NULL; in hci_uart_dequeue()
59 struct hci_uart *hu = container_of(work, struct hci_uart, write_work); in hci_uart_write_work() local
60 struct serdev_device *serdev = hu->serdev; in hci_uart_write_work()
61 struct hci_dev *hdev = hu->hdev; in hci_uart_write_work()
68 clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); in hci_uart_write_work()
70 while ((skb = hci_uart_dequeue(hu))) { in hci_uart_write_work()
79 hu->tx_skb = skb; in hci_uart_write_work()
83 hci_uart_tx_complete(hu, hci_skb_pkt_type(skb)); in hci_uart_write_work()
86 } while (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)); in hci_uart_write_work()
88 clear_bit(HCI_UART_SENDING, &hu->tx_state); in hci_uart_write_work()
96 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_flush() local
98 BT_DBG("hdev %p serdev %p", hdev, hu->serdev); in hci_uart_flush()
100 if (hu->tx_skb) { in hci_uart_flush()
101 kfree_skb(hu->tx_skb); hu->tx_skb = NULL; in hci_uart_flush()
105 serdev_device_write_flush(hu->serdev); in hci_uart_flush()
107 if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) in hci_uart_flush()
108 hu->proto->flush(hu); in hci_uart_flush()
116 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_open() local
125 if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) { in hci_uart_open()
126 err = serdev_device_open(hu->serdev); in hci_uart_open()
129 set_bit(HCI_UART_PROTO_READY, &hu->flags); in hci_uart_open()
141 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_close() local
145 if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) in hci_uart_close()
156 clear_bit(HCI_UART_PROTO_READY, &hu->flags); in hci_uart_close()
157 serdev_device_close(hu->serdev); in hci_uart_close()
166 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_send_frame() local
171 hu->proto->enqueue(hu, skb); in hci_uart_send_frame()
173 hci_uart_tx_wakeup(hu); in hci_uart_send_frame()
180 struct hci_uart *hu = hci_get_drvdata(hdev); in hci_uart_setup() local
187 if (hu->init_speed) in hci_uart_setup()
188 speed = hu->init_speed; in hci_uart_setup()
189 else if (hu->proto->init_speed) in hci_uart_setup()
190 speed = hu->proto->init_speed; in hci_uart_setup()
195 serdev_device_set_baudrate(hu->serdev, speed); in hci_uart_setup()
198 if (hu->oper_speed) in hci_uart_setup()
199 speed = hu->oper_speed; in hci_uart_setup()
200 else if (hu->proto->oper_speed) in hci_uart_setup()
201 speed = hu->proto->oper_speed; in hci_uart_setup()
205 if (hu->proto->set_baudrate && speed) { in hci_uart_setup()
206 err = hu->proto->set_baudrate(hu, speed); in hci_uart_setup()
210 serdev_device_set_baudrate(hu->serdev, speed); in hci_uart_setup()
213 if (hu->proto->setup) in hci_uart_setup()
214 return hu->proto->setup(hu); in hci_uart_setup()
216 if (!test_bit(HCI_UART_VND_DETECT, &hu->hdev_flags)) in hci_uart_setup()
242 struct hci_uart *hu = serdev_device_get_drvdata(serdev); in hci_uart_write_wakeup() local
246 if (!hu || serdev != hu->serdev) { in hci_uart_write_wakeup()
251 if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) in hci_uart_write_wakeup()
252 hci_uart_tx_wakeup(hu); in hci_uart_write_wakeup()
268 struct hci_uart *hu = serdev_device_get_drvdata(serdev); in hci_uart_receive_buf() local
270 if (!hu || serdev != hu->serdev) { in hci_uart_receive_buf()
275 if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) in hci_uart_receive_buf()
281 hu->proto->recv(hu, data, count); in hci_uart_receive_buf()
283 if (hu->hdev) in hci_uart_receive_buf()
284 hu->hdev->stat.byte_rx += count; in hci_uart_receive_buf()
294 int hci_uart_register_device(struct hci_uart *hu, in hci_uart_register_device() argument
302 serdev_device_set_client_ops(hu->serdev, &hci_serdev_client_ops); in hci_uart_register_device()
304 err = serdev_device_open(hu->serdev); in hci_uart_register_device()
308 err = p->open(hu); in hci_uart_register_device()
312 hu->proto = p; in hci_uart_register_device()
313 set_bit(HCI_UART_PROTO_READY, &hu->flags); in hci_uart_register_device()
323 hu->hdev = hdev; in hci_uart_register_device()
326 hci_set_drvdata(hdev, hu); in hci_uart_register_device()
328 INIT_WORK(&hu->init_ready, hci_uart_init_work); in hci_uart_register_device()
329 INIT_WORK(&hu->write_work, hci_uart_write_work); in hci_uart_register_device()
330 percpu_init_rwsem(&hu->proto_lock); in hci_uart_register_device()
336 if (hu->proto->setup) in hci_uart_register_device()
337 hdev->manufacturer = hu->proto->manufacturer; in hci_uart_register_device()
344 SET_HCIDEV_DEV(hdev, &hu->serdev->dev); in hci_uart_register_device()
346 if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) in hci_uart_register_device()
349 if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) in hci_uart_register_device()
352 if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) in hci_uart_register_device()
357 if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) in hci_uart_register_device()
366 set_bit(HCI_UART_REGISTERED, &hu->flags); in hci_uart_register_device()
373 clear_bit(HCI_UART_PROTO_READY, &hu->flags); in hci_uart_register_device()
374 p->close(hu); in hci_uart_register_device()
376 serdev_device_close(hu->serdev); in hci_uart_register_device()
381 void hci_uart_unregister_device(struct hci_uart *hu) in hci_uart_unregister_device() argument
383 struct hci_dev *hdev = hu->hdev; in hci_uart_unregister_device()
385 cancel_work_sync(&hu->init_ready); in hci_uart_unregister_device()
386 if (test_bit(HCI_UART_REGISTERED, &hu->flags)) in hci_uart_unregister_device()
390 cancel_work_sync(&hu->write_work); in hci_uart_unregister_device()
392 hu->proto->close(hu); in hci_uart_unregister_device()
394 if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) { in hci_uart_unregister_device()
395 clear_bit(HCI_UART_PROTO_READY, &hu->flags); in hci_uart_unregister_device()
396 serdev_device_close(hu->serdev); in hci_uart_unregister_device()