summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-06-27 14:36:47 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 15:11:47 -0700
commit48442962ebccec92d8a65f465420423cd2ce0bc8 (patch)
tree5ea80864ac4cc4c86e649a364451acab0f5c6bc8
parentdae4c1d2362292ccd3318ff67d18aa5c22ee820c (diff)
downloadop-kernel-dev-48442962ebccec92d8a65f465420423cd2ce0bc8.zip
op-kernel-dev-48442962ebccec92d8a65f465420423cd2ce0bc8.tar.gz
[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: Roland Dreier <rolandd@cisco.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/infiniband/core/packer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/infiniband/core/packer.c b/drivers/infiniband/core/packer.c
index 5f15fef..eb5ff54 100644
--- a/drivers/infiniband/core/packer.c
+++ b/drivers/infiniband/core/packer.c
@@ -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 {
@@ -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,
OpenPOWER on IntegriCloud