From: Bernd Schmidt <bernds_...@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_...@t-online.de>
Signed-off-by: Mike Frysinger <vap...@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

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to