[PATCH 351/437] s390: hw_random: convert to read/write iterators

Jens Axboe posted 437 patches 1 year, 8 months ago
[PATCH 351/437] s390: hw_random: convert to read/write iterators
Posted by Jens Axboe 1 year, 8 months ago
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/hw_random/s390-trng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/s390-trng.c b/drivers/char/hw_random/s390-trng.c
index d27e32e9bfee..b1e1b896907c 100644
--- a/drivers/char/hw_random/s390-trng.c
+++ b/drivers/char/hw_random/s390-trng.c
@@ -53,9 +53,9 @@ static int trng_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t trng_read(struct file *file, char __user *ubuf,
-			 size_t nbytes, loff_t *ppos)
+static ssize_t trng_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t nbytes = iov_iter_count(to);
 	u8 buf[32];
 	u8 *p = buf;
 	unsigned int n;
@@ -85,12 +85,11 @@ static ssize_t trng_read(struct file *file, char __user *ubuf,
 		n = nbytes > PAGE_SIZE ? PAGE_SIZE : nbytes;
 		cpacf_trng(NULL, 0, p, n);
 		atomic64_add(n, &trng_dev_counter);
-		if (copy_to_user(ubuf, p, n)) {
+		if (!copy_to_iter_full(p, n, to)) {
 			ret = -EFAULT;
 			break;
 		}
 		nbytes -= n;
-		ubuf += n;
 		ret += n;
 	}
 
@@ -139,7 +138,7 @@ static const struct file_operations trng_fops = {
 	.owner		= THIS_MODULE,
 	.open		= &trng_open,
 	.release	= NULL,
-	.read		= &trng_read,
+	.read_iter	= trng_read,
 	.llseek		= noop_llseek,
 };
 
-- 
2.43.0