Bluetooth: Rename hci_acl_disconn

As hci_acl_disconn function basically sends the HCI Disconnect Command
and it is used to disconnect ACL, SCO and LE links, renaming it to
hci_disconnect is more suitable.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Bluetooth: Add initial hooks for HCI transaction support

This patch adds the initial context variables and functions for HCI
transaction support. HCI transactions are essentially just groups of HCI
commands with an optional callback for notifying the completion of the
transaction.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Add basic start/complete HCI transaction functions

With these functions it will be possible to declare the start and end of
a transaction. hci_start_transaction() creates hdev->build_transaction
which will be used by hci_send_command() to construct a transaction.
hci_complete_transaction() indicates the end of a transaction with an
optional complete callback to be called once the transaction is
complete. The transaction is either moved to hdev->current_transaction
(if no other transaction is in progress) or appended to
hdev->transaction_q.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Add hci_transaction_cmd_complete function

This function is used to process the HCI transaction state, including
things like picking the next command to send, calling the complete
callback for the current transaction and moving the next transaction
from the queue (if any) to hdev->current_transaction.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Add hci_transaction_from_skb function

This function is needed for situations where a transaction needs to be
constructed straight from an skb. This happens e.g. when going through
the HCI driver initialization commands in hci_init_req() or when
receiving commands from user space through a raw HCI socket.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Switch from hdev->cmd_q to using transactions

This patch converts the code from using a single hdev->cmd_q HCI command
queue to use the HCI transaction infrastructure.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Remove unused hdev->cmd_q HCI command queue

This patch removes the now unused hdev->cmd_q HCI command queue. The HCI
transaction framework takes care of the same functionality.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Fix mgmt powered indication by using a HCI transaction

The response to mgmt_set_powered should be returned only when all
related HCI commands have completed. To properly do this make use of a
HCI transaction with a callback to indicate its completion.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Enable HCI transaction support cmd_status 0

Some HCI commands do not result in a command complete event and generate
an intermediate command status 0 in between. Inquiry is one of these
procedures and needs to be handled properly since the legacy ioctl for
it uses hci_request which in turn will make use of the HCI transaction
framework.

If the ncmd HCI event parameter indicates that we can send more commands
to the controller we should do it if we have any commands in our queue.
However, for the ongoing HCI transaction to be properly notified for
completion we need to hold off this notification if possible when the
command status event comes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Add HCI init sequence support for HCI transactions

There's a special quirk needed for unexpected HCI reset command
completes during the init process. This patch adds this quirk to the HCI
transaction code so that hci_init_req can be converted to use the HCI
transaction framework.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Convert hci_request to use HCI transactions

This patch converts the hci_request procedure to make use of HCI
transactions. Since the completion callback is now private to hci_core.c
there is no need to have a public hci_req_complete() function anymore.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Remove unused hdev->init_last_cmd

This variable is no longer needed as the functionality is provided by
the HCI transaction framework.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Remove empty HCI event handlers

With the removal of hci_req_complete() several HCI event handles have
essentially become empty and can be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Bluetooth: Make hci_le_scan use HCI transaction

This patch changes hci_le_scan helper so it uses the HCI transaction
framework to enable LE scanning. The LE scanning disable timeout
was removed from the helper and it is now handled by mgmt start_
discovery code.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Remove LE scan work

This patch removes the LE scan work and all code related to it. We
now use the HCI transaction framework to enable LE scanning. The
LE scan work is no longer needed.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Merge LE-only and interleaved cases

This patch merges the LE-only and interleaved discovery type cases.
Since hci_le_scan helper uses the hci transaction framework, those
cases are pretty much the same now.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Remove timeout handling from hci_cancel_le_scan

Since LE scanning timeout is not handled by LE scanning helpers
anymore, we should handle it in stop_discovery instead of
hci_cancel_le_scan.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Use helper in LE scan disable function

This patch changes LE scan disable work function so it uses hci_cancel_
le_scan helper instead of sending HCI command to disable LE scanning.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Change LE scanning timeout macros

Define LE scanning timeout macros in jiffies just like others timeout
macros do.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Add LE scan type macros

This patch adds macros for active and passive LE scan type values. It
also removes the LE_SCAN_TYPE macro since it is not used anymore.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>