summaryrefslogtreecommitdiff
path: root/include/asm-m68k/bitops.h
diff options
context:
space:
mode:
authorTsiChungLiew <Tsi-Chung.Liew@freescale.com>2007-08-05 04:31:18 -0500
committerStefan Roese <sr@denx.de>2007-08-08 09:47:43 +0200
commit1a33ce65a4c51a69190dd8c408f9e1c62a66e94f (patch)
treebffec58b0314514d15a151b50e279ec8277a9042 /include/asm-m68k/bitops.h
parenteaf9e447beb3e498818ef8ad0b8c1597cd506149 (diff)
downloadu-boot-imx-1a33ce65a4c51a69190dd8c408f9e1c62a66e94f.zip
u-boot-imx-1a33ce65a4c51a69190dd8c408f9e1c62a66e94f.tar.gz
u-boot-imx-1a33ce65a4c51a69190dd8c408f9e1c62a66e94f.tar.bz2
Added NAND support
Signed-off-by: TsiChungLiew <Tsi-Chung.Liew@freescale.com>
Diffstat (limited to 'include/asm-m68k/bitops.h')
-rw-r--r--include/asm-m68k/bitops.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 3283714..0f9e8ab 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -15,4 +15,43 @@ extern int test_and_set_bit(int nr, volatile void *addr);
extern int test_and_clear_bit(int nr, volatile void *addr);
extern int test_and_change_bit(int nr, volatile void *addr);
+#ifdef __KERNEL__
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+#define __ffs(x) (ffs(x) - 1)
+
+#endif /* __KERNEL__ */
+
#endif /* _M68K_BITOPS_H */