Skip to contentSkip to conversation

hog-lib: Fix not waiting for UHID_START

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Feb 25, 2022 – Mar 2, 2022 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 hog-lib: Fix not waiting for UHID_START

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

With use of UHID_CREATE2 the code needs to wait for UHID_START in order to know if the reports are numbered or not.

---
 profiles/input/hog-lib.c | 41 +++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
profiles/input/hog-lib.c +22 -19
index 5af99fcda..b611f6b4a 100644
@@ -81,6 +81,7 @@ struct bt_hog {
 	struct bt_uhid		*uhid;
 	int			uhid_fd;
 	bool			uhid_created;
+	bool			uhid_start;
 	uint64_t		uhid_flags;
 	uint16_t		bcdhid;
 	uint8_t			bcountrycode;
@@ -358,8 +359,8 @@ static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
 		ev.u.input.size = len;
 	}
 
-	/* If uhid had not been created yet queue up the input */
-	if (!hog->uhid_created) {
+	/* If uhid had not sent UHID_START yet queue up the input */
+	if (!hog->uhid_created || !hog->uhid_start) {
 		if (!hog->input)
 			hog->input = queue_new();
 
@@ -809,16 +810,34 @@ static void set_numbered(void *data, void *user_data)
 	}
 }
 
+static bool input_dequeue(const void *data, const void *match_data)
+{
+	const struct uhid_event *ev = data;
+	const struct bt_hog *hog = match_data;
+	int err;
+
+	err = bt_uhid_send(hog->uhid, ev);
+	if (err < 0) {
+		error("bt_uhid_send: %s (%d)", strerror(-err), -err);
+		return false;
+	}
+
+	return true;
+}
+
 static void start_flags(struct uhid_event *ev, void *user_data)
 {
 	struct bt_hog *hog = user_data;
 
+	hog->uhid_start = true;
 	hog->uhid_flags = ev->u.start.dev_flags;
 
 	DBG("uHID device flags: 0x%16" PRIx64, hog->uhid_flags);
 
 	if (hog->uhid_flags)
 		g_slist_foreach(hog->reports, set_numbered, hog);
+
+	queue_remove_all(hog->input, input_dequeue, hog, free);
 }
 
 static void set_report_cb(guint8 status, const guint8 *pdu,
@@ -992,21 +1011,6 @@ fail:
 	report_reply(hog, err, 0, false, 0, NULL);
 }
 
-static bool input_dequeue(const void *data, const void *match_data)
-{
-	const struct uhid_event *ev = data;
-	const struct bt_hog *hog = match_data;
-	int err;
-
-	err = bt_uhid_send(hog->uhid, ev);
-	if (err < 0) {
-		error("bt_uhid_send: %s (%d)", strerror(-err), -err);
-		return false;
-	}
-
-	return true;
-}
-
 static void uhid_create(struct bt_hog *hog, uint8_t *report_map,
 							size_t report_map_len)
 {
@@ -1068,10 +1072,9 @@ static void uhid_create(struct bt_hog *hog, uint8_t *report_map,
 	bt_uhid_register(hog->uhid, UHID_SET_REPORT, set_report, hog);
 
 	hog->uhid_created = true;
+	hog->uhid_start = false;
 
 	DBG("HoG created uHID device");
-
-	queue_remove_all(hog->input, input_dequeue, hog, free);
 }
 
 static void db_report_map_write_value_cb(struct gatt_db_attribute *attr,
Signature · 1 line
2.35.1
#1 lore raw

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=618207

---Test result---

Test Summary:

CheckPatch                    PASS      1.55 seconds
GitLint                       PASS      0.99 seconds
Prep - Setup ELL              PASS      48.60 seconds
Build - Prep                  PASS      0.77 seconds
Build - Configure             PASS      9.84 seconds
Build - Make                  PASS      1447.35 seconds
Make Check                    PASS      13.06 seconds
Make Check w/Valgrind         PASS      514.12 seconds
Make Distcheck                PASS      269.49 seconds
Build w/ext ELL - Configure   PASS      9.91 seconds
Build w/ext ELL - Make        PASS      1414.84 seconds
Incremental Build with patchesPASS      0.00 seconds

---
Regards,
Linux Bluetooth

author maintainer
#2 lore raw

Hi,

Quoted 27 lines · On Sat, Feb 26, 2022 at 12:24 AM <[email protected]> wrote:

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=618207

---Test result---

Test Summary:

CheckPatch                    PASS      1.55 seconds
GitLint                       PASS      0.99 seconds
Prep - Setup ELL              PASS      48.60 seconds
Build - Prep                  PASS      0.77 seconds
Build - Configure             PASS      9.84 seconds
Build - Make                  PASS      1447.35 seconds
Make Check                    PASS      13.06 seconds
Make Check w/Valgrind         PASS      514.12 seconds
Make Distcheck                PASS      269.49 seconds
Build w/ext ELL - Configure   PASS      9.91 seconds
Build w/ext ELL - Make        PASS      1414.84 seconds
Incremental Build with patchesPASS      0.00 seconds
Quoted 4 lines

---
Regards,
Linux Bluetooth

Pushed

Signature · 1 line
Luiz Augusto von Dentz