Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: hci_core: Introduce hci_recv_event_data

This introduces hci_recv_event_data to make it simpler to access the
contents of last received event rather than having to pass its contents
to the likes of *_ind/*_cfm callbacks.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+37
+2
include/net/bluetooth/hci_core.h
··· 525 525 struct sk_buff_head cmd_q; 526 526 527 527 struct sk_buff *sent_cmd; 528 + struct sk_buff *recv_event; 528 529 529 530 struct mutex req_lock; 530 531 wait_queue_head_t req_wait_q; ··· 1748 1747 void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); 1749 1748 1750 1749 void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); 1750 + void *hci_recv_event_data(struct hci_dev *hdev, __u8 event); 1751 1751 1752 1752 u32 hci_conn_get_phy(struct hci_conn *conn); 1753 1753
+32
net/bluetooth/hci_core.c
··· 2712 2712 2713 2713 ida_simple_remove(&hci_index_ida, hdev->id); 2714 2714 kfree_skb(hdev->sent_cmd); 2715 + kfree_skb(hdev->recv_event); 2715 2716 kfree(hdev); 2716 2717 } 2717 2718 EXPORT_SYMBOL(hci_release_dev); ··· 3017 3016 BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); 3018 3017 3019 3018 return hdev->sent_cmd->data + HCI_COMMAND_HDR_SIZE; 3019 + } 3020 + 3021 + /* Get data from last received event */ 3022 + void *hci_recv_event_data(struct hci_dev *hdev, __u8 event) 3023 + { 3024 + struct hci_event_hdr *hdr; 3025 + int offset; 3026 + 3027 + if (!hdev->recv_event) 3028 + return NULL; 3029 + 3030 + hdr = (void *)hdev->recv_event->data; 3031 + offset = sizeof(*hdr); 3032 + 3033 + if (hdr->evt != event) { 3034 + /* In case of LE metaevent check the subevent match */ 3035 + if (hdr->evt == HCI_EV_LE_META) { 3036 + struct hci_ev_le_meta *ev; 3037 + 3038 + ev = (void *)hdev->recv_event->data + offset; 3039 + offset += sizeof(*ev); 3040 + if (ev->subevent == event) 3041 + goto found; 3042 + } 3043 + return NULL; 3044 + } 3045 + 3046 + found: 3047 + bt_dev_dbg(hdev, "event 0x%2.2x", event); 3048 + 3049 + return hdev->recv_event->data + offset; 3020 3050 } 3021 3051 3022 3052 /* Send ACL data */
+3
net/bluetooth/hci_event.c
··· 6936 6936 goto done; 6937 6937 } 6938 6938 6939 + kfree_skb(hdev->recv_event); 6940 + hdev->recv_event = skb_clone(skb, GFP_KERNEL); 6941 + 6939 6942 event = hdr->evt; 6940 6943 if (!event) { 6941 6944 bt_dev_warn(hdev, "Received unexpected HCI Event 0x%2.2x",