]> www.infradead.org Git - users/hch/block.git/commitdiff
bvec: add memcpy_{from,to}_bvec and memzero_bvec helper
authorChristoph Hellwig <hch@lst.de>
Thu, 20 May 2021 12:41:29 +0000 (14:41 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 20 May 2021 12:44:57 +0000 (14:44 +0200)
Add helpers to perform common memory operation on a bvec.

Signed-off-by: Christoph Hellwig <hch@lst.de>
include/linux/bvec.h

index 5048df1b432ca2699a5bf6c5a604fe99868628f0..a9c16cabddc010f622324f9d3009c381da0247f0 100644 (file)
@@ -189,4 +189,19 @@ static inline char *bvec_kmap_local(struct bio_vec *bvec)
        return kmap_local_page(bvec->bv_page) + bvec->bv_offset;
 }
 
+static inline void memcpy_from_bvec(char *to, struct bio_vec *bvec)
+{
+       memcpy_from_page(to, bvec->bv_page, bvec->bv_offset, bvec->bv_len);
+}
+
+static inline void memcpy_to_bvec(struct bio_vec *bvec, const char *from)
+{
+       memcpy_to_page(bvec->bv_page, bvec->bv_offset, from, bvec->bv_len);
+}
+
+static inline void memzero_bvec(struct bio_vec *bvec)
+{
+       memzero_page(bvec->bv_page, bvec->bv_offset, bvec->bv_len);
+}
+
 #endif /* __LINUX_BVEC_H */