From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Poe-0002j4-Eo for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:47:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Pob-0003ru-I2 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:56 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45781 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Pob-0003rR-74 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:53 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 23 Jul 2013 01:45:57 +0200 Message-Id: <1374536796-13983-17-git-send-email-afaerber@suse.de> In-Reply-To: <1374536796-13983-1-git-send-email-afaerber@suse.de> References: <1374536796-13983-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 16/55] ide/ich: QOM parent field cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?Andreas=20F=C3=A4rber?= Replace direct uses of AHCIPCIState::card with QOM casts and rename it to parent_obj. Acked-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- hw/ide/ahci.c | 11 ++++++----- hw/ide/ahci.h | 5 ++++- hw/ide/ich.c | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 1d863b5..f295732 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -117,12 +117,13 @@ static uint32_t ahci_port_read(AHCIState *s, int p= ort, int offset) =20 static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev) { - struct AHCIPCIState *d =3D container_of(s, AHCIPCIState, ahci); + AHCIPCIState *d =3D container_of(s, AHCIPCIState, ahci); + PCIDevice *pci_dev =3D PCI_DEVICE(d); =20 DPRINTF(0, "raise irq\n"); =20 - if (msi_enabled(&d->card)) { - msi_notify(&d->card, 0); + if (msi_enabled(pci_dev)) { + msi_notify(pci_dev, 0); } else { qemu_irq_raise(s->irq); } @@ -130,11 +131,11 @@ static void ahci_irq_raise(AHCIState *s, AHCIDevice= *dev) =20 static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev) { - struct AHCIPCIState *d =3D container_of(s, AHCIPCIState, ahci); + AHCIPCIState *d =3D container_of(s, AHCIPCIState, ahci); =20 DPRINTF(0, "lower irq\n"); =20 - if (!msi_enabled(&d->card)) { + if (!msi_enabled(PCI_DEVICE(d))) { qemu_irq_lower(s->irq); } } diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h index f997c67..20e412c 100644 --- a/hw/ide/ahci.h +++ b/hw/ide/ahci.h @@ -301,7 +301,10 @@ typedef struct AHCIState { } AHCIState; =20 typedef struct AHCIPCIState { - PCIDevice card; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + AHCIState ahci; } AHCIPCIState; =20 diff --git a/hw/ide/ich.c b/hw/ide/ich.c index a6f78dc..4eb5488 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -84,7 +84,7 @@ static const VMStateDescription vmstate_ich9_ahci =3D { .unmigratable =3D 1, /* Still buggy under I/O load */ .version_id =3D 1, .fields =3D (VMStateField []) { - VMSTATE_PCI_DEVICE(card, AHCIPCIState), + VMSTATE_PCI_DEVICE(parent_obj, AHCIPCIState), VMSTATE_AHCI(ahci, AHCIPCIState), VMSTATE_END_OF_LIST() }, @@ -106,30 +106,30 @@ static int pci_ich9_ahci_init(PCIDevice *dev) =20 ahci_init(&d->ahci, DEVICE(dev), pci_get_address_space(dev), 6); =20 - pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_RE= V_1); + pci_config_set_prog_interface(dev->config, AHCI_PROGMODE_MAJOR_REV_1= ); =20 - d->card.config[PCI_CACHE_LINE_SIZE] =3D 0x08; /* Cache line size */ - d->card.config[PCI_LATENCY_TIMER] =3D 0x00; /* Latency timer */ - pci_config_set_interrupt_pin(d->card.config, 1); + dev->config[PCI_CACHE_LINE_SIZE] =3D 0x08; /* Cache line size */ + dev->config[PCI_LATENCY_TIMER] =3D 0x00; /* Latency timer */ + pci_config_set_interrupt_pin(dev->config, 1); =20 /* XXX Software should program this register */ - d->card.config[0x90] =3D 1 << 6; /* Address Map Register - AHCI mo= de */ + dev->config[0x90] =3D 1 << 6; /* Address Map Register - AHCI mode = */ =20 msi_init(dev, 0x50, 1, true, false); - d->ahci.irq =3D d->card.irq[0]; + d->ahci.irq =3D dev->irq[0]; =20 - pci_register_bar(&d->card, ICH9_IDP_BAR, PCI_BASE_ADDRESS_SPACE_IO, + pci_register_bar(dev, ICH9_IDP_BAR, PCI_BASE_ADDRESS_SPACE_IO, &d->ahci.idp); - pci_register_bar(&d->card, ICH9_MEM_BAR, PCI_BASE_ADDRESS_SPACE_MEMO= RY, + pci_register_bar(dev, ICH9_MEM_BAR, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->ahci.mem); =20 - sata_cap_offset =3D pci_add_capability(&d->card, PCI_CAP_ID_SATA, + sata_cap_offset =3D pci_add_capability(dev, PCI_CAP_ID_SATA, ICH9_SATA_CAP_OFFSET, SATA_CAP_= SIZE); if (sata_cap_offset < 0) { return sata_cap_offset; } =20 - sata_cap =3D d->card.config + sata_cap_offset; + sata_cap =3D dev->config + sata_cap_offset; pci_set_word(sata_cap + SATA_CAP_REV, 0x10); pci_set_long(sata_cap + SATA_CAP_BAR, (ICH9_IDP_BAR + 0x4) | (ICH9_IDP_INDEX_LOG2 << 4)); --=20 1.8.1.4