thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
958e1b
From ccf8ee841c1d72d74bc4b6b54247089eb847087b Mon Sep 17 00:00:00 2001
958e1b
From: Gerd Hoffmann <kraxel@redhat.com>
958e1b
Date: Fri, 11 Jul 2014 14:20:34 +0200
958e1b
Subject: [PATCH 01/43] usb/hcd-xhci: QOM Upcast Sweep
958e1b
MIME-Version: 1.0
958e1b
Content-Type: text/plain; charset=UTF-8
958e1b
Content-Transfer-Encoding: 8bit
958e1b
958e1b
Message-id: <1405088470-24115-2-git-send-email-kraxel@redhat.com>
958e1b
Patchwork-id: 59835
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 01/37] usb/hcd-xhci: QOM Upcast Sweep
958e1b
Bugzilla: 980747
958e1b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
958e1b
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
958e1b
958e1b
Define and use standard QOM cast macro. Remove usages of DO_UPCAST()
958e1b
and direct -> style upcasting.
958e1b
958e1b
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
958e1b
[AF: Dropped usb_xhci_init() DeviceState argument and renamed variable]
958e1b
Signed-off-by: Andreas Färber <afaerber@suse.de>
958e1b
958e1b
(cherry picked from commit 37034575d23a06447e4f44ab365afec6b198c53f)
958e1b
---
958e1b
 hw/usb/hcd-xhci.c | 21 ++++++++++++++-------
958e1b
 1 file changed, 14 insertions(+), 7 deletions(-)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/usb/hcd-xhci.c | 21 ++++++++++++++-------
958e1b
 1 file changed, 14 insertions(+), 7 deletions(-)
958e1b
958e1b
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
958e1b
index 2c9e36a..8fa1c6e 100644
958e1b
--- a/hw/usb/hcd-xhci.c
958e1b
+++ b/hw/usb/hcd-xhci.c
958e1b
@@ -485,6 +485,11 @@ struct XHCIState {
958e1b
     XHCIRing cmd_ring;
958e1b
 };
958e1b
 
958e1b
+#define TYPE_XHCI "nec-usb-xhci"
958e1b
+
958e1b
+#define XHCI(obj) \
958e1b
+    OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI)
958e1b
+
958e1b
 typedef struct XHCIEvRingSeg {
958e1b
     uint32_t addr_low;
958e1b
     uint32_t addr_high;
958e1b
@@ -2719,7 +2724,7 @@ static void xhci_port_reset(XHCIPort *port, bool warm_reset)
958e1b
 
958e1b
 static void xhci_reset(DeviceState *dev)
958e1b
 {
958e1b
-    XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev.qdev, dev);
958e1b
+    XHCIState *xhci = XHCI(dev);
958e1b
     int i;
958e1b
 
958e1b
     trace_usb_xhci_reset();
958e1b
@@ -2968,6 +2973,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
958e1b
                             uint64_t val, unsigned size)
958e1b
 {
958e1b
     XHCIState *xhci = ptr;
958e1b
+    DeviceState *d = DEVICE(ptr);
958e1b
 
958e1b
     trace_usb_xhci_oper_write(reg, val);
958e1b
 
958e1b
@@ -2989,7 +2995,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
958e1b
         xhci->usbcmd = val & 0xc0f;
958e1b
         xhci_mfwrap_update(xhci);
958e1b
         if (val & USBCMD_HCRST) {
958e1b
-            xhci_reset(&xhci->pci_dev.qdev);
958e1b
+            xhci_reset(d);
958e1b
         }
958e1b
         xhci_intx_update(xhci);
958e1b
         break;
958e1b
@@ -3315,8 +3321,9 @@ static USBBusOps xhci_bus_ops = {
958e1b
     .wakeup_endpoint = xhci_wakeup_endpoint,
958e1b
 };
958e1b
 
958e1b
-static void usb_xhci_init(XHCIState *xhci, DeviceState *dev)
958e1b
+static void usb_xhci_init(XHCIState *xhci)
958e1b
 {
958e1b
+    DeviceState *dev = DEVICE(xhci);
958e1b
     XHCIPort *port;
958e1b
     int i, usbports, speedmask;
958e1b
 
958e1b
@@ -3331,7 +3338,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState *dev)
958e1b
     usbports = MAX(xhci->numports_2, xhci->numports_3);
958e1b
     xhci->numports = xhci->numports_2 + xhci->numports_3;
958e1b
 
958e1b
-    usb_bus_new(&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev);
958e1b
+    usb_bus_new(&xhci->bus, &xhci_bus_ops, dev);
958e1b
 
958e1b
     for (i = 0; i < usbports; i++) {
958e1b
         speedmask = 0;
958e1b
@@ -3363,14 +3370,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
958e1b
 {
958e1b
     int i, ret;
958e1b
 
958e1b
-    XHCIState *xhci = DO_UPCAST(XHCIState, pci_dev, dev);
958e1b
+    XHCIState *xhci = XHCI(dev);
958e1b
 
958e1b
     xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30;    /* xHCI */
958e1b
     xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
958e1b
     xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
958e1b
     xhci->pci_dev.config[0x60] = 0x30; /* release number */
958e1b
 
958e1b
-    usb_xhci_init(xhci, &dev->qdev);
958e1b
+    usb_xhci_init(xhci);
958e1b
 
958e1b
     if (xhci->numintrs > MAXINTRS) {
958e1b
         xhci->numintrs = MAXINTRS;
958e1b
@@ -3644,7 +3651,7 @@ static void xhci_class_init(ObjectClass *klass, void *data)
958e1b
 }
958e1b
 
958e1b
 static const TypeInfo xhci_info = {
958e1b
-    .name          = "nec-usb-xhci",
958e1b
+    .name          = TYPE_XHCI,
958e1b
     .parent        = TYPE_PCI_DEVICE,
958e1b
     .instance_size = sizeof(XHCIState),
958e1b
     .class_init    = xhci_class_init,
958e1b
-- 
958e1b
1.8.3.1
958e1b