aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/map_rom.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/mtd/chips/map_rom.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/mtd/chips/map_rom.c')
-rw-r--r--drivers/mtd/chips/map_rom.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
new file mode 100644
index 000000000000..624c12c232c8
--- /dev/null
+++ b/drivers/mtd/chips/map_rom.c
@@ -0,0 +1,94 @@
1/*
2 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd.
4 * $Id: map_rom.c,v 1.23 2005/01/05 18:05:12 dwmw2 Exp $
5 */
6
7#include <linux/module.h>
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <asm/io.h>
11#include <asm/byteorder.h>
12#include <linux/errno.h>
13#include <linux/slab.h>
14#include <linux/init.h>
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/map.h>
17#include <linux/mtd/compatmac.h>
18
19static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
20static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
21static void maprom_nop (struct mtd_info *);
22static struct mtd_info *map_rom_probe(struct map_info *map);
23
24static struct mtd_chip_driver maprom_chipdrv = {
25 .probe = map_rom_probe,
26 .name = "map_rom",
27 .module = THIS_MODULE
28};
29
30static struct mtd_info *map_rom_probe(struct map_info *map)
31{
32 struct mtd_info *mtd;
33
34 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
35 if (!mtd)
36 return NULL;
37
38 memset(mtd, 0, sizeof(*mtd));
39
40 map->fldrv = &maprom_chipdrv;
41 mtd->priv = map;
42 mtd->name = map->name;
43 mtd->type = MTD_ROM;
44 mtd->size = map->size;
45 mtd->read = maprom_read;
46 mtd->write = maprom_write;
47 mtd->sync = maprom_nop;
48 mtd->flags = MTD_CAP_ROM;
49 mtd->erasesize = 131072;
50 while(mtd->size & (mtd->erasesize - 1))
51 mtd->erasesize >>= 1;
52
53 __module_get(THIS_MODULE);
54 return mtd;
55}
56
57
58static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
59{
60 struct map_info *map = mtd->priv;
61
62 map_copy_from(map, buf, from, len);
63 *retlen = len;
64 return 0;
65}
66
67static void maprom_nop(struct mtd_info *mtd)
68{
69 /* Nothing to see here */
70}
71
72static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
73{
74 printk(KERN_NOTICE "maprom_write called\n");
75 return -EIO;
76}
77
78static int __init map_rom_init(void)
79{
80 register_mtd_chip_driver(&maprom_chipdrv);
81 return 0;
82}
83
84static void __exit map_rom_exit(void)
85{
86 unregister_mtd_chip_driver(&maprom_chipdrv);
87}
88
89module_init(map_rom_init);
90module_exit(map_rom_exit);
91
92MODULE_LICENSE("GPL");
93MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
94MODULE_DESCRIPTION("MTD chip driver for ROM chips");