diff options
author | David Howells <dhowells@redhat.com> | 2009-02-12 05:40:00 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-03-24 05:00:19 -0400 |
commit | 402d326519c1a4859c527702383f4e60f606ef52 (patch) | |
tree | beb302d56d7671d372ae73f2664feed2a5b1226d /drivers/mtd/chips | |
parent | 9ce969082e490d0a5a81862b364337c93dc3482a (diff) |
NOMMU: Present backing device capabilities for MTD chardevs
Present backing device capabilities for MTD character device files to allow
NOMMU mmap to do direct mapping where possible.
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Bernd Schmidt <bernd.schmidt@analog.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r-- | drivers/mtd/chips/map_ram.c | 17 | ||||
-rw-r--r-- | drivers/mtd/chips/map_rom.c | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index 072dd8abf33..6bdc50c727e 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c | |||
@@ -21,6 +21,8 @@ static int mapram_write (struct mtd_info *, loff_t, size_t, size_t *, const u_ch | |||
21 | static int mapram_erase (struct mtd_info *, struct erase_info *); | 21 | static int mapram_erase (struct mtd_info *, struct erase_info *); |
22 | static void mapram_nop (struct mtd_info *); | 22 | static void mapram_nop (struct mtd_info *); |
23 | static struct mtd_info *map_ram_probe(struct map_info *map); | 23 | static struct mtd_info *map_ram_probe(struct map_info *map); |
24 | static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, | ||
25 | unsigned long, unsigned long); | ||
24 | 26 | ||
25 | 27 | ||
26 | static struct mtd_chip_driver mapram_chipdrv = { | 28 | static struct mtd_chip_driver mapram_chipdrv = { |
@@ -64,6 +66,7 @@ static struct mtd_info *map_ram_probe(struct map_info *map) | |||
64 | mtd->type = MTD_RAM; | 66 | mtd->type = MTD_RAM; |
65 | mtd->size = map->size; | 67 | mtd->size = map->size; |
66 | mtd->erase = mapram_erase; | 68 | mtd->erase = mapram_erase; |
69 | mtd->get_unmapped_area = mapram_unmapped_area; | ||
67 | mtd->read = mapram_read; | 70 | mtd->read = mapram_read; |
68 | mtd->write = mapram_write; | 71 | mtd->write = mapram_write; |
69 | mtd->sync = mapram_nop; | 72 | mtd->sync = mapram_nop; |
@@ -79,6 +82,20 @@ static struct mtd_info *map_ram_probe(struct map_info *map) | |||
79 | } | 82 | } |
80 | 83 | ||
81 | 84 | ||
85 | /* | ||
86 | * Allow NOMMU mmap() to directly map the device (if not NULL) | ||
87 | * - return the address to which the offset maps | ||
88 | * - return -ENOSYS to indicate refusal to do the mapping | ||
89 | */ | ||
90 | static unsigned long mapram_unmapped_area(struct mtd_info *mtd, | ||
91 | unsigned long len, | ||
92 | unsigned long offset, | ||
93 | unsigned long flags) | ||
94 | { | ||
95 | struct map_info *map = mtd->priv; | ||
96 | return (unsigned long) map->virt + offset; | ||
97 | } | ||
98 | |||
82 | static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) | 99 | static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
83 | { | 100 | { |
84 | struct map_info *map = mtd->priv; | 101 | struct map_info *map = mtd->priv; |
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index c76d6e5f47e..076090a67b9 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c | |||
@@ -20,6 +20,8 @@ static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_ch | |||
20 | static void maprom_nop (struct mtd_info *); | 20 | static void maprom_nop (struct mtd_info *); |
21 | static struct mtd_info *map_rom_probe(struct map_info *map); | 21 | static struct mtd_info *map_rom_probe(struct map_info *map); |
22 | static int maprom_erase (struct mtd_info *mtd, struct erase_info *info); | 22 | static int maprom_erase (struct mtd_info *mtd, struct erase_info *info); |
23 | static unsigned long maprom_unmapped_area(struct mtd_info *, unsigned long, | ||
24 | unsigned long, unsigned long); | ||
23 | 25 | ||
24 | static struct mtd_chip_driver maprom_chipdrv = { | 26 | static struct mtd_chip_driver maprom_chipdrv = { |
25 | .probe = map_rom_probe, | 27 | .probe = map_rom_probe, |
@@ -40,6 +42,7 @@ static struct mtd_info *map_rom_probe(struct map_info *map) | |||
40 | mtd->name = map->name; | 42 | mtd->name = map->name; |
41 | mtd->type = MTD_ROM; | 43 | mtd->type = MTD_ROM; |
42 | mtd->size = map->size; | 44 | mtd->size = map->size; |
45 | mtd->get_unmapped_area = maprom_unmapped_area; | ||
43 | mtd->read = maprom_read; | 46 | mtd->read = maprom_read; |
44 | mtd->write = maprom_write; | 47 | mtd->write = maprom_write; |
45 | mtd->sync = maprom_nop; | 48 | mtd->sync = maprom_nop; |
@@ -53,6 +56,20 @@ static struct mtd_info *map_rom_probe(struct map_info *map) | |||
53 | } | 56 | } |
54 | 57 | ||
55 | 58 | ||
59 | /* | ||
60 | * Allow NOMMU mmap() to directly map the device (if not NULL) | ||
61 | * - return the address to which the offset maps | ||
62 | * - return -ENOSYS to indicate refusal to do the mapping | ||
63 | */ | ||
64 | static unsigned long maprom_unmapped_area(struct mtd_info *mtd, | ||
65 | unsigned long len, | ||
66 | unsigned long offset, | ||
67 | unsigned long flags) | ||
68 | { | ||
69 | struct map_info *map = mtd->priv; | ||
70 | return (unsigned long) map->virt + offset; | ||
71 | } | ||
72 | |||
56 | static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) | 73 | static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
57 | { | 74 | { |
58 | struct map_info *map = mtd->priv; | 75 | struct map_info *map = mtd->priv; |