fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / cris / arch-v10 / drivers / axisflashmap.c
index 3277019..ffade19 100644 (file)
  * partition split defined below.
  *
  * $Log: axisflashmap.c,v $
+ * Revision 1.11  2004/11/15 10:27:14  starvik
+ * Corrected typo (Thanks to Milton Miller <miltonm@bga.com>).
+ *
+ * Revision 1.10  2004/08/16 12:37:22  starvik
+ * Merge of Linux 2.6.8
+ *
  * Revision 1.8  2004/05/14 07:58:03  starvik
  * Merge of changes from 2.4
  *
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/config.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <linux/mtd/concat.h>
 #include <linux/mtd/map.h>
 #define FLASH_CACHED_ADDR    KSEG_F
 #endif
 
+#if CONFIG_ETRAX_FLASH_BUSWIDTH==1
+#define flash_data __u8
+#elif CONFIG_ETRAX_FLASH_BUSWIDTH==2
+#define flash_data __u16
+#elif CONFIG_ETRAX_FLASH_BUSWIDTH==4
+#define flash_data __u32
+#endif
+
 /* From head.S */
 extern unsigned long romfs_start, romfs_length, romfs_in_flash;
 
@@ -161,19 +175,11 @@ struct mtd_info* axisflash_mtd = NULL;
 
 /* Map driver functions. */
 
-static __u8 flash_read8(struct map_info *map, unsigned long ofs)
-{
-       return *(__u8 *)(map->map_priv_1 + ofs);
-}
-
-static __u16 flash_read16(struct map_info *map, unsigned long ofs)
-{
-       return *(__u16 *)(map->map_priv_1 + ofs);
-}
-
-static __u32 flash_read32(struct map_info *map, unsigned long ofs)
+static map_word flash_read(struct map_info *map, unsigned long ofs)
 {
-       return *(volatile unsigned int *)(map->map_priv_1 + ofs);
+       map_word tmp;
+       tmp.x[0] = *(flash_data *)(map->map_priv_1 + ofs);
+       return tmp;
 }
 
 static void flash_copy_from(struct map_info *map, void *to,
@@ -182,19 +188,9 @@ static void flash_copy_from(struct map_info *map, void *to,
        memcpy(to, (void *)(map->map_priv_1 + from), len);
 }
 
-static void flash_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
-       *(__u8 *)(map->map_priv_1 + adr) = d;
-}
-
-static void flash_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
-       *(__u16 *)(map->map_priv_1 + adr) = d;
-}
-
-static void flash_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void flash_write(struct map_info *map, map_word d, unsigned long adr)
 {
-       *(__u32 *)(map->map_priv_1 + adr) = d;
+       *(flash_data *)(map->map_priv_1 + adr) = (flash_data)d.x[0];
 }
 
 /*
@@ -215,14 +211,10 @@ static void flash_write32(struct map_info *map, __u32 d, unsigned long adr)
 static struct map_info map_cse0 = {
        .name = "cse0",
        .size = MEM_CSE0_SIZE,
-       .buswidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
-       .read8 = flash_read8,
-       .read16 = flash_read16,
-       .read32 = flash_read32,
+       .bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
+       .read = flash_read,
        .copy_from = flash_copy_from,
-       .write8 = flash_write8,
-       .write16 = flash_write16,
-       .write32 = flash_write32,
+       .write = flash_write,
        .map_priv_1 = FLASH_UNCACHED_ADDR
 };
 
@@ -235,14 +227,10 @@ static struct map_info map_cse0 = {
 static struct map_info map_cse1 = {
        .name = "cse1",
        .size = MEM_CSE1_SIZE,
-       .buswidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
-       .read8 = flash_read8,
-       .read16 = flash_read16,
-       .read32 = flash_read32,
+       .bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
+       .read = flash_read,
        .copy_from = flash_copy_from,
-       .write8 = flash_write8,
-       .write16 = flash_write16,
-       .write32 = flash_write32,
+       .write = flash_write,
        .map_priv_1 = FLASH_UNCACHED_ADDR + MEM_CSE0_SIZE
 };
 
@@ -528,7 +516,7 @@ static int __init init_axis_flash(void)
 #else
                struct mtd_info *mtd_ram;
 
-               mtd_ram = (struct mtd_info *)kmalloc(sizeof(struct mtd_info),
+               mtd_ram = kmalloc(sizeof(struct mtd_info),
                                                     GFP_KERNEL);
                if (!mtd_ram) {
                        panic("axisflashmap couldn't allocate memory for "