Commit 4421cca0 authored by Mike Rapoport's avatar Mike Rapoport Committed by Linus Torvalds
Browse files

memblock: use memblock_free for freeing virtual pointers

Rename memblock_free_ptr() to memblock_free() and use memblock_free()
when freeing a virtual pointer so that memblock_free() will be a
counterpart of memblock_alloc()

The callers are updated with the below semantic patch and manual
addition of (void *) casting to pointers that are represented by
unsigned long variables.

    @@
    identifier vaddr;
    expression size;
    @@
    (
    - memblock_phys_free(__pa(vaddr), size);
    + memblock_free(vaddr, size);
    |
    - memblock_free_ptr(vaddr, size);
    + memblock_free(vaddr, size);
    )

[sfr@canb.auug.org.au: fixup]
  Link: https://lkml.kernel.org/r/20211018192940.3d1d532f@canb.auug.org.au

Link: https://lkml.kernel.org/r/20210930185031.18648-7-rppt@kernel.org


Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Juergen Gross <jgross@suse.com>
Cc: Shahab Vahedi <Shahab.Vahedi@synopsys.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3ecc6834
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -233,8 +233,7 @@ albacore_init_arch(void)
			unsigned long size;

			size = initrd_end - initrd_start;
			memblock_phys_free(__pa(initrd_start),
					   PAGE_ALIGN(size));
			memblock_free((void *)initrd_start, PAGE_ALIGN(size));
			if (!move_initrd(pci_mem))
				printk("irongate_init_arch: initrd too big "
				       "(%ldK)\ndisabling initrd\n",
+1 −1
Original line number Diff line number Diff line
@@ -529,7 +529,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,

static void __init pcpu_fc_free(void *ptr, size_t size)
{
	memblock_phys_free(__pa(ptr), size);
	memblock_free(ptr, size);
}

void __init setup_per_cpu_areas(void)
+2 −2
Original line number Diff line number Diff line
@@ -1095,7 +1095,7 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char

	cpufeatures_setup_finished();

	memblock_phys_free(__pa(dt_cpu_features),
	memblock_free(dt_cpu_features,
		      sizeof(struct dt_cpu_feature) * nr_dt_cpu_features);

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -825,7 +825,7 @@ static void __init smp_setup_pacas(void)
		set_hard_smp_processor_id(cpu, cpu_to_phys_id[cpu]);
	}

	memblock_phys_free(__pa(cpu_to_phys_id), nr_cpu_ids * sizeof(u32));
	memblock_free(cpu_to_phys_id, nr_cpu_ids * sizeof(u32));
	cpu_to_phys_id = NULL;
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -812,7 +812,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,

static void __init pcpu_free_bootmem(void *ptr, size_t size)
{
	memblock_phys_free(__pa(ptr), size);
	memblock_free(ptr, size);
}

static int pcpu_cpu_distance(unsigned int from, unsigned int to)
Loading