mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
iov_iter: add iter_iovec() helper
This returns a pointer to the current iovec entry in the iterator. Only useful with ITER_IOVEC right now, but it prepares us to treat ITER_UBUF and ITER_IOVEC identically for the first segment. Rename struct iov_iter->iov to iov_iter->__iov to find any potentially troublesome spots, and also to prevent anyone from adding new code that accesses iter->iov directly. Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -51,7 +51,8 @@ struct iov_iter {
|
||||
};
|
||||
size_t count;
|
||||
union {
|
||||
const struct iovec *iov;
|
||||
/* use iter_iov() to get the current vec */
|
||||
const struct iovec *__iov;
|
||||
const struct kvec *kvec;
|
||||
const struct bio_vec *bvec;
|
||||
struct xarray *xarray;
|
||||
@@ -68,6 +69,8 @@ struct iov_iter {
|
||||
};
|
||||
};
|
||||
|
||||
#define iter_iov(iter) (iter)->__iov
|
||||
|
||||
static inline enum iter_type iov_iter_type(const struct iov_iter *i)
|
||||
{
|
||||
return i->iter_type;
|
||||
@@ -146,9 +149,9 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
|
||||
static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
|
||||
{
|
||||
return (struct iovec) {
|
||||
.iov_base = iter->iov->iov_base + iter->iov_offset,
|
||||
.iov_base = iter_iov(iter)->iov_base + iter->iov_offset,
|
||||
.iov_len = min(iter->count,
|
||||
iter->iov->iov_len - iter->iov_offset),
|
||||
iter_iov(iter)->iov_len - iter->iov_offset),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user