From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 2/2] linux/bitops.h: GENMASK copy from linux
Date: Wed, 21 Oct 2015 16:46:51 +0530 [thread overview]
Message-ID: <1445426211-10135-2-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1445426211-10135-1-git-send-email-jteki@openedev.com>
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 <trini@konsulko.com>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
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
diff --git a/include/asm-generic/bitsperlong.h b/include/asm-generic/bitsperlong.h
new file mode 100644
index 0000000..75ee21e
--- /dev/null
+++ b/include/asm-generic/bitsperlong.h
@@ -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 */
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 8ed0cf5..6b801b4 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -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).
--
1.9.1
next prev parent reply other threads:[~2015-10-21 11:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-21 11:16 [U-Boot] [PATCH 1/2] linux/bitops: Move BIT defination at top Jagan Teki
2015-10-21 11:16 ` Jagan Teki [this message]
2015-10-22 11:24 ` [U-Boot] [PATCH v3 2/2] linux/bitops.h: GENMASK copy from linux Tom Rini
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=1445426211-10135-2-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