[PATCH 349/437] s390: monreader: convert to read/write iterators
From: Jens Axboe
Date: Thu Apr 11 2024 - 13:21:51 EST
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/s390/char/monreader.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 7207a7f5842a..151030779624 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -358,10 +358,10 @@ static int mon_close(struct inode *inode, struct file *filp)
return 0;
}
-static ssize_t mon_read(struct file *filp, char __user *data,
- size_t count, loff_t *ppos)
+static ssize_t mon_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct mon_private *monpriv = filp->private_data;
+ struct mon_private *monpriv = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
struct mon_msg *monmsg;
int ret;
u32 mce_start;
@@ -371,7 +371,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
return PTR_ERR(monmsg);
if (!monmsg) {
- if (filp->f_flags & O_NONBLOCK)
+ if (iocb->ki_filp->f_flags & O_NONBLOCK)
return -EAGAIN;
ret = wait_event_interruptible(mon_read_wait_queue,
atomic_read(&monpriv->read_ready) ||
@@ -392,7 +392,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
mce_start = mon_mca_start(monmsg) + monmsg->mca_offset;
if ((monmsg->pos >= mce_start) && (monmsg->pos < mce_start + 12)) {
count = min(count, (size_t) mce_start + 12 - monmsg->pos);
- ret = copy_to_user(data, __va(monmsg->pos), count);
+ ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
if (ret)
return -EFAULT;
monmsg->pos += count;
@@ -405,7 +405,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
if (monmsg->pos <= mon_rec_end(monmsg)) {
count = min(count, (size_t) mon_rec_end(monmsg) - monmsg->pos
+ 1);
- ret = copy_to_user(data, __va(monmsg->pos), count);
+ ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
if (ret)
return -EFAULT;
monmsg->pos += count;
@@ -418,7 +418,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
return ret;
out_copy:
- *ppos += count;
+ iocb->ki_pos += count;
return count;
}
@@ -438,7 +438,7 @@ static const struct file_operations mon_fops = {
.owner = THIS_MODULE,
.open = &mon_open,
.release = &mon_close,
- .read = &mon_read,
+ .read_iter = &mon_read,
.poll = &mon_poll,
.llseek = noop_llseek,
};
--
2.43.0