From patchwork Wed Feb 20 21:46:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 222152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EA6062C007C for ; Thu, 21 Feb 2013 08:47:19 +1100 (EST) Received: from localhost ([::1]:50454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HVW-0007SX-0E for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 16:47:18 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HVB-0007EG-Mb for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8HV6-0008G7-G2 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:46:57 -0500 Received: from merlin.infradead.org ([2001:4978:20e::2]:50164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HV6-0008FT-Ar for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:46:52 -0500 Received: from shinybook.infradead.org ([2001:8b0:10b:1:e6ce:8fff:fe1f:f2c0]) by merlin.infradead.org with esmtpsa (Exim 4.76 #1 (Red Hat Linux)) id 1U8HV5-0004vY-0O for qemu-devel@nongnu.org; Wed, 20 Feb 2013 21:46:51 +0000 Received: from dwmw2 by shinybook.infradead.org with local (Exim 4.80.1 #2 (Red Hat Linux)) id 1U8HV3-0003Nn-Ac for qemu-devel@nongnu.org; Wed, 20 Feb 2013 21:46:49 +0000 From: David Woodhouse To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 21:46:46 +0000 Message-Id: <1361396809-12973-1-git-send-email-dwmw2@infradead.org> X-Mailer: git-send-email 1.8.1.2 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org See http://www.infradead.org/rpr.html X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4978:20e::2 Subject: [Qemu-devel] [PATCH 1/4] piix_pci: Clean up i440FX object handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: David Woodhouse Define and use I440FX_PCI_DEVICE() instead of using DO_UPCAST(). Signed-off-by: David Woodhouse Reviewed-by: Andreas Färber --- hw/piix_pci.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/piix_pci.c b/hw/piix_pci.c index 6c77e49..6b69e26 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -82,6 +82,10 @@ typedef struct PIIX3State { MemoryRegion rcr_mem; } PIIX3State; +#define TYPE_I440FX_PCI_DEVICE "i440FX" +#define I440FX_PCI_DEVICE(obj) \ + OBJECT_CHECK(PCII440FXState, (obj), TYPE_I440FX_PCI_DEVICE) + struct PCII440FXState { PCIDevice dev; MemoryRegion *system_memory; @@ -141,7 +145,7 @@ static void i440fx_set_smm(int val, void *arg) static void i440fx_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len) { - PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); + PCII440FXState *d = I440FX_PCI_DEVICE(dev); /* XXX: implement SMRAM.D_LOCK */ pci_default_write_config(dev, address, val, len); @@ -212,7 +216,7 @@ static int i440fx_pcihost_initfn(SysBusDevice *dev) static int i440fx_initfn(PCIDevice *dev) { - PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); + PCII440FXState *d = I440FX_PCI_DEVICE(dev); d->dev.config[I440FX_SMRAM] = 0x02; @@ -252,7 +256,7 @@ static PCIBus *i440fx_common_init(const char *device_name, qdev_init_nofail(dev); d = pci_create_simple(b, 0, device_name); - *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d); + *pi440fx_state = I440FX_PCI_DEVICE(d); f = *pi440fx_state; f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; @@ -326,7 +330,8 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, { PCIBus *b; - b = i440fx_common_init("i440FX", pi440fx_state, piix3_devfn, isa_bus, pic, + b = i440fx_common_init(TYPE_I440FX_PCI_DEVICE, pi440fx_state, + piix3_devfn, isa_bus, pic, address_space_mem, address_space_io, ram_size, pci_hole_start, pci_hole_size, pci_hole64_start, pci_hole64_size, @@ -618,7 +623,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data) } static const TypeInfo i440fx_info = { - .name = "i440FX", + .name = TYPE_I440FX_PCI_DEVICE, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCII440FXState), .class_init = i440fx_class_init,