Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Unified Diff: device/hid/hid_connection_linux.cc

Issue 411463005: hid: Linux expects the report ID in the output report buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_connection_linux.cc
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
index 0220c2e496ea0d7a6d23e91b6b7a31305b011bc6..dcc4106633a4e69027be23313b0d658e7e79890d 100644
--- a/device/hid/hid_connection_linux.cc
+++ b/device/hid/hid_connection_linux.cc
@@ -104,17 +104,20 @@ void HidConnectionLinux::PlatformWrite(
uint8_t report_id,
scoped_refptr<net::IOBufferWithSize> buffer,
const IOCallback& callback) {
- // If report ID is non-zero, insert it into a new copy of the buffer.
- if (report_id != 0)
- buffer = CopyBufferWithReportId(buffer, report_id);
- int bytes_written = HANDLE_EINTR(
+ // Linux always expects the first byte of the buffer to be the report ID.
+ buffer = CopyBufferWithReportId(buffer, report_id);
+ const int bytes_written = HANDLE_EINTR(
write(device_file_.GetPlatformFile(), buffer->data(), buffer->size()));
if (bytes_written < 0) {
VPLOG(1) << "Write failed";
Disconnect();
callback.Run(false, 0);
} else {
- callback.Run(true, bytes_written);
+ if (bytes_written != buffer->size()) {
+ LOG(WARNING) << "Incomplete HID write: "
+ << bytes_written << " != " << buffer->size();
+ }
+ callback.Run(true, bytes_written == 0 ? 0 : bytes_written - 1);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698