| From | Jens Axboe <> | Subject | [PATCH 110/437] fs/pstore: convert to read/write iterators | Date | Thu, 11 Apr 2024 09:14:10 -0600 |
| |
Signed-off-by: Jens Axboe <axboe@kernel.dk> --- fs/pstore/ftrace.c | 16 ++++++++-------- fs/pstore/inode.c | 13 ++++++------- fs/pstore/pmsg.c | 3 ++- 3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c index 776cae20af4e..8c7244df7787 100644 --- a/fs/pstore/ftrace.c +++ b/fs/pstore/ftrace.c @@ -88,13 +88,14 @@ static int pstore_set_ftrace_enabled(bool on) return ret; } -static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf, - size_t count, loff_t *ppos) +static ssize_t pstore_ftrace_knob_write(struct kiocb *iocb, + struct iov_iter *from) { + size_t count = iov_iter_count(from); u8 on; ssize_t ret; - ret = kstrtou8_from_user(buf, count, 2, &on); + ret = kstrtou8_from_iter(from, count, 2, &on); if (ret) return ret; @@ -108,18 +109,17 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf, return ret; } -static ssize_t pstore_ftrace_knob_read(struct file *f, char __user *buf, - size_t count, loff_t *ppos) +static ssize_t pstore_ftrace_knob_read(struct kiocb *iocb, struct iov_iter *to) { char val[] = { '0' + pstore_ftrace_enabled, '\n' }; - return simple_read_from_buffer(buf, count, ppos, val, sizeof(val)); + return simple_copy_to_iter(val, &iocb->ki_pos, sizeof(val), to); } static const struct file_operations pstore_knob_fops = { .open = simple_open, - .read = pstore_ftrace_knob_read, - .write = pstore_ftrace_knob_write, + .read_iter = pstore_ftrace_knob_read, + .write_iter = pstore_ftrace_knob_write, }; static struct dentry *pstore_ftrace_dir; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 56815799ce79..581f014149a9 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -127,16 +127,15 @@ static const struct seq_operations pstore_ftrace_seq_ops = { .show = pstore_ftrace_seq_show, }; -static ssize_t pstore_file_read(struct file *file, char __user *userbuf, - size_t count, loff_t *ppos) +static ssize_t pstore_file_read(struct kiocb *iocb, struct iov_iter *to) { - struct seq_file *sf = file->private_data; + struct seq_file *sf = iocb->ki_filp->private_data; struct pstore_private *ps = sf->private; if (ps->record->type == PSTORE_TYPE_FTRACE) - return seq_read(file, userbuf, count, ppos); - return simple_read_from_buffer(userbuf, count, ppos, - ps->record->buf, ps->total_size); + return seq_read_iter(iocb, to); + return simple_copy_to_iter(ps->record->buf, &iocb->ki_pos, + ps->total_size, to); } static int pstore_file_open(struct inode *inode, struct file *file) @@ -170,7 +169,7 @@ static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence) static const struct file_operations pstore_file_operations = { .open = pstore_file_open, - .read = pstore_file_read, + .read_iter = pstore_file_read, .llseek = pstore_file_llseek, .release = seq_release, }; diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c index 55f139afa327..83fef50ecce5 100644 --- a/fs/pstore/pmsg.c +++ b/fs/pstore/pmsg.c @@ -33,11 +33,12 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf, mutex_unlock(&pmsg_lock); return ret ? ret : count; } +FOPS_WRITE_ITER_HELPER(write_pmsg); static const struct file_operations pmsg_fops = { .owner = THIS_MODULE, .llseek = noop_llseek, - .write = write_pmsg, + .write_iter = write_pmsg_iter, }; static struct class *pmsg_class; -- 2.43.0
|