semaphore: __down_common: use signal_pending_state()
[linux-2.6/mini2440.git] / drivers / mtd / chips / map_rom.c
blob821d0ed6bae3970453a38d2e40bb0bb802930b1d
1 /*
2 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd.
4 */
6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <asm/io.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,
25 .name = "map_rom",
26 .module = THIS_MODULE
29 static struct mtd_info *map_rom_probe(struct map_info *map)
31 struct mtd_info *mtd;
33 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
34 if (!mtd)
35 return NULL;
37 map->fldrv = &maprom_chipdrv;
38 mtd->priv = map;
39 mtd->name = map->name;
40 mtd->type = MTD_ROM;
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;
47 mtd->writesize = 1;
49 __module_get(THIS_MODULE);
50 return mtd;
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);
59 *retlen = len;
60 return 0;
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");
71 return -EIO;
74 static int __init map_rom_init(void)
76 register_mtd_chip_driver(&maprom_chipdrv);
77 return 0;
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");