[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>
This commit is contained in:
parent
66531c65aa
commit
e4f8df8679
@ -1925,20 +1925,8 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages)
|
|||||||
return min(npages, maxpages);
|
return min(npages, maxpages);
|
||||||
}
|
}
|
||||||
if (iov_iter_is_xarray(i)) {
|
if (iov_iter_is_xarray(i)) {
|
||||||
size_t size = i->count;
|
unsigned offset = (i->xarray_start + i->iov_offset) % PAGE_SIZE;
|
||||||
unsigned offset;
|
int npages = DIV_ROUND_UP(offset + i->count, PAGE_SIZE);
|
||||||
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++;
|
|
||||||
}
|
|
||||||
return min(npages, maxpages);
|
return min(npages, maxpages);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user