From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1PoX-0002T8-AS for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1PoV-0003oM-R1 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:49 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45753 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1PoV-0003oE-HJ for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:47 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 23 Jul 2013 01:45:48 +0200 Message-Id: <1374536796-13983-8-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 07/55] usb/hcd-xhci: QOM Upcast Sweep List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gerd Hoffmann From: Peter Crosthwaite Define and use standard QOM cast macro. Remove usages of DO_UPCAST() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite [AF: Dropped usb_xhci_init() DeviceState argument and renamed variable] Signed-off-by: Andreas F=C3=A4rber --- hw/usb/hcd-xhci.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index d7a54fd..0566886 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -482,6 +482,11 @@ struct XHCIState { XHCIRing cmd_ring; }; =20 +#define TYPE_XHCI "nec-usb-xhci" + +#define XHCI(obj) \ + OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI) + typedef struct XHCIEvRingSeg { uint32_t addr_low; uint32_t addr_high; @@ -2681,7 +2686,7 @@ static void xhci_port_reset(XHCIPort *port) =20 static void xhci_reset(DeviceState *dev) { - XHCIState *xhci =3D DO_UPCAST(XHCIState, pci_dev.qdev, dev); + XHCIState *xhci =3D XHCI(dev); int i; =20 trace_usb_xhci_reset(); @@ -2926,6 +2931,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, uint64_t val, unsigned size) { XHCIState *xhci =3D ptr; + DeviceState *d =3D DEVICE(ptr); =20 trace_usb_xhci_oper_write(reg, val); =20 @@ -2939,7 +2945,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, xhci->usbcmd =3D val & 0xc0f; xhci_mfwrap_update(xhci); if (val & USBCMD_HCRST) { - xhci_reset(&xhci->pci_dev.qdev); + xhci_reset(d); } xhci_intx_update(xhci); break; @@ -3265,8 +3271,9 @@ static USBBusOps xhci_bus_ops =3D { .wakeup_endpoint =3D xhci_wakeup_endpoint, }; =20 -static void usb_xhci_init(XHCIState *xhci, DeviceState *dev) +static void usb_xhci_init(XHCIState *xhci) { + DeviceState *dev =3D DEVICE(xhci); XHCIPort *port; int i, usbports, speedmask; =20 @@ -3281,7 +3288,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceSt= ate *dev) usbports =3D MAX(xhci->numports_2, xhci->numports_3); xhci->numports =3D xhci->numports_2 + xhci->numports_3; =20 - usb_bus_new(&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev); + usb_bus_new(&xhci->bus, &xhci_bus_ops, dev); =20 for (i =3D 0; i < usbports; i++) { speedmask =3D 0; @@ -3313,14 +3320,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev) { int i, ret; =20 - XHCIState *xhci =3D DO_UPCAST(XHCIState, pci_dev, dev); + XHCIState *xhci =3D XHCI(dev); =20 xhci->pci_dev.config[PCI_CLASS_PROG] =3D 0x30; /* xHCI */ xhci->pci_dev.config[PCI_INTERRUPT_PIN] =3D 0x01; /* interrupt pin 1= */ xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] =3D 0x10; xhci->pci_dev.config[0x60] =3D 0x30; /* release number */ =20 - usb_xhci_init(xhci, &dev->qdev); + usb_xhci_init(xhci); =20 if (xhci->numintrs > MAXINTRS) { xhci->numintrs =3D MAXINTRS; @@ -3581,7 +3588,7 @@ static void xhci_class_init(ObjectClass *klass, voi= d *data) } =20 static const TypeInfo xhci_info =3D { - .name =3D "nec-usb-xhci", + .name =3D TYPE_XHCI, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(XHCIState), .class_init =3D xhci_class_init, --=20 1.8.1.4