From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuCEp-0001To-4w for qemu-devel@nongnu.org; Tue, 02 Jul 2013 21:52:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UuCEn-0007at-Nw for qemu-devel@nongnu.org; Tue, 02 Jul 2013 21:52:07 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40478 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuCEn-0007al-Ei for qemu-devel@nongnu.org; Tue, 02 Jul 2013 21:52:05 -0400 Message-ID: <51D383C0.2050403@suse.de> Date: Wed, 03 Jul 2013 03:52:00 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 02/26] ohci: QOM'ify some more List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Peter Crosthwaite , qemu-devel , Gerd Hoffmann Am 01.07.2013 12:18, schrieb Hu Tao: > Introduce type constant and avoid DO_UPCAST(). >=20 > Signed-off-by: Hu Tao > --- > hw/usb/hcd-ohci.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) >=20 > diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c > index 5513924..912255d 100644 > --- a/hw/usb/hcd-ohci.c > +++ b/hw/usb/hcd-ohci.c > @@ -1842,6 +1842,8 @@ static int usb_ohci_init(OHCIState *ohci, DeviceS= tate *dev, > return 0; > } > =20 > +#define TYPE_PCI_OHCI "pci-ohci" > +#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI) I added a while line here and converted the last three remaining uses of pci_dev in the initfn so that both fields could be renamed to parent_obj as proof of complete conversion. Thanks, queued this and the following one on qom-next: https://github.com/afaerber/qemu-cpu/commits/qom-next There was an overlap with Peter's usb/* PCIDevice patch, I believe this one is a superset of the ohci part. Andreas > typedef struct { > PCIDevice pci_dev; > OHCIState state; > @@ -1852,23 +1854,25 @@ typedef struct { > =20 > static int usb_ohci_initfn_pci(struct PCIDevice *dev) > { > - OHCIPCIState *ohci =3D DO_UPCAST(OHCIPCIState, pci_dev, dev); > + OHCIPCIState *ohci =3D PCI_OHCI(dev); > =20 > ohci->pci_dev.config[PCI_CLASS_PROG] =3D 0x10; /* OHCI */ > ohci->pci_dev.config[PCI_INTERRUPT_PIN] =3D 0x01; /* interrupt pin= A */ > =20 > - if (usb_ohci_init(&ohci->state, &dev->qdev, ohci->num_ports, 0, > + if (usb_ohci_init(&ohci->state, DEVICE(dev), ohci->num_ports, 0, > ohci->masterbus, ohci->firstport, > pci_get_address_space(dev)) !=3D 0) { > return -1; > } > ohci->state.irq =3D ohci->pci_dev.irq[0]; > =20 > - /* TODO: avoid cast below by using dev */ > - pci_register_bar(&ohci->pci_dev, 0, 0, &ohci->state.mem); > + pci_register_bar(dev, 0, 0, &ohci->state.mem); > return 0; > } > =20 > +#define TYPE_SYSBUS_OHCI "sysbus-ohci" > +#define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYS= BUS_OHCI) > + > typedef struct { > SysBusDevice busdev; > OHCIState ohci; > @@ -1878,10 +1882,10 @@ typedef struct { > =20 > static int ohci_init_pxa(SysBusDevice *dev) > { > - OHCISysBusState *s =3D FROM_SYSBUS(OHCISysBusState, dev); > + OHCISysBusState *s =3D SYSBUS_OHCI(dev); > =20 > /* Cannot fail as we pass NULL for masterbus */ > - usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset, N= ULL, 0, > + usb_ohci_init(&s->ohci, DEVICE(dev), s->num_ports, s->dma_offset, = NULL, 0, > &address_space_memory); > sysbus_init_irq(dev, &s->ohci.irq); > sysbus_init_mmio(dev, &s->ohci.mem); > @@ -1911,7 +1915,7 @@ static void ohci_pci_class_init(ObjectClass *klas= s, void *data) > } > =20 > static const TypeInfo ohci_pci_info =3D { > - .name =3D "pci-ohci", > + .name =3D TYPE_PCI_OHCI, > .parent =3D TYPE_PCI_DEVICE, > .instance_size =3D sizeof(OHCIPCIState), > .class_init =3D ohci_pci_class_init, > @@ -1934,7 +1938,7 @@ static void ohci_sysbus_class_init(ObjectClass *k= lass, void *data) > } > =20 > static const TypeInfo ohci_sysbus_info =3D { > - .name =3D "sysbus-ohci", > + .name =3D TYPE_SYSBUS_OHCI, > .parent =3D TYPE_SYS_BUS_DEVICE, > .instance_size =3D sizeof(OHCISysBusState), > .class_init =3D ohci_sysbus_class_init, >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg