[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-354-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:18:13 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 353/437] arch/s390: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
arch/s390/crypto/prng.c | 18 ++++++++----------
arch/s390/hypfs/hypfs_dbfs.c | 11 +++++------
arch/s390/kernel/debug.c | 29 +++++++++++++----------------
arch/s390/kernel/sysinfo.c | 6 +++---
arch/s390/pci/pci_debug.c | 12 ++++++------
5 files changed, 35 insertions(+), 41 deletions(-)
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index a077087bc6cc..472ff3fe73a9 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -509,9 +509,9 @@ static int prng_open(struct inode *inode, struct file *file)
}
-static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
- size_t nbytes, loff_t *ppos)
+static ssize_t prng_tdes_read(struct kiocb *iocb, struct iov_iter *to)
{
+ size_t nbytes = iov_iter_count(to);
int chunk, n, ret = 0;
/* lock prng_data struct */
@@ -570,14 +570,13 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
prng_data->prngws.byte_counter += n;
prng_data->prngws.reseed_counter += n;
- if (copy_to_user(ubuf, prng_data->buf, chunk)) {
+ if (!copy_to_iter_full(prng_data->buf, chunk, to)) {
ret = -EFAULT;
break;
}
nbytes -= chunk;
ret += chunk;
- ubuf += chunk;
}
/* unlock prng_data struct */
@@ -587,9 +586,9 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
}
-static ssize_t prng_sha512_read(struct file *file, char __user *ubuf,
- size_t nbytes, loff_t *ppos)
+static ssize_t prng_sha512_read(struct kiocb *iocb, struct iov_iter *to)
{
+ size_t nbytes = iov_iter_count(to);
int n, ret = 0;
u8 *p;
@@ -640,12 +639,11 @@ static ssize_t prng_sha512_read(struct file *file, char __user *ubuf,
prng_data->rest = 0;
}
}
- if (copy_to_user(ubuf, p, n)) {
+ if (!copy_to_iter_full(p, n, to)) {
ret = -EFAULT;
break;
}
memzero_explicit(p, n);
- ubuf += n;
nbytes -= n;
ret += n;
}
@@ -663,14 +661,14 @@ static const struct file_operations prng_sha512_fops = {
.owner = THIS_MODULE,
.open = &prng_open,
.release = NULL,
- .read = &prng_sha512_read,
+ .read_iter = &prng_sha512_read,
.llseek = noop_llseek,
};
static const struct file_operations prng_tdes_fops = {
.owner = THIS_MODULE,
.open = &prng_open,
.release = NULL,
- .read = &prng_tdes_read,
+ .read_iter = &prng_tdes_read,
.llseek = noop_llseek,
};
diff --git a/arch/s390/hypfs/hypfs_dbfs.c b/arch/s390/hypfs/hypfs_dbfs.c
index 4024599eb448..964247caf5fb 100644
--- a/arch/s390/hypfs/hypfs_dbfs.c
+++ b/arch/s390/hypfs/hypfs_dbfs.c
@@ -28,17 +28,16 @@ static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)
kfree(data);
}
-static ssize_t dbfs_read(struct file *file, char __user *buf,
- size_t size, loff_t *ppos)
+static ssize_t dbfs_read(struct kiocb *iocb, struct iov_iter *to)
{
struct hypfs_dbfs_data *data;
struct hypfs_dbfs_file *df;
ssize_t rc;
- if (*ppos != 0)
+ if (iocb->ki_pos != 0)
return 0;
- df = file_inode(file)->i_private;
+ df = file_inode(iocb->ki_filp)->i_private;
mutex_lock(&df->lock);
data = hypfs_dbfs_data_alloc(df);
if (!data) {
@@ -53,7 +52,7 @@ static ssize_t dbfs_read(struct file *file, char __user *buf,
}
mutex_unlock(&df->lock);
- rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size);
+ rc = simple_copy_to_iter(data->buf, &iocb->ki_pos, data->size, to);
hypfs_dbfs_data_free(data);
return rc;
}
@@ -73,7 +72,7 @@ static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}
static const struct file_operations dbfs_ops = {
- .read = dbfs_read,
+ .read_iter = dbfs_read,
.llseek = no_llseek,
.unlocked_ioctl = dbfs_ioctl,
};
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 85328a0ef3b6..2ba1ee0a0f1d 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -66,10 +66,8 @@ typedef struct {
/* internal function prototyes */
static int debug_init(void);
-static ssize_t debug_output(struct file *file, char __user *user_buf,
- size_t user_len, loff_t *offset);
-static ssize_t debug_input(struct file *file, const char __user *user_buf,
- size_t user_len, loff_t *offset);
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t debug_input_iter(struct kiocb *iocb, struct iov_iter *from);
static int debug_open(struct inode *inode, struct file *file);
static int debug_close(struct inode *inode, struct file *file);
static debug_info_t *debug_info_create(const char *name, int pages_per_area,
@@ -159,8 +157,8 @@ static int debug_critical;
static const struct file_operations debug_file_ops = {
.owner = THIS_MODULE,
- .read = debug_output,
- .write = debug_input,
+ .read_iter = debug_output,
+ .write_iter = debug_input_iter,
.open = debug_open,
.release = debug_close,
.llseek = no_llseek,
@@ -452,17 +450,15 @@ static inline int debug_next_entry(file_private_info_t *p_info)
* - called for user read()
* - copies formated debug entries to the user buffer
*/
-static ssize_t debug_output(struct file *file, /* file descriptor */
- char __user *user_buf, /* user buffer */
- size_t len, /* length of buffer */
- loff_t *offset) /* offset in the file */
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to)
{
size_t count = 0;
size_t entry_offset;
file_private_info_t *p_info;
+ size_t len = iov_iter_count(to);
- p_info = (file_private_info_t *) file->private_data;
- if (*offset != p_info->offset)
+ p_info = (file_private_info_t *) iocb->ki_filp->private_data;
+ if (iocb->ki_pos != p_info->offset)
return -EPIPE;
if (p_info->act_area >= p_info->debug_info_snap->nr_areas)
return 0;
@@ -478,8 +474,8 @@ static ssize_t debug_output(struct file *file, /* file descriptor */
user_buf_residue = len-count;
copy_size = min(user_buf_residue, formatted_line_residue);
if (copy_size) {
- if (copy_to_user(user_buf + count, p_info->temp_buf
- + entry_offset, copy_size))
+ if (!copy_to_iter_full(p_info->temp_buf
+ + entry_offset, copy_size, to))
return -EFAULT;
count += copy_size;
entry_offset += copy_size;
@@ -491,9 +487,9 @@ static ssize_t debug_output(struct file *file, /* file descriptor */
}
}
out:
- p_info->offset = *offset + count;
+ p_info->offset = iocb->ki_pos + count;
p_info->act_entry_offset = entry_offset;
- *offset = p_info->offset;
+ iocb->ki_pos = p_info->offset;
return count;
}
@@ -520,6 +516,7 @@ static ssize_t debug_input(struct file *file, const char __user *user_buf,
mutex_unlock(&debug_mutex);
return rc; /* number of input characters */
}
+FOPS_WRITE_ITER_HELPER(debug_input);
/*
* debug_open:
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 2be30a96696a..84cca91e86ff 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -497,7 +497,7 @@ static int stsi_open_##fc##_##s1##_##s2(struct inode *inode, struct file *file)\
static const struct file_operations stsi_##fc##_##s1##_##s2##_fs_ops = { \
.open = stsi_open_##fc##_##s1##_##s2, \
.release = stsi_release, \
- .read = stsi_read, \
+ .read_iter = stsi_read, \
.llseek = no_llseek, \
};
@@ -507,9 +507,9 @@ static int stsi_release(struct inode *inode, struct file *file)
return 0;
}
-static ssize_t stsi_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
+static ssize_t stsi_read(struct kiocb *iocb, struct iov_iter *to)
{
- return simple_read_from_buffer(buf, size, ppos, file->private_data, PAGE_SIZE);
+ return simple_copy_to_iter(iocb->ki_filp->private_data, &iocb->ki_pos, PAGE_SIZE, to);
}
STSI_FILE( 1, 1, 1);
diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
index 2cb5043a997d..9c4b1eb26103 100644
--- a/arch/s390/pci/pci_debug.c
+++ b/arch/s390/pci/pci_debug.c
@@ -134,17 +134,17 @@ static int pci_perf_show(struct seq_file *m, void *v)
return 0;
}
-static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
- size_t count, loff_t *off)
+static ssize_t pci_perf_seq_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct zpci_dev *zdev = ((struct seq_file *) file->private_data)->private;
+ struct zpci_dev *zdev = ((struct seq_file *) iocb->ki_filp->private_data)->private;
+ size_t count = iov_iter_count(from);
unsigned long val;
int rc;
if (!zdev)
return 0;
- rc = kstrtoul_from_user(ubuf, count, 10, &val);
+ rc = kstrtoul_from_iter(from, count, 10, &val);
if (rc)
return rc;
@@ -169,8 +169,8 @@ static int pci_perf_seq_open(struct inode *inode, struct file *filp)
static const struct file_operations debugfs_pci_perf_fops = {
.open = pci_perf_seq_open,
- .read = seq_read,
- .write = pci_perf_seq_write,
+ .read_iter = seq_read_iter,
+ .write_iter = pci_perf_seq_write,
.llseek = seq_lseek,
.release = single_release,
};
--
2.43.0
Powered by blists - more mailing lists