From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [99.236.101.138] (helo=crashcourse.ca) by astoria.ccjclearline.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1IpPtN-00055I-BV for linux-mm@kvack.org; Tue, 06 Nov 2007 09:59:01 -0500 Date: Tue, 6 Nov 2007 09:57:16 -0500 (EST) From: "Robert P. J. Day" Subject: [PATCH] MM: Use is_power_of_2() macro where appropriate. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: linux-mm@kvack.org List-ID: Signed-off-by: Robert P. J. Day --- mm/bootmem.c | 3 ++- mm/slab.c | 3 ++- mm/slub.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/bootmem.c b/mm/bootmem.c index 00a9697..47f9b59 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -189,7 +190,7 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, printk("__alloc_bootmem_core(): zero-sized request\n"); BUG(); } - BUG_ON(align & (align-1)); + BUG_ON(!is_power_of_2(align)); if (limit && bdata->node_boot_start >= limit) return NULL; diff --git a/mm/slab.c b/mm/slab.c index cfa6be4..f13d46d 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -110,6 +110,7 @@ #include #include #include +#include #include #include @@ -1782,7 +1783,7 @@ static void dump_line(char *data, int offset, int limit) if (bad_count == 1) { error ^= POISON_FREE; - if (!(error & (error - 1))) { + if (is_power_of_2(error)) { printk(KERN_ERR "Single bit error detected. Probably " "bad RAM.\n"); #ifdef CONFIG_X86 diff --git a/mm/slub.c b/mm/slub.c index 84f59fd..413cdc6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -21,6 +21,7 @@ #include #include #include +#include /* * Lock order: @@ -2851,7 +2852,7 @@ void __init kmem_cache_init(void) * around with ARCH_KMALLOC_MINALIGN */ BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 || - (KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1))); + !is_power_of_2(KMALLOC_MIN_SIZE)); for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) size_index[(i - 1) / 8] = KMALLOC_SHIFT_LOW; -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://crashcourse.ca ======================================================================== -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org