summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arc/include/asm/bitops.h5
-rw-r--r--arch/arm/include/asm/bitops.h5
-rw-r--r--arch/arm/mach-mvebu/mbus.c2
-rw-r--r--arch/avr32/include/asm/bitops.h5
-rw-r--r--arch/blackfin/include/asm/bitops.h4
-rw-r--r--arch/m68k/include/asm/bitops.h4
-rw-r--r--arch/microblaze/include/asm/bitops.h4
-rw-r--r--arch/mips/include/asm/bitops.h5
-rw-r--r--arch/mips/lib/bootm.c196
-rw-r--r--arch/nds32/include/asm/bitops.h4
-rw-r--r--arch/nios2/include/asm/bitops.h5
-rw-r--r--arch/openrisc/include/asm/bitops.h4
-rw-r--r--arch/powerpc/cpu/mpc83xx/law.c5
-rw-r--r--arch/powerpc/cpu/mpc85xx/tlb.c2
-rw-r--r--arch/powerpc/cpu/mpc8xxx/law.c5
-rw-r--r--arch/powerpc/include/asm/bitops.h11
-rw-r--r--arch/powerpc/include/asm/fsl_law.h1
-rw-r--r--arch/powerpc/include/asm/fsl_srio.h2
-rw-r--r--arch/sandbox/include/asm/bitops.h4
-rw-r--r--arch/sh/include/asm/bitops.h5
-rw-r--r--arch/sparc/include/asm/bitops.h5
-rw-r--r--arch/x86/include/asm/bitops.h21
22 files changed, 184 insertions, 120 deletions
diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index 85721aaee3..370cb46e9f 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -16,4 +16,9 @@
#define hweight16(x) generic_hweight16(x)
#define hweight8(x) generic_hweight8(x)
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#endif /* __ASM_ARC_BITOPS_H */
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 9b78043db7..d479a38291 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -190,4 +190,9 @@ found_middle:
#endif /* __KERNEL__ */
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/__ffs.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/fls64.h>
+
#endif /* _ARM_BITOPS_H */
diff --git a/arch/arm/mach-mvebu/mbus.c b/arch/arm/mach-mvebu/mbus.c
index 771cce6fa3..346278e1be 100644
--- a/arch/arm/mach-mvebu/mbus.c
+++ b/arch/arm/mach-mvebu/mbus.c
@@ -52,7 +52,7 @@
#include <asm/io.h>
#include <asm/arch/cpu.h>
#include <asm/arch/soc.h>
-#include <linux/compat.h>
+#include <linux/log2.h>
#include <linux/mbus.h>
/* DDR target is the same on all platforms */
diff --git a/arch/avr32/include/asm/bitops.h b/arch/avr32/include/asm/bitops.h
index 0ec678487d..0d425c20f9 100644
--- a/arch/avr32/include/asm/bitops.h
+++ b/arch/avr32/include/asm/bitops.h
@@ -6,4 +6,9 @@
#ifndef __ASM_AVR32_BITOPS_H
#define __ASM_AVR32_BITOPS_H
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#endif /* __ASM_AVR32_BITOPS_H */
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index cd7e356459..6cde6dbfde 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -15,6 +15,10 @@
#include <asm/byteorder.h>
#include <asm/system.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
#ifdef __KERNEL__
/*
diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h
index f9c434b4a3..69ea26a729 100644
--- a/arch/m68k/include/asm/bitops.h
+++ b/arch/m68k/include/asm/bitops.h
@@ -6,6 +6,10 @@
#define _M68K_BITOPS_H
#include <asm/byteorder.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
extern void set_bit(int nr, volatile void *addr);
extern void clear_bit(int nr, volatile void *addr);
diff --git a/arch/microblaze/include/asm/bitops.h b/arch/microblaze/include/asm/bitops.h
index 0ac78d76f9..d24f2cf9d3 100644
--- a/arch/microblaze/include/asm/bitops.h
+++ b/arch/microblaze/include/asm/bitops.h
@@ -7,6 +7,10 @@
#include <asm/byteorder.h> /* swab32 */
#include <asm/system.h> /* save_flags */
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
#ifdef __KERNEL__
/*
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index b5c2a6367d..c31ff6efb4 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -17,6 +17,11 @@
#include <asm/sgidefs.h>
#include <asm/system.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
/*
* clear_bit() doesn't provide any barrier for the compiler.
*/
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 9c647aa428..eed159cd46 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -15,24 +15,6 @@ DECLARE_GLOBAL_DATA_PTR;
#define LINUX_MAX_ENVS 256
#define LINUX_MAX_ARGS 256
-#if defined(CONFIG_MALTA)
-#define mips_boot_malta 1
-#else
-#define mips_boot_malta 0
-#endif
-
-#if defined(CONFIG_MIPS_BOOT_CMDLINE_LEGACY)
-#define mips_boot_cmdline_legacy 1
-#else
-#define mips_boot_cmdline_legacy 0
-#endif
-
-#if defined(CONFIG_MIPS_BOOT_ENV_LEGACY)
-#define mips_boot_env_legacy 1
-#else
-#define mips_boot_env_legacy 0
-#endif
-
static int linux_argc;
static char **linux_argv;
static char *linux_argp;
@@ -62,50 +44,6 @@ void arch_lmb_reserve(struct lmb *lmb)
lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
}
-static int boot_setup_linux(bootm_headers_t *images)
-{
- int ret;
- ulong rd_len;
-
- rd_len = images->rd_end - images->rd_start;
- ret = boot_ramdisk_high(&images->lmb, images->rd_start,
- rd_len, &images->initrd_start, &images->initrd_end);
- if (ret)
- return ret;
-
-#if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
- if (images->ft_len) {
- boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
-
- ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
- &images->ft_len);
- if (ret)
- return ret;
- }
-#endif
-
- return 0;
-}
-
-static void boot_setup_fdt(bootm_headers_t *images)
-{
-#if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
- u64 mem_start = 0;
- u64 mem_size = gd->ram_size;
-
- debug("## setup FDT\n");
-
- fdt_chosen(images->ft_addr);
- fdt_fixup_memory_banks(images->ft_addr, &mem_start, &mem_size, 1);
- fdt_fixup_ethernet(images->ft_addr);
- fdt_initrd(images->ft_addr, images->initrd_start, images->initrd_end);
-
-#if defined(CONFIG_OF_BOARD_SETUP)
- ft_board_setup(images->ft_addr, gd->bd);
-#endif
-#endif
-}
-
static void linux_cmdline_init(void)
{
linux_argc = 1;
@@ -197,18 +135,6 @@ static void linux_cmdline_append(bootm_headers_t *images)
}
}
-static void boot_cmdline_linux(bootm_headers_t *images)
-{
- if (mips_boot_cmdline_legacy && !images->ft_len) {
- linux_cmdline_legacy(images);
-
- if (!mips_boot_env_legacy)
- linux_cmdline_append(images);
-
- linux_cmdline_dump();
- }
-}
-
static void linux_env_init(void)
{
linux_env = (char **)(((ulong) linux_argp + 15) & ~15);
@@ -225,7 +151,7 @@ static void linux_env_set(const char *env_name, const char *env_val)
strcpy(linux_env_p, env_name);
linux_env_p += strlen(env_name);
- if (mips_boot_malta) {
+ if (CONFIG_IS_ENABLED(MALTA)) {
linux_env_p++;
linux_env[++linux_env_idx] = linux_env_p;
} else {
@@ -246,14 +172,15 @@ static void linux_env_legacy(bootm_headers_t *images)
const char *cp;
ulong rd_start, rd_size;
-#ifdef CONFIG_MEMSIZE_IN_BYTES
- sprintf(env_buf, "%lu", (ulong)gd->ram_size);
- debug("## Giving linux memsize in bytes, %lu\n", (ulong)gd->ram_size);
-#else
- sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20));
- debug("## Giving linux memsize in MB, %lu\n",
- (ulong)(gd->ram_size >> 20));
-#endif /* CONFIG_MEMSIZE_IN_BYTES */
+ if (CONFIG_IS_ENABLED(MEMSIZE_IN_BYTES)) {
+ sprintf(env_buf, "%lu", (ulong)gd->ram_size);
+ debug("## Giving linux memsize in bytes, %lu\n",
+ (ulong)gd->ram_size);
+ } else {
+ sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20));
+ debug("## Giving linux memsize in MB, %lu\n",
+ (ulong)(gd->ram_size >> 20));
+ }
rd_start = UNCACHED_SDRAM(images->initrd_start);
rd_size = images->initrd_end - images->initrd_start;
@@ -282,19 +209,87 @@ static void linux_env_legacy(bootm_headers_t *images)
if (cp)
linux_env_set("eth1addr", cp);
- if (mips_boot_malta) {
+ if (CONFIG_IS_ENABLED(MALTA)) {
sprintf(env_buf, "%un8r", gd->baudrate);
linux_env_set("modetty0", env_buf);
}
}
+static int boot_reloc_ramdisk(bootm_headers_t *images)
+{
+ ulong rd_len = images->rd_end - images->rd_start;
+
+ /*
+ * In case of legacy uImage's, relocation of ramdisk is already done
+ * by do_bootm_states() and should not repeated in 'bootm prep'.
+ */
+ if (images->state & BOOTM_STATE_RAMDISK) {
+ debug("## Ramdisk already relocated\n");
+ return 0;
+ }
+
+ return boot_ramdisk_high(&images->lmb, images->rd_start,
+ rd_len, &images->initrd_start, &images->initrd_end);
+}
+
+static int boot_reloc_fdt(bootm_headers_t *images)
+{
+ /*
+ * In case of legacy uImage's, relocation of FDT is already done
+ * by do_bootm_states() and should not repeated in 'bootm prep'.
+ */
+ if (images->state & BOOTM_STATE_FDT) {
+ debug("## FDT already relocated\n");
+ return 0;
+ }
+
+#if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
+ boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
+ return boot_relocate_fdt(&images->lmb, &images->ft_addr,
+ &images->ft_len);
+#else
+ return 0;
+#endif
+}
+
+int arch_fixup_memory_node(void *blob)
+{
+#if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
+ u64 mem_start = 0;
+ u64 mem_size = gd->ram_size;
+
+ return fdt_fixup_memory_banks(blob, &mem_start, &mem_size, 1);
+#else
+ return 0;
+#endif
+}
+
+static int boot_setup_fdt(bootm_headers_t *images)
+{
+ return image_setup_libfdt(images, images->ft_addr, images->ft_len,
+ &images->lmb);
+}
+
static void boot_prep_linux(bootm_headers_t *images)
{
- if (mips_boot_env_legacy && !images->ft_len)
- linux_env_legacy(images);
+ boot_reloc_ramdisk(images);
- if (images->ft_len)
+ if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) {
+ boot_reloc_fdt(images);
boot_setup_fdt(images);
+ } else {
+ if (CONFIG_IS_ENABLED(CONFIG_MIPS_BOOT_ENV_LEGACY))
+ linux_env_legacy(images);
+
+ if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
+ linux_cmdline_legacy(images);
+
+ if (!CONFIG_IS_ENABLED(CONFIG_MIPS_BOOT_ENV_LEGACY))
+ linux_cmdline_append(images);
+
+ linux_cmdline_dump();
+ }
+ }
}
static void boot_jump_linux(bootm_headers_t *images)
@@ -307,13 +302,13 @@ static void boot_jump_linux(bootm_headers_t *images)
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
- if (mips_boot_malta)
+ if (CONFIG_IS_ENABLED(MALTA))
linux_extra = gd->ram_size;
-#ifdef CONFIG_BOOTSTAGE_FDT
+#if CONFIG_IS_ENABLED(BOOTSTAGE_FDT)
bootstage_fdt_add_report();
#endif
-#ifdef CONFIG_BOOTSTAGE_REPORT
+#if CONFIG_IS_ENABLED(BOOTSTAGE_REPORT)
bootstage_report();
#endif
@@ -327,35 +322,28 @@ static void boot_jump_linux(bootm_headers_t *images)
int do_bootm_linux(int flag, int argc, char * const argv[],
bootm_headers_t *images)
{
- int ret;
-
/* No need for those on MIPS */
if (flag & BOOTM_STATE_OS_BD_T)
return -1;
- if (flag & BOOTM_STATE_OS_CMDLINE) {
- boot_cmdline_linux(images);
+ /*
+ * Cmdline init has been moved to 'bootm prep' because it has to be
+ * done after relocation of ramdisk to always pass correct values
+ * for rd_start and rd_size to Linux kernel.
+ */
+ if (flag & BOOTM_STATE_OS_CMDLINE)
return 0;
- }
if (flag & BOOTM_STATE_OS_PREP) {
boot_prep_linux(images);
return 0;
}
- if (flag & BOOTM_STATE_OS_GO) {
+ if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
boot_jump_linux(images);
return 0;
}
- ret = boot_setup_linux(images);
- if (ret)
- return ret;
-
- boot_cmdline_linux(images);
- boot_prep_linux(images);
- boot_jump_linux(images);
-
/* does not return */
return 1;
}
diff --git a/arch/nds32/include/asm/bitops.h b/arch/nds32/include/asm/bitops.h
index f1aa9a356b..7ee37c37bc 100644
--- a/arch/nds32/include/asm/bitops.h
+++ b/arch/nds32/include/asm/bitops.h
@@ -21,6 +21,10 @@
#ifdef __KERNEL__
#include <asm/system.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
#define smp_mb__before_clear_bit() do { } while (0)
#define smp_mb__after_clear_bit() do { } while (0)
diff --git a/arch/nios2/include/asm/bitops.h b/arch/nios2/include/asm/bitops.h
index 3e17964f25..ee46f3722c 100644
--- a/arch/nios2/include/asm/bitops.h
+++ b/arch/nios2/include/asm/bitops.h
@@ -13,4 +13,9 @@
#include <asm/bitops/non-atomic.h>
#include <asm/bitops/ffs.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#endif /* __ASM_NIOS2_BITOPS_H */
diff --git a/arch/openrisc/include/asm/bitops.h b/arch/openrisc/include/asm/bitops.h
index 6d0b57c014..28c4658672 100644
--- a/arch/openrisc/include/asm/bitops.h
+++ b/arch/openrisc/include/asm/bitops.h
@@ -12,6 +12,10 @@
#define PLATFORM_FFS
#include <asm/bitops/ffs.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#define hweight32(x) generic_hweight32(x)
#define hweight16(x) generic_hweight16(x)
#define hweight8(x) generic_hweight8(x)
diff --git a/arch/powerpc/cpu/mpc83xx/law.c b/arch/powerpc/cpu/mpc83xx/law.c
index 66c88b697e..262ae7f711 100644
--- a/arch/powerpc/cpu/mpc83xx/law.c
+++ b/arch/powerpc/cpu/mpc83xx/law.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <asm/fsl_law.h>
#include <asm/mmu.h>
+#include <linux/log2.h>
int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id)
{
@@ -20,7 +21,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id)
if (start == 0)
start_align = 1ull << (LAW_SIZE_2G + 1);
else
- start_align = 1ull << (ffs64(start) - 1);
+ start_align = 1ull << (__ffs64(start) - 1);
law_sz = min(start_align, sz);
law_sz_enc = __ilog2_u64(law_sz) - 1;
@@ -40,7 +41,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id)
if (sz) {
start += law_sz;
- start_align = 1ull << (ffs64(start) - 1);
+ start_align = 1ull << (__ffs64(start) - 1);
law_sz = min(start_align, sz);
law_sz_enc = __ilog2_u64(law_sz) - 1;
ecm = &immap->sysconf.ddrlaw[1];
diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c
index 8e0508f362..cf31eb2ef3 100644
--- a/arch/powerpc/cpu/mpc85xx/tlb.c
+++ b/arch/powerpc/cpu/mpc85xx/tlb.c
@@ -14,6 +14,8 @@
#include <addr_map.h>
#endif
+#include <linux/log2.h>
+
DECLARE_GLOBAL_DATA_PTR;
void invalidate_tlb(u8 tlb)
diff --git a/arch/powerpc/cpu/mpc8xxx/law.c b/arch/powerpc/cpu/mpc8xxx/law.c
index 33d53a8cfe..24baad442e 100644
--- a/arch/powerpc/cpu/mpc8xxx/law.c
+++ b/arch/powerpc/cpu/mpc8xxx/law.c
@@ -11,6 +11,7 @@
#include <linux/compiler.h>
#include <asm/fsl_law.h>
#include <asm/io.h>
+#include <linux/log2.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -187,7 +188,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id)
if (start == 0)
start_align = 1ull << (LAW_SIZE_32G + 1);
else
- start_align = 1ull << (ffs64(start) - 1);
+ start_align = 1ull << (__ffs64(start) - 1);
law_sz = min(start_align, sz);
law_sz_enc = __ilog2_u64(law_sz) - 1;
@@ -202,7 +203,7 @@ int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id)
if (sz) {
start += law_sz;
- start_align = 1ull << (ffs64(start) - 1);
+ start_align = 1ull << (__ffs64(start) - 1);
law_sz = min(start_align, sz);
law_sz_enc = __ilog2_u64(law_sz) - 1;
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index a6bcf3c3fe..14217ef751 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -6,6 +6,7 @@
#define _PPC_BITOPS_H
#include <asm/byteorder.h>
+#include <asm-generic/bitops/__ffs.h>
extern void set_bit(int nr, volatile void *addr);
extern void clear_bit(int nr, volatile void *addr);
@@ -209,16 +210,6 @@ static inline int fls64(__u64 x)
#error BITS_PER_LONG not 32 or 64
#endif
-static inline int __ilog2_u64(u64 n)
-{
- return fls64(n) - 1;
-}
-
-static inline int ffs64(u64 x)
-{
- return __ilog2_u64(x & -x) + 1ull;
-}
-
#ifdef __KERNEL__
/*
diff --git a/arch/powerpc/include/asm/fsl_law.h b/arch/powerpc/include/asm/fsl_law.h
index 3b504875e0..8e1d22adef 100644
--- a/arch/powerpc/include/asm/fsl_law.h
+++ b/arch/powerpc/include/asm/fsl_law.h
@@ -10,6 +10,7 @@
#define _FSL_LAW_H_
#include <asm/io.h>
+#include <linux/log2.h>
#define LAW_EN 0x80000000
diff --git a/arch/powerpc/include/asm/fsl_srio.h b/arch/powerpc/include/asm/fsl_srio.h
index e5aab2a71f..ec25e16829 100644
--- a/arch/powerpc/include/asm/fsl_srio.h
+++ b/arch/powerpc/include/asm/fsl_srio.h
@@ -7,6 +7,8 @@
#ifndef _FSL_SRIO_H_
#define _FSL_SRIO_H_
+#include <linux/log2.h>
+
enum atmu_size {
ATMU_SIZE_4K = 0xb,
ATMU_SIZE_8K,
diff --git a/arch/sandbox/include/asm/bitops.h b/arch/sandbox/include/asm/bitops.h
index f1a7aeee93..f27d5e98c5 100644
--- a/arch/sandbox/include/asm/bitops.h
+++ b/arch/sandbox/include/asm/bitops.h
@@ -21,6 +21,10 @@
#include <linux/compiler.h>
#include <asm/system.h>
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
#ifdef __KERNEL__
diff --git a/arch/sh/include/asm/bitops.h b/arch/sh/include/asm/bitops.h
index c57d628478..8cb8385d76 100644
--- a/arch/sh/include/asm/bitops.h
+++ b/arch/sh/include/asm/bitops.h
@@ -1,6 +1,11 @@
#ifndef __ASM_SH_BITOPS_H
#define __ASM_SH_BITOPS_H
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#ifdef __KERNEL__
#include <asm/irqflags.h>
/* For __swab32 */
diff --git a/arch/sparc/include/asm/bitops.h b/arch/sparc/include/asm/bitops.h
index fa39fa3fc6..c66f730c88 100644
--- a/arch/sparc/include/asm/bitops.h
+++ b/arch/sparc/include/asm/bitops.h
@@ -9,4 +9,9 @@
#ifndef _SPARC_BITOPS_H
#define _SPARC_BITOPS_H
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+#include <asm-generic/bitops/__ffs.h>
+
#endif /* _SPARC_BITOPS_H */
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 5a7e4cba2b..f97dc66439 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -14,6 +14,10 @@
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
*/
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+
#ifdef CONFIG_SMP
#define LOCK_PREFIX "lock ; "
#else
@@ -332,6 +336,20 @@ static __inline__ unsigned long ffz(unsigned long word)
#ifdef __KERNEL__
/**
+ * __ffs - find first set bit in word
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static inline unsigned long __ffs(unsigned long word)
+{
+ __asm__("rep; bsf %1,%0"
+ : "=r" (word)
+ : "rm" (word));
+ return word;
+}
+
+/**
* ffs - find first bit set
* @x: the word to search
*
@@ -346,7 +364,8 @@ static __inline__ int ffs(int x)
__asm__("bsfl %1,%0\n\t"
"jnz 1f\n\t"
"movl $-1,%0\n"
- "1:" : "=r" (r) : "g" (x));
+ "1:" : "=r" (r) : "rm" (x));
+
return r+1;
}
#define PLATFORM_FFS
OpenPOWER on IntegriCloud