From 8e3d81e956d25d0060afdf9b0faf2f17c013318b Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Tue, 30 Jan 2007 06:06:00 -0500 Subject: [PATCH] --- yaml --- r: 46847 b: refs/heads/master c: 63c2f782e8f6aafbc11b14b2cb291b3dc9fc217d h: refs/heads/master i: 46845: 813ed05a3a51610ed7a2c116da0e5f450c27f97c 46843: 76badce20887ecb803d7176630da7d47a63c9636 46839: 1aa0740ca9408b9f606b0f3d3de6af741e77d9cb 46831: 991cd4df459bea5c917acc06ce72be5cb4dd0ca7 46815: cd38564ecb2fc971e9d667efa5d168d8de81175f 46783: eeba1f8b3e6f038507780bb86be6dc1aaad1cbfe 46719: 292f1753f0ae3d096315712de2f743753d37ac50 46591: 94c827bc88c274ae3cd75c4e84ace59f52d3fa6a v: v3 --- [refs] | 2 +- trunk/arch/powerpc/mm/pgtable_32.c | 5 +---- trunk/arch/ppc/mm/pgtable.c | 5 +---- trunk/arch/ppc/syslib/ppc85xx_rio.c | 2 -- trunk/drivers/net/gianfar_ethtool.c | 2 -- trunk/include/linux/log2.h | 11 +++++++++++ 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index b7bfb72c3cb4..7891366f715b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7df2457db83bc922fcc8b462526b77f1ffe8c84b +refs/heads/master: 63c2f782e8f6aafbc11b14b2cb291b3dc9fc217d diff --git a/trunk/arch/powerpc/mm/pgtable_32.c b/trunk/arch/powerpc/mm/pgtable_32.c index 1891dbeeb8e9..bd02272bcb0f 100644 --- a/trunk/arch/powerpc/mm/pgtable_32.c +++ b/trunk/arch/powerpc/mm/pgtable_32.c @@ -294,11 +294,8 @@ void __init mapin_ram(void) } } -/* is x a power of 2? */ -#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0)) - /* is x a power of 4? */ -#define is_power_of_4(x) ((x) != 0 && (((x) & (x-1)) == 0) && (ffs(x) & 1)) +#define is_power_of_4(x) is_power_of_2(x) && (ffs(x) & 1)) /* * Set up a mapping for a block of I/O. diff --git a/trunk/arch/ppc/mm/pgtable.c b/trunk/arch/ppc/mm/pgtable.c index 354a9408f024..82b06a1ef95d 100644 --- a/trunk/arch/ppc/mm/pgtable.c +++ b/trunk/arch/ppc/mm/pgtable.c @@ -313,11 +313,8 @@ void __init mapin_ram(void) } } -/* is x a power of 2? */ -#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0)) - /* is x a power of 4? */ -#define is_power_of_4(x) ((x) != 0 && (((x) & (x-1)) == 0) && (ffs(x) & 1)) +#define is_power_of_4(x) is_power_of_2(x) && (ffs(x) & 1)) /* * Set up a mapping for a block of I/O. diff --git a/trunk/arch/ppc/syslib/ppc85xx_rio.c b/trunk/arch/ppc/syslib/ppc85xx_rio.c index 05b0e9415085..2b097800cdd9 100644 --- a/trunk/arch/ppc/syslib/ppc85xx_rio.c +++ b/trunk/arch/ppc/syslib/ppc85xx_rio.c @@ -59,8 +59,6 @@ #define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET)) #define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET)) -#define is_power_of_2(x) (((x) & ((x) - 1)) == 0) - struct rio_atmu_regs { u32 rowtar; u32 pad1; diff --git a/trunk/drivers/net/gianfar_ethtool.c b/trunk/drivers/net/gianfar_ethtool.c index 6d71bea5e900..0d6943d67096 100644 --- a/trunk/drivers/net/gianfar_ethtool.c +++ b/trunk/drivers/net/gianfar_ethtool.c @@ -42,8 +42,6 @@ #include "gianfar.h" -#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0)) - extern void gfar_start(struct net_device *dev); extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); diff --git a/trunk/include/linux/log2.h b/trunk/include/linux/log2.h index d02e1a547a7e..99922bedfcc9 100644 --- a/trunk/include/linux/log2.h +++ b/trunk/include/linux/log2.h @@ -43,6 +43,17 @@ int __ilog2_u64(u64 n) } #endif +/* + * Determine whether some value is a power of two, where zero is + * *not* considered a power of two. + */ + +static inline __attribute__((const)) +bool is_power_of_2(unsigned long n) +{ + return (n != 0 && ((n & (n - 1)) == 0)); +} + /* * round up to nearest power of two */