crypto: af_alg - use DIV_ROUND_UP helper macro for calculations
authorWu Bo <wubo40@huawei.com>
Tue, 25 May 2021 08:15:19 +0000 (16:15 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 3 Jun 2021 12:24:04 +0000 (20:24 +0800)
Replace open coded divisor calculations with the DIV_ROUND_UP kernel
macro for better readability.

Signed-off-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/af_alg.c

index 18cc82dc4a42f0804e9439ee7b36ece1bd9406b5..8bd288d2b089b0348bd957bd3d3e93462a29a3cd 100644 (file)
@@ -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);
        if (WARN_ON(npages == 0))
                return -EINVAL;
        /* Add one extra for linking */