From: Christoph Hellwig Date: Wed, 4 Aug 2021 09:56:20 +0000 (+0200) Subject: bvec: add a bvec_virt helper X-Git-Tag: accepted/tizen/unified/20230118.172025~6559^2~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1113f0b69c6a98ff4e733c306a6658a31f8cbc49;p=platform%2Fkernel%2Flinux-rpi.git bvec: add a bvec_virt helper Add a helper to get the virtual address for a bvec. This avoids that all callers need to know about the page + offset representation. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Martin K. Petersen Link: https://lore.kernel.org/r/20210804095634.460779-2-hch@lst.de Signed-off-by: Jens Axboe --- diff --git a/include/linux/bvec.h b/include/linux/bvec.h index f9fa43b..0e9bdd4 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -229,4 +229,16 @@ static inline void memzero_bvec(struct bio_vec *bvec) memzero_page(bvec->bv_page, bvec->bv_offset, bvec->bv_len); } +/** + * bvec_virt - return the virtual address for a bvec + * @bvec: bvec to return the virtual address for + * + * Note: the caller must ensure that @bvec->bv_page is not a highmem page. + */ +static inline void *bvec_virt(struct bio_vec *bvec) +{ + WARN_ON_ONCE(PageHighMem(bvec->bv_page)); + return page_address(bvec->bv_page) + bvec->bv_offset; +} + #endif /* __LINUX_BVEC_H */