diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2007-05-10 06:15:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-10 12:26:52 -0400 |
commit | 218e180e7ea5334e1f94121940ba82cd1f0f4e58 (patch) | |
tree | 5b7aa47a2439c40b8b68a3bfd9e2f72bf07cf385 /include/linux | |
parent | 894b8788d7f265eb7c6f75a9a77cedeb48f51586 (diff) |
add upper-32-bits macro
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>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kernel.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 144b615f3a89..8645181fca0f 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -41,6 +41,16 @@ extern const char linux_proc_banner[]; | |||
41 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 41 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
42 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) | 42 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) |
43 | 43 | ||
44 | /** | ||
45 | * upper_32_bits - return bits 32-63 of a number | ||
46 | * @n: the number we're accessing | ||
47 | * | ||
48 | * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress | ||
49 | * the "right shift count >= width of type" warning when that quantity is | ||
50 | * 32-bits. | ||
51 | */ | ||
52 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) | ||
53 | |||
44 | #define KERN_EMERG "<0>" /* system is unusable */ | 54 | #define KERN_EMERG "<0>" /* system is unusable */ |
45 | #define KERN_ALERT "<1>" /* action must be taken immediately */ | 55 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
46 | #define KERN_CRIT "<2>" /* critical conditions */ | 56 | #define KERN_CRIT "<2>" /* critical conditions */ |