diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-27 23:17:26 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-03-01 16:55:58 -0500 |
commit | 6a919082e9b82a0de20f1248a33f3b3f005cebaf (patch) | |
tree | 0784dda7a89db37c0c185bb1bf7c9e94a7db8c53 /net/bluetooth | |
parent | bdb6d97154b7b7e98867e9b71bae0f47ec70b1d7 (diff) |
Bluetooth: mgmt: Initialize HCI_MGMT flag for any command
The read_controller_info is typically the first command that user space
sends when taking a controller into use. This is also the reason why
this command has been used as the trigger to set the HCI_MGMT flag.
However, when not running the user-space daemon and using command line
tools it is possible that read_controller_info is not the first
controller specific command. This patch moves the HCI_MGMT
initialization to a generic place where it will be set for whatever
happens to be the first mgmt command targetting a specific controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/mgmt.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cc9fb64def90..cf8c8403571e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -610,8 +610,11 @@ static void service_cache_off(struct work_struct *work) | |||
610 | hci_dev_unlock(hdev); | 610 | hci_dev_unlock(hdev); |
611 | } | 611 | } |
612 | 612 | ||
613 | static void mgmt_init_hdev(struct hci_dev *hdev) | 613 | static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) |
614 | { | 614 | { |
615 | if (!test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) | ||
616 | return; | ||
617 | |||
615 | if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) { | 618 | if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) { |
616 | INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); | 619 | INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); |
617 | 620 | ||
@@ -632,9 +635,6 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev) | |||
632 | 635 | ||
633 | hci_dev_lock(hdev); | 636 | hci_dev_lock(hdev); |
634 | 637 | ||
635 | if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) | ||
636 | mgmt_init_hdev(hdev); | ||
637 | |||
638 | memset(&rp, 0, sizeof(rp)); | 638 | memset(&rp, 0, sizeof(rp)); |
639 | 639 | ||
640 | bacpy(&rp.bdaddr, &hdev->bdaddr); | 640 | bacpy(&rp.bdaddr, &hdev->bdaddr); |
@@ -2764,6 +2764,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
2764 | MGMT_STATUS_INVALID_PARAMS); | 2764 | MGMT_STATUS_INVALID_PARAMS); |
2765 | goto done; | 2765 | goto done; |
2766 | } | 2766 | } |
2767 | |||
2768 | mgmt_init_hdev(sk, hdev); | ||
2767 | } | 2769 | } |
2768 | 2770 | ||
2769 | cp = buf + sizeof(*hdr); | 2771 | cp = buf + sizeof(*hdr); |