From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 06/11] Bluetooth: Introduce new hci_req_cmd function
Date: Mon, 4 Mar 2013 12:09:03 +0200 [thread overview]
Message-ID: <1362391748-21653-7-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1362391748-21653-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This function is analogous to hci_send_cmd() but instead of directly
queuing the command to hdev->cmd_q it adds it to the local queue of the
asynchronous HCI request being build (inside struct hci_request).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7191217..1a75d2a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1048,6 +1048,7 @@ struct hci_request {
void hci_req_init(struct hci_request *req, struct hci_dev *hdev);
int hci_req_run(struct hci_request *req, hci_req_complete_t complete);
+int hci_req_cmd(struct hci_request *req, u16 opcode, u32 plen, void *param);
int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param);
void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1a441a3..f99d29c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2515,6 +2515,28 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
return 0;
}
+/* Queue a command to an asynchronous HCI request */
+int hci_req_cmd(struct hci_request *req, u16 opcode, u32 plen, void *param)
+{
+ struct hci_dev *hdev = req->hdev;
+ struct sk_buff *skb;
+
+ BT_DBG("%s opcode 0x%4.4x plen %d", hdev->name, opcode, plen);
+
+ skb = hci_prepare_cmd(hdev, opcode, plen, param);
+ if (!skb) {
+ BT_ERR("%s no memory for command", hdev->name);
+ return -ENOMEM;
+ }
+
+ if (skb_queue_empty(&req->cmd_q))
+ bt_cb(skb)->req.start = true;
+
+ skb_queue_tail(&req->cmd_q, skb);
+
+ return 0;
+}
+
/* Get data from the previously sent command */
void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode)
{
--
1.7.10.4
next prev parent reply other threads:[~2013-03-04 10:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 10:08 [PATCH 00/11] Bluetooth: Add asynchronous request support Johan Hedberg
2013-03-04 10:08 ` [PATCH 01/11] Bluetooth: Rename hci_request to hci_req_sync Johan Hedberg
2013-03-04 18:57 ` Marcel Holtmann
2013-03-04 10:08 ` [PATCH 02/11] Bluetooth: Fix __hci_req_sync() handling of empty requests Johan Hedberg
2013-03-04 10:09 ` [PATCH 03/11] Bluetooth: Split HCI init sequence into three stages Johan Hedberg
2013-03-04 10:59 ` Anderson Lizardo
2013-03-04 11:35 ` Johan Hedberg
2013-03-04 13:36 ` Anderson Lizardo
2013-03-04 18:54 ` Marcel Holtmann
2013-03-04 21:07 ` Johan Hedberg
2013-03-04 21:58 ` Marcel Holtmann
2013-03-04 10:09 ` [PATCH 04/11] Bluetooth: Add initial skeleton for asynchronous HCI requests Johan Hedberg
2013-03-04 19:03 ` Marcel Holtmann
2013-03-04 21:16 ` Johan Hedberg
2013-03-04 21:54 ` Marcel Holtmann
2013-03-04 10:09 ` [PATCH 05/11] Bluetooth: Refactor HCI command skb creation Johan Hedberg
2013-03-04 10:09 ` Johan Hedberg [this message]
2013-03-04 19:06 ` [PATCH 06/11] Bluetooth: Introduce new hci_req_cmd function Marcel Holtmann
2013-03-04 21:17 ` Johan Hedberg
2013-03-04 10:09 ` [PATCH 07/11] Bluetooth: Introduce a hci_req_from_skb function Johan Hedberg
2013-03-04 10:09 ` [PATCH 08/11] Bluetooth: Add request cmd_complete and cmd_status functions Johan Hedberg
2013-03-04 10:09 ` [PATCH 09/11] Bluetooth: Use async requests internally in hci_req_sync Johan Hedberg
2013-03-04 10:09 ` [PATCH 10/11] Bluetooth: Remove unused hdev->init_last_cmd Johan Hedberg
2013-03-04 10:09 ` [PATCH 11/11] Bluetooth: Remove empty HCI event handlers Johan Hedberg
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=1362391748-21653-7-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