[PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu)

Benjamin Herrenschmidt
2007-04-04T04:03:45Z

This also fixes a bug, I think, it used to return a pgoff (pfn)
instead of an address. (To split ?)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

drivers/char/mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-cell/drivers/char/mem.c
===================================================================
--- linux-cell.orig/drivers/char/mem.c 2007-03-22 16:24:04.000000000 +1100
+++ linux-cell/drivers/char/mem.c 2007-03-22 16:26:30.000000000 +1100
@@ -246,9 +246,12 @@ static unsigned long get_unmapped_area_m
unsigned long pgoff,
unsigned long flags)
{
+ if (flags & MAP_FIXED)
+ if ((addr >> PAGE_SHIFT) != pgoff)
+ return (unsigned long) -EINVAL;
if (!valid_mmap_phys_addr_range(pgoff, len))
return (unsigned long) -EINVAL;
- return pgoff;
+ return pgoff << PAGE_SHIFT;
}

/* can't do an in-place private mapping if there's no MMU */