aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_request.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-11-11 01:11:25 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-11-19 11:50:30 -0500
commita1d01db1202ee6795c0a665b43896293ad4e2a77 (patch)
tree6819b41eac718e063be46d8dee6aa860486f2b20 /net/bluetooth/hci_request.c
parent591752afbcc8179979296698cae698541d2e5431 (diff)
Bluetooth: Add error return value to hci_req_sync callback
In some circumstances it may be useful to abort the request through checks done in the request callback. To make the feature possible this patch changes the return value of the request callback from void to int and aborts the request if a non-zero value is returned. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_request.c')
-rw-r--r--net/bluetooth/hci_request.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 4588fe2bfc0e..ecfa4105e00d 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -184,8 +184,8 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
184EXPORT_SYMBOL(__hci_cmd_sync); 184EXPORT_SYMBOL(__hci_cmd_sync);
185 185
186/* Execute request and wait for completion. */ 186/* Execute request and wait for completion. */
187int __hci_req_sync(struct hci_dev *hdev, void (*func)(struct hci_request *req, 187int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
188 unsigned long opt), 188 unsigned long opt),
189 unsigned long opt, u32 timeout, u8 *hci_status) 189 unsigned long opt, u32 timeout, u8 *hci_status)
190{ 190{
191 struct hci_request req; 191 struct hci_request req;
@@ -198,7 +198,12 @@ int __hci_req_sync(struct hci_dev *hdev, void (*func)(struct hci_request *req,
198 198
199 hdev->req_status = HCI_REQ_PEND; 199 hdev->req_status = HCI_REQ_PEND;
200 200
201 func(&req, opt); 201 err = func(&req, opt);
202 if (err) {
203 if (hci_status)
204 *hci_status = HCI_ERROR_UNSPECIFIED;
205 return err;
206 }
202 207
203 add_wait_queue(&hdev->req_wait_q, &wait); 208 add_wait_queue(&hdev->req_wait_q, &wait);
204 set_current_state(TASK_INTERRUPTIBLE); 209 set_current_state(TASK_INTERRUPTIBLE);
@@ -255,8 +260,8 @@ int __hci_req_sync(struct hci_dev *hdev, void (*func)(struct hci_request *req,
255 return err; 260 return err;
256} 261}
257 262
258int hci_req_sync(struct hci_dev *hdev, void (*req)(struct hci_request *req, 263int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
259 unsigned long opt), 264 unsigned long opt),
260 unsigned long opt, u32 timeout, u8 *hci_status) 265 unsigned long opt, u32 timeout, u8 *hci_status)
261{ 266{
262 int ret; 267 int ret;
@@ -830,11 +835,12 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
830 return 0; 835 return 0;
831} 836}
832 837
833static void update_bg_scan(struct hci_request *req, unsigned long opt) 838static int update_bg_scan(struct hci_request *req, unsigned long opt)
834{ 839{
835 hci_dev_lock(req->hdev); 840 hci_dev_lock(req->hdev);
836 __hci_update_background_scan(req); 841 __hci_update_background_scan(req);
837 hci_dev_unlock(req->hdev); 842 hci_dev_unlock(req->hdev);
843 return 0;
838} 844}
839 845
840static void bg_scan_update(struct work_struct *work) 846static void bg_scan_update(struct work_struct *work)
@@ -932,9 +938,10 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
932 } 938 }
933} 939}
934 940
935static void le_scan_disable(struct hci_request *req, unsigned long opt) 941static int le_scan_disable(struct hci_request *req, unsigned long opt)
936{ 942{
937 hci_req_add_le_scan_disable(req); 943 hci_req_add_le_scan_disable(req);
944 return 0;
938} 945}
939 946
940static void le_scan_disable_work(struct work_struct *work) 947static void le_scan_disable_work(struct work_struct *work)
@@ -1000,14 +1007,14 @@ unlock:
1000 hci_dev_unlock(hdev); 1007 hci_dev_unlock(hdev);
1001} 1008}
1002 1009
1003static void le_scan_restart(struct hci_request *req, unsigned long opt) 1010static int le_scan_restart(struct hci_request *req, unsigned long opt)
1004{ 1011{
1005 struct hci_dev *hdev = req->hdev; 1012 struct hci_dev *hdev = req->hdev;
1006 struct hci_cp_le_set_scan_enable cp; 1013 struct hci_cp_le_set_scan_enable cp;
1007 1014
1008 /* If controller is not scanning we are done. */ 1015 /* If controller is not scanning we are done. */
1009 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) 1016 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
1010 return; 1017 return 0;
1011 1018
1012 hci_req_add_le_scan_disable(req); 1019 hci_req_add_le_scan_disable(req);
1013 1020
@@ -1015,6 +1022,8 @@ static void le_scan_restart(struct hci_request *req, unsigned long opt)
1015 cp.enable = LE_SCAN_ENABLE; 1022 cp.enable = LE_SCAN_ENABLE;
1016 cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE; 1023 cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE;
1017 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); 1024 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
1025
1026 return 0;
1018} 1027}
1019 1028
1020static void le_scan_restart_work(struct work_struct *work) 1029static void le_scan_restart_work(struct work_struct *work)