Bluetooth: Make hci_le_create_connection return error

This patch changes hci_le_create_connection helper so it return error
if hci_send_cmd fails. It also does the proper error handling in
hci_connect_le.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Initialize hci_conn fields in hci_connect_le

This patch moves some hci_conn fields initialization from hci_le_
create_connection. It makes more sense to initialize these fields
within the function that creates the hci_conn object.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Refactor LE Connection Complete HCI event handler

This patch does some code refactorig in LE Connection Complete HCI
event handler. It basically adds a switch case to separate new master
connection code from new slave connection code.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Locking refactor in hci_le_conn_complete_evt

This patch moves hci_dev_lock and hci_dev_unlock calls to where they
are really required, reducing the critical region in hci_le_conn_
complete_evt function. hdev->lock is required only in hci_conn_del
and hci_conn_add call to protect concurrent add and remove operations
in hci_conn_hash list.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Add passive scanning helpers
WIP: Bluetooth: Add LE initiate connection helper
WIP: Bluetooth: Change LE connection routine
Bluetooth: Handle hci_conn timeout in BT_CONNECT

In order to properly cancel an ongoing LE connection attempts (hci_conn
in BT_CONNECT state), we should check the current le_state. If connection
is in HCI_CONN_LE_SCAN, we should send a HCI to disable the ongoing
scanning. If the connection is in HCI_CONN_LE_INITIATE state, we should
send a command to cancel the connection creation.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Remove status handling in hci_cs_le_create_conn

This patch removes the status error handling in hci_cs_le_create_conn
since this is alreay handled in le_conn_initiate_complete callback.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Remove unused functions

This patch removes the unused functions hci_le_create_connection and
hci_le_create_connection_cancel.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Prepare for multiple connection support
WIP: Bluetooth: Add proper handling for multiple connection failure

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Make fail_pending non-static

This patch makes fail_pending helper non-local so it can be reused
in hci_event.c.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Disable passive scanning temporarily if controller doesn't support state combination
WIP: Bluetooth: Remove BT_CONNECT check in hci_connect_le

Since the kernel is now prepared to handle multiple LE connection
attemps, we can remove this check.

Since the we supported only on LE connection attempt at a time, we
had to check if we already had one connection attempt running.
However, now we support multiple LE connection attempts so we can
safely remove this check in hci_connect_le function.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Don't set chan_timer for ATT fixed channel

According to Core spec (see Vol 3, Part A, 6.2.1), the channel timer
used to terminate the channel when the remote endpoint is unreponsive
to signaling requests. Since there is no signaling requests in LE ATT
fixed channel, there is no need we setup this timer.

As a side effect, LE connection attempts won't be aborted by the
channel timer anymore. Therefore, SOCK_NONBLOCK LE L2CAP sockets will
be ready (will receive POLLOUT event) when the LE connection is
established.

This patch modifies l2cap_chan_connect function so it doesn't set
the timer if the cid is L2CAP_CID_LE_DATA.

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