LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/6] arch/x86/xen: Use DIV_ROUND_UP
@ 2008-02-14 15:14 Julia Lawall
0 siblings, 0 replies; only message in thread
From: Julia Lawall @ 2008-02-14 15:14 UTC (permalink / raw)
To: jeremy, xen-devel, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.
An extract of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@haskernel@
@@
#include <linux/kernel.h>
@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: Julia Lawall <julia@diku.dk>
---
diff -u -p a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c 2008-02-02 15:28:17.000000000 +0100
+++ b/arch/x86/xen/enlighten.c 2008-02-13 20:48:15.000000000 +0100
@@ -293,7 +293,7 @@ static void xen_load_gdt(const struct de
unsigned long *frames;
unsigned long va = dtr->address;
unsigned int size = dtr->size + 1;
- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+ unsigned pages = DIV_ROUND_UP(size, PAGE_SIZE);
int f;
struct multicall_space mcs;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-14 15:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-14 15:14 [PATCH 1/6] arch/x86/xen: Use DIV_ROUND_UP Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).