Bluetooth: Fix background trigger/untrigger functions

This patch fixes to hci_trigger_background_scan() and hci_untrigger_
background_scan() so they can be called concurrently with the device
discovery procedure.

In hci_trigger_background_scan(), if it is the first trigger, we are
supposed to start the background scanning. However, if device discovery
is running, we should not send any HCI command. The background scanning
will be started once the discovery procedure is finished.

In hci_untrigger_background_scan(), if it is the last trigger, we are
supposed to stop the background scanning. However, if discovery is
running, it means the background is stopped so we don't need to send
any HCI command.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Fix hci_initiate_le_connection()

When a LE device we want automatically connect to is found during the
device discovery procedure, we initiate the connection. Since some LE
controllers don't support scanning and initiating state combination,
the scanning will be disabled and, therefore, we should set the
discovery state to DISCOVERY_STOPPED

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Background scan and controller reset

If the controller is reset, the connections are dropped and no
Disconnection Complete Event will be sent to host. This way, no
background scan will be triggered once a auto connect device is
disconnected.

To fix this issue, before reseting the controller, we trigger the
background scan for each auto connect device we are connected to.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Background scan and adapter power on

Once the adapter is powered on, we should start the background scan
if we have triggers registered. This way, we keep the auto connection
procedure running after a power off and power on sequence.

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