summaryrefslogtreecommitdiff
path: root/include/linux/compat.h
diff options
context:
space:
mode:
authorLijun Pan <LIJUN.PAN@FREESCALE.COM>2014-06-20 12:17:29 -0500
committerTom Rini <trini@ti.com>2014-07-22 07:44:24 -0400
commit8f2df5d369ea57a2c1e4697e508a86fc1346e76f (patch)
tree908ab7828c517bcd8823c9e256eb0a284c4218b6 /include/linux/compat.h
parent9d78b9ae8d39f59875607976dbdce0f6f31ed41c (diff)
linux/compat.h: port lower_32_bits and upper_32_bits from Linux
[backport from linux commit 204b885e and 218e180e7] 64 bit processors are becomming more and more popular. lower_32_bits and upper_32_bits save our labor doing shifts/manipulations like (u32)(n) and (u32)((n) >> 32). They are good helpers in both little and big endian cases. Port these two functions here from Linux:include/linux/kernel.h, cater the comment message to little/big endian cases. Later on, developers could include linux/compat.h if they want to use these two functions. Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
Diffstat (limited to 'include/linux/compat.h')
-rw-r--r--include/linux/compat.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3fdfb399b5..35e216e06e 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -57,4 +57,23 @@
, __FILE__, __LINE__); }
#define PAGE_SIZE 4096
+
+/**
+ * upper_32_bits - return MSB bits 32-63 of a number if little endian, or
+ * return MSB bits 0-31 of a number if big endian.
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return LSB bits 0-31 of a number if little endian, or
+ * return LSB bits 32-63 of a number if big endian.
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
#endif