aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/map_absent.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_absent.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_absent.c')
-rw-r--r--drivers/mtd/chips/map_absent.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
new file mode 100644
index 000000000000..c6c83833cc32
--- /dev/null
+++ b/drivers/mtd/chips/map_absent.c
@@ -0,0 +1,117 @@
1/*
2 * Common code to handle absent "placeholder" devices
3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
4 * $Id: map_absent.c,v 1.5 2004/11/16 18:29:00 dwmw2 Exp $
5 *
6 * This map driver is used to allocate "placeholder" MTD
7 * devices on systems that have socketed/removable media.
8 * Use of this driver as a fallback preserves the expected
9 * registration of MTD device nodes regardless of probe outcome.
10 * A usage example is as follows:
11 *
12 * my_dev[i] = do_map_probe("cfi", &my_map[i]);
13 * if(NULL == my_dev[i]) {
14 * my_dev[i] = do_map_probe("map_absent", &my_map[i]);
15 * }
16 *
17 * Any device 'probed' with this driver will return -ENODEV
18 * upon open.
19 */
20
21#include <linux/module.h>
22#include <linux/types.h>
23#include <linux/kernel.h>
24#include <linux/errno.h>
25#include <linux/slab.h>
26#include <linux/init.h>
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/map.h>
29#include <linux/mtd/compatmac.h>
30
31static int map_absent_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
32static int map_absent_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
33static int map_absent_erase (struct mtd_info *, struct erase_info *);
34static void map_absent_sync (struct mtd_info *);
35static struct mtd_info *map_absent_probe(struct map_info *map);
36static void map_absent_destroy (struct mtd_info *);
37
38
39static struct mtd_chip_driver map_absent_chipdrv = {
40 .probe = map_absent_probe,
41 .destroy = map_absent_destroy,
42 .name = "map_absent",
43 .module = THIS_MODULE
44};
45
46static struct mtd_info *map_absent_probe(struct map_info *map)
47{
48 struct mtd_info *mtd;
49
50 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
51 if (!mtd) {
52 return NULL;
53 }
54
55 memset(mtd, 0, sizeof(*mtd));
56
57 map->fldrv = &map_absent_chipdrv;
58 mtd->priv = map;
59 mtd->name = map->name;
60 mtd->type = MTD_ABSENT;
61 mtd->size = map->size;
62 mtd->erase = map_absent_erase;
63 mtd->read = map_absent_read;
64 mtd->write = map_absent_write;
65 mtd->sync = map_absent_sync;
66 mtd->flags = 0;
67 mtd->erasesize = PAGE_SIZE;
68
69 __module_get(THIS_MODULE);
70 return mtd;
71}
72
73
74static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
75{
76 *retlen = 0;
77 return -ENODEV;
78}
79
80static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
81{
82 *retlen = 0;
83 return -ENODEV;
84}
85
86static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr)
87{
88 return -ENODEV;
89}
90
91static void map_absent_sync(struct mtd_info *mtd)
92{
93 /* nop */
94}
95
96static void map_absent_destroy(struct mtd_info *mtd)
97{
98 /* nop */
99}
100
101static int __init map_absent_init(void)
102{
103 register_mtd_chip_driver(&map_absent_chipdrv);
104 return 0;
105}
106
107static void __exit map_absent_exit(void)
108{
109 unregister_mtd_chip_driver(&map_absent_chipdrv);
110}
111
112module_init(map_absent_init);
113module_exit(map_absent_exit);
114
115MODULE_LICENSE("GPL");
116MODULE_AUTHOR("Resilience Corporation - Eric Brower <ebrower@resilience.com>");
117MODULE_DESCRIPTION("Placeholder MTD chip driver for 'absent' chips");