alpha: cleanup in bitops.h
Remove 2 functions private to the alpha implemetation, in favor of similar functions in <linux/log2.h>. Provide a more efficient version of the fls64 function for pre-ev67 alphas. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
f54496f55a
commit
74fd1b687f
|
@ -7,6 +7,7 @@
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/bootmem.h>
|
#include <linux/bootmem.h>
|
||||||
|
#include <linux/log2.h>
|
||||||
|
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <asm/hwrpb.h>
|
#include <asm/hwrpb.h>
|
||||||
|
@ -53,7 +54,7 @@ size_for_memory(unsigned long max)
|
||||||
{
|
{
|
||||||
unsigned long mem = max_low_pfn << PAGE_SHIFT;
|
unsigned long mem = max_low_pfn << PAGE_SHIFT;
|
||||||
if (mem < max)
|
if (mem < max)
|
||||||
max = 1UL << ceil_log2(mem);
|
max = roundup_pow_of_two(mem);
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <linux/notifier.h>
|
#include <linux/notifier.h>
|
||||||
#include <asm/setup.h>
|
#include <asm/setup.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
#include <linux/log2.h>
|
||||||
|
|
||||||
extern struct atomic_notifier_head panic_notifier_list;
|
extern struct atomic_notifier_head panic_notifier_list;
|
||||||
static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
|
static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
|
||||||
|
@ -1303,7 +1304,7 @@ external_cache_probe(int minsize, int width)
|
||||||
long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
|
long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
|
||||||
|
|
||||||
if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
|
if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
|
||||||
maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
|
maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
|
||||||
|
|
||||||
/* Get the first block cached. */
|
/* Get the first block cached. */
|
||||||
read_mem_block(__va(0), stride, size);
|
read_mem_block(__va(0), stride, size);
|
||||||
|
|
|
@ -37,7 +37,8 @@ lib-y = __divqu.o __remqu.o __divlu.o __remlu.o \
|
||||||
$(ev6-y)clear_page.o \
|
$(ev6-y)clear_page.o \
|
||||||
$(ev6-y)copy_page.o \
|
$(ev6-y)copy_page.o \
|
||||||
fpreg.o \
|
fpreg.o \
|
||||||
callback_srm.o srm_puts.o srm_printk.o
|
callback_srm.o srm_puts.o srm_printk.o \
|
||||||
|
fls.o
|
||||||
|
|
||||||
lib-$(CONFIG_SMP) += dec_and_lock.o
|
lib-$(CONFIG_SMP) += dec_and_lock.o
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* arch/alpha/lib/fls.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <asm/bitops.h>
|
||||||
|
|
||||||
|
/* This is fls(x)-1, except zero is held to zero. This allows most
|
||||||
|
efficent input into extbl, plus it allows easy handling of fls(0)=0. */
|
||||||
|
|
||||||
|
const unsigned char __flsm1_tab[256] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1, 1,
|
||||||
|
2, 2, 2, 2,
|
||||||
|
3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
|
|
||||||
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
|
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||||
|
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPORT_SYMBOL(__flsm1_tab);
|
|
@ -313,32 +313,29 @@ static inline int ffs(int word)
|
||||||
* fls: find last bit set.
|
* fls: find last bit set.
|
||||||
*/
|
*/
|
||||||
#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
|
#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
|
||||||
static inline int fls(int word)
|
static inline int fls64(unsigned long word)
|
||||||
{
|
{
|
||||||
return 64 - __kernel_ctlz(word & 0xffffffff);
|
return 64 - __kernel_ctlz(word);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#include <asm-generic/bitops/fls.h>
|
extern const unsigned char __flsm1_tab[256];
|
||||||
#endif
|
|
||||||
#include <asm-generic/bitops/fls64.h>
|
|
||||||
|
|
||||||
/* Compute powers of two for the given integer. */
|
static inline int fls64(unsigned long x)
|
||||||
static inline long floor_log2(unsigned long word)
|
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
|
unsigned long t, a, r;
|
||||||
return 63 - __kernel_ctlz(word);
|
|
||||||
#else
|
t = __kernel_cmpbge (x, 0x0101010101010101);
|
||||||
long bit;
|
a = __flsm1_tab[t];
|
||||||
for (bit = -1; word ; bit++)
|
t = __kernel_extbl (x, a);
|
||||||
word >>= 1;
|
r = a*8 + __flsm1_tab[t] + (x != 0);
|
||||||
return bit;
|
|
||||||
#endif
|
return r;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline long ceil_log2(unsigned long word)
|
static inline int fls(int x)
|
||||||
{
|
{
|
||||||
long bit = floor_log2(word);
|
return fls64((unsigned int) x);
|
||||||
return bit + (word > (1UL << bit));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -353,9 +350,20 @@ static inline unsigned long hweight64(unsigned long w)
|
||||||
return __kernel_ctpop(w);
|
return __kernel_ctpop(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful)
|
static inline unsigned int hweight32(unsigned int w)
|
||||||
#define hweight16(x) (unsigned int) hweight64((x) & 0xfffful)
|
{
|
||||||
#define hweight8(x) (unsigned int) hweight64((x) & 0xfful)
|
return hweight64(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int hweight16(unsigned int w)
|
||||||
|
{
|
||||||
|
return hweight64(w & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int hweight8(unsigned int w)
|
||||||
|
{
|
||||||
|
return hweight64(w & 0xff);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#include <asm-generic/bitops/hweight.h>
|
#include <asm-generic/bitops/hweight.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue