[PATCH 334/437] arch/mips: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 12:57:10 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
arch/mips/kernel/rtlx.c | 6 ++++--
arch/mips/kernel/vpe.c | 14 +++++++-------
arch/mips/mm/sc-debugfs.c | 16 +++++++---------
3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 18c509c59f33..6e3bf6d4c64b 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -369,6 +369,7 @@ static ssize_t file_read(struct file *file, char __user *buffer, size_t count,

return rtlx_read(minor, buffer, count);
}
+FOPS_READ_ITER_HELPER(file_read);

static ssize_t file_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
@@ -390,13 +391,14 @@ static ssize_t file_write(struct file *file, const char __user *buffer,

return rtlx_write(minor, buffer, count);
}
+FOPS_WRITE_ITER_HELPER(file_write);

const struct file_operations rtlx_fops = {
.owner = THIS_MODULE,
.open = file_open,
.release = file_release,
- .write = file_write,
- .read = file_read,
+ .write_iter = file_write_iter,
+ .read_iter = file_read_iter,
.poll = file_poll,
.llseek = noop_llseek,
};
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 737d0d4fdcd3..55db91fba7b0 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -834,13 +834,13 @@ static int vpe_release(struct inode *inode, struct file *filp)
#endif
}

-static ssize_t vpe_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
+static ssize_t vpe_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
size_t ret = count;
struct vpe *v;

- if (iminor(file_inode(file)) != VPE_MODULE_MINOR)
+ if (iminor(file_inode(iocb->ki_filp)) != VPE_MODULE_MINOR)
return -ENODEV;

v = get_vpe(aprp_cpu_index());
@@ -853,19 +853,19 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
return -ENOMEM;
}

- count -= copy_from_user(v->pbuffer + v->len, buffer, count);
- if (!count)
+ ret !copy_from_iter_full(v->pbuffer + v->len, count, from);
+ if (!ret)
return -EFAULT;

v->len += count;
- return ret;
+ return count;
}

const struct file_operations vpe_fops = {
.owner = THIS_MODULE,
.open = vpe_open,
.release = vpe_release,
- .write = vpe_write,
+ .write_iter = vpe_write,
.llseek = noop_llseek,
};

diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c
index 80ff3947157d..d85e8b95d9b5 100644
--- a/arch/mips/mm/sc-debugfs.c
+++ b/arch/mips/mm/sc-debugfs.c
@@ -10,8 +10,7 @@
#include <linux/debugfs.h>
#include <linux/init.h>

-static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_read(struct kiocb *iocb, struct iov_iter *to)
{
bool enabled = bc_prefetch_is_enabled();
char buf[3];
@@ -20,17 +19,16 @@ static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
buf[1] = '\n';
buf[2] = 0;

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

-static ssize_t sc_prefetch_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
bool enabled;
int err;

- err = kstrtobool_from_user(user_buf, count, &enabled);
+ err = kstrtobool_from_iter(from, count, &enabled);
if (err)
return err;

@@ -45,8 +43,8 @@ static ssize_t sc_prefetch_write(struct file *file,
static const struct file_operations sc_prefetch_fops = {
.open = simple_open,
.llseek = default_llseek,
- .read = sc_prefetch_read,
- .write = sc_prefetch_write,
+ .read_iter = sc_prefetch_read,
+ .write_iter = sc_prefetch_write,
};

static int __init sc_debugfs_init(void)
--
2.43.0