lkml.org 
[lkml]   [2021]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] crypto: af_alg - use DIV_ROUND_UP helper macro for calculations
Wu Bo <wubo40@huawei.com> a écrit :

> From: Wu Bo <wubo40@huawei.com>
>
> Replace open coded divisor calculations with the DIV_ROUND_UP kernel
> macro for better readability.
>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
> ---
> crypto/af_alg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/af_alg.c b/crypto/af_alg.c
> index 18cc82d..8bd288d 100644
> --- a/crypto/af_alg.c
> +++ b/crypto/af_alg.c
> @@ -411,7 +411,7 @@ int af_alg_make_sg(struct af_alg_sgl *sgl,
> struct iov_iter *iter, int len)
> if (n < 0)
> return n;
>
> - npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT;
> + npages = DIV_ROUND_UP(off + n, PAGE_SIZE);

You should use PFN_UP()

> if (WARN_ON(npages == 0))
> return -EINVAL;
> /* Add one extra for linking */
> --
> 1.8.3.1


\
 
 \ /
  Last update: 2021-05-25 10:35    [W:0.111 / U:1.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site