Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 39832
b: refs/heads/master
c: 4550718
h: refs/heads/master
v: v3
  • Loading branch information
Grant Grundler authored and Greg Kroah-Hartman committed Oct 17, 2006
1 parent c678684 commit fa7cfe5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0e185b7922ac81516c5c4653dcf6aacbf6341e73
refs/heads/master: 4550718f6c75c9abe8b987fa4c625fd041aa95a2
24 changes: 17 additions & 7 deletions trunk/drivers/usb/input/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,21 +750,31 @@ static __inline__ __u32 s32ton(__s32 value, unsigned n)
}

/*
* Extract/implement a data field from/to a report.
* Extract/implement a data field from/to a little endian report (bit array).
*/

static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
{
report += (offset >> 5) << 2; offset &= 31;
return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1);
u32 x;

report += offset >> 3; /* adjust byte index */
offset &= 8 - 1;
x = get_unaligned((u32 *) report);
x = le32_to_cpu(x);
x = (x >> offset) & ((1 << n) - 1);
return x;
}

static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
{
report += (offset >> 5) << 2; offset &= 31;
put_unaligned((get_unaligned((__le64*)report)
& cpu_to_le64(~((((__u64) 1 << n) - 1) << offset)))
| cpu_to_le64((__u64)value << offset), (__le64*)report);
u32 x;

report += offset >> 3;
offset &= 8 - 1;
x = get_unaligned((u32 *)report);
x &= cpu_to_le32(~((((__u32) 1 << n) - 1) << offset));
x |= cpu_to_le32(value << offset);
put_unaligned(x,(u32 *)report);
}

/*
Expand Down

0 comments on commit fa7cfe5

Please sign in to comment.