diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2010-12-16 03:00:37 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-07 22:40:04 -0500 |
commit | 5add6af8fcbce269cac2457584c0ebfda055474a (patch) | |
tree | f27f5eb78f8193f636c576c979391c63bfc50c29 | |
parent | ab81cbf99c881ca2b9a83682a8722fc84b2483d2 (diff) |
Bluetooth: Add support for management powered event
This patch adds support for the powered event that's used to indicate to
userspace when the powered state of a local adapter changes.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 6 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 4 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 10 |
4 files changed, 21 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 75c4f201c1c6..32e11b37ef28 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -673,6 +673,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); | |||
673 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); | 673 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); |
674 | int mgmt_index_added(u16 index); | 674 | int mgmt_index_added(u16 index); |
675 | int mgmt_index_removed(u16 index); | 675 | int mgmt_index_removed(u16 index); |
676 | int mgmt_powered(u16 index, u8 powered); | ||
676 | 677 | ||
677 | /* HCI info for socket */ | 678 | /* HCI info for socket */ |
678 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 679 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index ca29c1367ffd..0ac1520573ed 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -85,3 +85,9 @@ struct mgmt_ev_index_added { | |||
85 | struct mgmt_ev_index_removed { | 85 | struct mgmt_ev_index_removed { |
86 | __le16 index; | 86 | __le16 index; |
87 | } __packed; | 87 | } __packed; |
88 | |||
89 | #define MGMT_EV_POWERED 0x0006 | ||
90 | struct mgmt_ev_powered { | ||
91 | __le16 index; | ||
92 | __u8 powered; | ||
93 | } __packed; | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b22ce9f8bf91..c5a78e797bc2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -535,6 +535,8 @@ int hci_dev_open(__u16 dev) | |||
535 | hci_dev_hold(hdev); | 535 | hci_dev_hold(hdev); |
536 | set_bit(HCI_UP, &hdev->flags); | 536 | set_bit(HCI_UP, &hdev->flags); |
537 | hci_notify(hdev, HCI_DEV_UP); | 537 | hci_notify(hdev, HCI_DEV_UP); |
538 | if (!test_bit(HCI_SETUP, &hdev->flags)) | ||
539 | mgmt_powered(hdev->id, 1); | ||
538 | } else { | 540 | } else { |
539 | /* Init failed, cleanup */ | 541 | /* Init failed, cleanup */ |
540 | tasklet_kill(&hdev->rx_task); | 542 | tasklet_kill(&hdev->rx_task); |
@@ -616,6 +618,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
616 | * and no tasks are scheduled. */ | 618 | * and no tasks are scheduled. */ |
617 | hdev->close(hdev); | 619 | hdev->close(hdev); |
618 | 620 | ||
621 | mgmt_powered(hdev->id, 0); | ||
622 | |||
619 | /* Clear flags */ | 623 | /* Clear flags */ |
620 | hdev->flags = 0; | 624 | hdev->flags = 0; |
621 | 625 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d479e241a9de..f746e19ebec0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -316,3 +316,13 @@ int mgmt_index_removed(u16 index) | |||
316 | 316 | ||
317 | return mgmt_event(MGMT_EV_INDEX_REMOVED, &ev, sizeof(ev)); | 317 | return mgmt_event(MGMT_EV_INDEX_REMOVED, &ev, sizeof(ev)); |
318 | } | 318 | } |
319 | |||
320 | int mgmt_powered(u16 index, u8 powered) | ||
321 | { | ||
322 | struct mgmt_ev_powered ev; | ||
323 | |||
324 | put_unaligned_le16(index, &ev.index); | ||
325 | ev.powered = powered; | ||
326 | |||
327 | return mgmt_event(MGMT_EV_POWERED, &ev, sizeof(ev)); | ||
328 | } | ||