OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [mtd/] [chips/] [map_absent.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Common code to handle absent "placeholder" devices
3
 * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
4
 * $Id: map_absent.c,v 1.1.1.1 2004-04-15 01:52:07 phoenix 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
 
27
#include <linux/mtd/map.h>
28
 
29
 
30
static int map_absent_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
31
static int map_absent_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
32
static int map_absent_erase (struct mtd_info *, struct erase_info *);
33
static void map_absent_sync (struct mtd_info *);
34
static struct mtd_info *map_absent_probe(struct map_info *map);
35
static void map_absent_destroy (struct mtd_info *);
36
 
37
 
38
static struct mtd_chip_driver map_absent_chipdrv = {
39
        probe:          map_absent_probe,
40
        destroy:        map_absent_destroy,
41
        name:           "map_absent",
42
        module:         THIS_MODULE
43
};
44
 
45
static struct mtd_info *map_absent_probe(struct map_info *map)
46
{
47
        struct mtd_info *mtd;
48
 
49
        mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
50
        if (!mtd) {
51
                return NULL;
52
        }
53
 
54
        memset(mtd, 0, sizeof(*mtd));
55
 
56
        map->fldrv      = &map_absent_chipdrv;
57
        mtd->priv       = map;
58
        mtd->name       = map->name;
59
        mtd->type       = MTD_ABSENT;
60
        mtd->size       = map->size;
61
        mtd->erase      = map_absent_erase;
62
        mtd->read       = map_absent_read;
63
        mtd->write      = map_absent_write;
64
        mtd->sync       = map_absent_sync;
65
        mtd->flags      = 0;
66
        mtd->erasesize = PAGE_SIZE;
67
 
68
        MOD_INC_USE_COUNT;
69
        return mtd;
70
}
71
 
72
 
73
static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
74
{
75
        *retlen = 0;
76
        return -ENODEV;
77
}
78
 
79
static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
80
{
81
        *retlen = 0;
82
        return -ENODEV;
83
}
84
 
85
static int map_absent_erase(struct mtd_info *mtd, struct erase_info *instr)
86
{
87
        return -ENODEV;
88
}
89
 
90
static void map_absent_sync(struct mtd_info *mtd)
91
{
92
        /* nop */
93
}
94
 
95
static void map_absent_destroy(struct mtd_info *mtd)
96
{
97
        /* nop */
98
}
99
 
100
int __init map_absent_init(void)
101
{
102
        register_mtd_chip_driver(&map_absent_chipdrv);
103
        return 0;
104
}
105
 
106
static void __exit map_absent_exit(void)
107
{
108
        unregister_mtd_chip_driver(&map_absent_chipdrv);
109
}
110
 
111
module_init(map_absent_init);
112
module_exit(map_absent_exit);
113
 
114
MODULE_LICENSE("GPL");
115
MODULE_AUTHOR("Resilience Corporation - Eric Brower <ebrower@resilience.com>");
116
MODULE_DESCRIPTION("Placeholder MTD chip driver for 'absent' chips");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.