| 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);
|
| }
|
| }
|
|
|
|
|