diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2022-06-17 22:07:49 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2022-07-07 02:32:34 +0200 |
commit | dd45ab9dd28c82fc495d98cd9788666fd8d76b99 (patch) | |
tree | f251186a6b788fa01da450c22b21d3697ef7cbb9 | |
parent | iov_iter: massage calling conventions for first_{iovec,bvec}_segment() (diff) | |
download | linux-dd45ab9dd28c82fc495d98cd9788666fd8d76b99.tar.xz linux-dd45ab9dd28c82fc495d98cd9788666fd8d76b99.zip |
first_iovec_segment(): just return address
... and calculate the offset in the caller
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | lib/iov_iter.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index d93c6a1ffe26..a4a44065cd37 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1293,22 +1293,19 @@ static ssize_t iter_xarray_get_pages(struct iov_iter *i, } /* must be done on non-empty ITER_IOVEC one */ -static unsigned long first_iovec_segment(const struct iov_iter *i, - size_t *size, size_t *start) +static unsigned long first_iovec_segment(const struct iov_iter *i, size_t *size) { size_t skip; long k; for (k = 0, skip = i->iov_offset; k < i->nr_segs; k++, skip = 0) { - unsigned long addr = (unsigned long)i->iov[k].iov_base + skip; size_t len = i->iov[k].iov_len - skip; if (unlikely(!len)) continue; if (*size > len) *size = len; - *start = addr % PAGE_SIZE; - return addr & PAGE_MASK; + return (unsigned long)i->iov[k].iov_base + skip; } BUG(); // if it had been empty, we wouldn't get called } @@ -1351,7 +1348,9 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, if (i->nofault) gup_flags |= FOLL_NOFAULT; - addr = first_iovec_segment(i, &maxsize, start); + addr = first_iovec_segment(i, &maxsize); + *start = addr % PAGE_SIZE; + addr &= PAGE_MASK; n = DIV_ROUND_UP(maxsize + *start, PAGE_SIZE); if (n > maxpages) n = maxpages; @@ -1482,7 +1481,9 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, if (i->nofault) gup_flags |= FOLL_NOFAULT; - addr = first_iovec_segment(i, &maxsize, start); + addr = first_iovec_segment(i, &maxsize); + *start = addr % PAGE_SIZE; + addr &= PAGE_MASK; n = DIV_ROUND_UP(maxsize + *start, PAGE_SIZE); p = get_pages_array(n); if (!p) |