aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-04-02 06:41:09 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-04-02 10:09:27 -0400
commitf60cb30579d3401cab1ed36b42df5c0568ae0ba7 (patch)
tree27f3b73ea066bb1053857cbee1c5c938c2564fd1 /net/bluetooth
parente6214487492566b15ff24e97c6747bb2e5d9e040 (diff)
Bluetooth: Convert hci_req_sync family of function to new request API
Now that there's an API in place that allows passing the resulting skb to the request callback we can conveniently convert the hci_req_sync and related functions to use it. Since we still need to get the skb from the async callback into the sleeping _sync() function the patch adds another req_skb variable to hci_dev where the sync request state is tracked. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8af3af324eee..5cbb0957edc7 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -141,13 +141,16 @@ static const struct file_operations dut_mode_fops = {
141 141
142/* ---- HCI requests ---- */ 142/* ---- HCI requests ---- */
143 143
144static void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode) 144static void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
145 struct sk_buff *skb)
145{ 146{
146 BT_DBG("%s result 0x%2.2x", hdev->name, result); 147 BT_DBG("%s result 0x%2.2x", hdev->name, result);
147 148
148 if (hdev->req_status == HCI_REQ_PEND) { 149 if (hdev->req_status == HCI_REQ_PEND) {
149 hdev->req_result = result; 150 hdev->req_result = result;
150 hdev->req_status = HCI_REQ_DONE; 151 hdev->req_status = HCI_REQ_DONE;
152 if (skb)
153 hdev->req_skb = skb_get(skb);
151 wake_up_interruptible(&hdev->req_wait_q); 154 wake_up_interruptible(&hdev->req_wait_q);
152 } 155 }
153} 156}
@@ -164,18 +167,10 @@ static void hci_req_cancel(struct hci_dev *hdev, int err)
164} 167}
165 168
166static struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode, 169static struct sk_buff *hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
167 u8 event) 170 u8 event, struct sk_buff *skb)
168{ 171{
169 struct hci_ev_cmd_complete *ev; 172 struct hci_ev_cmd_complete *ev;
170 struct hci_event_hdr *hdr; 173 struct hci_event_hdr *hdr;
171 struct sk_buff *skb;
172
173 hci_dev_lock(hdev);
174
175 skb = hdev->recv_evt;
176 hdev->recv_evt = NULL;
177
178 hci_dev_unlock(hdev);
179 174
180 if (!skb) 175 if (!skb)
181 return ERR_PTR(-ENODATA); 176 return ERR_PTR(-ENODATA);
@@ -223,6 +218,7 @@ struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
223{ 218{
224 DECLARE_WAITQUEUE(wait, current); 219 DECLARE_WAITQUEUE(wait, current);
225 struct hci_request req; 220 struct hci_request req;
221 struct sk_buff *skb;
226 int err = 0; 222 int err = 0;
227 223
228 BT_DBG("%s", hdev->name); 224 BT_DBG("%s", hdev->name);
@@ -236,7 +232,7 @@ struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
236 add_wait_queue(&hdev->req_wait_q, &wait); 232 add_wait_queue(&hdev->req_wait_q, &wait);
237 set_current_state(TASK_INTERRUPTIBLE); 233 set_current_state(TASK_INTERRUPTIBLE);
238 234
239 err = hci_req_run(&req, hci_req_sync_complete); 235 err = hci_req_run_skb(&req, hci_req_sync_complete);
240 if (err < 0) { 236 if (err < 0) {
241 remove_wait_queue(&hdev->req_wait_q, &wait); 237 remove_wait_queue(&hdev->req_wait_q, &wait);
242 set_current_state(TASK_RUNNING); 238 set_current_state(TASK_RUNNING);
@@ -265,13 +261,17 @@ struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
265 } 261 }
266 262
267 hdev->req_status = hdev->req_result = 0; 263 hdev->req_status = hdev->req_result = 0;
264 skb = hdev->req_skb;
265 hdev->req_skb = NULL;
268 266
269 BT_DBG("%s end: err %d", hdev->name, err); 267 BT_DBG("%s end: err %d", hdev->name, err);
270 268
271 if (err < 0) 269 if (err < 0) {
270 kfree_skb(skb);
272 return ERR_PTR(err); 271 return ERR_PTR(err);
272 }
273 273
274 return hci_get_cmd_complete(hdev, opcode, event); 274 return hci_get_cmd_complete(hdev, opcode, event, skb);
275} 275}
276EXPORT_SYMBOL(__hci_cmd_sync_ev); 276EXPORT_SYMBOL(__hci_cmd_sync_ev);
277 277
@@ -303,7 +303,7 @@ static int __hci_req_sync(struct hci_dev *hdev,
303 add_wait_queue(&hdev->req_wait_q, &wait); 303 add_wait_queue(&hdev->req_wait_q, &wait);
304 set_current_state(TASK_INTERRUPTIBLE); 304 set_current_state(TASK_INTERRUPTIBLE);
305 305
306 err = hci_req_run(&req, hci_req_sync_complete); 306 err = hci_req_run_skb(&req, hci_req_sync_complete);
307 if (err < 0) { 307 if (err < 0) {
308 hdev->req_status = 0; 308 hdev->req_status = 0;
309 309