[openib-general] [PATCH 2/3] IB: Fix pack/unpack when size_bits == 64

Roland Dreier rolandd at cisco.com
Fri Jun 24 14:54:42 PDT 2005


Fix handling of fields with size_bits == 64.  Pointed out by Hal Rosenstock.

Signed-off-by: Roland Dreier <rolandd at cisco.com>

---

 drivers/infiniband/core/packer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)



--- linux-export2.orig/drivers/infiniband/core/packer.c	2005-06-23 13:16:25.000000000 -0700
+++ linux-export2/drivers/infiniband/core/packer.c	2005-06-24 14:49:44.448271407 -0700
@@ -96,7 +96,7 @@
 			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 @@
 			__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,



More information about the general mailing list