[PATCH 182/437] drivers/uio: convert to ->read_iter and ->write_iter
From: Jens Axboe
Date: Thu Apr 11 2024 - 12:20:41 EST
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/uio/uio.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 009158fef2a8..510d3707e694 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -563,10 +563,10 @@ static __poll_t uio_poll(struct file *filep, poll_table *wait)
return 0;
}
-static ssize_t uio_read(struct file *filep, char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t uio_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct uio_listener *listener = filep->private_data;
+ struct uio_listener *listener = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
struct uio_device *idev = listener->dev;
DECLARE_WAITQUEUE(wait, current);
ssize_t retval = 0;
@@ -591,7 +591,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
event_count = atomic_read(&idev->event);
if (event_count != listener->event_count) {
__set_current_state(TASK_RUNNING);
- if (copy_to_user(buf, &event_count, count))
+ if (!copy_to_iter_full(&event_count, count, to))
retval = -EFAULT;
else {
listener->event_count = event_count;
@@ -600,7 +600,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
break;
}
- if (filep->f_flags & O_NONBLOCK) {
+ if (iocb->ki_filp->f_flags & O_NONBLOCK) {
retval = -EAGAIN;
break;
}
@@ -618,18 +618,18 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
return retval;
}
-static ssize_t uio_write(struct file *filep, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t uio_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct uio_listener *listener = filep->private_data;
+ struct uio_listener *listener = iocb->ki_filp->private_data;
struct uio_device *idev = listener->dev;
+ size_t count = iov_iter_count(from);
ssize_t retval;
s32 irq_on;
if (count != sizeof(s32))
return -EINVAL;
- if (copy_from_user(&irq_on, buf, count))
+ if (!copy_from_iter_full(&irq_on, count, from))
return -EFAULT;
mutex_lock(&idev->info_lock);
@@ -866,8 +866,8 @@ static const struct file_operations uio_fops = {
.owner = THIS_MODULE,
.open = uio_open,
.release = uio_release,
- .read = uio_read,
- .write = uio_write,
+ .read_iter = uio_read,
+ .write_iter = uio_write,
.mmap = uio_mmap,
.poll = uio_poll,
.fasync = uio_fasync,
--
2.43.0