[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251112094843.173238-2-13875017792@163.com>
Date: Wed, 12 Nov 2025 17:48:43 +0800
From: Gongwei Li <13875017792@....com>
To: Marcel Holtmann <marcel@...tmann.org>,
Luiz Augusto von Dentz <luiz.dentz@...il.com>
Cc: Johan Hedberg <johan.hedberg@...il.com>,
linux-bluetooth@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Gongwei Li <ligongwei@...inos.cn>
Subject: [PATCH 2/2] Bluetooth: Process Read Remote Version evt
From: Gongwei Li <ligongwei@...inos.cn>
Add processing for HCI Process Read Remote Version event.
Used to query the lmp version of remote devices.
Signed-off-by: Gongwei Li <ligongwei@...inos.cn>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_event.c | 23 +++++++++++++++++++++++
net/bluetooth/mgmt.c | 5 +++++
3 files changed, 29 insertions(+)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 32b1c08c8bba..bdd5e6ef3616 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -749,6 +749,7 @@ struct hci_conn {
__u8 remote_cap;
__u8 remote_auth;
+ __u8 remote_ver;
unsigned int sent;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f20c826509b6..7f8e3f8ec01e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3737,6 +3737,26 @@ static void hci_remote_features_evt(struct hci_dev *hdev, void *data,
hci_dev_unlock(hdev);
}
+static void hci_remote_version_evt(struct hci_dev *hdev, void *data,
+ struct sk_buff *skb)
+{
+ struct hci_ev_remote_version *ev = (void *)skb->data;
+ struct hci_conn *conn;
+
+ BT_DBG("%s", hdev->name);
+
+ hci_dev_lock(hdev);
+
+ conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
+ if (!conn)
+ goto unlock;
+
+ conn->remote_ver = ev->lmp_ver;
+
+unlock:
+ hci_dev_unlock(hdev);
+}
+
static inline void handle_cmd_cnt_and_timer(struct hci_dev *hdev, u8 ncmd)
{
cancel_delayed_work(&hdev->cmd_timer);
@@ -7448,6 +7468,9 @@ static const struct hci_ev {
/* [0x0b = HCI_EV_REMOTE_FEATURES] */
HCI_EV(HCI_EV_REMOTE_FEATURES, hci_remote_features_evt,
sizeof(struct hci_ev_remote_features)),
+ /* [0x0c = HCI_EV_REMOTE_VERSION] */
+ HCI_EV(HCI_EV_REMOTE_VERSION, hci_remote_version_evt,
+ sizeof(struct hci_ev_remote_version)),
/* [0x0e = HCI_EV_CMD_COMPLETE] */
HCI_EV_REQ_VL(HCI_EV_CMD_COMPLETE, hci_cmd_complete_evt,
sizeof(struct hci_ev_cmd_complete), HCI_MAX_EVENT_SIZE),
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 79762bfaea5f..c0bab45648f3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -9728,6 +9728,9 @@ void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
{
struct sk_buff *skb;
struct mgmt_ev_device_connected *ev;
+ struct hci_cp_read_remote_version cp;
+
+ memset(&cp, 0, sizeof(cp));
u16 eir_len = 0;
u32 flags = 0;
@@ -9774,6 +9777,8 @@ void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
ev->eir_len = cpu_to_le16(eir_len);
mgmt_event_skb(skb, NULL);
+
+ hci_send_cmd(hdev, HCI_OP_READ_REMOTE_VERSION, sizeof(cp), &cp);
}
static void unpair_device_rsp(struct mgmt_pending_cmd *cmd, void *data)
--
2.25.1
Powered by blists - more mailing lists