aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/highmem.h
diff options
context:
space:
mode:
authorIra Weiny <ira.weiny@intel.com>2021-02-09 22:22:16 -0800
committerDavid Sterba <dsterba@suse.com>2021-02-11 19:55:37 +0100
commit6a0996db6879cf09f989c5f44f9edd38240cb346 (patch)
tree55efe5ff583b0812a05dd2e29865a9807060b611 /include/linux/highmem.h
parent61b205f579911a11f0b576f73275eca2aed0d108 (diff)
downloadlinux-6a0996db6879cf09f989c5f44f9edd38240cb346.tar.gz
mm/highmem: Introduce memcpy_page(), memmove_page(), and memset_page()
3 more common kmap patterns are kmap/memcpy/kunmap, kmap/memmove/kunmap. and kmap/memset/kunmap. Add helper functions for those patterns which use kmap_local_page(). Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Christoph Hellwig <hch@infradead.org> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'include/linux/highmem.h')
-rw-r--r--include/linux/highmem.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index c17a175fe5fe21..0b5d89621cb958 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -276,6 +276,39 @@ static inline void copy_highpage(struct page *to, struct page *from)
#endif
+static inline void memcpy_page(struct page *dst_page, size_t dst_off,
+ struct page *src_page, size_t src_off,
+ size_t len)
+{
+ char *dst = kmap_local_page(dst_page);
+ char *src = kmap_local_page(src_page);
+
+ memcpy(dst + dst_off, src + src_off, len);
+ kunmap_local(src);
+ kunmap_local(dst);
+}
+
+static inline void memmove_page(struct page *dst_page, size_t dst_off,
+ struct page *src_page, size_t src_off,
+ size_t len)
+{
+ char *dst = kmap_local_page(dst_page);
+ char *src = kmap_local_page(src_page);
+
+ memmove(dst + dst_off, src + src_off, len);
+ kunmap_local(src);
+ kunmap_local(dst);
+}
+
+static inline void memset_page(struct page *page, size_t offset, int val,
+ size_t len)
+{
+ char *addr = kmap_local_page(page);
+
+ memset(addr + offset, val, len);
+ kunmap_local(addr);
+}
+
static inline void memcpy_from_page(char *to, struct page *page,
size_t offset, size_t len)
{