Merge with 2.4.0-test3-pre4.
[linux-2.6/linux-mips.git] / drivers / mtd / map_rom.c
blobd353938e9457abb9b03812dd524e7295ad872ac5
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.2 2000/07/03 10:01:38 dwmw2 Exp $
5 */
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/malloc.h>
15 #include <linux/mtd/map.h>
18 static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
19 static void maprom_nop (struct mtd_info *);
21 struct mtd_info *map_rom_probe(struct map_info *);
22 EXPORT_SYMBOL(map_rom_probe);
24 struct mtd_info *map_rom_probe(struct map_info *map)
26 struct mtd_info *mtd;
28 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
29 if (!mtd)
30 return NULL;
32 memset(mtd, 0, sizeof(*mtd));
34 map->fldrv_destroy = maprom_nop;
35 mtd->priv = map;
36 mtd->name = map->name;
37 mtd->type = MTD_ROM;
38 mtd->size = map->size;
39 mtd->read = maprom_read;
40 mtd->sync = maprom_nop;
41 mtd->flags = MTD_CAP_ROM;
43 MOD_INC_USE_COUNT;
44 return mtd;
48 static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
50 struct map_info *map = (struct map_info *)mtd->priv;
52 map->copy_from(map, buf, from, len);
53 *retlen = len;
54 return 0;
57 static void maprom_nop(struct mtd_info *mtd)
59 /* Nothing to see here */