mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: direct-io: use DIV_ROUND_UP helper macro for calculations
@ 2021-11-08  3:10 Wu Bo
  2021-11-08  3:17 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Wu Bo @ 2021-11-08  3:10 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel, linfeilong, wubo40

Replace open coded divisor calculations with the DIV_ROUND_UP kernel
macro for better readability.

Signed-off-by: Wu Bo <wubo40@huawei.com>
---
 fs/direct-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 6544435..e5869c2 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -194,7 +194,7 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio)
 		iov_iter_advance(sdio->iter, ret);
 		ret += sdio->from;
 		sdio->head = 0;
-		sdio->tail = (ret + PAGE_SIZE - 1) / PAGE_SIZE;
+		sdio->tail = DIV_ROUND_UP(ret, PAGE_SIZE);
 		sdio->to = ((ret - 1) & (PAGE_SIZE - 1)) + 1;
 		return 0;
 	}
-- 
2.29.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-08  4:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08  3:10 [PATCH] fs: direct-io: use DIV_ROUND_UP helper macro for calculations Wu Bo
2021-11-08  3:17 ` Joe Perches
2021-11-08  3:52   ` Matthew Wilcox
2021-11-08  4:02     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®