X-Git-Url: https://git.stricted.de/?a=blobdiff_plain;f=net%2Fbluetooth%2Fhci_core.c;h=1c678757c83a10940c25fb6d8a19279e2e53feeb;hb=e348fe6bbab85c513816d2536ffabac4be016442;hp=5c64398472868acd2efbed56db78053b168a23e5;hpb=bc4445c72cb5d1ed5af80c73e60214ab5ebd8e55;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5c6439847286..1c678757c83a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -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); @@ -2440,6 +2443,7 @@ void hci_req_init(struct hci_request *req, struct hci_dev *hdev) { skb_queue_head_init(&req->cmd_q); req->hdev = hdev; + req->err = 0; } int hci_req_run(struct hci_request *req, hci_req_complete_t complete) @@ -2450,9 +2454,17 @@ int hci_req_run(struct hci_request *req, hci_req_complete_t complete) BT_DBG("length %u", skb_queue_len(&req->cmd_q)); + /* If an error occured during request building, remove all HCI + * commands queued on the HCI request queue. + */ + if (req->err) { + skb_queue_purge(&req->cmd_q); + return req->err; + } + /* 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; @@ -2517,7 +2529,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param) } /* Queue a command to an asynchronous HCI request */ -int hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param) +void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param) { struct hci_dev *hdev = req->hdev; struct sk_buff *skb; @@ -2526,16 +2538,16 @@ int hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param) skb = hci_prepare_cmd(hdev, opcode, plen, param); if (!skb) { - BT_ERR("%s no memory for command", hdev->name); - return -ENOMEM; + BT_ERR("%s no memory for command (opcode 0x%4.4x)", + hdev->name, opcode); + req->err = -ENOMEM; + return; } if (skb_queue_empty(&req->cmd_q)) bt_cb(skb)->req.start = true; skb_queue_tail(&req->cmd_q, skb); - - return 0; } /* Get data from the previously sent command */