aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-04-03 14:54:47 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-04-04 12:16:10 -0400
commit7b1abbbed0f2a1bc19bb8c0d48a284466043092a (patch)
tree2f79924c7a5dc4c128a9a8c45fa4671c062a0efe /net/bluetooth
parent02350a725f5bc44490c30a10e7e04a12a5ecd406 (diff)
Bluetooth: Add __hci_cmd_sync_ev function
This patch adds a __hci_cmd_sync_ev function, analogous to __hci_cmd_sync except that it also takes an event parameter to indicate that the command completes with a special event instead of command complete. Internally this new function takes advantage of the hci_req_add_ev function introduced in the previous patch. The primary expected user of this new function are the setup routines of HCI drivers which may want to send custom commands and return only when they have completed. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 7f1413cae2cb..9567e32a1f0c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -79,7 +79,7 @@ static void hci_req_cancel(struct hci_dev *hdev, int err)
79 } 79 }
80} 80}
81 81
82struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode) 82struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 event)
83{ 83{
84 struct hci_ev_cmd_complete *ev; 84 struct hci_ev_cmd_complete *ev;
85 struct hci_event_hdr *hdr; 85 struct hci_event_hdr *hdr;
@@ -103,6 +103,12 @@ struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode)
103 hdr = (void *) skb->data; 103 hdr = (void *) skb->data;
104 skb_pull(skb, HCI_EVENT_HDR_SIZE); 104 skb_pull(skb, HCI_EVENT_HDR_SIZE);
105 105
106 if (event) {
107 if (hdr->evt != event)
108 goto failed;
109 return skb;
110 }
111
106 if (hdr->evt != HCI_EV_CMD_COMPLETE) { 112 if (hdr->evt != HCI_EV_CMD_COMPLETE) {
107 BT_DBG("Last event is not cmd complete (0x%2.2x)", hdr->evt); 113 BT_DBG("Last event is not cmd complete (0x%2.2x)", hdr->evt);
108 goto failed; 114 goto failed;
@@ -127,8 +133,8 @@ failed:
127 return ERR_PTR(-ENODATA); 133 return ERR_PTR(-ENODATA);
128} 134}
129 135
130struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 136struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
131 void *param, u32 timeout) 137 void *param, u8 event, u32 timeout)
132{ 138{
133 DECLARE_WAITQUEUE(wait, current); 139 DECLARE_WAITQUEUE(wait, current);
134 struct hci_request req; 140 struct hci_request req;
@@ -138,7 +144,7 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
138 144
139 hci_req_init(&req, hdev); 145 hci_req_init(&req, hdev);
140 146
141 hci_req_add(&req, opcode, plen, param); 147 hci_req_add_ev(&req, opcode, plen, param, event);
142 148
143 hdev->req_status = HCI_REQ_PEND; 149 hdev->req_status = HCI_REQ_PEND;
144 150
@@ -177,7 +183,14 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
177 if (err < 0) 183 if (err < 0)
178 return ERR_PTR(err); 184 return ERR_PTR(err);
179 185
180 return hci_get_cmd_complete(hdev, opcode); 186 return hci_get_cmd_complete(hdev, opcode, event);
187}
188EXPORT_SYMBOL(__hci_cmd_sync_ev);
189
190struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
191 void *param, u32 timeout)
192{
193 return __hci_cmd_sync_ev(hdev, opcode, plen, param, 0, timeout);
181} 194}
182EXPORT_SYMBOL(__hci_cmd_sync); 195EXPORT_SYMBOL(__hci_cmd_sync);
183 196