[5/7] hw/display: Let devices own the MemoryRegion they create
diff mbox series

Message ID 20200221173049.18134-6-philmd@redhat.com
State New
Headers show
Series
  • hw: Let devices own the MemoryRegion they create
Related show

Commit Message

Philippe Mathieu-Daudé Feb. 21, 2020, 5:30 p.m. UTC
To avoid orphean memory regions being added in the /unattached
QOM container, use the memory_region_owner_nonnull.cocci script
to set the correct ownership.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/display/cg3.c        | 4 ++--
 hw/display/g364fb.c     | 5 +++--
 hw/display/macfb.c      | 4 ++--
 hw/display/vmware_vga.c | 4 ++--
 4 files changed, 9 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 4fb67c6b1c..db2e291d16 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -315,8 +315,8 @@  static void cg3_realizefn(DeviceState *dev, Error **errp)
         }
     }
 
-    memory_region_init_ram(&s->vram_mem, NULL, "cg3.vram", s->vram_size,
-                           &error_fatal);
+    memory_region_init_ram(&s->vram_mem, OBJECT(dev), "cg3.vram",
+                           s->vram_size, &error_fatal);
     memory_region_set_log(&s->vram_mem, true, DIRTY_MEMORY_VGA);
     sysbus_init_mmio(sbd, &s->vram_mem);
 
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 55185c95c6..28785cceda 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -477,8 +477,9 @@  static void g364fb_init(DeviceState *dev, G364State *s)
 
     s->con = graphic_console_init(dev, 0, &g364fb_ops, s);
 
-    memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, s, "ctrl", 0x180000);
-    memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram",
+    memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s,
+                          "ctrl", 0x180000);
+    memory_region_init_ram_ptr(&s->mem_vram, OBJECT(dev), "vram",
                                s->vram_size, s->vram);
     vmstate_register_ram(&s->mem_vram, dev);
     memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA);
diff --git a/hw/display/macfb.c b/hw/display/macfb.c
index 8bff16d535..b68faff4bb 100644
--- a/hw/display/macfb.c
+++ b/hw/display/macfb.c
@@ -362,8 +362,8 @@  static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp)
         return;
     }
 
-    memory_region_init_io(&s->mem_ctrl, NULL, &macfb_ctrl_ops, s, "macfb-ctrl",
-                          0x1000);
+    memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s,
+                          "macfb-ctrl", 0x1000);
 
     memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram",
                                      MACFB_VRAM_SIZE, errp);
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 58ea82e3e5..79574e3c46 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1238,8 +1238,8 @@  static void vmsvga_init(DeviceState *dev, struct vmsvga_state_s *s,
     s->vga.con = graphic_console_init(dev, 0, &vmsvga_ops, s);
 
     s->fifo_size = SVGA_FIFO_SIZE;
-    memory_region_init_ram(&s->fifo_ram, NULL, "vmsvga.fifo", s->fifo_size,
-                           &error_fatal);
+    memory_region_init_ram(&s->fifo_ram, OBJECT(dev), "vmsvga.fifo",
+                           s->fifo_size, &error_fatal);
     s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
 
     vga_common_init(&s->vga, OBJECT(dev));