[RFC PATCH v2 104/137] hw/char: Give parallel and htif memory regions an explicit owner

Alexander Graf <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel,org.nongnu.qemu-riscv
Message-ID <[email protected]>
Thread Object *owner as the first argument through parallel_mm_init()
and htif_mm_init(). All callers are inside board init functions
and pass OBJECT(machine).

No functional change intended.

AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 hw/char/parallel.c           | 5 +++--
 hw/char/riscv_htif.c         | 5 +++--
 hw/hppa/machine.c            | 5 +++--
 hw/mips/jazz.c               | 2 +-
 hw/riscv/spike.c             | 2 +-
 include/hw/char/parallel.h   | 3 ++-
 include/hw/char/riscv_htif.h | 3 ++-
 7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 07bbc9443f..39a1d77e9f 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -585,7 +585,8 @@ static const MemoryRegionOps parallel_mm_ops = {
 };
 
 /* If fd is zero, it means that the parallel device uses the console */
-bool parallel_mm_init(MemoryRegion *address_space,
+bool parallel_mm_init(Object *owner,
+                      MemoryRegion *address_space,
                       hwaddr base, int it_shift, qemu_irq irq,
                       Chardev *chr)
 {
@@ -597,7 +598,7 @@ bool parallel_mm_init(MemoryRegion *address_space,
     s->it_shift = it_shift;
     qemu_register_reset(parallel_reset, s);
 
-    memory_region_init_io(&s->iomem, NULL, &parallel_mm_ops, s,
+    memory_region_init_io(&s->iomem, owner, &parallel_mm_ops, s,
                           "parallel", 8 << it_shift);
     memory_region_add_subregion(address_space, base, &s->iomem);
     return true;
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index 488f938d98..f9e39c31aa 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -329,7 +329,8 @@ static const MemoryRegionOps htif_mm_ops = {
     },
 };
 
-HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,
+HTIFState *htif_mm_init(Object *owner,
+                        MemoryRegion *address_space, Chardev *chr,
                         uint64_t nonelf_base, bool custom_base)
 {
     uint64_t base, size, tohost_offset, fromhost_offset;
@@ -359,7 +360,7 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,
     qemu_chr_fe_set_handlers(&s->chr, htif_can_recv, htif_recv, htif_event,
         htif_be_change, s, NULL, true);
 
-    memory_region_init_io(&s->mmio, NULL, &htif_mm_ops, s,
+    memory_region_init_io(&s->mmio, owner, &htif_mm_ops, s,
                           TYPE_HTIF_UART, size);
     memory_region_add_subregion_overlap(address_space, base,
                                         &s->mmio, 1);
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 233cf6318b..ea02b9e70e 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -613,7 +613,8 @@ static void machine_HP_715_init(MachineState *machine)
         serial_hd(0), DEVICE_BIG_ENDIAN);
 
     /* Parallel port */
-    parallel_mm_init(addr_space, translate(NULL, LASI_HPA_715 + LASI_LPT + 0x800), 0,
+    parallel_mm_init(OBJECT(machine), addr_space,
+                     translate(NULL, LASI_HPA_715 + LASI_LPT + 0x800), 0,
                      qdev_get_gpio_in(lasi_dev, LASI_IRQ_LPT_HPA),
                      parallel_hds[0]);
 
@@ -706,7 +707,7 @@ static void machine_HP_B160L_init(MachineState *machine)
         serial_hd(1), DEVICE_BIG_ENDIAN);
 
     /* Parallel port */
-    parallel_mm_init(addr_space,
+    parallel_mm_init(OBJECT(machine), addr_space,
                      translate(NULL, LASI_HPA + LASI_LPT + 0x800), 0,
                      qdev_get_gpio_in(lasi_dev, LASI_IRQ_LPT_HPA),
                      parallel_hds[0]);
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 8999efb352..ff18b28c86 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -385,7 +385,7 @@ static void mips_jazz_init(MachineState *machine,
 
     /* Parallel port */
     if (parallel_hds[0])
-        parallel_mm_init(address_space, 0x80008000, 0,
+        parallel_mm_init(OBJECT(machine), address_space, 0x80008000, 0,
                          qdev_get_gpio_in(rc4030, 0), parallel_hds[0]);
 
     /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index 9f1a1b5898..cd9a2ee0df 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -247,7 +247,7 @@ static void spike_board_init(MachineState *machine)
                               fdt_load_addr);
 
     /* initialize HTIF using symbols found in load_kernel */
-    htif_mm_init(system_memory, serial_hd(0), memmap[SPIKE_HTIF].base,
+    htif_mm_init(OBJECT(machine), system_memory, serial_hd(0), memmap[SPIKE_HTIF].base,
                  htif_custom_base);
 }
 
diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
index 782cc12602..7e8b9c9012 100644
--- a/include/hw/char/parallel.h
+++ b/include/hw/char/parallel.h
@@ -25,7 +25,8 @@ typedef struct ParallelState {
 
 void parallel_hds_isa_init(Object *parent, ISABus *bus, int n);
 
-bool parallel_mm_init(MemoryRegion *address_space,
+bool parallel_mm_init(Object *owner,
+                      MemoryRegion *address_space,
                       hwaddr base, int it_shift, qemu_irq irq,
                       Chardev *chr);
 
diff --git a/include/hw/char/riscv_htif.h b/include/hw/char/riscv_htif.h
index 9d61e60d0a..40516adc08 100644
--- a/include/hw/char/riscv_htif.h
+++ b/include/hw/char/riscv_htif.h
@@ -48,7 +48,8 @@ void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value,
     uint64_t st_size);
 
 /* legacy pre qom */
-HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,
+HTIFState *htif_mm_init(Object *owner,
+                        MemoryRegion *address_space, Chardev *chr,
                         uint64_t nonelf_base, bool custom_base);
 
 #endif
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.