summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-05-03 11:05:29 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2021-06-10 11:45:13 -0400
commite4f8df86798aea60aff6cfff40252b709431f850 (patch)
treef80d1ce812a3909f37d16af66c1bfe0215d85582 /lib
parent66531c65aa254e77c935785036beb50985d0fe89 (diff)
downloadlinux-stable-e4f8df86798aea60aff6cfff40252b709431f850.tar.gz
linux-stable-e4f8df86798aea60aff6cfff40252b709431f850.tar.bz2
linux-stable-e4f8df86798aea60aff6cfff40252b709431f850.zip
[xarray] iov_iter_npages(): just use DIV_ROUND_UP()
Compiler is capable of recognizing division by power of 2 and turning it into shifts. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/iov_iter.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 1c65de175371..72c5bb794e8d 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1925,20 +1925,8 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages)
return min(npages, maxpages);
}
if (iov_iter_is_xarray(i)) {
- size_t size = i->count;
- unsigned offset;
- int npages;
-
- offset = (i->xarray_start + i->iov_offset) & ~PAGE_MASK;
-
- npages = 1;
- if (size > PAGE_SIZE - offset) {
- size -= PAGE_SIZE - offset;
- npages += size >> PAGE_SHIFT;
- size &= ~PAGE_MASK;
- if (size)
- npages++;
- }
+ unsigned offset = (i->xarray_start + i->iov_offset) % PAGE_SIZE;
+ int npages = DIV_ROUND_UP(offset + i->count, PAGE_SIZE);
return min(npages, maxpages);
}
return 0;