qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	"Benoît Canet" <benoit.canet@gmail.com>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH] hw/sysbus.c: Remove unnecessary conditionals
Date: Mon, 19 Dec 2011 20:33:59 +0000	[thread overview]
Message-ID: <1324326839-28915-1-git-send-email-peter.maydell@linaro.org> (raw)

Now that all sysbus MMIO regions are MemoryRegions, mmio[n].memory
is never NULL, and we can remove some unnecessary conditionals.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
A minor tidyup following Benoît's now-applied patches to remove
sysbus_init_mmio_cb2().

 hw/sysbus.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/hw/sysbus.c b/hw/sysbus.c
index 81a57bd..24f619f 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -50,17 +50,12 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr)
     }
     if (dev->mmio[n].addr != (target_phys_addr_t)-1) {
         /* Unregister previous mapping.  */
-        if (dev->mmio[n].memory) {
-            memory_region_del_subregion(get_system_memory(),
-                                        dev->mmio[n].memory);
-        }
+        memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory);
     }
     dev->mmio[n].addr = addr;
-    if (dev->mmio[n].memory) {
-        memory_region_add_subregion(get_system_memory(),
-                                    addr,
-                                    dev->mmio[n].memory);
-    }
+    memory_region_add_subregion(get_system_memory(),
+                                addr,
+                                dev->mmio[n].memory);
 }
 
 
@@ -206,10 +201,7 @@ static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
 
     monitor_printf(mon, "%*sirq %d\n", indent, "", s->num_irq);
     for (i = 0; i < s->num_mmio; i++) {
-        size = 0;
-        if (s->mmio[i].memory) {
-            size = memory_region_size(s->mmio[i].memory);
-        }
+        size = memory_region_size(s->mmio[i].memory);
         monitor_printf(mon, "%*smmio " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
                        indent, "", s->mmio[i].addr, size);
     }
-- 
1.7.5.4

             reply	other threads:[~2011-12-19 20:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-19 20:33 Peter Maydell [this message]
2011-12-20 22:17 ` [Qemu-devel] [PATCH] hw/sysbus.c: Remove unnecessary conditionals Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1324326839-28915-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=aliguori@us.ibm.com \
    --cc=benoit.canet@gmail.com \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).