OSDN Git Service

ashmem: don't require a page aligned size
authorMarco Nelissen <marcone@android.com>
Tue, 23 Jun 2009 16:32:11 +0000 (09:32 -0700)
committerMarco Nelissen <marcone@android.com>
Tue, 23 Jun 2009 17:54:09 +0000 (10:54 -0700)
This makes ashmem more similar to shmem and mmap, by
not requiring the specified size to be page aligned,
instead rounding it internally as needed.

Signed-off-by: Marco Nelissen <marcone@android.com>
mm/ashmem.c

index 0eef9ac..230810f 100644 (file)
@@ -522,7 +522,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
 
        /* per custom, you can pass zero for len to mean "everything onward" */
        if (!pin.len)
-               pin.len = asma->size - pin.offset;
+               pin.len = PAGE_ALIGN(asma->size) - pin.offset;
 
        if (unlikely((pin.offset | pin.len) & ~PAGE_MASK))
                return -EINVAL;
@@ -530,7 +530,7 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
        if (unlikely(((__u32) -1) - pin.offset < pin.len))
                return -EINVAL;
 
-       if (unlikely(asma->size < pin.offset + pin.len))
+       if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len))
                return -EINVAL;
 
        pgstart = pin.offset / PAGE_SIZE;
@@ -569,7 +569,7 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                break;
        case ASHMEM_SET_SIZE:
                ret = -EINVAL;
-               if (!asma->file && !(arg & ~PAGE_MASK)) {
+               if (!asma->file) {
                        ret = 0;
                        asma->size = (size_t) arg;
                }