mtd/include/linux/mtd map.h,1.40,1.41
David Woodhouse
dwmw2 at infradead.org
Tue Jul 13 18:32:37 EDT 2004
Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv30490/include/linux/mtd
Modified Files:
map.h
Log Message:
inlines to check for supported bank width
Index: map.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/map.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- map.h 10 Jul 2004 21:14:18 -0000 1.40
+++ map.h 13 Jul 2004 22:32:34 -0000 1.41
@@ -11,10 +11,13 @@
#include <asm/unaligned.h>
#include <asm/system.h>
#include <asm/io.h>
+#include <asm/bug.h>
#ifdef CONFIG_MTD_MAP_BANK_WIDTH_1
#define map_bankwidth(map) 1
#define map_bankwidth_is_1(map) (map_bankwidth(map) == 1)
+#define map_bankwidth_is_large(map) (0)
+#define map_words(map) (1)
#define MAX_MAP_BANKWIDTH 1
#else
#define map_bankwidth_is_1(map) (0)
@@ -26,6 +29,8 @@
# define map_bankwidth(map) ((map)->bankwidth)
# else
# define map_bankwidth(map) 2
+# define map_bankwidth_is_large(map) (0)
+# define map_words(map) (1)
# endif
#define map_bankwidth_is_2(map) (map_bankwidth(map) == 2)
#undef MAX_MAP_BANKWIDTH
@@ -40,6 +45,8 @@
# define map_bankwidth(map) ((map)->bankwidth)
# else
# define map_bankwidth(map) 4
+# define map_bankwidth_is_large(map) (0)
+# define map_words(map) (1)
# endif
#define map_bankwidth_is_4(map) (map_bankwidth(map) == 4)
#undef MAX_MAP_BANKWIDTH
@@ -52,8 +59,16 @@
# ifdef map_bankwidth
# undef map_bankwidth
# define map_bankwidth(map) ((map)->bankwidth)
+# if BITS_PER_LONG < 64
+# undef map_bankwidth_is_large
+# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
+# undef map_words
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
+# endif
# else
# define map_bankwidth(map) 8
+# define map_bankwidth_is_large(map) (BITS_PER_LONG < 64)
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
# endif
#define map_bankwidth_is_8(map) (map_bankwidth(map) == 8)
#undef MAX_MAP_BANKWIDTH
@@ -66,8 +81,14 @@
# ifdef map_bankwidth
# undef map_bankwidth
# define map_bankwidth(map) ((map)->bankwidth)
+# undef map_bankwidth_is_large
+# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
+# undef map_words
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
# else
# define map_bankwidth(map) 16
+# define map_bankwidth_is_large(map) (1)
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
# endif
#define map_bankwidth_is_16(map) (map_bankwidth(map) == 16)
#undef MAX_MAP_BANKWIDTH
@@ -80,8 +101,14 @@
# ifdef map_bankwidth
# undef map_bankwidth
# define map_bankwidth(map) ((map)->bankwidth)
+# undef map_bankwidth_is_large
+# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
+# undef map_words
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
# else
# define map_bankwidth(map) 32
+# define map_bankwidth_is_large(map) (1)
+# define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
# endif
#define map_bankwidth_is_32(map) (map_bankwidth(map) == 32)
#undef MAX_MAP_BANKWIDTH
@@ -94,13 +121,33 @@
#error "No bus width supported. What's the point?"
#endif
-#if MAX_MAP_BANKWIDTH > (BITS_PER_LONG / 8)
-#define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
-#define map_words(map) (map_bankwidth(map) / sizeof(unsigned long))
-#else
-#define map_bankwidth_is_large(map) (0)
-#define map_words(map) (1)
+static inline int map_bankwidth_supported(int w)
+{
+ switch (w) {
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_1
+ case 1:
+#endif
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_2
+ case 2:
+#endif
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_4
+ case 4:
+#endif
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_8
+ case 8:
+#endif
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_16
+ case 16:
#endif
+#ifdef CONFIG_MTD_MAP_BANK_WIDTH_32
+ case 32:
+#endif
+ return 1;
+
+ default:
+ return 0;
+ }
+}
#define MAX_MAP_LONGS ( ((MAX_MAP_BANKWIDTH*8) + BITS_PER_LONG - 1) / BITS_PER_LONG )
@@ -351,7 +398,7 @@
#define map_copy_to(map, to, from, len) inline_map_copy_to(map, to, from, len)
-#define simple_map_init(map) do { } while (0)
+#define simple_map_init(map) BUG_ON(!map_bankwidth_supported(map->bankwidth))
#define map_is_linear(map) (1)
#endif /* !CONFIG_MTD_COMPLEX_MAPPINGS */
More information about the linux-mtd-cvs
mailing list