@@ -767,14 +767,19 @@
* The data mangled in the bit stream remains in little endian
* order the whole time. It make more sense to talk about
* endianness of register values by considering a register
- * a "cached" copy of the little endian bit stream.
+ * a "cached" copy of the little endiad bit stream.
*/
-static __inline__ void set_into_le_bitstream(__u8 *report, unsigned offset, unsigned bitfield_size, __u32 value)
+static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
{
- u64 m = (1ULL << bitfield_size) - 1;
+ u64 x;
+ u64 m = (1ULL << n) - 1;
+
+ if (n > 32)
+ printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n",
+ n, current->comm);
if (value > m)
- printk(KERN_WARNING "HID: set_into_le_bitstream() value (%u) too big for bitfield for %s\n",
+ printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n",
value, current->comm);
WARN_ON(value > m);
value &= m;
@@ -782,23 +787,10 @@
report += offset >> 3;
offset &= 7;
- if (bitfield_size > 32) {
- u64 x;
-
- printk(KERN_WARNING "HID: set_into_le_bitstream() called with bitfield_size %u > 32 for %s\n",
- bitfield_size, current->comm);
- x = get_unaligned_le64(report);
- x &= ~(m << offset);
- x |= ((u64)value) << offset;
- put_unaligned_le64(x, report);
- } else {
- u32 x;
-
- x = get_unaligned_le32(report);
- x &= ~(m << offset);
- x |= value << offset;
- put_unaligned_le32(x, report);
- }
+ x = get_unaligned_le64(report);
+ x &= ~(m << offset);
+ x |= ((u64)value) << offset;
+ put_unaligned_le64(x, report);
}
/*
@@ -959,9 +951,9 @@
for (n = 0; n < count; n++) {
if (field->logical_minimum < 0) /* signed values */
- set_into_le_bitstream(data, offset + n * size, size, s32ton(field->value[n], size));
+ implement(data, offset + n * size, size, s32ton(field->value[n], size));
else /* unsigned values */
- set_into_le_bitstream(data, offset + n * size, size, field->value[n]);
+ implement(data, offset + n * size, size, field->value[n]);
}
}