Skip to contentSkip to conversation

Bluetooth: Add bt_status

PATCH In review Luiz Augusto von Dentz 2 participants 5 messages May 5, 2022

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 Bluetooth: Add bt_status

From: Luiz Augusto von Dentz <[email protected]>

This adds bt_status which can be used to convert Unix errno to Bluetooth status.

---
 include/net/bluetooth/bluetooth.h |  1 +
 net/bluetooth/lib.c               | 71 +++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
include/net/bluetooth/bluetooth.h +1 -0
index 6b48d9e2aab9..cfe6159f26bc 100644
@@ -521,6 +521,7 @@ static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk,
 }
 
 int bt_to_errno(u16 code);
+__u8 bt_status(int err);
 
 void hci_sock_set_flag(struct sock *sk, int nr);
 void hci_sock_clear_flag(struct sock *sk, int nr);
net/bluetooth/lib.c +71 -0

77 lines not on this page · raw message

Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 1/1 Bluetooth: eir: Add helpers for managing service data

From: Luiz Augusto von Dentz <[email protected]>

This adds helpers for accessing and appending service data (0x16) ad type.

---
 include/net/bluetooth/hci.h |  1 +
 net/bluetooth/eir.c         | 31 +++++++++++++++++++++++++++++++
 net/bluetooth/eir.h         |  4 ++++
 3 files changed, 36 insertions(+)
include/net/bluetooth/hci.h +1 -0
index 62a9bb022aed..fe7935be7dc4 100644
@@ -625,6 +625,7 @@ enum {
 #define EIR_SSP_RAND_R192	0x0F /* Simple Pairing Randomizer R-192 */
 #define EIR_DEVICE_ID		0x10 /* device ID */
 #define EIR_APPEARANCE		0x19 /* Device appearance */
+#define EIR_SERVICE_DATA	0x16 /* Service Data */
 #define EIR_LE_BDADDR		0x1B /* LE Bluetooth device address */
 #define EIR_LE_ROLE		0x1C /* LE role */
 #define EIR_SSP_HASH_C256	0x1D /* Simple Pairing Hash C-256 */
net/bluetooth/eir.c +31 -0
index 7e930f77ecab..7d77fb00c2bf 100644
@@ -55,6 +55,19 @@ u8 eir_append_appearance(struct hci_dev *hdev, u8 *ptr, u8 ad_len)
 	return eir_append_le16(ptr, ad_len, EIR_APPEARANCE, hdev->appearance);
 }
 
+u8 eir_append_service_data(u8 *eir, u16 eir_len, u16 uuid, u8 *data,
+			   u8 data_len)
+{
+	eir[eir_len++] = sizeof(u8) + sizeof(uuid) + data_len;
+	eir[eir_len++] = EIR_SERVICE_DATA;
+	put_unaligned_le16(uuid, &eir[eir_len]);
+	eir_len += sizeof(uuid);
+	memcpy(&eir[eir_len], data, data_len);
+	eir_len += data_len;
+
+	return eir_len;
+}
+
 static u8 *create_uuid16_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
 {
 	u8 *ptr = data, *uuids_start = NULL;
@@ -333,3 +346,21 @@ u8 eir_create_scan_rsp(struct hci_dev *hdev, u8 instance, u8 *ptr)
 
 	return scan_rsp_len;
 }
+
+void *eir_get_service_data(u8 *eir, size_t eir_len, u16 uuid, size_t *len)
+{
+	while ((eir = eir_get_data(eir, eir_len, EIR_SERVICE_DATA, len))) {
+		u16 value = get_unaligned_le16(eir);
+
+		if (uuid == value) {
+			if (len)
+				*len -= 2;
+			return &eir[2];
+		}
+
+		eir += *len;
+		eir_len -= *len;
+	}
+
+	return NULL;
+}
net/bluetooth/eir.h +4 -0
index 43f1945bffc5..62f2374078f2 100644
@@ -14,6 +14,8 @@ u8 eir_create_scan_rsp(struct hci_dev *hdev, u8 instance, u8 *ptr);
 
 u8 eir_append_local_name(struct hci_dev *hdev, u8 *eir, u8 ad_len);
 u8 eir_append_appearance(struct hci_dev *hdev, u8 *ptr, u8 ad_len);
+u8 eir_append_service_data(u8 *eir, u16 eir_len, u16 uuid, u8 *data,
+			   u8 data_len);
 
 static inline u16 eir_precalc_len(u8 data_len)
 {
@@ -92,3 +94,5 @@ static inline void *eir_get_data(u8 *eir, size_t eir_len, u8 type,
 
 	return NULL;
 }
+
+void *eir_get_service_data(u8 *eir, size_t eir_len, u16 uuid, size_t *len);
Signature · 1 line
2.35.1
#2 lore raw

RE: Bluetooth: eir: Add helpers for managing service data

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=638503

---Test result---

Test Summary:

CheckPatch                    PASS      1.85 seconds
GitLint                       PASS      0.99 seconds
SubjectPrefix                 PASS      0.86 seconds
BuildKernel                   PASS      32.21 seconds
BuildKernel32                 PASS      29.10 seconds
Incremental Build with patchesPASS      38.34 seconds
TestRunner: Setup             PASS      475.83 seconds
TestRunner: l2cap-tester      PASS      17.45 seconds
TestRunner: bnep-tester       PASS      6.18 seconds
TestRunner: mgmt-tester       PASS      102.95 seconds
TestRunner: rfcomm-tester     PASS      9.73 seconds
TestRunner: sco-tester        PASS      9.52 seconds
TestRunner: smp-tester        PASS      9.53 seconds
TestRunner: userchan-tester   PASS      6.60 seconds

---
Regards,
Linux Bluetooth

author maintainer
#3 lore raw

PATCH 2/2 Bluetooth: Use bt_status to convert from errno

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

If a command cannot be sent or there is a internal error an errno maybe set instead of a command status.

---
 net/bluetooth/hci_conn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_conn.c +1 -1
index 882a7df13005..4a5193499b77 100644
@@ -946,7 +946,7 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err)
 	if (!conn)
 		goto done;
 
-	hci_le_conn_failed(conn, err);
+	hci_le_conn_failed(conn, bt_status(err));
 
 done:
 	hci_dev_unlock(hdev);
Signature · 1 line
2.35.1
#4 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=638502

---Test result---

Test Summary:

CheckPatch                    PASS      3.43 seconds
GitLint                       PASS      2.05 seconds
SubjectPrefix                 PASS      1.78 seconds
BuildKernel                   PASS      31.76 seconds
BuildKernel32                 PASS      28.77 seconds
Incremental Build with patchesPASS      44.42 seconds
TestRunner: Setup             PASS      469.08 seconds
TestRunner: l2cap-tester      PASS      17.42 seconds
TestRunner: bnep-tester       PASS      6.15 seconds
TestRunner: mgmt-tester       PASS      101.62 seconds
TestRunner: rfcomm-tester     PASS      9.60 seconds
TestRunner: sco-tester        PASS      9.39 seconds
TestRunner: smp-tester        PASS      9.47 seconds
TestRunner: userchan-tester   PASS      6.38 seconds

---
Regards,
Linux Bluetooth