From: Stefano Garzarella Date: Mon, 15 Mar 2021 16:34:42 +0000 (+0100) Subject: vringh: add vringh_kiov_length() helper X-Git-Tag: accepted/tizen/unified/20230118.172025~7283^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14c9ac05ce09c8c6a89ffcca6ffb68707cba36c2;p=platform%2Fkernel%2Flinux-rpi.git vringh: add vringh_kiov_length() helper This new helper returns the total number of bytes covered by a vringh_kiov. Suggested-by: Jason Wang Acked-by: Jason Wang Signed-off-by: Stefano Garzarella Link: https://lore.kernel.org/r/20210315163450.254396-7-sgarzare@redhat.com Signed-off-by: Michael S. Tsirkin --- diff --git a/include/linux/vringh.h b/include/linux/vringh.h index 755211e..84db7b8 100644 --- a/include/linux/vringh.h +++ b/include/linux/vringh.h @@ -199,6 +199,17 @@ static inline void vringh_kiov_cleanup(struct vringh_kiov *kiov) kiov->iov = NULL; } +static inline size_t vringh_kiov_length(struct vringh_kiov *kiov) +{ + size_t len = 0; + int i; + + for (i = kiov->i; i < kiov->used; i++) + len += kiov->iov[i].iov_len; + + return len; +} + void vringh_kiov_advance(struct vringh_kiov *kiov, size_t len); int vringh_getdesc_kern(struct vringh *vrh,