Merge tag 'clk-for-linus-3.20' of git://git.linaro.org/people/mike.turquette/linux
[cascardo/linux.git] / drivers / mtd / chips / map_rom.c
index 47a43cf..e67f73a 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/of.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 
@@ -28,6 +29,15 @@ static struct mtd_chip_driver maprom_chipdrv = {
        .module = THIS_MODULE
 };
 
+static unsigned int default_erasesize(struct map_info *map)
+{
+       const __be32 *erase_size = NULL;
+
+       erase_size = of_get_property(map->device_node, "erase-size", NULL);
+
+       return !erase_size ? map->size : be32_to_cpu(*erase_size);
+}
+
 static struct mtd_info *map_rom_probe(struct map_info *map)
 {
        struct mtd_info *mtd;
@@ -47,8 +57,9 @@ static struct mtd_info *map_rom_probe(struct map_info *map)
        mtd->_sync = maprom_nop;
        mtd->_erase = maprom_erase;
        mtd->flags = MTD_CAP_ROM;
-       mtd->erasesize = map->size;
+       mtd->erasesize = default_erasesize(map);
        mtd->writesize = 1;
+       mtd->writebufsize = 1;
 
        __module_get(THIS_MODULE);
        return mtd;