Bluetooth: Check hci_req_run returning value in __hci_req_sync
authorAndre Guedes <andre.guedes@openbossa.org>
Fri, 8 Mar 2013 14:20:15 +0000 (11:20 -0300)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Sat, 9 Mar 2013 20:10:37 +0000 (17:10 -0300)
Since hci_req_run will be returning more than one error code, we
should check its returning value in __hci_req_sync.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
net/bluetooth/hci_core.c

index d841046daeda646d9ff5a17d0d86e05a9425c3ab..4603464b91e2e6002ad2176097b355b59d8c2331 100644 (file)
@@ -100,13 +100,16 @@ static int __hci_req_sync(struct hci_dev *hdev,
        err = hci_req_run(&req, hci_req_sync_complete);
        if (err < 0) {
                hdev->req_status = 0;
-               /* req_run will fail if the request did not add any
-                * commands to the queue, something that can happen when
-                * a request with conditionals doesn't trigger any
-                * commands to be sent. This is normal behavior and
-                * should not trigger an error return.
+
+               /* ENODATA means the HCI request command queue is empty.
+                * This can happen when a request with conditionals doesn't
+                * trigger any commands to be sent. This is normal behavior
+                * and should not trigger an error return.
                 */
-               return 0;
+               if (err == -ENODATA)
+                       return 0;
+
+               return err;
        }
 
        add_wait_queue(&hdev->req_wait_q, &wait);