]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
add upper-32-bits macro
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 10 May 2007 10:15:18 +0000 (03:15 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 10 May 2007 16:26:52 +0000 (09:26 -0700)
We keep on getting "right shift count >= width of type" warnings when doing
things like

sector_t s;

x = s >> 56;

because with CONFIG_LBD=n, s is only 32-bit.  Similar problems can occur with
dma_addr_t's.

So add a simple wrapper function which code can use to avoid this warning.
The above example would become

x = upper_32_bits(s) >> 24;

The first user is in fact AFS.

Cc: James Bottomley <James.Bottomley@SteelEye.com>
Cc: "Cameron, Steve" <Steve.Cameron@hp.com>
Cc: "Miller, Mike (OS Dev)" <Mike.Miller@hp.com>
Cc: Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/kernel.h

index 144b615f3a8999c800eddb4ad270c11419b044dc..8645181fca0fba6e68079b03b0df290779c6f9f5 100644 (file)
@@ -41,6 +41,16 @@ extern const char linux_proc_banner[];
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
 
+/**
+ * upper_32_bits - return bits 32-63 of a number
+ * @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))
+
 #define        KERN_EMERG      "<0>"   /* system is unusable                   */
 #define        KERN_ALERT      "<1>"   /* action must be taken immediately     */
 #define        KERN_CRIT       "<2>"   /* critical conditions                  */