[PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
Mike Frysinger
vapier at gentoo.org
Sun May 23 03:30:23 EDT 2010
From: Bernd Schmidt <bernds_cb1 at t-online.de>
Currently, romfs XIP doesn't work in flash memory (the kernel crashes
with a null pointer dereference). The problem is that the mtd physmap
driver isn't setting up a get_unmapped_area pointer for the mtd
partitions it creates.
Signed-off-by: Bernd Schmidt <bernds_cb1 at t-online.de>
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
drivers/mtd/maps/physmap.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 09d89ff..370da18 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -72,6 +72,20 @@ static int physmap_flash_remove(struct platform_device *dev)
return 0;
}
+/*
+ * Allow NOMMU mmap() to directly map the device (if not NULL)
+ * - return the address to which the offset maps
+ * - return -ENOSYS to indicate refusal to do the mapping
+ */
+static unsigned long physmap_unmapped_area(struct mtd_info *mtd,
+ unsigned long len,
+ unsigned long offset,
+ unsigned long flags)
+{
+ struct map_info *map = mtd->priv;
+ return (unsigned long) map->virt + offset;
+}
+
static const char *rom_probe_types[] = {
"cfi_probe",
"jedec_probe",
@@ -149,6 +163,8 @@ static int physmap_flash_probe(struct platform_device *dev)
} else {
devices_found++;
}
+ if (info->mtd[i]->get_unmapped_area == NULL)
+ info->mtd[i]->get_unmapped_area = physmap_unmapped_area;
info->mtd[i]->owner = THIS_MODULE;
info->mtd[i]->dev.parent = &dev->dev;
}
--
1.7.1
More information about the linux-mtd
mailing list