[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-232-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:16:11 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 231/437] drivers/firewire: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
drivers/firewire/core-cdev.c | 15 +++++++--------
drivers/firewire/nosy.c | 18 ++++++++----------
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 6274b86eb943..ded5873c444b 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -301,9 +301,9 @@ static void queue_event(struct client *client, struct event *event,
wake_up_interruptible(&client->wait);
}
-static int dequeue_event(struct client *client,
- char __user *buffer, size_t count)
+static int dequeue_event(struct client *client, struct iov_iter *to)
{
+ size_t count = iov_iter_count(to);
struct event *event;
size_t size, total;
int i, ret;
@@ -326,7 +326,7 @@ static int dequeue_event(struct client *client,
total = 0;
for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) {
size = min(event->v[i].size, count - total);
- if (copy_to_user(buffer + total, event->v[i].data, size)) {
+ if (!copy_to_iter_full(event->v[i].data, size, to)) {
ret = -EFAULT;
goto out;
}
@@ -340,12 +340,11 @@ static int dequeue_event(struct client *client,
return ret;
}
-static ssize_t fw_device_op_read(struct file *file, char __user *buffer,
- size_t count, loff_t *offset)
+static ssize_t fw_device_op_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct client *client = file->private_data;
+ struct client *client = iocb->ki_filp->private_data;
- return dequeue_event(client, buffer, count);
+ return dequeue_event(client, to);
}
static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event,
@@ -1922,7 +1921,7 @@ const struct file_operations fw_device_ops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = fw_device_op_open,
- .read = fw_device_op_read,
+ .read_iter = fw_device_op_read,
.unlocked_ioctl = fw_device_op_ioctl,
.mmap = fw_device_op_mmap,
.release = fw_device_op_release,
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index b0d671db178a..d4e7f465afc4 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -133,8 +133,7 @@ packet_buffer_destroy(struct packet_buffer *buffer)
kfree(buffer->data);
}
-static int
-packet_buffer_get(struct client *client, char __user *data, size_t user_length)
+static int packet_buffer_get(struct client *client, struct iov_iter *to)
{
struct packet_buffer *buffer = &client->buffer;
size_t length;
@@ -154,15 +153,15 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
length = buffer->head->length;
if (&buffer->head->data[length] < end) {
- if (copy_to_user(data, buffer->head->data, length))
+ if (!copy_to_iter_full(buffer->head->data, length, to))
return -EFAULT;
buffer->head = (struct packet *) &buffer->head->data[length];
} else {
size_t split = end - buffer->head->data;
- if (copy_to_user(data, buffer->head->data, split))
+ if (!copy_to_iter_full(buffer->head->data, split, to))
return -EFAULT;
- if (copy_to_user(data + split, buffer->data, length - split))
+ if (!copy_to_iter_full(buffer->data, length - split, to))
return -EFAULT;
buffer->head = (struct packet *) &buffer->data[length - split];
}
@@ -332,12 +331,11 @@ nosy_poll(struct file *file, poll_table *pt)
return ret;
}
-static ssize_t
-nosy_read(struct file *file, char __user *buffer, size_t count, loff_t *offset)
+static ssize_t nosy_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct client *client = file->private_data;
+ struct client *client = iocb->ki_filp->private_data;
- return packet_buffer_get(client, buffer, count);
+ return packet_buffer_get(client, to);
}
static long
@@ -393,7 +391,7 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
static const struct file_operations nosy_ops = {
.owner = THIS_MODULE,
- .read = nosy_read,
+ .read_iter = nosy_read,
.unlocked_ioctl = nosy_ioctl,
.poll = nosy_poll,
.open = nosy_open,
--
2.43.0
Powered by blists - more mailing lists