30 #include <linux/module.h>
31 #include <linux/kernel.h>
34 #include <linux/sched.h>
35 #include <linux/types.h>
36 #include <linux/fcntl.h>
38 #include <linux/ptrace.h>
39 #include <linux/poll.h>
41 #include <linux/slab.h>
42 #include <linux/tty.h>
43 #include <linux/errno.h>
44 #include <linux/string.h>
45 #include <linux/signal.h>
55 #define HCILL_GO_TO_SLEEP_IND 0x30
56 #define HCILL_GO_TO_SLEEP_ACK 0x31
57 #define HCILL_WAKE_UP_IND 0x32
58 #define HCILL_WAKE_UP_ACK 0x33
61 #define HCILL_W4_PACKET_TYPE 0
62 #define HCILL_W4_EVENT_HDR 1
63 #define HCILL_W4_ACL_HDR 2
64 #define HCILL_W4_SCO_HDR 3
65 #define HCILL_W4_DATA 4
100 BT_DBG(
"hu %p cmd 0x%x", hu, cmd);
105 BT_ERR(
"cannot allocate memory for HCILL packet");
122 static int ll_open(
struct hci_uart *hu)
132 skb_queue_head_init(&ll->
txq);
144 static int ll_flush(
struct hci_uart *hu)
157 static int ll_close(
struct hci_uart *hu)
182 static void __ll_do_awake(
struct ll_struct *ll)
195 static void ll_device_want_to_wakeup(
struct hci_uart *hu)
217 BT_DBG(
"dual wake-up-indication");
222 BT_ERR(
"cannot acknowledge device wake up");
236 spin_unlock_irqrestore(&ll->
hcill_lock, flags);
245 static void ll_device_want_to_sleep(
struct hci_uart *hu)
261 BT_ERR(
"cannot acknowledge device sleep");
269 spin_unlock_irqrestore(&ll->
hcill_lock, flags);
278 static void ll_device_woke_up(
struct hci_uart *hu)
295 spin_unlock_irqrestore(&ll->
hcill_lock, flags);
305 unsigned long flags = 0;
308 BT_DBG(
"hu %p skb %p", hu, skb);
319 BT_DBG(
"device awake, sending normally");
323 BT_DBG(
"device asleep, waking up and queueing packet");
328 BT_ERR(
"cannot wake up device");
334 BT_DBG(
"device waking up, queueing packet");
344 spin_unlock_irqrestore(&ll->
hcill_lock, flags);
349 static inline int ll_check_data_len(
struct ll_struct *ll,
int len)
351 int room = skb_tailroom(ll->
rx_skb);
353 BT_DBG(
"len %d room %d", len, room);
357 }
else if (len > room) {
358 BT_ERR(
"Data length is too large");
390 ll->
rx_count -= len; count -= len; ptr += len;
407 BT_DBG(
"Event header: evt 0x%2.2x plen %d", eh->
evt, eh->
plen);
409 ll_check_data_len(ll, eh->
plen);
416 BT_DBG(
"ACL header: dlen %d", dlen);
418 ll_check_data_len(ll, dlen);
426 ll_check_data_len(ll, sh->
dlen);
456 BT_DBG(
"HCILL_GO_TO_SLEEP_IND packet");
457 ll_device_want_to_sleep(hu);
468 BT_DBG(
"HCILL_WAKE_UP_IND packet");
469 ll_device_want_to_wakeup(hu);
474 BT_DBG(
"HCILL_WAKE_UP_ACK packet");
475 ll_device_woke_up(hu);
480 BT_ERR(
"Unknown HCI packet type %2.2x", (
__u8)*ptr);
481 hu->
hdev->stat.err_rx++;
491 BT_ERR(
"Can't allocate mem for new packet");
515 .enqueue = ll_enqueue,
516 .dequeue = ll_dequeue,
525 BT_INFO(
"HCILL protocol initialized");
527 BT_ERR(
"HCILL protocol registration failed");