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

[POWERPC] Limit range of __init_ref_ok somewhat

This patch introduces zalloc_maybe_bootmem and uses it so that we don't
have to mark a whole (largish) routine as __init_ref_ok.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Stephen Rothwell and committed by
Paul Mackerras
5669c3cf 88de3cab

+18 -8
+2 -8
arch/powerpc/kernel/irq.c
··· 424 424 return h->of_node != NULL && h->of_node == np; 425 425 } 426 426 427 - __init_refok struct irq_host *irq_alloc_host(struct device_node *of_node, 427 + struct irq_host *irq_alloc_host(struct device_node *of_node, 428 428 unsigned int revmap_type, 429 429 unsigned int revmap_arg, 430 430 struct irq_host_ops *ops, ··· 439 439 /* Allocate structure and revmap table if using linear mapping */ 440 440 if (revmap_type == IRQ_HOST_MAP_LINEAR) 441 441 size += revmap_arg * sizeof(unsigned int); 442 - if (mem_init_done) 443 - host = kzalloc(size, GFP_KERNEL); 444 - else { 445 - host = alloc_bootmem(size); 446 - if (host) 447 - memset(host, 0, size); 448 - } 442 + host = zalloc_maybe_bootmem(size, GFP_KERNEL); 449 443 if (host == NULL) 450 444 return NULL; 451 445
+15
arch/powerpc/lib/alloc.c
··· 2 2 #include <linux/init.h> 3 3 #include <linux/slab.h> 4 4 #include <linux/bootmem.h> 5 + #include <linux/string.h> 5 6 6 7 #include <asm/system.h> 7 8 ··· 12 11 return kmalloc(size, mask); 13 12 else 14 13 return alloc_bootmem(size); 14 + } 15 + 16 + void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask) 17 + { 18 + void *p; 19 + 20 + if (mem_init_done) 21 + p = kzalloc(size, mask); 22 + else { 23 + p = alloc_bootmem(size); 24 + if (p) 25 + memset(p, 0, size); 26 + } 27 + return p; 15 28 }
+1
include/asm-powerpc/system.h
··· 190 190 extern unsigned long klimit; 191 191 192 192 extern void *alloc_maybe_bootmem(size_t size, gfp_t mask); 193 + extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); 193 194 194 195 extern int powersave_nap; /* set if nap mode can be used in idle loop */ 195 196