[PATCH v2 2/3] hog: enable HoG report notifications only after uHID is ready

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HoG report notifications should be enabled only after the uHID device
has been created. uHID layer cannot process HoG reports any earlier.
---
 profiles/input/hog.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 5661e39..ff0c559 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -83,6 +83,7 @@ struct hog_device {
 	struct gatt_primary	*hog_primary;
 	GSList			*reports;
 	struct bt_uhid		*uhid;
+	gboolean		uhid_created;
 	gboolean		has_report_id;
 	uint16_t		bcdhid;
 	uint8_t			bcountrycode;
@@ -168,6 +169,9 @@ static void enable_report_notifications(struct report *report,
 	struct hog_device *hogdev = report->hogdev;
 	uint8_t value[2];
 
+	if (!hogdev->uhid_created)
+		return;
+
 	if (!report->ccc_handle)
 		return;
 
@@ -627,6 +631,7 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	ssize_t vlen;
 	char itemstr[20]; /* 5x3 (data) + 4 (continuation) + 1 (null) */
 	int i, err;
+	GSList *l;
 
 	if (status != 0) {
 		error("Report Map read failed: %s", att_ecode2str(status));
@@ -696,6 +701,14 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	bt_uhid_register(hogdev->uhid, UHID_OUTPUT, forward_report, hogdev);
 	bt_uhid_register(hogdev->uhid, UHID_SET_REPORT, set_report, hogdev);
 	bt_uhid_register(hogdev->uhid, UHID_GET_REPORT, get_report, hogdev);
+
+	hogdev->uhid_created = TRUE;
+
+	for (l = hogdev->reports; l; l = l->next) {
+		struct report *r = l->data;
+
+		enable_report_notifications(r, true);
+	}
 }
 
 static void info_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux