Skip to content

Commit

Permalink
crypto: af_alg - use DIV_ROUND_UP helper macro for calculations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wu Bo authored and herbertx committed Jun 3, 2021
1 parent e9009fb commit 7551a07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 7551a07

Please sign in to comment.