[PATCH 412/437] hv: convert to read/write iterators

Jens Axboe
2024-04-11T15:43:11Z

drivers/hv/hv_utils_transport.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 832885198643..fa93ac3800ae 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -24,13 +24,13 @@ static void hvt_reset(struct hvutil_transport *hvt)
hvt->on_reset();
}

-static ssize_t hvt_op_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t hvt_op_read(struct kiocb *iocb, struct iov_iter *to)
{
+ size_t count = iov_iter_count(to);
struct hvutil_transport *hvt;
int ret;

- hvt = container_of(file->f_op, struct hvutil_transport, fops);
+ hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops);

if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0 ||
hvt->mode != HVUTIL_TRANSPORT_CHARDEV))
@@ -53,7 +53,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
goto out_unlock;
}

- if (!copy_to_user(buf, hvt->outmsg, hvt->outmsg_len))
+ if (copy_to_iter_full(hvt->outmsg, hvt->outmsg_len, to))
ret = hvt->outmsg_len;
else
ret = -EFAULT;
@@ -71,16 +71,16 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
return ret;
}

-static ssize_t hvt_op_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t hvt_op_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
struct hvutil_transport *hvt;
u8 *inmsg;
int ret;

- hvt = container_of(file->f_op, struct hvutil_transport, fops);
+ hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops);

- inmsg = memdup_user(buf, count);
+ inmsg = iterdup(from, count);
if (IS_ERR(inmsg))
return PTR_ERR(inmsg);

@@ -285,8 +285,8 @@ struct hvutil_transport *hvutil_transport_init(const char *name,
hvt->mdev.name = name;

hvt->fops.owner = THIS_MODULE;
- hvt->fops.read = hvt_op_read;
- hvt->fops.write = hvt_op_write;
+ hvt->fops.read_iter = hvt_op_read;
+ hvt->fops.write_iter = hvt_op_write;
hvt->fops.poll = hvt_op_poll;
hvt->fops.open = hvt_op_open;
hvt->fops.release = hvt_op_release;
--
2.43.0