[PATCH 071/437] dma-debug: convert to read/write iterators

Jens Axboe
2024-04-11T15:33:43Z

kernel/dma/debug.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index a6e3792b15f8..4be49922129b 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -717,8 +717,7 @@ static void dma_entry_free(struct dma_debug_entry *entry)
* 2. Preallocate a given number of dma_debug_entry structs
*/

-static ssize_t filter_read(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t filter_read(struct kiocb *iocb, struct iov_iter *to)
{
char buf[NAME_MAX_LEN + 1];
unsigned long flags;
@@ -736,12 +735,12 @@ static ssize_t filter_read(struct file *file, char __user *user_buf,
len = scnprintf(buf, NAME_MAX_LEN + 1, "%s\n", current_driver_name);
read_unlock_irqrestore(&driver_name_lock, flags);

- return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
}

-static ssize_t filter_write(struct file *file, const char __user *userbuf,
- size_t count, loff_t *ppos)
+static ssize_t filter_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
char buf[NAME_MAX_LEN];
unsigned long flags;
size_t len;
@@ -754,7 +753,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
* need to copy to temporary buffer first
*/
len = min(count, (size_t)(NAME_MAX_LEN - 1));
- if (copy_from_user(buf, userbuf, len))
+ if (!copy_from_iter_full(buf, len, from))
return -EFAULT;

buf[len] = 0;
@@ -804,8 +803,8 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
}

static const struct file_operations filter_fops = {
- .read = filter_read,
- .write = filter_write,
+ .read_iter = filter_read,
+ .write_iter = filter_write,
.llseek = default_llseek,
};

--
2.43.0