Skip to contentSkip to conversation

usb-ohci: return USBBus in usb_ohci_init_pci

PATCH In review Anthony Liguori 4 participants 5 messages Dec 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-ohci: return USBBus in usb_ohci_init_pci

Untested, but seemingly obvious and hard to screw up..

---
 hw/usb-ohci.c |    7 +++++--
 hw/usb-ohci.h |    3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)
hw/usb-ohci.c +5 -2
index e68be70..4c56548 100644
@@ -1810,9 +1810,12 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev)
     return 0;
 }
 
-void usb_ohci_init_pci(struct PCIBus *bus, int devfn)
+USBBus *usb_ohci_init_pci(struct PCIBus *bus, int devfn)
 {
-    pci_create_simple(bus, devfn, "pci-ohci");
+    PCIDevice *dev = pci_create_simple(bus, devfn, "pci-ohci");
+    OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
+
+    return &ohci->state.bus
 }
 
 typedef struct {
hw/usb-ohci.h +2 -1
index eefcef3..2a63ca9 100644
@@ -2,8 +2,9 @@
 #define QEMU_USB_OHCI_H
 
 #include "qemu-common.h"
+#include "usb.h"
 
-void usb_ohci_init_pci(struct PCIBus *bus, int devfn);
+USBBus *usb_ohci_init_pci(struct PCIBus *bus, int devfn);
 
 #endif
 
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 1 line · Anthony Liguori

Untested, but seemingly obvious and hard to screw up..

Sounds like a challenge so let's take a look...

hw/usb-ohci.c static int usb_ohci_initfn_pci(struct PCIDevice *dev) · line 1818

Quoted 8 lines
hw/usb-ohci.c +5 -2
-void usb_ohci_init_pci(struct PCIBus *bus, int devfn)
+USBBus *usb_ohci_init_pci(struct PCIBus *bus, int devfn)
 {
-    pci_create_simple(bus, devfn, "pci-ohci");
+    PCIDevice *dev = pci_create_simple(bus, devfn, "pci-ohci");
+    OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
+
+    return &ohci->state.bus

Missing semicolon.

Stefan

#2 lore raw
Quoted 5 lines · Stefan Hajnoczi
Quoted 1 line · Anthony Liguori

Untested, but seemingly obvious and hard to screw up..

Sounds like a challenge so let's take a look...

Quoted 10 lines

hw/usb-ohci.c static int usb_ohci_initfn_pci(struct PCIDevice *dev)

Quoted 8 lines
hw/usb-ohci.c +5 -2
-void usb_ohci_init_pci(struct PCIBus *bus, int devfn)
+USBBus *usb_ohci_init_pci(struct PCIBus *bus, int devfn)
  {
-    pci_create_simple(bus, devfn, "pci-ohci");
+    PCIDevice *dev = pci_create_simple(bus, devfn, "pci-ohci");
+    OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
+
+    return&ohci->state.bus

Missing semicolon.

Heh, awesome :-) Okay, I'll actually test it next time.

Regards,

Anthony Liguori

Quoted 4 lines

Stefan

#3 lore raw

Hi,

Quoted 1 line

Heh, awesome :-) Okay, I'll actually test it next time.

Could you also add some justification for the change to the commit message please? Just for itself the change looks somewhat odd as there is no obvious reason for it ...

thanks,
Gerd

#4 lore raw
Quoted 7 lines · Gerd Hoffmann
   Hi,
Quoted 1 line

Heh, awesome :-) Okay, I'll actually test it next time.

Could you also add some justification for the change to the commit message please? Just for itself the change looks somewhat odd as there is no obvious reason for it ...

Yup.

Regards,

Anthony Liguori

Quoted 4 lines

thanks,
Gerd