[PATCH 1/4] Bluetooth: Check hci_req_run error code in __hci_req_sync

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since hci_req_run will be returning more than one error code, we
should check its returning value in __hci_req_sync.

This patch also changes the returning value of hci_req_run in case
the HCI request is empty.

Signed-off-by: Andre Guedes <andre.guedes@xxxxxxxxxxxxx>
---
 net/bluetooth/hci_core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b6d44a2..a1bbf6d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -101,7 +101,7 @@ static int __hci_req_sync(struct hci_dev *hdev,
 	func(&req, opt);
 
 	err = hci_req_run(&req, hci_req_sync_complete);
-	if (err < 0) {
+	if (err == -ENODATA) {
 		hdev->req_status = 0;
 		remove_wait_queue(&hdev->req_wait_q, &wait);
 		/* req_run will fail if the request did not add any
@@ -112,6 +112,11 @@ static int __hci_req_sync(struct hci_dev *hdev,
 		 */
 		return 0;
 	}
+	if (err < 0) {
+		hdev->req_status = HCI_REQ_CANCELED;
+		remove_wait_queue(&hdev->req_wait_q, &wait);
+		return err;
+	}
 
 	schedule_timeout(timeout);
 
@@ -2453,7 +2458,7 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete)
 
 	/* Do not allow empty requests */
 	if (skb_queue_empty(&req->cmd_q))
-		return -EINVAL;
+		return -ENODATA;
 
 	skb = skb_peek_tail(&req->cmd_q);
 	bt_cb(skb)->req.complete = complete;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux