Skip to content

Commit

Permalink
Merge branch 'field-zeroing' into for-linus
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Kosina committed Apr 29, 2007
2 parents f61c912 + 46386b5 commit 11941a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 11941a3

Please sign in to comment.