mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 18:11:20 +00:00
net: move iov_pages() to net/core/iovec.c
To let it be reused and reduce code duplication. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6261d983f2
commit
b4bf07771f
4 changed files with 26 additions and 46 deletions
|
@ -212,3 +212,27 @@ out_fault:
|
|||
goto out;
|
||||
}
|
||||
EXPORT_SYMBOL(csum_partial_copy_fromiovecend);
|
||||
|
||||
unsigned long iov_pages(const struct iovec *iov, int offset,
|
||||
unsigned long nr_segs)
|
||||
{
|
||||
unsigned long seg, base;
|
||||
int pages = 0, len, size;
|
||||
|
||||
while (nr_segs && (offset >= iov->iov_len)) {
|
||||
offset -= iov->iov_len;
|
||||
++iov;
|
||||
--nr_segs;
|
||||
}
|
||||
|
||||
for (seg = 0; seg < nr_segs; seg++) {
|
||||
base = (unsigned long)iov[seg].iov_base + offset;
|
||||
len = iov[seg].iov_len - offset;
|
||||
size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
|
||||
pages += size;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
return pages;
|
||||
}
|
||||
EXPORT_SYMBOL(iov_pages);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue