2 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd.
6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
10 #include <asm/byteorder.h>
11 #include <linux/errno.h>
12 #include <linux/slab.h>
13 #include <linux/init.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/compatmac.h>
18 static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
19 static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
20 static void maprom_nop (struct mtd_info *);
21 static struct mtd_info *map_rom_probe(struct map_info *map);
23 static struct mtd_chip_driver maprom_chipdrv = {
24 .probe = map_rom_probe,
29 static struct mtd_info *map_rom_probe(struct map_info *map)
33 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
37 map->fldrv = &maprom_chipdrv;
39 mtd->name = map->name;
41 mtd->size = map->size;
42 mtd->read = maprom_read;
43 mtd->write = maprom_write;
44 mtd->sync = maprom_nop;
45 mtd->flags = MTD_CAP_ROM;
46 mtd->erasesize = map->size;
49 __module_get(THIS_MODULE);
54 static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
56 struct map_info *map = mtd->priv;
58 map_copy_from(map, buf, from, len);
63 static void maprom_nop(struct mtd_info *mtd)
65 /* Nothing to see here */
68 static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
70 printk(KERN_NOTICE "maprom_write called\n");
74 static int __init map_rom_init(void)
76 register_mtd_chip_driver(&maprom_chipdrv);
80 static void __exit map_rom_exit(void)
82 unregister_mtd_chip_driver(&maprom_chipdrv);
85 module_init(map_rom_init);
86 module_exit(map_rom_exit);
88 MODULE_LICENSE("GPL");
89 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
90 MODULE_DESCRIPTION("MTD chip driver for ROM chips");