diff options
author | Jason Wang <jasowang@redhat.com> | 2013-08-06 17:45:03 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-07 16:52:33 -0700 |
commit | b4bf07771faaf959b0a916d35b1b930c030e30a8 (patch) | |
tree | 9292ea7010fc74fb5c3f5039ee3886b1f42702f3 /net/core | |
parent | 6261d983f226f0a6a8d4d32b57a032bc23a5ebb6 (diff) | |
download | op-kernel-dev-b4bf07771faaf959b0a916d35b1b930c030e30a8.zip op-kernel-dev-b4bf07771faaf959b0a916d35b1b930c030e30a8.tar.gz |
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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/iovec.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/core/iovec.c b/net/core/iovec.c index de178e4..b77eeec 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c @@ -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); |