[PATCH 316/437] drivers/net/ppp: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 12:58:04 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/net/ppp/ppp_generic.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index fe380fe196e7..6601b6c3e2b2 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -492,11 +492,12 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
out:
return ret;
}
+FOPS_READ_ITER_HELPER(ppp_read);

-static ssize_t ppp_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t ppp_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct ppp_file *pf = file->private_data;
+ struct ppp_file *pf = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
struct sk_buff *skb;
ssize_t ret;

@@ -511,7 +512,7 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,
goto out;
skb_reserve(skb, pf->hdrlen);
ret = -EFAULT;
- if (copy_from_user(skb_put(skb, count), buf, count)) {
+ if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
kfree_skb(skb);
goto out;
}
@@ -1092,8 +1093,8 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,

static const struct file_operations ppp_device_fops = {
.owner = THIS_MODULE,
- .read = ppp_read,
- .write = ppp_write,
+ .read_iter = ppp_read_iter,
+ .write_iter = ppp_write,
.poll = ppp_poll,
.unlocked_ioctl = ppp_ioctl,
#ifdef CONFIG_COMPAT
--
2.43.0