hog: Fix read order of attributes
Luiz Augusto von Dentz
maintainerPATCH 1/1 hog: Fix read order of attributes
From: Luiz Augusto von Dentz <[email protected]>
The Report Map must be read after the Report Reference otherwise the driver may start using UHID_SET_REPORT which requires the report->id to be known what attribute to send to.
--- profiles/input/hog-lib.c | 43 +++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-)
profiles/input/hog-lib.c +31 -12
@@ -1349,24 +1349,17 @@ static void db_report_map_read_value_cb(struct gatt_db_attribute *attrib,memcpy (map->value, value, map->length); } -static void foreach_hog_chrc (struct gatt_db_attribute *attr,void *user_data) +static void foreach_hog_report_map (struct gatt_db_attribute *attr, +void *user_data) {struct bt_hog *hog = user_data; -bt_uuid_t uuid, report_uuid, report_map_uuid, info_uuid; -bt_uuid_t proto_mode_uuid, ctrlpt_uuid; +bt_uuid_t uuid, report_map_uuid;uint16_t handle, value_handle;struct report_map report_map = {0 };gatt_db_attribute_get_char_data (attr, &handle, &value_handle,NULL ,NULL , &uuid); -bt_uuid16_create (&report_uuid,HOG_REPORT_UUID ); -if (!bt_uuid_cmp (&report_uuid, &uuid)) { -struct report *report =report_add (hog, attr); -gatt_db_service_foreach_desc (attr, foreach_hog_report, report); -return ; - } -bt_uuid16_create (&report_map_uuid,HOG_REPORT_MAP_UUID );if (!bt_uuid_cmp (&report_map_uuid, &uuid)) {
@@ -1392,6 +1385,23 @@ static void foreach_hog_chrc(struct gatt_db_attribute *attr, void *user_data) }gatt_db_service_foreach_desc (attr, foreach_hog_external, hog); + } +} + +static void foreach_hog_chrc (struct gatt_db_attribute *attr,void *user_data) +{ +struct bt_hog *hog = user_data; +bt_uuid_t uuid, report_uuid, info_uuid; +bt_uuid_t proto_mode_uuid, ctrlpt_uuid; +uint16_t handle, value_handle; + +gatt_db_attribute_get_char_data (attr, &handle, &value_handle,NULL , +NULL , &uuid); + +bt_uuid16_create (&report_uuid,HOG_REPORT_UUID ); +if (!bt_uuid_cmp (&report_uuid, &uuid)) { +struct report *report =report_add (hog, attr); +gatt_db_service_foreach_desc (attr, foreach_hog_report, report);return ; }
@@ -1706,10 +1716,19 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)if (!hog->uhid_created) {DBG ("HoG discovering characteristics" ); -if (hog->attr) +if (hog->attr) {gatt_db_service_foreach_char (hog->attr, foreach_hog_chrc, hog); -else +/* Report Map must be read last since that can result +* in uhid being created and the driver may start to +* use UHID_SET_REPORT which requires the report->id to +* be known or order to send the request to the right +* attribute/handle. +*/ +gatt_db_service_foreach_char (hog->attr, + foreach_hog_report_map, + hog); + }else discover_char(hog, hog->attrib, hog->primary->range.start, hog->primary->range.end, NULL,
Signature · 1 line
2.33.1
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=604337
---Test result---
Test Summary:
CheckPatch FAIL 5.70 seconds GitLint PASS 0.98 seconds Prep - Setup ELL PASS 42.22 seconds Build - Prep PASS 0.73 seconds Build - Configure PASS 8.38 seconds Build - Make PASS 1357.51 seconds Make Check PASS 11.76 seconds Make Check w/Valgrind PASS 438.80 seconds Make Distcheck PASS 225.56 seconds Build w/ext ELL - Configure PASS 8.77 seconds Build w/ext ELL - Make PASS 1328.88 seconds Incremental Build with patchesPASS 0.00 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf Output:
[BlueZ] hog: Fix read order of attributes WARNING:LINE_SPACING: Missing a blank line after declarations #141: FILE: profiles/input/hog-lib.c:1404:
+ struct report *report = report_add(hog, attr);
+ gatt_db_service_foreach_desc(attr, foreach_hog_report, report);
/github/workspace/src/12709406.patch total: 0 errors, 1 warnings, 71 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/12709406.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth