From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/5] Bluetooth: mgmt: Initialize HCI_MGMT flag for any command
Date: Thu, 1 Mar 2012 12:33:29 -0800 [thread overview]
Message-ID: <1330634012-4502-2-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1330634012-4502-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
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>
---
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 cc9fb64..cf8c840 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -610,8 +610,11 @@ static void service_cache_off(struct work_struct *work)
hci_dev_unlock(hdev);
}
-static void mgmt_init_hdev(struct hci_dev *hdev)
+static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev)
{
+ if (!test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags))
+ return;
+
if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) {
INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off);
@@ -632,9 +635,6 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev)
hci_dev_lock(hdev);
- if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags))
- mgmt_init_hdev(hdev);
-
memset(&rp, 0, sizeof(rp));
bacpy(&rp.bdaddr, &hdev->bdaddr);
@@ -2764,6 +2764,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
MGMT_STATUS_INVALID_PARAMS);
goto done;
}
+
+ mgmt_init_hdev(sk, hdev);
}
cp = buf + sizeof(*hdr);
--
1.7.9.1
next prev parent reply other threads:[~2012-03-01 20:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 20:33 [PATCH 1/5] Bluetooth: mgmt: Refactor hci_dev lookup for commands johan.hedberg
2012-03-01 20:33 ` johan.hedberg [this message]
2012-03-01 20:46 ` [PATCH 2/5] Bluetooth: mgmt: Initialize HCI_MGMT flag for any command Marcel Holtmann
2012-03-01 20:33 ` [PATCH 3/5] Bluetooth: mgmt: Move command handlers into a table johan.hedberg
2012-03-01 20:47 ` Marcel Holtmann
2012-03-01 20:33 ` [PATCH 4/5] Bluetooth: mgmt: Add defines for command sizes johan.hedberg
2012-03-01 20:47 ` Marcel Holtmann
2012-03-02 13:29 ` Andrei Emeltchenko
2012-03-01 20:33 ` [PATCH 5/5] Bluetooth: mgmt: Centralize message length checks johan.hedberg
2012-03-01 20:48 ` Marcel Holtmann
2012-03-01 20:45 ` [PATCH 1/5] Bluetooth: mgmt: Refactor hci_dev lookup for commands Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330634012-4502-2-git-send-email-johan.hedberg@gmail.com \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).