[PATCH v2 2/2] Bluetooth: Process Read Remote Version evt

From: Gongwei Li

Date: Thu Nov 13 2025 - 01:11:50 EST


From: Gongwei Li <ligongwei@xxxxxxxxxx>

Add processing for HCI Process Read Remote Version event.
Used to query the lmp version of remote devices.

Signed-off-by: Gongwei Li <ligongwei@xxxxxxxxxx>
Reviewed-by: Paul Menzel <pmenzel@xxxxxxxxxxxxx>
---
v1->v2: Add bt_dev_dbg to print remote_ver
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_event.c | 25 +++++++++++++++++++++++++
net/bluetooth/mgmt.c | 5 +++++
3 files changed, 31 insertions(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 9efdefed3..424349b74 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -750,6 +750,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 7c4ca14f1..762a3e58b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3738,6 +3738,28 @@ 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_dev_dbg(hdev, "");
+
+ 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;
+
+ bt_dev_dbg(hdev, "remote_ver 0x%2.2x", conn->remote_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);
@@ -7523,6 +7545,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 c11cdef42..9b8add6a2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -9745,6 +9745,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;

@@ -9791,6 +9794,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