extern unsigned int rtas_data;
 extern unsigned long long memory_limit;
-extern bool init_mem_is_free;
 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
 
 struct device_node;
 
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <asm/code-patching.h>
-#include <asm/setup.h>
 #include <asm/inst.h>
 
 static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr)
 int patch_instruction(u32 *addr, ppc_inst_t instr)
 {
        /* Make sure we aren't patching a freed init section */
-       if (init_mem_is_free && init_section_contains(addr, 4))
+       if (system_state >= SYSTEM_FREEING_INITMEM && init_section_contains(addr, 4))
                return 0;
 
        return do_patch_instruction(addr, instr);
 
 #include <mm/mmu_decl.h>
 
 unsigned long long memory_limit;
-bool init_mem_is_free;
 
 unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
 EXPORT_SYMBOL(empty_zero_page);
 {
        ppc_md.progress = ppc_printk_progress;
        mark_initmem_nx();
-       init_mem_is_free = true;
        free_initmem_default(POISON_FREE_INITMEM);
 }