aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Wilson <njw@osdl.org>2005-06-25 17:59:00 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 19:25:02 -0400
commit8c0e33c133021ee241e9d51255b9fb18eb34ef0e (patch)
tree30ddff7f7cf375c36d11d49352365a42b25e1def
parentf45494480f31342125870c1a184999d7c5a59471 (diff)
[PATCH] Use ALIGN to remove duplicate code
This patch makes use of ALIGN() to remove duplicate round-up code. Signed-off-by: Nick Wilson <njw@osdl.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/a.out.h2
-rw-r--r--kernel/resource.c2
-rw-r--r--lib/bitmap.c3
-rw-r--r--mm/bootmem.c6
4 files changed, 6 insertions, 7 deletions
diff --git a/include/linux/a.out.h b/include/linux/a.out.h
index af8a1dfa5c32..f913cc3e1b0d 100644
--- a/include/linux/a.out.h
+++ b/include/linux/a.out.h
@@ -138,7 +138,7 @@ enum machine_type {
138#endif 138#endif
139#endif 139#endif
140 140
141#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) 141#define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
142 142
143#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) 143#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
144 144
diff --git a/kernel/resource.c b/kernel/resource.c
index 52f696f11adf..26967e042201 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -263,7 +263,7 @@ static int find_resource(struct resource *root, struct resource *new,
263 new->start = min; 263 new->start = min;
264 if (new->end > max) 264 if (new->end > max)
265 new->end = max; 265 new->end = max;
266 new->start = (new->start + align - 1) & ~(align - 1); 266 new->start = ALIGN(new->start, align);
267 if (alignf) 267 if (alignf)
268 alignf(alignf_data, new, size, align); 268 alignf(alignf_data, new, size, align);
269 if (new->start < new->end && new->end - new->start >= size - 1) { 269 if (new->start < new->end && new->end - new->start >= size - 1) {
diff --git a/lib/bitmap.c b/lib/bitmap.c
index d1388a5ce89c..fb9371fdd44a 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -289,7 +289,6 @@ EXPORT_SYMBOL(__bitmap_weight);
289 289
290#define CHUNKSZ 32 290#define CHUNKSZ 32
291#define nbits_to_hold_value(val) fls(val) 291#define nbits_to_hold_value(val) fls(val)
292#define roundup_power2(val,modulus) (((val) + (modulus) - 1) & ~((modulus) - 1))
293#define unhex(c) (isdigit(c) ? (c - '0') : (toupper(c) - 'A' + 10)) 292#define unhex(c) (isdigit(c) ? (c - '0') : (toupper(c) - 'A' + 10))
294#define BASEDEC 10 /* fancier cpuset lists input in decimal */ 293#define BASEDEC 10 /* fancier cpuset lists input in decimal */
295 294
@@ -316,7 +315,7 @@ int bitmap_scnprintf(char *buf, unsigned int buflen,
316 if (chunksz == 0) 315 if (chunksz == 0)
317 chunksz = CHUNKSZ; 316 chunksz = CHUNKSZ;
318 317
319 i = roundup_power2(nmaskbits, CHUNKSZ) - CHUNKSZ; 318 i = ALIGN(nmaskbits, CHUNKSZ) - CHUNKSZ;
320 for (; i >= 0; i -= CHUNKSZ) { 319 for (; i >= 0; i -= CHUNKSZ) {
321 chunkmask = ((1ULL << chunksz) - 1); 320 chunkmask = ((1ULL << chunksz) - 1);
322 word = i / BITS_PER_LONG; 321 word = i / BITS_PER_LONG;
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 45275f1f8947..c1330cc19783 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -65,7 +65,7 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat,
65 pgdat->pgdat_next = pgdat_list; 65 pgdat->pgdat_next = pgdat_list;
66 pgdat_list = pgdat; 66 pgdat_list = pgdat;
67 67
68 mapsize = (mapsize + (sizeof(long) - 1UL)) & ~(sizeof(long) - 1UL); 68 mapsize = ALIGN(mapsize, sizeof(long));
69 bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); 69 bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT);
70 bdata->node_boot_start = (start << PAGE_SHIFT); 70 bdata->node_boot_start = (start << PAGE_SHIFT);
71 bdata->node_low_pfn = end; 71 bdata->node_low_pfn = end;
@@ -186,7 +186,7 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
186 } else 186 } else
187 preferred = 0; 187 preferred = 0;
188 188
189 preferred = ((preferred + align - 1) & ~(align - 1)) >> PAGE_SHIFT; 189 preferred = ALIGN(preferred, align) >> PAGE_SHIFT;
190 preferred += offset; 190 preferred += offset;
191 areasize = (size+PAGE_SIZE-1)/PAGE_SIZE; 191 areasize = (size+PAGE_SIZE-1)/PAGE_SIZE;
192 incr = align >> PAGE_SHIFT ? : 1; 192 incr = align >> PAGE_SHIFT ? : 1;
@@ -227,7 +227,7 @@ found:
227 */ 227 */
228 if (align < PAGE_SIZE && 228 if (align < PAGE_SIZE &&
229 bdata->last_offset && bdata->last_pos+1 == start) { 229 bdata->last_offset && bdata->last_pos+1 == start) {
230 offset = (bdata->last_offset+align-1) & ~(align-1); 230 offset = ALIGN(bdata->last_offset, align);
231 BUG_ON(offset > PAGE_SIZE); 231 BUG_ON(offset > PAGE_SIZE);
232 remaining_size = PAGE_SIZE-offset; 232 remaining_size = PAGE_SIZE-offset;
233 if (size < remaining_size) { 233 if (size < remaining_size) {