linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v6 16/23] Bluetooth: hci_sync: Convert MGMT_OP_READ_LOCAL_OOB_EXT_DATA
Date: Tue, 26 Oct 2021 16:03:17 -0700	[thread overview]
Message-ID: <20211026230324.1533907-17-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20211026230324.1533907-1-luiz.dentz@gmail.com>

From: Brian Gix <brian.gix@intel.com>

Uses existing *_sync functions

mgmt-test paths:
Read Local OOB Ext Data - Invalid index
Read Local OOB Ext Data - Legacy pairing
Read Local OOB Ext Data - Success SSP
Read Local OOB Ext Data - Success SC

Signed-off-by: Brian Gix <brian.gix@intel.com>
---
 net/bluetooth/mgmt.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a0997b0f3366..20cefd3e2295 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7365,21 +7365,27 @@ static int set_public_address(struct sock *sk, struct hci_dev *hdev,
 	return err;
 }
 
-static void read_local_oob_ext_data_complete(struct hci_dev *hdev, u8 status,
-					     u16 opcode, struct sk_buff *skb)
+static void read_local_oob_ext_data_complete(struct hci_dev *hdev, void *data,
+					     int err)
 {
 	const struct mgmt_cp_read_local_oob_ext_data *mgmt_cp;
 	struct mgmt_rp_read_local_oob_ext_data *mgmt_rp;
 	u8 *h192, *r192, *h256, *r256;
-	struct mgmt_pending_cmd *cmd;
+	struct mgmt_pending_cmd *cmd = data;
+	struct sk_buff *skb = cmd->skb;
+	u8 status = mgmt_status(err);
 	u16 eir_len;
-	int err;
 
-	bt_dev_dbg(hdev, "status %u", status);
+	if (!status) {
+		if (!skb)
+			status = MGMT_STATUS_FAILED;
+		else if (IS_ERR(skb))
+			status = mgmt_status(PTR_ERR(skb));
+		else
+			status = mgmt_status(skb->data[0]);
+	}
 
-	cmd = pending_find(MGMT_OP_READ_LOCAL_OOB_EXT_DATA, hdev);
-	if (!cmd)
-		return;
+	bt_dev_dbg(hdev, "status %u", status);
 
 	mgmt_cp = cmd->param;
 
@@ -7391,7 +7397,7 @@ static void read_local_oob_ext_data_complete(struct hci_dev *hdev, u8 status,
 		r192 = NULL;
 		h256 = NULL;
 		r256 = NULL;
-	} else if (opcode == HCI_OP_READ_LOCAL_OOB_DATA) {
+	} else if (!bredr_sc_enabled(hdev)) {
 		struct hci_rp_read_local_oob_data *rp;
 
 		if (skb->len != sizeof(*rp)) {
@@ -7472,6 +7478,9 @@ static void read_local_oob_ext_data_complete(struct hci_dev *hdev, u8 status,
 				 mgmt_rp, sizeof(*mgmt_rp) + eir_len,
 				 HCI_MGMT_OOB_DATA_EVENTS, cmd->sk);
 done:
+	if (skb && !IS_ERR(skb))
+		kfree_skb(skb);
+
 	kfree(mgmt_rp);
 	mgmt_pending_remove(cmd);
 }
@@ -7480,7 +7489,6 @@ static int read_local_ssp_oob_req(struct hci_dev *hdev, struct sock *sk,
 				  struct mgmt_cp_read_local_oob_ext_data *cp)
 {
 	struct mgmt_pending_cmd *cmd;
-	struct hci_request req;
 	int err;
 
 	cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_EXT_DATA, hdev,
@@ -7488,14 +7496,9 @@ static int read_local_ssp_oob_req(struct hci_dev *hdev, struct sock *sk,
 	if (!cmd)
 		return -ENOMEM;
 
-	hci_req_init(&req, hdev);
-
-	if (bredr_sc_enabled(hdev))
-		hci_req_add(&req, HCI_OP_READ_LOCAL_OOB_EXT_DATA, 0, NULL);
-	else
-		hci_req_add(&req, HCI_OP_READ_LOCAL_OOB_DATA, 0, NULL);
+	err = hci_cmd_sync_queue(hdev, read_local_oob_data_sync, cmd,
+				 read_local_oob_ext_data_complete);
 
-	err = hci_req_run_skb(&req, read_local_oob_ext_data_complete);
 	if (err < 0) {
 		mgmt_pending_remove(cmd);
 		return err;
-- 
2.31.1


  parent reply	other threads:[~2021-10-26 23:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 23:03 [PATCH v6 00/23] Bluetooth: HCI command synchronization Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 01/23] Bluetooth: Add helper for serialized HCI command execution Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 02/23] Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 1 Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 03/23] Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2 Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 04/23] Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 3 Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 05/23] Bluetooth: hci_sync: Enable advertising when LL privacy is enabled Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 06/23] Bluetooth: hci_sync: Rework background scan Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 07/23] Bluetooth: hci_sync: Convert MGMT_SET_POWERED Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 08/23] Bluetooth: hci_sync: Convert MGMT_OP_START_DISCOVERY Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 09/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_FAST_CONNECTABLE Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 10/23] Bluetooth: hci_sync: Enable synch'd set_bredr Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 11/23] Bluetooth: hci_sync: Convert MGMT_OP_GET_CONN_INFO Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 12/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_SECURE_CONN Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 13/23] Bluetooth: hci_sync: Convert MGMT_OP_GET_CLOCK_INFO Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 14/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_LE Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 15/23] Bluetooth: hci_sync: Convert MGMT_OP_READ_LOCAL_OOB_DATA Luiz Augusto von Dentz
2021-10-26 23:03 ` Luiz Augusto von Dentz [this message]
2021-10-26 23:03 ` [PATCH v6 17/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_LOCAL_NAME Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 18/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_PHY_CONFIGURATION Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 19/23] Bluetooth: hci_sync: Convert MGMT_OP_SET_ADVERTISING Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 20/23] Bluetooth: hci_sync: Convert adv_expire Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 21/23] Bluetooth: hci_sync: Convert MGMT_OP_SSP Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 22/23] Bluetooth: hci_sync: Rework init stages Luiz Augusto von Dentz
2021-10-26 23:03 ` [PATCH v6 23/23] Bluetooth: hci_sync: Rework hci_suspend_notifier Luiz Augusto von Dentz

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=20211026230324.1533907-17-luiz.dentz@gmail.com \
    --to=luiz.dentz@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).