staging: lustre: lustre: llite: use DIV_ROUND_UP
authorTapasweni Pathak <tapaswenipathak@gmail.com>
Wed, 8 Oct 2014 17:26:44 +0000 (22:56 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Oct 2014 02:29:17 +0000 (10:29 +0800)
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.

Coccinelle script used :

// <smpl>
@haskernel@
@@
@depends on haskernel@
expression n,d;
@@
(
- (n + d - 1) / d
+ DIV_ROUND_UP(n,d)
|
- (n + (d - 1)) / d
+ DIV_ROUND_UP(n,d)
)
@depends on haskernel@
expression n,d;
@@
- DIV_ROUND_UP((n),d)
+ DIV_ROUND_UP(n,d)
@depends on haskernel@
expression n,d;
@@
- DIV_ROUND_UP(n,(d))
+ DIV_ROUND_UP(n,d)
// </smpl>

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/rw26.c

index 4c77ae8b9350bce2a4db50e3ecd5e1e014257250..eac2131e6b85db01a5e1d08d333c32eb7c033189 100644 (file)
@@ -417,7 +417,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
 
                result = iov_iter_get_pages_alloc(iter, &pages, count, &offs);
                if (likely(result > 0)) {
-                       int n = (result + offs + PAGE_SIZE - 1) / PAGE_SIZE;
+                       int n = DIV_ROUND_UP(result + offs, PAGE_SIZE);
                        result = ll_direct_IO_26_seg(env, io, rw, inode,
                                                     file->f_mapping,
                                                     result, file_offset,
This page took 0.026078 seconds and 5 git commands to generate.