[PATCH 347/437] s390: zcore: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 13:00:06 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/s390/char/zcore.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
index 0969fa01df58..8f5c890605ce 100644
--- a/drivers/s390/char/zcore.c
+++ b/drivers/s390/char/zcore.c
@@ -134,8 +134,7 @@ static void release_hsa(void)
hsa_available = 0;
}

-static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t zcore_reipl_write(struct kiocb *iocb, struct iov_iter *from)
{
if (zcore_ipl_block) {
diag308(DIAG308_SET, zcore_ipl_block);
@@ -147,7 +146,7 @@ static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
else
diag308(DIAG308_LOAD_NORMAL, NULL);
}
- return count;
+ return iov_iter_count(from);
}

static int zcore_reipl_open(struct inode *inode, struct file *filp)
@@ -162,14 +161,13 @@ static int zcore_reipl_release(struct inode *inode, struct file *filp)

static const struct file_operations zcore_reipl_fops = {
.owner = THIS_MODULE,
- .write = zcore_reipl_write,
+ .write_iter = zcore_reipl_write,
.open = zcore_reipl_open,
.release = zcore_reipl_release,
.llseek = no_llseek,
};

-static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_read(struct kiocb *iocb, struct iov_iter *to)
{
static char str[18];

@@ -177,28 +175,27 @@ static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
snprintf(str, sizeof(str), "%lx\n", sclp.hsa_size);
else
snprintf(str, sizeof(str), "0\n");
- return simple_read_from_buffer(buf, count, ppos, str, strlen(str));
+ return simple_copy_to_iter(str, &iocb->ki_pos, strlen(str), to);
}

-static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_write(struct kiocb *iocb, struct iov_iter *from)
{
char value;

- if (*ppos != 0)
+ if (iocb->ki_pos != 0)
return -EPIPE;
- if (copy_from_user(&value, buf, 1))
+ if (!copy_from_iter_full(&value, 1, from))
return -EFAULT;
if (value != '0')
return -EINVAL;
release_hsa();
- return count;
+ return iov_iter_count(from);
}

static const struct file_operations zcore_hsa_fops = {
.owner = THIS_MODULE,
- .write = zcore_hsa_write,
- .read = zcore_hsa_read,
+ .write_iter = zcore_hsa_write,
+ .read_iter = zcore_hsa_read,
.open = nonseekable_open,
.llseek = no_llseek,
};
--
2.43.0