Commit 48442962 authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds

[PATCH] IB: Fix pack/unpack when size_bits == 64

Fix handling of fields with size_bits == 64.  Pointed out by Hal Rosenstock.
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dae4c1d2
...@@ -96,7 +96,7 @@ void ib_pack(const struct ib_field *desc, ...@@ -96,7 +96,7 @@ void ib_pack(const struct ib_field *desc,
else else
val = 0; 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 = (__be64 *) ((__be32 *) buf + desc[i].offset_words);
*addr = (*addr & ~mask) | (cpu_to_be64(val) & mask); *addr = (*addr & ~mask) | (cpu_to_be64(val) & mask);
} else { } else {
...@@ -176,7 +176,7 @@ void ib_unpack(const struct ib_field *desc, ...@@ -176,7 +176,7 @@ void ib_unpack(const struct ib_field *desc,
__be64 *addr; __be64 *addr;
shift = 64 - desc[i].offset_bits - desc[i].size_bits; 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; addr = (__be64 *) buf + desc[i].offset_words;
val = (be64_to_cpup(addr) & mask) >> shift; val = (be64_to_cpup(addr) & mask) >> shift;
value_write(desc[i].struct_offset_bytes, value_write(desc[i].struct_offset_bytes,
......
Markdown is supported
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