summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2007-04-29 22:19:02 +0200
committerJiri Kosina <jkosina@suse.cz>2007-04-29 22:19:02 +0200
commit11941a321d49cd2cafc8e64f66cbfed60fc1c691 (patch)
tree4a0055d4a3f4903565b159347ca06b64d5f20e67
parentUSB HID: don't warn on idVendor == 0 (diff)
parentHID: introduce proper zeroing of unused bits in output reports (diff)
downloadlinux-11941a321d49cd2cafc8e64f66cbfed60fc1c691.tar.xz
linux-11941a321d49cd2cafc8e64f66cbfed60fc1c691.zip
Merge branch 'field-zeroing' into for-linus
-rw-r--r--drivers/hid/hid-core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 7c0fab1efb2e..e8387cb95d7f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -872,8 +872,13 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
unsigned count = field->report_count;
unsigned offset = field->report_offset;
unsigned size = field->report_size;
+ unsigned bitsused = offset + count * size;
unsigned n;
+ /* make sure the unused bits in the last byte are zeros */
+ if (count > 0 && size > 0 && (bitsused % 8) != 0)
+ data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1;
+
for (n = 0; n < count; n++) {
if (field->logical_minimum < 0) /* signed values */
implement(data, offset + n * size, size, s32ton(field->value[n], size));