Commit 316389e9 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/syscalls: Simplify do_mmap2()

When shift is nul, operations remain valid so no test needed.

And 'ret' is unnecessary.

And use IS_ALIGNED() to check alignment, that's more clear.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/373ec500f386374bc5735007df3d3869eac47be1.1624618701.git.christophe.leroy@csgroup.eu
parent e0847283
...@@ -41,20 +41,13 @@ static inline long do_mmap2(unsigned long addr, size_t len, ...@@ -41,20 +41,13 @@ static inline long do_mmap2(unsigned long addr, size_t len,
unsigned long prot, unsigned long flags, unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long off, int shift) unsigned long fd, unsigned long off, int shift)
{ {
long ret = -EINVAL;
if (!arch_validate_prot(prot, addr)) if (!arch_validate_prot(prot, addr))
goto out; return -EINVAL;
if (shift) { if (!IS_ALIGNED(off, 1 << shift))
if (off & ((1 << shift) - 1)) return -EINVAL;
goto out;
off >>= shift;
}
ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off); return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> shift);
out:
return ret;
} }
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len, SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment