[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-356-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:18:15 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 355/437] arch/um: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
arch/um/drivers/harddog_kern.c | 6 +++---
arch/um/drivers/hostaudio_kern.c | 22 +++++++++++-----------
arch/um/drivers/mmapper_kern.c | 16 +++++++---------
3 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index 60d1c6cab8a9..77fa33f229f2 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -109,9 +109,9 @@ static int harddog_release(struct inode *inode, struct file *file)
return 0;
}
-static ssize_t harddog_write(struct file *file, const char __user *data, size_t len,
- loff_t *ppos)
+static ssize_t harddog_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t len = iov_iter_count(from);
/*
* Refresh the timer.
*/
@@ -158,7 +158,7 @@ static long harddog_ioctl(struct file *file,
static const struct file_operations harddog_fops = {
.owner = THIS_MODULE,
- .write = harddog_write,
+ .write_iter = harddog_write,
.unlocked_ioctl = harddog_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = harddog_open,
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index c42b793bce65..8ea3bb32867c 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -67,10 +67,10 @@ static DEFINE_MUTEX(hostaudio_mutex);
/* /dev/dsp file operations */
-static ssize_t hostaudio_read(struct file *file, char __user *buffer,
- size_t count, loff_t *ppos)
+static ssize_t hostaudio_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct hostaudio_state *state = file->private_data;
+ struct hostaudio_state *state = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
void *kbuf;
int err;
@@ -86,7 +86,7 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
if (err < 0)
goto out;
- if (copy_to_user(buffer, kbuf, err))
+ if (!copy_to_iter_full(kbuf, err, to))
err = -EFAULT;
out:
@@ -94,10 +94,10 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
return err;
}
-static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
+static ssize_t hostaudio_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct hostaudio_state *state = file->private_data;
+ struct hostaudio_state *state = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
void *kbuf;
int err;
@@ -105,14 +105,14 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
#endif
- kbuf = memdup_user(buffer, count);
+ kbuf = iterdup(from, count);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
err = os_write_file(state->fd, kbuf, count);
if (err < 0)
goto out;
- *ppos += err;
+ iocb->ki_pos += err;
out:
kfree(kbuf);
@@ -292,8 +292,8 @@ static int hostmixer_release(struct inode *inode, struct file *file)
static const struct file_operations hostaudio_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .read = hostaudio_read,
- .write = hostaudio_write,
+ .read_iter = hostaudio_read,
+ .write_iter = hostaudio_write,
.poll = hostaudio_poll,
.unlocked_ioctl = hostaudio_ioctl,
.compat_ioctl = compat_ptr_ioctl,
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 807cd3358740..db66090177d4 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -26,19 +26,17 @@ static unsigned long mmapper_size;
static unsigned long p_buf;
static char *v_buf;
-static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
- loff_t *ppos)
+static ssize_t mmapper_read(struct kiocb *iocb, struct iov_iter *to)
{
- return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
+ return simple_copy_to_iter(v_buf, &iocb->ki_pos, mmapper_size, to);
}
-static ssize_t mmapper_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t mmapper_write(struct kiocb *iocb, struct iov_iter *from)
{
- if (*ppos > mmapper_size)
+ if (iocb->ki_pos > mmapper_size)
return -EINVAL;
- return simple_write_to_buffer(v_buf, mmapper_size, ppos, buf, count);
+ return simple_copy_from_iter(v_buf, &iocb->ki_pos, mmapper_size, from);
}
static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -82,8 +80,8 @@ static int mmapper_release(struct inode *inode, struct file *file)
static const struct file_operations mmapper_fops = {
.owner = THIS_MODULE,
- .read = mmapper_read,
- .write = mmapper_write,
+ .read_iter = mmapper_read,
+ .write_iter = mmapper_write,
.unlocked_ioctl = mmapper_ioctl,
.mmap = mmapper_mmap,
.open = mmapper_open,
--
2.43.0
Powered by blists - more mailing lists