[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-346-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:18:05 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 345/437] s390: vmcp: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
drivers/s390/char/vmcp.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index eb0520a9d4af..348e528a386d 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -128,14 +128,13 @@ static int vmcp_release(struct inode *inode, struct file *file)
return 0;
}
-static ssize_t
-vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
+static ssize_t vmcp_read(struct kiocb *iocb, struct iov_iter *to)
{
ssize_t ret;
size_t size;
struct vmcp_session *session;
- session = file->private_data;
+ session = iocb->ki_filp->private_data;
if (mutex_lock_interruptible(&session->mutex))
return -ERESTARTSYS;
if (!session->response) {
@@ -143,27 +142,25 @@ vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
return 0;
}
size = min_t(size_t, session->resp_size, session->bufsize);
- ret = simple_read_from_buffer(buff, count, ppos,
- session->response, size);
+ ret = simple_copy_to_iter(session->response, &iocb->ki_pos, size, to);
mutex_unlock(&session->mutex);
return ret;
}
-static ssize_t
-vmcp_write(struct file *file, const char __user *buff, size_t count,
- loff_t *ppos)
+static ssize_t vmcp_write(struct kiocb *iocb, struct iov_iter *from)
{
char *cmd;
struct vmcp_session *session;
+ size_t count = iov_iter_count(from);
if (count > 240)
return -EINVAL;
- cmd = memdup_user_nul(buff, count);
+ cmd = iterdup_nul(from, count);
if (IS_ERR(cmd))
return PTR_ERR(cmd);
- session = file->private_data;
+ session = iocb->ki_filp->private_data;
if (mutex_lock_interruptible(&session->mutex)) {
kfree(cmd);
return -ERESTARTSYS;
@@ -180,7 +177,7 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
&session->resp_code);
mutex_unlock(&session->mutex);
kfree(cmd);
- *ppos = 0; /* reset the file pointer after a command */
+ iocb->ki_pos = 0; /* reset the file pointer after a command */
return count;
}
@@ -238,8 +235,8 @@ static const struct file_operations vmcp_fops = {
.owner = THIS_MODULE,
.open = vmcp_open,
.release = vmcp_release,
- .read = vmcp_read,
- .write = vmcp_write,
+ .read_iter = vmcp_read,
+ .write_iter = vmcp_write,
.unlocked_ioctl = vmcp_ioctl,
.compat_ioctl = vmcp_ioctl,
.llseek = no_llseek,
--
2.43.0
Powered by blists - more mailing lists