[PATCH 402/437] drivers/rapidio: convert to read/write iterators

Jens Axboe
2024-04-11T15:42:55Z

drivers/rapidio/devices/rio_mport_cdev.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 27afbb9d544b..de1628737808 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -2297,12 +2297,13 @@ static ssize_t mport_read(struct file *filp, char __user *buf, size_t count,

return ret;
}
+FOPS_READ_ITER_HELPER(mport_read);

-static ssize_t mport_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t mport_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct mport_cdev_priv *priv = filp->private_data;
+ struct mport_cdev_priv *priv = iocb->ki_filp->private_data;
struct rio_mport *mport = priv->md->mport;
+ size_t count = iov_iter_count(from);
struct rio_event event;
int len, ret;

@@ -2314,7 +2315,7 @@ static ssize_t mport_write(struct file *filp, const char __user *buf,

len = 0;
while ((count - len) >= (int)sizeof(event)) {
- if (copy_from_user(&event, buf, sizeof(event)))
+ if (!copy_from_iter_full(&event,sizeof(event), from))
return -EFAULT;

if (event.header != RIO_DOORBELL)
@@ -2327,7 +2328,6 @@ static ssize_t mport_write(struct file *filp, const char __user *buf,
return ret;

len += sizeof(event);
- buf += sizeof(event);
}

return len;
@@ -2338,8 +2338,8 @@ static const struct file_operations mport_fops = {
.open = mport_cdev_open,
.release = mport_cdev_release,
.poll = mport_cdev_poll,
- .read = mport_read,
- .write = mport_write,
+ .read_iter = mport_read_iter,
+ .write_iter = mport_write,
.mmap = mport_cdev_mmap,
.fasync = mport_cdev_fasync,
.unlocked_ioctl = mport_cdev_ioctl
--
2.43.0