Skip to contentSkip to conversation

linux/bitops: Move BIT defination at top

PATCH Superseded Jagan Teki 2 participants 3 messages Oct 21, 2015 – Oct 22, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH 1/2 linux/bitops: Move BIT defination at top

Since it's a copy from Linux, this patch moved all BIT definations to top so-that it looks same as Linux file.

---
 include/linux/bitops.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/bitops.h +2 -3
index 7d30ace..8ed0cf5 100644
@@ -4,6 +4,8 @@
 #include <asm/types.h>
 
 #define BIT(nr)		(1UL << (nr))
+#define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
+#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -106,9 +108,6 @@ static inline unsigned int generic_hweight8(unsigned int w)
 	return (res & 0x0F) + ((res >> 4) & 0x0F);
 }
 
-#define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
-
 #include <asm/bitops.h>
 
 /* linux/include/asm-generic/bitops/non-atomic.h */
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 2/2 linux/bitops.h: GENMASK copy from linux

GENMASK is used to create a contiguous bitmask([hi:lo]).

This patch is a copy from Linux, with below commit details "bitops: Fix shift overflow in GENMASK macros" (sha1: 00b4d9a14125f1e51874def2b9de6092e007412d)

Cc Tom Rini <[email protected]>
Cc Masahiro Yamada <[email protected]>

---
Changes for v3:
- Rebase to master
- Added bitsperlong.h

 include/asm-generic/bitsperlong.h |  8 ++++++++
 include/linux/bitops.h            | 11 +++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 include/asm-generic/bitsperlong.h
include/asm-generic/bitsperlong.h new file +8 -0
new file mode 100644
index 0000000..75ee21e
@@ -0,0 +1,8 @@
+#ifndef __ASM_GENERIC_BITS_PER_LONG
+#define __ASM_GENERIC_BITS_PER_LONG
+
+#ifndef BITS_PER_LONG_LONG
+#define BITS_PER_LONG_LONG 64
+#endif
+
+#endif /* __ASM_GENERIC_BITS_PER_LONG */
include/linux/bitops.h +11 -0
index 8ed0cf5..6b801b4 100644
@@ -8,6 +8,17 @@
 #define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
 
 /*
+ * Create a contiguous bitmask starting at bit position @l and ending at
+ * position @h. For example
+ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
+ */
+#define GENMASK(h, l) \
+	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+
+#define GENMASK_ULL(h, l) \
+	(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+
+/*
  * ffs: find first bit set. This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
  * differs in spirit from the above ffz (man ffs).
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/2 linux/bitops.h: GENMASK copy from linux

Quoted 9 lines · Jagan Teki

GENMASK is used to create a contiguous bitmask([hi:lo]).

This patch is a copy from Linux, with below commit details "bitops: Fix shift overflow in GENMASK macros" (sha1: 00b4d9a14125f1e51874def2b9de6092e007412d)

Cc Tom Rini <[email protected]>
Cc Masahiro Yamada <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151022/ed356645/attachment-0001.sig>