[PATCH 078/437] kernel/time: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 11:56:33 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
kernel/time/posix-clock.c | 3 ++-
kernel/time/test_udelay.c | 10 +++++-----
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 4782edcbe7b9..766ff113753a 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -54,6 +54,7 @@ static ssize_t posix_clock_read(struct file *fp, char __user *buf,

return err;
}
+FOPS_READ_ITER_HELPER(posix_clock_read);

static __poll_t posix_clock_poll(struct file *fp, poll_table *wait)
{
@@ -169,7 +170,7 @@ static int posix_clock_release(struct inode *inode, struct file *fp)
static const struct file_operations posix_clock_file_operations = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .read = posix_clock_read,
+ .read_iter = posix_clock_read_iter,
.poll = posix_clock_poll,
.unlocked_ioctl = posix_clock_ioctl,
.open = posix_clock_open,
diff --git a/kernel/time/test_udelay.c b/kernel/time/test_udelay.c
index 20d5df631570..9b6e832f4f47 100644
--- a/kernel/time/test_udelay.c
+++ b/kernel/time/test_udelay.c
@@ -96,9 +96,9 @@ static int udelay_test_open(struct inode *inode, struct file *file)
return single_open(file, udelay_test_show, inode->i_private);
}

-static ssize_t udelay_test_write(struct file *file, const char __user *buf,
- size_t count, loff_t *pos)
+static ssize_t udelay_test_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
char lbuf[32];
int ret;
int usecs;
@@ -107,7 +107,7 @@ static ssize_t udelay_test_write(struct file *file, const char __user *buf,
if (count >= sizeof(lbuf))
return -EINVAL;

- if (copy_from_user(lbuf, buf, count))
+ if (!copy_from_iter_full(lbuf, count, from))
return -EFAULT;
lbuf[count] = '\0';

@@ -128,8 +128,8 @@ static ssize_t udelay_test_write(struct file *file, const char __user *buf,
static const struct file_operations udelay_test_debugfs_ops = {
.owner = THIS_MODULE,
.open = udelay_test_open,
- .read = seq_read,
- .write = udelay_test_write,
+ .read_iter = seq_read_iter,
+ .write_iter = udelay_test_write,
.llseek = seq_lseek,
.release = single_release,
};
--
2.43.0