summaryrefslogtreecommitdiffstats
path: root/device/hid
diff options
context:
space:
mode:
authorreillyg@chromium.org <reillyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 21:15:00 +0000
committerreillyg@chromium.org <reillyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 21:15:00 +0000
commit19b11b30717d1aa68c5d5e9d238b1d3b7cf8d266 (patch)
tree000d4139b293b2eabf8b491516b0462a54d86790 /device/hid
parentd1bac2b8f8a505d1aac10e95a0c2e9fde072d420 (diff)
downloadchromium_src-19b11b30717d1aa68c5d5e9d238b1d3b7cf8d266.zip
chromium_src-19b11b30717d1aa68c5d5e9d238b1d3b7cf8d266.tar.gz
chromium_src-19b11b30717d1aa68c5d5e9d238b1d3b7cf8d266.tar.bz2
hid: Linux expects the report ID in the output report buffer.
The Linux hidraw interface expects the buffer written to the device to always have the report ID as the first byte. Remove the conditional that only added this data when the report ID was non-zero. BUG= R=rockot@chromium.org Review URL: https://codereview.chromium.org/411463005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid')
-rw-r--r--device/hid/hid_connection_linux.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
index 0220c2e..dcc4106 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);
}
}