Skip to content

Commit

Permalink
memory: Simplify mr_add_subregion() if-else
Browse files Browse the repository at this point in the history
This if else is not needed. The previous call to memory_region_add
(whether _overlap or not) will always set priority and may_overlap
to desired values. And its not possible to get here without having
called memory_region_add_subregion due to the null guard on parent.
So we can just directly call memory_region_add_subregion_common.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
pete128 authored and bonzini committed Jun 17, 2014
1 parent 4dc5615 commit 3fb5bf5
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions memory.c
Expand Up @@ -1514,8 +1514,6 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled)
void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
{
MemoryRegion *parent = mr->parent;
int priority = mr->priority;
bool may_overlap = mr->may_overlap;

if (addr == mr->addr || !parent) {
mr->addr = addr;
Expand All @@ -1525,11 +1523,7 @@ void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
memory_region_transaction_begin();
memory_region_ref(mr);
memory_region_del_subregion(parent, mr);
if (may_overlap) {
memory_region_add_subregion_overlap(parent, addr, mr, priority);
} else {
memory_region_add_subregion(parent, addr, mr);
}
memory_region_add_subregion_common(parent, addr, mr);
memory_region_unref(mr);
memory_region_transaction_commit();
}
Expand Down

0 comments on commit 3fb5bf5

Please sign in to comment.