diff options
Diffstat (limited to 'include/linux/bvec.h')
| -rw-r--r-- | include/linux/bvec.h | 41 | 
1 files changed, 40 insertions, 1 deletions
diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 35c25dff651a..555aae5448ae 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -12,7 +12,6 @@  #include <linux/errno.h>  #include <linux/limits.h>  #include <linux/minmax.h> -#include <linux/mm.h>  #include <linux/types.h>  struct page; @@ -35,6 +34,46 @@ struct bio_vec {  	unsigned int	bv_offset;  }; +/** + * bvec_set_page - initialize a bvec based off a struct page + * @bv:		bvec to initialize + * @page:	page the bvec should point to + * @len:	length of the bvec + * @offset:	offset into the page + */ +static inline void bvec_set_page(struct bio_vec *bv, struct page *page, +		unsigned int len, unsigned int offset) +{ +	bv->bv_page = page; +	bv->bv_len = len; +	bv->bv_offset = offset; +} + +/** + * bvec_set_folio - initialize a bvec based off a struct folio + * @bv:		bvec to initialize + * @folio:	folio the bvec should point to + * @len:	length of the bvec + * @offset:	offset into the folio + */ +static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio, +		unsigned int len, unsigned int offset) +{ +	bvec_set_page(bv, &folio->page, len, offset); +} + +/** + * bvec_set_virt - initialize a bvec based on a virtual address + * @bv:		bvec to initialize + * @vaddr:	virtual address to set the bvec to + * @len:	length of the bvec + */ +static inline void bvec_set_virt(struct bio_vec *bv, void *vaddr, +		unsigned int len) +{ +	bvec_set_page(bv, virt_to_page(vaddr), len, offset_in_page(vaddr)); +} +  struct bvec_iter {  	sector_t		bi_sector;	/* device address in 512 byte  						   sectors */  |