aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/map_rom.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2009-01-11 14:52:19 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-01-11 14:56:46 -0500
commit5f877607cdfe8b60bf96fb96e527e0ce2a21e68b (patch)
tree5e13766a4d7df3e7032b1b26e498099c04b06c16 /drivers/mtd/chips/map_rom.c
parent57c1a24ee276a33190008243f986419e122c0dea (diff)
[MTD] map_rom has NULL erase pointer
Which means if inftl or similar are loaded with it (which is a dumb thing to do admittedly) it may oops. Closes #8108 [dwmw2: change error to -EROFS to match write-protected flash] Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/chips/map_rom.c')
-rw-r--r--drivers/mtd/chips/map_rom.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
index 821d0ed6bae3..c76d6e5f47ee 100644
--- a/drivers/mtd/chips/map_rom.c
+++ b/drivers/mtd/chips/map_rom.c
@@ -19,6 +19,7 @@ static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
19static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 19static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
20static void maprom_nop (struct mtd_info *); 20static void maprom_nop (struct mtd_info *);
21static struct mtd_info *map_rom_probe(struct map_info *map); 21static struct mtd_info *map_rom_probe(struct map_info *map);
22static int maprom_erase (struct mtd_info *mtd, struct erase_info *info);
22 23
23static struct mtd_chip_driver maprom_chipdrv = { 24static struct mtd_chip_driver maprom_chipdrv = {
24 .probe = map_rom_probe, 25 .probe = map_rom_probe,
@@ -42,6 +43,7 @@ static struct mtd_info *map_rom_probe(struct map_info *map)
42 mtd->read = maprom_read; 43 mtd->read = maprom_read;
43 mtd->write = maprom_write; 44 mtd->write = maprom_write;
44 mtd->sync = maprom_nop; 45 mtd->sync = maprom_nop;
46 mtd->erase = maprom_erase;
45 mtd->flags = MTD_CAP_ROM; 47 mtd->flags = MTD_CAP_ROM;
46 mtd->erasesize = map->size; 48 mtd->erasesize = map->size;
47 mtd->writesize = 1; 49 mtd->writesize = 1;
@@ -71,6 +73,12 @@ static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
71 return -EIO; 73 return -EIO;
72} 74}
73 75
76static int maprom_erase (struct mtd_info *mtd, struct erase_info *info)
77{
78 /* We do our best 8) */
79 return -EROFS;
80}
81
74static int __init map_rom_init(void) 82static int __init map_rom_init(void)
75{ 83{
76 register_mtd_chip_driver(&maprom_chipdrv); 84 register_mtd_chip_driver(&maprom_chipdrv);