mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
of: reserved_mem: rearrange code a bit
Move __rmem_check_for_overlap() and __rmem_cmp() functions before fdt_scan_reserved_mem_reg_nodes() to avoid forward declaration and keep related code close together. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://patch.msgid.link/20260325090023.3175348-6-m.szyprowski@samsung.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
parent
7fd3981202
commit
427864f793
|
|
@ -214,7 +214,55 @@ static int __init __reserved_mem_check_root(unsigned long node)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void __init __rmem_check_for_overlap(void);
|
||||
static int __init __rmem_cmp(const void *a, const void *b)
|
||||
{
|
||||
const struct reserved_mem *ra = a, *rb = b;
|
||||
|
||||
if (ra->base < rb->base)
|
||||
return -1;
|
||||
|
||||
if (ra->base > rb->base)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* Put the dynamic allocations (address == 0, size == 0) before static
|
||||
* allocations at address 0x0 so that overlap detection works
|
||||
* correctly.
|
||||
*/
|
||||
if (ra->size < rb->size)
|
||||
return -1;
|
||||
if (ra->size > rb->size)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __init __rmem_check_for_overlap(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (reserved_mem_count < 2)
|
||||
return;
|
||||
|
||||
sort(reserved_mem, reserved_mem_count, sizeof(reserved_mem[0]),
|
||||
__rmem_cmp, NULL);
|
||||
for (i = 0; i < reserved_mem_count - 1; i++) {
|
||||
struct reserved_mem *this, *next;
|
||||
|
||||
this = &reserved_mem[i];
|
||||
next = &reserved_mem[i + 1];
|
||||
|
||||
if (this->base + this->size > next->base) {
|
||||
phys_addr_t this_end, next_end;
|
||||
|
||||
this_end = this->base + this->size;
|
||||
next_end = next->base + next->size;
|
||||
pr_err("OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
|
||||
this->name, &this->base, &this_end,
|
||||
next->name, &next->base, &next_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fdt_scan_reserved_mem_reg_nodes() - Store info for the "reg" defined
|
||||
|
|
@ -565,55 +613,6 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int __init __rmem_cmp(const void *a, const void *b)
|
||||
{
|
||||
const struct reserved_mem *ra = a, *rb = b;
|
||||
|
||||
if (ra->base < rb->base)
|
||||
return -1;
|
||||
|
||||
if (ra->base > rb->base)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* Put the dynamic allocations (address == 0, size == 0) before static
|
||||
* allocations at address 0x0 so that overlap detection works
|
||||
* correctly.
|
||||
*/
|
||||
if (ra->size < rb->size)
|
||||
return -1;
|
||||
if (ra->size > rb->size)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __init __rmem_check_for_overlap(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (reserved_mem_count < 2)
|
||||
return;
|
||||
|
||||
sort(reserved_mem, reserved_mem_count, sizeof(reserved_mem[0]),
|
||||
__rmem_cmp, NULL);
|
||||
for (i = 0; i < reserved_mem_count - 1; i++) {
|
||||
struct reserved_mem *this, *next;
|
||||
|
||||
this = &reserved_mem[i];
|
||||
next = &reserved_mem[i + 1];
|
||||
|
||||
if (this->base + this->size > next->base) {
|
||||
phys_addr_t this_end, next_end;
|
||||
|
||||
this_end = this->base + this->size;
|
||||
next_end = next->base + next->size;
|
||||
pr_err("OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
|
||||
this->name, &this->base, &this_end,
|
||||
next->name, &next->base, &next_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fdt_init_reserved_mem_node() - Initialize a reserved memory region
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user