Bluetooth: Fix __hci_request synchronization for hci_open_dev
authorJohan Hedberg <johan.hedberg@nokia.com>
Tue, 21 Dec 2010 21:01:27 +0000 (23:01 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 23 Dec 2010 00:58:07 +0000 (22:58 -0200)
commit23bb57633df97ede067ea26f3cdc8a7ba2cd8109
tree3aa9a25b17da84975691af7159b030f810560e38
parentc71e97bfaadfa727669fcfcf12301744fd169091
Bluetooth: Fix __hci_request synchronization for hci_open_dev

The initialization function used by hci_open_dev (hci_init_req) sends
many different HCI commands. The __hci_request function should only
return when all of these commands have completed (or a timeout occurs).
Several of these commands cause hci_req_complete to be called which
causes __hci_request to return prematurely.

This patch fixes the issue by adding a new hdev->req_last_cmd variable
which is set during the initialization procedure. The hci_req_complete
function will no longer mark the request as complete until the command
matching hdev->req_last_cmd completes.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c