summaryrefslogtreecommitdiffstats
path: root/linux-2.4.x/drivers/mtd/chips/map_ram.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-2.4.x/drivers/mtd/chips/map_ram.c')
-rw-r--r--linux-2.4.x/drivers/mtd/chips/map_ram.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/linux-2.4.x/drivers/mtd/chips/map_ram.c b/linux-2.4.x/drivers/mtd/chips/map_ram.c
index 287a255..bd2e876 100644
--- a/linux-2.4.x/drivers/mtd/chips/map_ram.c
+++ b/linux-2.4.x/drivers/mtd/chips/map_ram.c
@@ -1,7 +1,7 @@
/*
* Common code to handle map devices which are simple RAM
* (C) 2000 Red Hat. GPL'd.
- * $Id: map_ram.c,v 1.14 2001/10/02 15:05:12 dwmw2 Exp $
+ * $Id: map_ram.c,v 1.22 2005/01/05 18:05:12 dwmw2 Exp $
*/
#include <linux/module.h>
@@ -11,8 +11,10 @@
#include <asm/byteorder.h>
#include <linux/errno.h>
#include <linux/slab.h>
-
+#include <linux/init.h>
+#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
+#include <linux/mtd/compatmac.h>
static int mapram_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
@@ -23,9 +25,9 @@ static struct mtd_info *map_ram_probe(struct map_info *map);
static struct mtd_chip_driver mapram_chipdrv = {
- probe: map_ram_probe,
- name: "map_ram",
- module: THIS_MODULE
+ .probe = map_ram_probe,
+ .name = "map_ram",
+ .module = THIS_MODULE
};
static struct mtd_info *map_ram_probe(struct map_info *map)
@@ -34,21 +36,21 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
/* Check the first byte is RAM */
#if 0
- map->write8(map, 0x55, 0);
- if (map->read8(map, 0) != 0x55)
+ map_write8(map, 0x55, 0);
+ if (map_read8(map, 0) != 0x55)
return NULL;
- map->write8(map, 0xAA, 0);
- if (map->read8(map, 0) != 0xAA)
+ map_write8(map, 0xAA, 0);
+ if (map_read8(map, 0) != 0xAA)
return NULL;
/* Check the last byte is RAM */
- map->write8(map, 0x55, map->size-1);
- if (map->read8(map, map->size-1) != 0x55)
+ map_write8(map, 0x55, map->size-1);
+ if (map_read8(map, map->size-1) != 0x55)
return NULL;
- map->write8(map, 0xAA, map->size-1);
- if (map->read8(map, map->size-1) != 0xAA)
+ map_write8(map, 0xAA, map->size-1);
+ if (map_read8(map, map->size-1) != 0xAA)
return NULL;
#endif
/* OK. It seems to be RAM. */
@@ -74,25 +76,25 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
while(mtd->size & (mtd->erasesize - 1))
mtd->erasesize >>= 1;
- MOD_INC_USE_COUNT;
+ __module_get(THIS_MODULE);
return mtd;
}
static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
{
- struct map_info *map = (struct map_info *)mtd->priv;
+ struct map_info *map = mtd->priv;
- map->copy_from(map, buf, from, len);
+ map_copy_from(map, buf, from, len);
*retlen = len;
return 0;
}
static int mapram_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
{
- struct map_info *map = (struct map_info *)mtd->priv;
+ struct map_info *map = mtd->priv;
- map->copy_to(map, to, buf, len);
+ map_copy_to(map, to, buf, len);
*retlen = len;
return 0;
}
@@ -101,14 +103,18 @@ static int mapram_erase (struct mtd_info *mtd, struct erase_info *instr)
{
/* Yeah, it's inefficient. Who cares? It's faster than a _real_
flash erase. */
- struct map_info *map = (struct map_info *)mtd->priv;
+ struct map_info *map = mtd->priv;
+ map_word allff;
unsigned long i;
- for (i=0; i<instr->len; i++)
- map->write8(map, 0xFF, instr->addr + i);
+ allff = map_word_ff(map);
+
+ for (i=0; i<instr->len; i += map_bankwidth(map))
+ map_write(map, allff, instr->addr + i);
+
+ instr->state = MTD_ERASE_DONE;
- if (instr->callback)
- instr->callback(instr);
+ mtd_erase_callback(instr);
return 0;
}
@@ -118,7 +124,7 @@ static void mapram_nop(struct mtd_info *mtd)
/* Nothing to see here */
}
-int __init map_ram_init(void)
+static int __init map_ram_init(void)
{
register_mtd_chip_driver(&mapram_chipdrv);
return 0;