mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[POWERPC] Add "is_power_of_2" checking to log2.h.
Add the inline function "is_power_of_2()" to log2.h, where the value zero is *not* considered to be a power of two. Signed-off-by: Robert P. J. Day <rpjday@mindspring.com> Acked-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
7df2457db8
commit
63c2f782e8
5 changed files with 13 additions and 12 deletions
|
@ -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? */
|
/* 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.
|
* Set up a mapping for a block of I/O.
|
||||||
|
|
|
@ -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? */
|
/* 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.
|
* Set up a mapping for a block of I/O.
|
||||||
|
|
|
@ -59,8 +59,6 @@
|
||||||
#define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET))
|
#define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET))
|
||||||
#define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET))
|
#define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET))
|
||||||
|
|
||||||
#define is_power_of_2(x) (((x) & ((x) - 1)) == 0)
|
|
||||||
|
|
||||||
struct rio_atmu_regs {
|
struct rio_atmu_regs {
|
||||||
u32 rowtar;
|
u32 rowtar;
|
||||||
u32 pad1;
|
u32 pad1;
|
||||||
|
|
|
@ -42,8 +42,6 @@
|
||||||
|
|
||||||
#include "gianfar.h"
|
#include "gianfar.h"
|
||||||
|
|
||||||
#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
|
|
||||||
|
|
||||||
extern void gfar_start(struct net_device *dev);
|
extern void gfar_start(struct net_device *dev);
|
||||||
extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
|
extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,17 @@ int __ilog2_u64(u64 n)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
* round up to nearest power of two
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue