fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / mtd / chips / map_rom.c
index 8ccf917..cb27f85 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Common code to handle map devices which are simple ROM
  * (C) 2000 Red Hat. GPL'd.
- * $Id: map_rom.c,v 1.20 2003/05/28 12:51:49 dwmw2 Exp $
+ * $Id: map_rom.c,v 1.23 2005/01/05 18:05:12 dwmw2 Exp $
  */
 
 #include <linux/module.h>
@@ -19,7 +19,7 @@
 static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
 static void maprom_nop (struct mtd_info *);
-struct mtd_info *map_rom_probe(struct map_info *map);
+static struct mtd_info *map_rom_probe(struct map_info *map);
 
 static struct mtd_chip_driver maprom_chipdrv = {
        .probe  = map_rom_probe,
@@ -27,16 +27,14 @@ static struct mtd_chip_driver maprom_chipdrv = {
        .module = THIS_MODULE
 };
 
-struct mtd_info *map_rom_probe(struct map_info *map)
+static struct mtd_info *map_rom_probe(struct map_info *map)
 {
        struct mtd_info *mtd;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd)
                return NULL;
 
-       memset(mtd, 0, sizeof(*mtd));
-
        map->fldrv = &maprom_chipdrv;
        mtd->priv = map;
        mtd->name = map->name;
@@ -46,9 +44,8 @@ struct mtd_info *map_rom_probe(struct map_info *map)
        mtd->write = maprom_write;
        mtd->sync = maprom_nop;
        mtd->flags = MTD_CAP_ROM;
-       mtd->erasesize = 131072;
-       while(mtd->size & (mtd->erasesize - 1))
-               mtd->erasesize >>= 1;
+       mtd->erasesize = map->size;
+       mtd->writesize = 1;
 
        __module_get(THIS_MODULE);
        return mtd;
@@ -57,7 +54,7 @@ struct mtd_info *map_rom_probe(struct map_info *map)
 
 static int maprom_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);
        *retlen = len;
@@ -75,7 +72,7 @@ static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
        return -EIO;
 }
 
-int __init map_rom_init(void)
+static int __init map_rom_init(void)
 {
        register_mtd_chip_driver(&maprom_chipdrv);
        return 0;