Skip to contentSkip to conversation

HID: surface-hid: Fix get-report request

PATCH Applied Maximilian Luz 2 participants 2 messages Jun 8, 2021 – Jun 15, 2021

Subsystems (2)
lore
Share & tools
lore

Maximilian Luz

author maintainer
#0 lore raw

PATCH 1/1 HID: surface-hid: Fix get-report request

Getting a report (e.g. feature report) from a device requires us to send a request indicating which report we want to retrieve and then waiting for the corresponding response containing that report. We already provide the response structure to the request call, but the request isn't marked as a request that expects a response. Thus the request returns before we receive the response and the response buffer indicates a zero length response due to that.

This essentially means that the get-report calls are broken and will always indicate that a report of length zero has been read.

Fix this by appropriately marking the request.

Fixes b05ff1002a5c ("HID: Add support for Surface Aggregator Module HID transport")
---
 drivers/hid/surface-hid/surface_hid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/surface-hid/surface_hid.c +1 -1
index 3477b31611ae..a3a70e4f3f6c 100644
@@ -143,7 +143,7 @@ static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id,
 	rqst.target_id = shid->uid.target;
 	rqst.instance_id = shid->uid.instance;
 	rqst.command_id = SURFACE_HID_CID_GET_FEATURE_REPORT;
-	rqst.flags = 0;
+	rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
 	rqst.length = sizeof(rprt_id);
 	rqst.payload = &rprt_id;
 
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 24 lines · Maximilian Luz

Getting a report (e.g. feature report) from a device requires us to send a request indicating which report we want to retrieve and then waiting for the corresponding response containing that report. We already provide the response structure to the request call, but the request isn't marked as a request that expects a response. Thus the request returns before we receive the response and the response buffer indicates a zero length response due to that.

This essentially means that the get-report calls are broken and will always indicate that a report of length zero has been read.

Fix this by appropriately marking the request.

Fixes b05ff1002a5c ("HID: Add support for Surface Aggregator Module HID transport")
---
 drivers/hid/surface-hid/surface_hid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/surface-hid/surface_hid.c +0 -0
index 3477b31611ae..a3a70e4f3f6c 100644

drivers/hid/surface-hid/surface_hid.c static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id, · line 148

Quoted 7 lines
drivers/hid/surface-hid/surface_hid.c +1 -1
@@ -143,7 +143,7 @@ static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id,
 	rqst.target_id = shid->uid.target;
 	rqst.instance_id = shid->uid.instance;
 	rqst.command_id = SURFACE_HID_CID_GET_FEATURE_REPORT;
-	rqst.flags = 0;
+	rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
 	rqst.length = sizeof(rprt_id);
 	rqst.payload = &rprt_id;

Queued in for-5.13/upstream-fixes branch, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs