[PATCH 222/437] drivers/isdn: convert to read/write iterators

Jens Axboe
2024-04-11T15:37:53Z

drivers/isdn/capi/capi.c | 22 +++++++++++-----------
drivers/isdn/mISDN/timerdev.c | 16 ++++++++--------
2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 3ed257334562..6b613e03d85b 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -648,10 +648,10 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)

/* -------- file_operations for capidev ----------------------------- */

-static ssize_t
-capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct capidev *cdev = file->private_data;
+ struct capidev *cdev = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
struct sk_buff *skb;
size_t copied;
int err;
@@ -661,7 +661,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)

skb = skb_dequeue(&cdev->recvqueue);
if (!skb) {
- if (file->f_flags & O_NONBLOCK)
+ if (iocb->ki_filp->f_flags & O_NONBLOCK)
return -EAGAIN;
err = wait_event_interruptible(cdev->recvwait,
(skb = skb_dequeue(&cdev->recvqueue)));
@@ -672,7 +672,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
skb_queue_head(&cdev->recvqueue, skb);
return -EMSGSIZE;
}
- if (copy_to_user(buf, skb->data, skb->len)) {
+ if (!copy_to_iter_full(skb->data, skb->len, to)) {
skb_queue_head(&cdev->recvqueue, skb);
return -EFAULT;
}
@@ -683,10 +683,10 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
return copied;
}

-static ssize_t
-capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct capidev *cdev = file->private_data;
+ struct capidev *cdev = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
struct sk_buff *skb;
u16 mlen;

@@ -700,7 +700,7 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos
if (!skb)
return -ENOMEM;

- if (copy_from_user(skb_put(skb, count), buf, count)) {
+ if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
kfree_skb(skb);
return -EFAULT;
}
@@ -1025,8 +1025,8 @@ static const struct file_operations capi_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
- .read = capi_read,
- .write = capi_write,
+ .read_iter = capi_read,
+ .write_iter = capi_write,
.poll = capi_poll,
.unlocked_ioctl = capi_unlocked_ioctl,
#ifdef CONFIG_COMPAT
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 83d6b484d3c6..cf52b08e2fad 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -89,17 +89,17 @@ mISDN_close(struct inode *ino, struct file *filep)
return 0;
}

-static ssize_t
-mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
+static ssize_t mISDN_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct mISDNtimerdev *dev = filep->private_data;
+ struct mISDNtimerdev *dev = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
struct list_head *list = &dev->expired;
struct mISDNtimer *timer;
int ret = 0;

if (*debug & DEBUG_TIMER)
- printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__,
- filep, buf, (int)count, off);
+ printk(KERN_DEBUG "%s(%p, %d)\n", __func__,
+ iocb->ki_filp, (int)count);

if (count < sizeof(int))
return -ENOSPC;
@@ -107,7 +107,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
spin_lock_irq(&dev->lock);
while (list_empty(list) && (dev->work == 0)) {
spin_unlock_irq(&dev->lock);
- if (filep->f_flags & O_NONBLOCK)
+ if (iocb->ki_filp->f_flags & O_NONBLOCK)
return -EAGAIN;
wait_event_interruptible(dev->wait, (dev->work ||
!list_empty(list)));
@@ -121,7 +121,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
timer = list_first_entry(list, struct mISDNtimer, list);
list_del(&timer->list);
spin_unlock_irq(&dev->lock);
- if (put_user(timer->id, (int __user *)buf))
+ if (put_iter(timer->id, to))
ret = -EFAULT;
else
ret = sizeof(int);
@@ -261,7 +261,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)

static const struct file_operations mISDN_fops = {
.owner = THIS_MODULE,
- .read = mISDN_read,
+ .read_iter = mISDN_read,
.poll = mISDN_poll,
.unlocked_ioctl = mISDN_ioctl,
.open = mISDN_open,
--
2.43.0