From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/5] linux/bitops.h: GENMASK copy from linux
Date: Sun, 10 May 2015 20:52:09 +0530 [thread overview]
Message-ID: <1431271330-7169-5-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1431271330-7169-1-git-send-email-jteki@openedev.com>
GENMASK is used to create a contiguous bitmask([hi:lo]).
Signed-off-by: Jagan Teki <jteki@openedev.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
---
include/linux/bitops.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index c098c9a..08db119 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -108,6 +108,17 @@ static inline unsigned int generic_hweight8(unsigned int w)
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+/*
+ * Create a contiguous bitmask starting@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))))
+
#include <asm/bitops.h>
/* linux/include/asm-generic/bitops/non-atomic.h */
--
1.9.1
next prev parent reply other threads:[~2015-05-10 15:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-10 15:22 [U-Boot] [PATCH v2 0/5] Introduce BIT and GENMASK Jagan Teki
2015-05-10 15:22 ` [U-Boot] [PATCH v2 1/5] spi/sf: Add BIT macro in linux/bitops.h Jagan Teki
2015-05-10 15:22 ` [U-Boot] [PATCH v2 2/5] spi: Remove #define BIT in local file Jagan Teki
2015-05-10 15:22 ` [U-Boot] [PATCH v2 3/5] spi/sf: Use BIT macro from linux/bitops.h Jagan Teki
2015-05-10 15:22 ` Jagan Teki [this message]
2015-05-10 15:22 ` [U-Boot] [PATCH v2 5/5] spi: Use GENMASK instead of numeric hexcodes Jagan Teki
2015-05-12 11:25 ` [U-Boot] [PATCH v2 0/5] Introduce BIT and GENMASK Jagan Teki
2015-05-12 11:33 ` Marek Vasut
2015-05-12 15:02 ` Tom Rini
2015-05-12 15:23 ` Marek Vasut
2015-05-13 1:48 ` Simon Glass
2015-05-15 19:19 ` Jagan Teki
2015-05-15 19:46 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431271330-7169-5-git-send-email-jteki@openedev.com \
--to=jteki@openedev.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox