* [Qemu-devel] [PATCH memory v1 1/1] memory: Simplify mr_add_subregion() if-else
@ 2014-05-12 8:13 Peter Crosthwaite
2014-05-13 10:24 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Peter Crosthwaite @ 2014-05-12 8:13 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini
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>
---
memory.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/memory.c b/memory.c
index 3f1df23..1352881 100644
--- a/memory.c
+++ b/memory.c
@@ -1501,8 +1501,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;
@@ -1512,11 +1510,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();
}
--
1.9.2.1.g06c4abd
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH memory v1 1/1] memory: Simplify mr_add_subregion() if-else
2014-05-12 8:13 [Qemu-devel] [PATCH memory v1 1/1] memory: Simplify mr_add_subregion() if-else Peter Crosthwaite
@ 2014-05-13 10:24 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-05-13 10:24 UTC (permalink / raw)
To: Peter Crosthwaite, qemu-devel
Il 12/05/2014 10:13, Peter Crosthwaite ha scritto:
> 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>
> ---
>
> memory.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/memory.c b/memory.c
> index 3f1df23..1352881 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1501,8 +1501,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;
> @@ -1512,11 +1510,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();
> }
>
Thanks, I'll include this in the next memory pull request.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-13 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12 8:13 [Qemu-devel] [PATCH memory v1 1/1] memory: Simplify mr_add_subregion() if-else Peter Crosthwaite
2014-05-13 10:24 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).