Patchwork [08/13] ide: include bus in MMIOState

login
register
mail settings
Submitter Juan Quintela
Date Oct. 14, 2009, 11:37 a.m.
Message ID <8224ed67b2605f915bc41854ea7121c292c33362.1255520033.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/35951/
State New
Headers show

Comments

Juan Quintela - Oct. 14, 2009, 11:37 a.m.
Change pointer to struct by embedded struct.

Adjust all callers

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/ide/mmio.c |   34 ++++++++++++++--------------------
 1 files changed, 14 insertions(+), 20 deletions(-)

Patch

diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index 7a6bf32..8c1ee04 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -37,31 +37,29 @@ 
  */

 typedef struct {
-    IDEBus *bus;
+    IDEBus bus;
     int shift;
 } MMIOState;

 static uint32_t mmio_ide_read (void *opaque, target_phys_addr_t addr)
 {
     MMIOState *s = opaque;
-    IDEBus *bus = s->bus;
     addr >>= s->shift;
     if (addr & 7)
-        return ide_ioport_read(bus, addr);
+        return ide_ioport_read(&s->bus, addr);
     else
-        return ide_data_readw(bus, 0);
+        return ide_data_readw(&s->bus, 0);
 }

 static void mmio_ide_write (void *opaque, target_phys_addr_t addr,
 	uint32_t val)
 {
     MMIOState *s = opaque;
-    IDEBus *bus = s->bus;
     addr >>= s->shift;
     if (addr & 7)
-        ide_ioport_write(bus, addr, val);
+        ide_ioport_write(&s->bus, addr, val);
     else
-        ide_data_writew(bus, 0, val);
+        ide_data_writew(&s->bus, 0, val);
 }

 static CPUReadMemoryFunc * const mmio_ide_reads[] = {
@@ -79,16 +77,14 @@  static CPUWriteMemoryFunc * const mmio_ide_writes[] = {
 static uint32_t mmio_ide_status_read (void *opaque, target_phys_addr_t addr)
 {
     MMIOState *s= opaque;
-    IDEBus *bus = s->bus;
-    return ide_status_read(bus, 0);
+    return ide_status_read(&s->bus, 0);
 }

 static void mmio_ide_cmd_write (void *opaque, target_phys_addr_t addr,
 	uint32_t val)
 {
     MMIOState *s = opaque;
-    IDEBus *bus = s->bus;
-    ide_cmd_write(bus, 0, val);
+    ide_cmd_write(&s->bus, 0, val);
 }

 static CPUReadMemoryFunc * const mmio_ide_status[] = {
@@ -107,18 +103,18 @@  static void mmio_ide_save(QEMUFile* f, void *opaque)
 {
     MMIOState *s = opaque;

-    idebus_save(f, s->bus);
-    ide_save(f, &s->bus->ifs[0]);
-    ide_save(f, &s->bus->ifs[1]);
+    idebus_save(f, &s->bus);
+    ide_save(f, &s->bus.ifs[0]);
+    ide_save(f, &s->bus.ifs[1]);
 }

 static int mmio_ide_load(QEMUFile* f, void *opaque, int version_id)
 {
     MMIOState *s = opaque;

-    idebus_load(f, s->bus, version_id);
-    ide_load(f, &s->bus->ifs[0], version_id);
-    ide_load(f, &s->bus->ifs[1], version_id);
+    idebus_load(f, &s->bus, version_id);
+    ide_load(f, &s->bus.ifs[0], version_id);
+    ide_load(f, &s->bus.ifs[1], version_id);
     return 0;
 }

@@ -127,12 +123,10 @@  void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
                     DriveInfo *hd0, DriveInfo *hd1)
 {
     MMIOState *s = qemu_mallocz(sizeof(MMIOState));
-    IDEBus *bus = qemu_mallocz(sizeof(*bus));
     int mem1, mem2;

-    ide_init2(bus, hd0, hd1, irq);
+    ide_init2(&s->bus, hd0, hd1, irq);

-    s->bus = bus;
     s->shift = shift;

     mem1 = cpu_register_io_memory(mmio_ide_reads, mmio_ide_writes, s);