Skip to content
Commit 46386b58 authored by Simon Budig's avatar Simon Budig Committed by Jiri Kosina
Browse files

HID: introduce proper zeroing of unused bits in output reports



Some HID devices are looking on the unused bits in the HID reports they
receive. This is violating the specification, but we want to make those
devices work. Well-behaving devices are unaffected, as they don't care
about the unused bits.

If bitsused % 8 is 0 all bits in data[] get used and we don't need to
clear anything. Otherwise (bitsused % 8) bits of the last byte get used.
By shifting 1 for (bitsused % 8) bits and subtracting 1 we create a mask
consisting of (bitsused % 8) ones and remaining zeroes. By ANDing we
clear the upper unused bits.

Signed-off-by: default avatarSimon Budig <simon@budig.de>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a21bd69e
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment