Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] bootwrapper: Use `unsigned long' for malloc sizes

Use `unsigned long' for malloc sizes, to match common practice and types used
by most callers and callees.
Also use `unsigned long' for integers representing pointers in simple_alloc.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@eu.sony.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Geert Uytterhoeven and committed by
Paul Mackerras
4ca478e6 e58923ed

+21 -20
+1 -1
arch/powerpc/boot/of.c
··· 173 173 return (void *) virt; 174 174 } 175 175 176 - static void *of_try_claim(u32 size) 176 + static void *of_try_claim(unsigned long size) 177 177 { 178 178 unsigned long addr = 0; 179 179
+4 -4
arch/powerpc/boot/ops.h
··· 23 23 struct platform_ops { 24 24 void (*fixups)(void); 25 25 void (*image_hdr)(const void *); 26 - void * (*malloc)(u32 size); 26 + void * (*malloc)(unsigned long size); 27 27 void (*free)(void *ptr); 28 28 void * (*realloc)(void *ptr, unsigned long size); 29 29 void (*exit)(void); ··· 79 79 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device); 80 80 int serial_console_init(void); 81 81 int ns16550_console_init(void *devp, struct serial_console_data *scdp); 82 - void *simple_alloc_init(char *base, u32 heap_size, u32 granularity, 83 - u32 max_allocs); 82 + void *simple_alloc_init(char *base, unsigned long heap_size, 83 + unsigned long granularity, unsigned long max_allocs); 84 84 extern void flush_cache(void *, unsigned long); 85 85 int dt_xlate_reg(void *node, int res, unsigned long *addr, 86 86 unsigned long *size); ··· 164 164 (char *)&linuxphandle, sizeof(u32)); 165 165 } 166 166 167 - static inline void *malloc(u32 size) 167 + static inline void *malloc(unsigned long size) 168 168 { 169 169 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; 170 170 }
+16 -15
arch/powerpc/boot/simple_alloc.c
··· 19 19 #define ENTRY_IN_USE 0x02 20 20 21 21 static struct alloc_info { 22 - u32 flags; 23 - u32 base; 24 - u32 size; 22 + unsigned long flags; 23 + unsigned long base; 24 + unsigned long size; 25 25 } *alloc_tbl; 26 26 27 - static u32 tbl_entries; 28 - static u32 alloc_min; 29 - static u32 next_base; 30 - static u32 space_left; 27 + static unsigned long tbl_entries; 28 + static unsigned long alloc_min; 29 + static unsigned long next_base; 30 + static unsigned long space_left; 31 31 32 32 /* 33 33 * First time an entry is used, its base and size are set. 34 34 * An entry can be freed and re-malloc'd but its base & size don't change. 35 35 * Should be smart enough for needs of bootwrapper. 36 36 */ 37 - static void *simple_malloc(u32 size) 37 + static void *simple_malloc(unsigned long size) 38 38 { 39 - u32 i; 39 + unsigned long i; 40 40 struct alloc_info *p = alloc_tbl; 41 41 42 42 if (size == 0) ··· 67 67 68 68 static struct alloc_info *simple_find_entry(void *ptr) 69 69 { 70 - u32 i; 70 + unsigned long i; 71 71 struct alloc_info *p = alloc_tbl; 72 72 73 73 for (i=0; i<tbl_entries; i++,p++) { 74 74 if (!(p->flags & ENTRY_BEEN_USED)) 75 75 break; 76 - if ((p->flags & ENTRY_IN_USE) && (p->base == (u32)ptr)) 76 + if ((p->flags & ENTRY_IN_USE) && 77 + (p->base == (unsigned long)ptr)) 77 78 return p; 78 79 } 79 80 return NULL; ··· 123 122 * Returns addr of first byte after heap so caller can see if it took 124 123 * too much space. If so, change args & try again. 125 124 */ 126 - void *simple_alloc_init(char *base, u32 heap_size, u32 granularity, 127 - u32 max_allocs) 125 + void *simple_alloc_init(char *base, unsigned long heap_size, 126 + unsigned long granularity, unsigned long max_allocs) 128 127 { 129 - u32 heap_base, tbl_size; 128 + unsigned long heap_base, tbl_size; 130 129 131 130 heap_size = _ALIGN_UP(heap_size, granularity); 132 131 alloc_min = granularity; ··· 137 136 alloc_tbl = (struct alloc_info *)_ALIGN_UP((unsigned long)base, 8); 138 137 memset(alloc_tbl, 0, tbl_size); 139 138 140 - heap_base = _ALIGN_UP((u32)alloc_tbl + tbl_size, alloc_min); 139 + heap_base = _ALIGN_UP((unsigned long)alloc_tbl + tbl_size, alloc_min); 141 140 142 141 next_base = heap_base; 143 142 space_left = heap_size;