public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Wu Bo <wubo40@huawei.com>
To: <viro@zeniv.linux.org.uk>, <herbert@gondor.apana.org.au>,
	<davem@davemloft.net>, <linux-fsdevel@vger.kernel.org>,
	<linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: [PATCH 1/2] crypto: af_alg - use DIV_ROUND_UP helper macro for calculations
Date: Tue, 25 May 2021 16:15:19 +0800	[thread overview]
Message-ID: <1621930520-515336-2-git-send-email-wubo40@huawei.com> (raw)
In-Reply-To: <1621930520-515336-1-git-send-email-wubo40@huawei.com>

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);
 	if (WARN_ON(npages == 0))
 		return -EINVAL;
 	/* Add one extra for linking */
-- 
1.8.3.1


  reply	other threads:[~2021-05-25  8:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  8:15 [PATCH 0/2] use DIV_ROUND_UP helper macro for calculations Wu Bo
2021-05-25  8:15 ` Wu Bo [this message]
2021-05-25  8:37   ` [PATCH 1/2] crypto: af_alg - " Christophe Leroy
2021-05-26  8:31     ` Dave Chinner
2021-06-03 12:30   ` Herbert Xu
2021-05-25  8:15 ` [PATCH 2/2] fs: direct-io: " Wu Bo
2021-05-25  8:38   ` Christophe Leroy
2021-05-25  8:41 ` [PATCH 0/2] " Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1621930520-515336-2-git-send-email-wubo40@huawei.com \
    --to=wubo40@huawei.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linfeilong@huawei.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox