lkml.org 
[lkml]   [2024]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 351/437] s390: hw_random: convert to read/write iterators
    Date
    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

    \
     
     \ /
      Last update: 2024-05-27 16:36    [W:4.027 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site