summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2010-12-15 13:53:18 +0200
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-08 01:40:04 -0200
commitab81cbf99c881ca2b9a83682a8722fc84b2483d2 (patch)
tree7e9478c23bfa7e794fe31be04f317f5776bc80b7 /net/bluetooth/mgmt.c
parent7990681c409e8a31eac122342e64da6c3b77a249 (diff)
downloadblackbird-op-linux-ab81cbf99c881ca2b9a83682a8722fc84b2483d2.tar.gz
blackbird-op-linux-ab81cbf99c881ca2b9a83682a8722fc84b2483d2.zip
Bluetooth: Implement automatic setup procedure for local adapters
This patch implements automatic initialization of basic information about newly registered Bluetooth adapters. E.g. the address and features are always needed so it makes sense for the kernel to automatically power on adapters and read this information. A new HCI_SETUP flag is added to track this state. In order to not consume unnecessary amounts of power if there isn't a user space available that could switch the adapter back off, a timer is added to do this automatically as long as no Bluetooth user space seems to be present. A new HCI_AUTO_OFF flag is added that user space needs to clear to avoid the automatic power off. Additionally, the management interface index_added event is moved to the end of the HCI_SETUP stage so a user space supporting the managment inteface has all the necessary information available for fetching when it gets notified of a new adapter. The HCI_DEV_REG event is kept in the same place as before since existing HCI raw socket based user space versions depend on seeing the kernels initialization sequence (hci_init_req) to determine when the adapter is ready for use. Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ace872615c06..d479e241a9de 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -129,6 +129,12 @@ static int read_index_list(struct sock *sk)
i = 0;
list_for_each(p, &hci_dev_list) {
struct hci_dev *d = list_entry(p, struct hci_dev, list);
+
+ hci_del_off_timer(d);
+
+ if (test_bit(HCI_SETUP, &d->flags))
+ continue;
+
put_unaligned_le16(d->id, &rp->index[i++]);
BT_DBG("Added hci%u", d->id);
}
@@ -180,6 +186,8 @@ static int read_controller_info(struct sock *sk, unsigned char *data, u16 len)
return cmd_status(sk, MGMT_OP_READ_INFO, ENODEV);
}
+ hci_del_off_timer(hdev);
+
hci_dev_lock_bh(hdev);
put_unaligned_le16(hdev->id, &rp->index);
OpenPOWER on IntegriCloud