Skip to content

Commit

Permalink
[PATCH] IB: Fix pack/unpack when size_bits == 64
Browse files Browse the repository at this point in the history
Fix handling of fields with size_bits == 64.  Pointed out by Hal Rosenstock.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Roland Dreier authored and Linus Torvalds committed Jun 27, 2005
1 parent dae4c1d commit 4844296
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/core/packer.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ib_pack(const struct ib_field *desc,
else
val = 0;

mask = cpu_to_be64(((1ull << desc[i].size_bits) - 1) << shift);
mask = cpu_to_be64((~0ull >> (64 - desc[i].size_bits)) << shift);
addr = (__be64 *) ((__be32 *) buf + desc[i].offset_words);
*addr = (*addr & ~mask) | (cpu_to_be64(val) & mask);
} else {
Expand Down Expand Up @@ -176,7 +176,7 @@ void ib_unpack(const struct ib_field *desc,
__be64 *addr;

shift = 64 - desc[i].offset_bits - desc[i].size_bits;
mask = ((1ull << desc[i].size_bits) - 1) << shift;
mask = (~0ull >> (64 - desc[i].size_bits)) << shift;
addr = (__be64 *) buf + desc[i].offset_words;
val = (be64_to_cpup(addr) & mask) >> shift;
value_write(desc[i].struct_offset_bytes,
Expand Down

0 comments on commit 4844296

Please sign in to comment.