All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v3 4/7] Bluetooth: Introduce HCI_MGMT_HDEV_OPTIONAL option
Date: Wed,  6 May 2020 09:57:49 +0200	[thread overview]
Message-ID: <32fc749671997c463575394666b2e003917355f5.1588751831.git.marcel@holtmann.org> (raw)
In-Reply-To: <c1c28c073acf0c37cb7804d33a43c42486c9e796.1588751831.git.marcel@holtmann.org>

When setting HCI_MGMT_HDEV_OPTIONAL it is possible to target a specific
conntroller or a global interface.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_sock.c         | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 239ab72f16c6..0c7f3ad76665 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1554,6 +1554,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);
 #define HCI_MGMT_NO_HDEV	BIT(1)
 #define HCI_MGMT_UNTRUSTED	BIT(2)
 #define HCI_MGMT_UNCONFIGURED	BIT(3)
+#define HCI_MGMT_HDEV_OPTIONAL	BIT(4)
 
 struct hci_mgmt_handler {
 	int (*func) (struct sock *sk, struct hci_dev *hdev, void *data,
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 9c4a093f8960..caf38a8ea6a8 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1579,11 +1579,13 @@ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
 		}
 	}
 
-	no_hdev = (handler->flags & HCI_MGMT_NO_HDEV);
-	if (no_hdev != !hdev) {
-		err = mgmt_cmd_status(sk, index, opcode,
-				      MGMT_STATUS_INVALID_INDEX);
-		goto done;
+	if (!(handler->flags & HCI_MGMT_HDEV_OPTIONAL)) {
+		no_hdev = (handler->flags & HCI_MGMT_NO_HDEV);
+		if (no_hdev != !hdev) {
+			err = mgmt_cmd_status(sk, index, opcode,
+					      MGMT_STATUS_INVALID_INDEX);
+			goto done;
+		}
 	}
 
 	var_len = (handler->flags & HCI_MGMT_VAR_LEN);
-- 
2.26.2


  reply	other threads:[~2020-05-06  7:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  7:57 [PATCH v3 0/7] Patches introducing experimental feature support Marcel Holtmann
2020-05-06  7:57 ` [PATCH v3 1/7] Bluetooth: Add MGMT_EV_PHY_CONFIGURATION_CHANGED to supported list Marcel Holtmann
2020-05-06  7:57   ` [PATCH v3 2/7] Bluetooth: Replace BT_DBG with bt_dev_dbg for management support Marcel Holtmann
2020-05-06  7:57     ` [PATCH v3 3/7] Bluetooth: replace zero-length array with flexible-array member Marcel Holtmann
2020-05-06  7:57       ` Marcel Holtmann [this message]
2020-05-06  7:57         ` [PATCH v3 5/7] Bluetooth: Replace BT_DBG with bt_dev_dbg for security manager support Marcel Holtmann
2020-05-06  7:57           ` [PATCH v3 6/7] Bluetooth: Add support for experimental features configuration Marcel Holtmann
2020-05-06  7:57             ` [PATCH v3 7/7] Bluetooth: Introduce debug feature when dynamic debug is disabled Marcel Holtmann
2020-05-08 15:17               ` Alain Michaud
2020-05-08 15:15     ` [PATCH v3 2/7] Bluetooth: Replace BT_DBG with bt_dev_dbg for management support Alain Michaud
2020-05-08  8:59 ` [PATCH v3 0/7] Patches introducing experimental feature support Johan Hedberg
2020-05-08 15:19   ` Alain Michaud

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=32fc749671997c463575394666b2e003917355f5.1588751831.git.marcel@holtmann.org \
    --to=marcel@holtmann.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.