PCI: Cleanup legacy casts in device land
cover PCI: Cleanup legacy casts in device land
From: Peter Crosthwaite <[email protected]>
There are a number of different cast implementations from various stages of QEMU development out in device model land. This series cleans up the ones involving TYPE_PCI_DEVICE to consistently use proper QOM casts for both up and down casts.
Some were easy, some needed QOM cast macros which are added as appropriate.
Following the recent discussion RE performance consequences of QOM casts, im interested in any reports of possible performance regressions here, although I am hoping that Anthony current efforts to improve QOM casting efficiency make this a non-issue.
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast Sweep
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep virtio/virtio-pci: QOM casting sweep virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweep
isa/*: QOM casting sweep
pci/*: QOM casting sweep pci-bridge/pci_bridge_dev: Don't use DO_UPCAST pci-bridge/*: substitute ->qdev casts with DEVICE() misc/vfio: substitute ->qdev casts with DEVICE() net/eepro100: substitute ->qdev casts with DEVICE() net/ne2000: substitute ->qdev casts with DEVICE() usb/*: substitute ->qdev casts with DEVICE() watchdog/wdt_i6300esb: substitute ->qdev casts with DEVICE() scsi/vmw_pvscsi: substitute ->qdev casts with DEVICE() i2c/smbus_ich9: substitute ->qdev casts with DEVICE() ide/cmd646: substitute ->qdev casts with DEVICE() ide/via: substitute ->qdev casts with DEVICE() pci-host/*: substitute ->qdev casts with DEVICE() i386/*: substitute ->qdev casts with DEVICE()
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- hw/display/vmware_vga.c | 13 ++++++++----- hw/i2c/smbus_ich9.c | 2 +- hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.h | 5 +++++ hw/ide/cmd646.c | 8 ++++---- hw/ide/ich.c | 10 +++++----- hw/ide/piix.c | 8 ++++---- hw/ide/via.c | 4 ++-- hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/isa/piix4.c | 4 ++-- hw/isa/vt82c686.c | 14 +++++++------- hw/misc/ivshmem.c | 18 +++++++++++------- hw/misc/pci-testdev.c | 11 ++++++++--- hw/misc/vfio.c | 4 ++-- hw/net/e1000.c | 20 +++++++++++++------- hw/net/eepro100.c | 14 ++++++++------ hw/net/ne2000.c | 6 ++++-- hw/net/pcnet-pci.c | 14 +++++++++----- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- hw/pci-bridge/dec.c | 2 +- hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pci_bridge.c | 7 ++++--- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- hw/scsi/esp-pci.c | 14 +++++++++----- hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- hw/scsi/megasas.c | 17 +++++++++++------ hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 19 +++++++++++++------ hw/virtio/virtio-pci.c | 4 ++-- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 48 files changed, 271 insertions(+), 191 deletions(-)
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/30 net/e1000: QOM Upcast Sweep
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/e1000.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
hw/net/e1000.c +13 -7
@@ -138,6 +138,11 @@ typedef struct E1000State_st {uint32_t compat_flags; } E1000State; +#define TYPE_E1000 "e1000" + +#define E1000 (obj) \ + OBJECT_CHECK(E1000State, (obj), TYPE_E1000) +#define defreg (x) x = (E1000_##x>>2)enum { defreg(CTRL), defreg(EECD), defreg(EERD), defreg(GPRC),
@@ -1175,7 +1180,7 @@ static int e1000_post_load(void *opaque, int version_id) }static const VMStateDescription vmstate_e1000 = { - .name ="e1000" , + .name =TYPE_E1000 , .version_id =2 , .minimum_version_id =1 , .minimum_version_id_old =1 ,
@@ -1296,7 +1301,7 @@ e1000_cleanup(NetClientState *nc)static void pci_e1000_uninit (PCIDevice *dev) { -E1000State *d =DO_UPCAST (E1000State, dev, dev); +E1000State *d =E1000 (dev);qemu_del_timer (d->autoneg_timer);qemu_free_timer (d->autoneg_timer);
@@ -1316,7 +1321,8 @@ static NetClientInfo net_e1000_info = {static int pci_e1000_init (PCIDevice *pci_dev) { -E1000State *d =DO_UPCAST (E1000State, dev, pci_dev); +DeviceState *dev =DEVICE (pci_dev); +E1000State *d =E1000 (pci_dev);uint8_t *pci_conf;uint16_t checksum =0 ;int i;
@@ -1347,11 +1353,11 @@ static int pci_e1000_init(PCIDevice *pci_dev) d->eeprom_data[EEPROM_CHECKSUM_REG ] = checksum; d->nic =qemu_new_nic (&net_e1000_info, &d->conf, -object_get_typename (OBJECT (d)), d->dev.qdev.id, d); +object_get_typename (OBJECT (d)), dev->id, d);qemu_format_nic_info_str (qemu_get_queue (d->nic), macaddr); -add_boot_device_path (d->conf.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (d->conf.bootindex, dev,"/ethernet-phy@0" ); d->autoneg_timer =qemu_new_timer_ms (vm_clock, e1000_autoneg_timer, d);
@@ -1360,7 +1366,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)static void qdev_e1000_reset (DeviceState *dev) { -E1000State *d =DO_UPCAST (E1000State, dev.qdev, dev); +E1000State *d =E1000 (dev);e1000_reset (d); }
@@ -1390,7 +1396,7 @@ static void e1000_class_init(ObjectClass *klass, void *data) }static const TypeInfo e1000_info = { - .name ="e1000" , + .name =TYPE_E1000 , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (E1000State), .class_init = e1000_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [RFT PATCH v1 01/30] net/e1000: QOM Upcast Sweep
Quoted 28 lines · On Tue, Jun 11, 2013 at 4:40 PM, <[email protected]> wrote:
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/net/e1000.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)hw/net/e1000.c +5
-0@@ -138,6 +138,11 @@ typedef struct E1000State_st {uint32_t compat_flags; } E1000State; +#define TYPE_E1000 "e1000" + +#define E1000 (obj) \ + OBJECT_CHECK(E1000State, (obj), TYPE_E1000) +#define defreg (x) x = (E1000_##x>>2)enum { defreg(CTRL), defreg(EECD), defreg(EERD), defreg(GPRC),
hw/net/e1000.c static int e1000_post_load(void *opaque, int version_id) · line 1183
Quoted 5 lines
hw/net/e1000.c +1
-1@@ -1175,7 +1180,7 @@ static int e1000_post_load(void *opaque, int version_id) }static const VMStateDescription vmstate_e1000 = { - .name ="e1000" , + .name =TYPE_E1000 ,
Will fix v2 as per discussion recent discussion on type string usages.
Regards,
Peter
PATCH 2/30 net/rtl8139: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/rtl8139.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
hw/net/rtl8139.c +18 -8
@@ -92,6 +92,11 @@ static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...) }#endif +#define TYPE_RTL8139 "rtl8139" + +#define RTL8139 (obj) \ + OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139) +/* Symbolic offsets to registers. */ enum RTL8139_registers {MAC0 =0 ,/* Ethernet hardware address. */
@@ -1197,7 +1202,7 @@ static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize)static void rtl8139_reset (DeviceState *d) { -RTL8139State *s =container_of (d, RTL8139State, dev.qdev); +RTL8139State *s =RTL8139 (d);int i;/* restore MAC address */
@@ -1364,6 +1369,8 @@ static const VMStateDescription vmstate_tally_counters = {static void rtl8139_ChipCmd_write (RTL8139State *s,uint32_t val) { +DeviceState *d =DEVICE (s); + val &=0xff ;DPRINTF ("ChipCmd write val=0x%08x\n" , val);
@@ -1371,7 +1378,7 @@ static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)if (val & CmdReset) {DPRINTF ("ChipCmd reset\n" ); -rtl8139_reset (&s->dev.qdev); +rtl8139_reset (d); }if (val & CmdRxEnb) {
@@ -1525,6 +1532,8 @@ static uint32_t rtl8139_BasicModeStatus_read(RTL8139State *s)static void rtl8139_Cfg9346_write (RTL8139State *s,uint32_t val) { +DeviceState *d =DEVICE (s); + val &=0xff ;DPRINTF ("Cfg9346 write val=0x%02x\n" , val);
@@ -1544,7 +1553,7 @@ static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val) }else if (opmode ==0x40 ) {/* Reset. */ val =0 ; -rtl8139_reset (&s->dev.qdev); +rtl8139_reset (d); } s->Cfg9346 = val;
@@ -3439,7 +3448,7 @@ static void rtl8139_cleanup(NetClientState *nc)static void pci_rtl8139_uninit (PCIDevice *dev) { -RTL8139State *s =DO_UPCAST (RTL8139State, dev, dev); +RTL8139State *s =RTL8139 (dev);memory_region_destroy (&s->bar_io);memory_region_destroy (&s->bar_mem);
@@ -3477,7 +3486,8 @@ static NetClientInfo net_rtl8139_info = {static int pci_rtl8139_init (PCIDevice *dev) { -RTL8139State * s =DO_UPCAST (RTL8139State, dev, dev); +RTL8139State *s =RTL8139 (dev); +DeviceState *d =DEVICE (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -3505,7 +3515,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->eeprom.contents[9 ] = s->conf.macaddr.a[4 ] | s->conf.macaddr.a[5 ] <<8 ; s->nic =qemu_new_nic (&net_rtl8139_info, &s->conf, -object_get_typename (OBJECT (dev)), dev->qdev.id, s); +object_get_typename (OBJECT (dev)), d->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->conf.macaddr.a); s->cplus_txbuffer =NULL ;
@@ -3516,7 +3526,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->timer =qemu_new_timer_ns (vm_clock, rtl8139_timer, s);rtl8139_set_next_tctr_time (s,qemu_get_clock_ns (vm_clock)); -add_boot_device_path (s->conf.bootindex, &dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->conf.bootindex, d,"/ethernet-phy@0" );return 0 ; }
@@ -3544,7 +3554,7 @@ static void rtl8139_class_init(ObjectClass *klass, void *data) }static const TypeInfo rtl8139_info = { - .name ="rtl8139" , + .name =TYPE_RTL8139 , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (RTL8139State), .class_init = rtl8139_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 3/30 net/pcnet-pci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/pcnet-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/net/pcnet-pci.c +9 -5
@@ -43,6 +43,10 @@//#define PCNET_DEBUG_TMD //#define PCNET_DEBUG_MATCH +#define TYPE_PCI_PC_NET "pcnet" + +#define PCI_PC_NET (obj) \ + OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET) typedef struct { PCIDevice pci_dev;
@@ -273,7 +277,7 @@ static void pci_pcnet_cleanup(NetClientState *nc)static void pci_pcnet_uninit (PCIDevice *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);memory_region_destroy (&d->state.mmio);memory_region_destroy (&d->io_bar);
@@ -293,7 +297,7 @@ static NetClientInfo net_pci_pcnet_info = {static int pci_pcnet_init (PCIDevice *pci_dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev); +PCIPCNetState *d =PCI_PC_NET (pci_dev);PCNetState *s = &d->state;uint8_t *pci_conf;
@@ -329,12 +333,12 @@ static int pci_pcnet_init(PCIDevice *pci_dev) s->phys_mem_write = pci_physical_memory_write; s->dma_opaque = pci_dev; -return pcnet_common_init (&pci_dev->qdev, s, &net_pci_pcnet_info); +return pcnet_common_init (DEVICE (pci_dev), s, &net_pci_pcnet_info); }static void pci_reset (DeviceState *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev.qdev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);pcnet_h_reset (&d->state); }
@@ -362,7 +366,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) }static const TypeInfo pcnet_info = { - .name ="pcnet" , + .name =TYPE_PCI_PC_NET , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIPCNetState), .class_init = pcnet_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 4/30 usb/hcd-xhci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/usb/hcd-xhci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hw/usb/hcd-xhci.c +13 -6
@@ -482,6 +482,11 @@ struct XHCIState {XHCIRing cmd_ring; }; +#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)static void xhci_reset (DeviceState *dev) { -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev.qdev, dev); +XHCIState *xhci =XHCI (dev);int i;trace_usb_xhci_reset ();
@@ -2926,6 +2931,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, uint64_t val, unsigned size) {XHCIState *xhci = ptr; +DeviceState *d =DEVICE (ptr);trace_usb_xhci_oper_write (reg, val);
@@ -2939,7 +2945,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, xhci->usbcmd = val &0xc0f ;xhci_mfwrap_update (xhci);if (val &USBCMD_HCRST ) { -xhci_reset (&xhci->pci_dev.qdev); +xhci_reset (d); }xhci_intx_update (xhci);break ;
@@ -3267,6 +3273,7 @@ static USBBusOps xhci_bus_ops = {static void usb_xhci_init (XHCIState *xhci,DeviceState *dev) { +DeviceState *d =DEVICE (xhci);XHCIPort *port;int i, usbports, speedmask;
@@ -3281,7 +3288,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState *dev) usbports =MAX (xhci->numports_2, xhci->numports_3); xhci->numports = xhci->numports_2 + xhci->numports_3; -usb_bus_new (&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev); +usb_bus_new (&xhci->bus, &xhci_bus_ops, d);for (i =0 ; i < usbports; i++) { speedmask =0 ;
@@ -3313,14 +3320,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev) {int i, ret; -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev, dev); +XHCIState *xhci =XHCI (dev); xhci->pci_dev.config[PCI_CLASS_PROG ] =0x30 ;/* xHCI */ xhci->pci_dev.config[PCI_INTERRUPT_PIN ] =0x01 ;/* interrupt pin 1 */ xhci->pci_dev.config[PCI_CACHE_LINE_SIZE ] =0x10 ; xhci->pci_dev.config[0x60 ] =0x30 ;/* release number */ -usb_xhci_init (xhci, &dev->qdev); +usb_xhci_init (xhci,DEVICE (dev));if (xhci->numintrs >MAXINTRS ) { xhci->numintrs =MAXINTRS ;
@@ -3581,7 +3588,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) }static const TypeInfo xhci_info = { - .name ="nec-usb-xhci" , + .name =TYPE_XHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (XHCIState), .class_init = xhci_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 5/30 scsi/lsi53c895a: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
hw/scsi/lsi53c895a.c +16 -10
@@ -275,6 +275,11 @@ typedef struct {uint32_t script_ram[2048 ]; } LSIState; +#define TYPE_LSI53C895A "lsi53c895a" + +#define LSI53C895A (obj) \ + OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A) +static inline int lsi_irq_on_rsl (LSIState *s) {return (s->sien0 &LSI_SIST0_RSL ) && (s->scid &LSI_SCID_RRE );
@@ -653,7 +658,7 @@ static void lsi_request_free(LSIState *s, lsi_request *p)static void lsi_request_cancelled (SCSIRequest *req) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);lsi_request *p = req->hba_private; req->hba_private =NULL ;
@@ -692,7 +697,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req, uint32_t len)/* Callback to indicate that the SCSI layer has completed a command. */ static void lsi_command_complete (SCSIRequest *req,uint32_t status,size_t resid) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out; out = (s->sstat1 &PHASE_MASK ) ==PHASE_DO ;
@@ -717,7 +722,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid/* Callback to indicate that the SCSI layer has completed a transfer. */ static void lsi_transfer_data (SCSIRequest *req,uint32_t len) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out;assert (req->hba_private);
@@ -1726,7 +1731,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)lsi_execute_script (s); }if (val &LSI_ISTAT0_SRST ) { -qdev_reset_all (&s->dev.qdev); +qdev_reset_all (DEVICE (s)); }break ;case 0x16 :/* MBOX0 */
@@ -1960,7 +1965,7 @@ static const MemoryRegionOps lsi_io_ops = {static void lsi_scsi_reset (DeviceState *dev) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, dev); +LSIState *s =LSI53C895A (dev);lsi_soft_reset (s); }
@@ -2061,7 +2066,7 @@ static const VMStateDescription vmstate_lsi_scsi = {static void lsi_scsi_uninit (PCIDevice *d) { -LSIState *s =DO_UPCAST (LSIState, dev, d); +LSIState *s =LSI53C895A (d);memory_region_destroy (&s->mmio_io);memory_region_destroy (&s->ram_io);
@@ -2080,7 +2085,8 @@ static const struct SCSIBusInfo lsi_scsi_info = {static int lsi_scsi_init (PCIDevice *dev) { -LSIState *s =DO_UPCAST (LSIState, dev, dev); +LSIState *s =LSI53C895A (dev); +DeviceState *d =DEVICE (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -2099,8 +2105,8 @@ static int lsi_scsi_init(PCIDevice *dev)pci_register_bar (&s->dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io);QTAILQ_INIT (&s->queue); -scsi_bus_new (&s->bus, &dev->qdev, &lsi_scsi_info,NULL ); -if (!dev->qdev.hotplugged) { +scsi_bus_new (&s->bus, d, &lsi_scsi_info,NULL ); +if (!d->hotplugged) {return scsi_bus_legacy_handle_cmdline (&s->bus); }return 0 ;
@@ -2122,7 +2128,7 @@ static void lsi_class_init(ObjectClass *klass, void *data) }static const TypeInfo lsi_info = { - .name ="lsi53c895a" , + .name =TYPE_LSI53C895A , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (LSIState), .class_init = lsi_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 6/30 scsi/megasas: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/megasas.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/scsi/megasas.c +11 -6
@@ -108,6 +108,11 @@ typedef struct MegasasState {SCSIBus bus; } MegasasState; +#define TYPE_MEGASAS "megasas" + +#define MEGASAS (obj) \ + OBJECT_CHECK(MegasasState, (obj), TYPE_MEGASAS) +#define MEGASAS_INTR_DISABLED_MASK 0xFFFFFFFFstatic bool megasas_intr_enabled (MegasasState *s)
@@ -2039,13 +2044,13 @@ static void megasas_soft_reset(MegasasState *s)static void megasas_scsi_reset (DeviceState *dev) { -MegasasState *s =DO_UPCAST (MegasasState, dev.qdev, dev); +MegasasState *s =MEGASAS (dev);megasas_soft_reset (s); }static const VMStateDescription vmstate_megasas = { - .name ="megasas" , + .name =TYPE_MEGASAS , .version_id =0 , .minimum_version_id =0 , .minimum_version_id_old =0 ,
@@ -2064,7 +2069,7 @@ static const VMStateDescription vmstate_megasas = {static void megasas_scsi_uninit (PCIDevice *d) { -MegasasState *s =DO_UPCAST (MegasasState, dev, d); +MegasasState *s =MEGASAS (d);#ifdef USE_MSIX msix_uninit (&s->dev, &s->mmio_io);
@@ -2087,7 +2092,7 @@ static const struct SCSIBusInfo megasas_scsi_info = {static int megasas_scsi_init (PCIDevice *dev) { -MegasasState *s =DO_UPCAST (MegasasState, dev, dev); +MegasasState *s =MEGASAS (dev);uint8_t *pci_conf;int i, bar_type;
@@ -2158,7 +2163,7 @@ static int megasas_scsi_init(PCIDevice *dev) s->frames[i].state = s; } -scsi_bus_new (&s->bus, &dev->qdev, &megasas_scsi_info,NULL ); +scsi_bus_new (&s->bus,DEVICE (dev), &megasas_scsi_info,NULL );scsi_bus_legacy_handle_cmdline (&s->bus);return 0 ; }
@@ -2198,7 +2203,7 @@ static void megasas_class_init(ObjectClass *oc, void *data) }static const TypeInfo megasas_info = { - .name ="megasas" , + .name =TYPE_MEGASAS , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (MegasasState), .class_init = megasas_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [RFT PATCH v1 06/30] scsi/megasas: QOM Upcast Sweep
Quoted 30 lines · On Tue, Jun 11, 2013 at 4:44 PM, <[email protected]> wrote:
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/scsi/megasas.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)hw/scsi/megasas.c +5
-0@@ -108,6 +108,11 @@ typedef struct MegasasState {SCSIBus bus; } MegasasState; +#define TYPE_MEGASAS "megasas" + +#define MEGASAS (obj) \ + OBJECT_CHECK(MegasasState, (obj), TYPE_MEGASAS) +#define MEGASAS_INTR_DISABLED_MASK 0xFFFFFFFFstatic bool megasas_intr_enabled (MegasasState *s)@@ -2039,13 +2044,13 @@ static void megasas_soft_reset(MegasasState *s)static void megasas_scsi_reset (DeviceState *dev)
hw/scsi/megasas.c static void megasas_soft_reset(MegasasState *s) · line 2053
Quoted 10 lines
hw/scsi/megasas.c +2
-2{ -MegasasState *s =DO_UPCAST (MegasasState, dev.qdev, dev); +MegasasState *s =MEGASAS (dev);megasas_soft_reset (s); }static const VMStateDescription vmstate_megasas = { - .name ="megasas" , + .name =TYPE_MEGASAS ,
Will fix v2.
Regards,
Peter
PATCH 7/30 scsi/esp-pci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/esp-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/scsi/esp-pci.c +9 -5
@@ -31,6 +31,9 @@#define TYPE_AM53C974_DEVICE "am53c974" +#define PCI_ESP (obj) \ + OBJECT_CHECK(PCIESPState, (obj), TYPE_AM53C974_DEVICE) +#define DMA_CMD 0x0#define DMA_STC 0x1#define DMA_SPA 0x2
@@ -288,7 +291,7 @@ static const MemoryRegionOps esp_pci_io_ops = {static void esp_pci_hard_reset (DeviceState *dev) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev.qdev, dev); +PCIESPState *pci =PCI_ESP (dev);esp_hard_reset (&pci->esp); pci->dma_regs[DMA_CMD ] &= ~(DMA_CMD_DIR |DMA_CMD_INTE_D |DMA_CMD_INTE_P |DMA_CMD_MDL |DMA_CMD_DIAG |DMA_CMD_MASK );
@@ -336,7 +339,8 @@ static const struct SCSIBusInfo esp_pci_scsi_info = {static int esp_pci_scsi_init (PCIDevice *dev) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev, dev); +PCIESPState *pci =PCI_ESP (dev); +DeviceState *d =DEVICE (dev);ESPState *s = &pci->esp;uint8_t *pci_conf;
@@ -354,8 +358,8 @@ static int esp_pci_scsi_init(PCIDevice *dev)pci_register_bar (&pci->dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &pci->io); s->irq = pci->dev.irq[0 ]; -scsi_bus_new (&s->bus, &dev->qdev, &esp_pci_scsi_info,NULL ); -if (!dev->qdev.hotplugged) { +scsi_bus_new (&s->bus, d, &esp_pci_scsi_info,NULL ); +if (!d->hotplugged) {return scsi_bus_legacy_handle_cmdline (&s->bus); }return 0 ;
@@ -363,7 +367,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)static void esp_pci_scsi_uninit (PCIDevice *d) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev, d); +PCIESPState *pci =PCI_ESP (d);memory_region_destroy (&pci->io); }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 8/30 ide/ich: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/ide/ahci.h | 5 +++++ hw/ide/ich.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
hw/ide/ahci.h +5 -0
@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState; +#define TYPE_ICH_AHCI "ich9-ahci" + +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI) +extern const VMStateDescription vmstate_ahci;#define VMSTATE_AHCI (_field, _state) { \
hw/ide/ich.c +5 -5
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {static void pci_ich9_reset (DeviceState *dev) { - struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); +struct AHCIPCIState *d =ICH_AHCI (dev);ahci_reset (&d->ahci); }
@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)struct AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev); -ahci_init (&d->ahci, &dev->qdev,pci_dma_context (dev),6 ); +ahci_init (&d->ahci,DEVICE (dev),pci_dma_context (dev),6 );pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 );
@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)static void pci_ich9_uninit (PCIDevice *dev) {struct AHCIPCIState *d; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev);msi_uninit (dev);ahci_uninit (&d->ahci);
@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) }static const TypeInfo ich_ahci_info = { - .name ="ich9-ahci" , + .name =TYPE_ICH_AHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (AHCIPCIState), .class_init = ich_ahci_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 9/30 ide/piix: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usage of DO_UPCAST and direct -> style upcasting.
---
hw/ide/piix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ide/piix.c +4 -4
@@ -135,7 +135,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));
@@ -159,7 +159,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);pci_piix_init_ports (d);
@@ -173,7 +173,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)DriveInfo *di;int i =0 ; - pci_dev =DO_UPCAST (PCIDevice, qdev, dev); + pci_dev =PCI_DEVICE (dev); pci_ide =DO_UPCAST (PCIIDEState, dev, pci_dev);for (; i <3 ; i++) {
@@ -188,7 +188,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)drive_put_ref (di); } } -qdev_reset_all (&(pci_ide->dev.qdev)); +qdev_reset_all (DEVICE (dev));return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 10/30 acpi/piix4: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +17 -14
@@ -96,6 +96,11 @@ typedef struct PIIX4PMState {Notifier cpu_added_notifier; } PIIX4PMState; +#define TYPE_PIIX4_PM "PIIX4_PM" + +#define PIIX4_PM (obj) \ + OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM) +static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,PCIBus *bus,PIIX4PMState *s);
@@ -300,7 +305,7 @@ static const VMStateDescription vmstate_acpi = {static void acpi_piix_eject_slot (PIIX4PMState *s,unsigned slots) {BusChild *kid, *next; -BusState *bus =qdev_get_parent_bus (&s->dev.qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (s));int slot =ffs (slots) -1 ;bool slot_free = true;
@@ -326,8 +331,7 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)static void piix4_update_hotplug (PIIX4PMState *s) { -PCIDevice *dev = &s->dev; -BusState *bus =qdev_get_parent_bus (&dev->qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (s));BusChild *kid, *next;/* Execute any pending removes during reset */
@@ -395,7 +399,7 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)static int piix4_pm_initfn (PCIDevice *dev) { -PIIX4PMState *s =DO_UPCAST (PIIX4PMState, dev, dev); +PIIX4PMState *s =PIIX4_PM (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -418,7 +422,7 @@ static int piix4_pm_initfn(PCIDevice *dev) pci_conf[0x90 ] = s->smb_io_base |1 ; pci_conf[0x91 ] = s->smb_io_base >>8 ; pci_conf[0xd2 ] =0x09 ; -pm_smbus_init (&s->dev.qdev, &s->smb); +pm_smbus_init (DEVICE (dev), &s->smb);memory_region_set_enabled (&s->smb.io, pci_conf[0xd2 ] &1 );memory_region_add_subregion (pci_address_space_io (dev), s->smb_io_base, &s->smb.io);
@@ -449,18 +453,18 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, int kvm_enabled, FWCfgState *fw_cfg) { - PCIDevice *dev; + DeviceState *dev;PIIX4PMState *s; - dev =pci_create (bus, devfn,"PIIX4_PM" ); -qdev_prop_set_uint32 (&dev->qdev,"smb_io_base" , smb_io_base); + dev =DEVICE (pci_create (bus, devfn,TYPE_PIIX4_PM )); +qdev_prop_set_uint32 (dev,"smb_io_base" , smb_io_base); - s =DO_UPCAST (PIIX4PMState, dev, dev); + s =PIIX4_PM (dev); s->irq = sci_irq; s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (dev);if (fw_cfg) {uint8_t suspend[6 ] = {128 ,0 ,0 ,129 ,128 ,128 };
@@ -500,7 +504,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) }static const TypeInfo piix4_pm_info = { - .name ="PIIX4_PM" , + .name =TYPE_PIIX4_PM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PIIX4PMState), .class_init = piix4_pm_class_init,
@@ -678,7 +682,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, PCI_HOTPLUG_SIZE);memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , &s->io_pci); -pci_bus_hotplug (bus, piix4_device_hotplug, &s->dev.qdev); +pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s));qemu_for_each_cpu (piix4_init_cpu_status, &s->gpe_cpu); memory_region_init_io(&s->io_cpu, &cpu_hotplug_ops, s, "apci-cpu-hotplug",
@@ -704,8 +708,7 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, PCIHotplugState state) {int slot =PCI_SLOT (dev->devfn); -PIIX4PMState *s =DO_UPCAST (PIIX4PMState, dev, -PCI_DEVICE (qdev)); +PIIX4PMState *s =PIIX4_PM (qdev);/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 11/30 misc/pci-testdev: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/misc/pci-testdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/misc/pci-testdev.c +8 -3
@@ -83,6 +83,11 @@ typedef struct PCITestDevState {int current; } PCITestDevState; +#define TYPE_PCI_TEST_DEV "pci-testdev" + +#define PCI_TEST_DEV (obj) \ + OBJECT_CHECK(PCITestDevState, (obj), TYPE_PCI_TEST_DEV) +#define IOTEST_IS_MEM (i) (strcmp(IOTEST_TYPE(i), "portio"))#define IOTEST_REGION (d, i) (IOTEST_IS_MEM(i) ? &(d)->mmio : &(d)->portio)#define IOTEST_SIZE (i) (IOTEST_IS_MEM(i) ? IOTEST_MEMSIZE : IOTEST_IOSIZE)
@@ -274,7 +279,7 @@ static int pci_testdev_init(PCIDevice *pci_dev)static void pci_testdev_uninit (PCIDevice *dev) { -PCITestDevState *d =DO_UPCAST (PCITestDevState, dev, dev); +PCITestDevState *d =PCI_TEST_DEV (dev);int i;pci_testdev_reset (d);
@@ -291,7 +296,7 @@ pci_testdev_uninit(PCIDevice *dev)static void qdev_pci_testdev_reset (DeviceState *dev) { -PCITestDevState *d =DO_UPCAST (PCITestDevState, dev.qdev, dev); +PCITestDevState *d =PCI_TEST_DEV (dev);pci_testdev_reset (d); }
@@ -311,7 +316,7 @@ static void pci_testdev_class_init(ObjectClass *klass, void *data) }static const TypeInfo pci_testdev_info = { - .name ="pci-testdev" , + .name =TYPE_PCI_TEST_DEV , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCITestDevState), .class_init = pci_testdev_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 12/30 virtio/virtio-pci: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of container_of() and direct -> style upcasting.
---
hw/virtio/virtio-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-pci.c +2 -2
@@ -98,7 +98,7 @@ static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);/* DeviceState to VirtIOPCIProxy. For use off data-path. TODO: use QOM. */ static inline VirtIOPCIProxy *to_virtio_pci_proxy (DeviceState *d) { -return container_of (d, VirtIOPCIProxy, pci_dev.qdev); +return VIRTIO_PCI (d); }/* DeviceState to VirtIOPCIProxy. Note: used on datapath,
@@ -106,7 +106,7 @@ static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d)*/ static inline VirtIOPCIProxy *to_virtio_pci_proxy_fast (DeviceState *d) { -return container_of (d, VirtIOPCIProxy, pci_dev.qdev); +return VIRTIO_PCI (d); }static void virtio_pci_notify (DeviceState *d,uint16_t vector)
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [RFT PATCH v1 12/30] virtio/virtio-pci: QOM casting sweep
Hi,
Quoted 6 lines · On 11/06/2013 08:49, [email protected] wrote:
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of
container_of()and direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>
[...]
hw/virtio/virtio-pci.c static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev); · line 102
Quoted 5 lines
static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d) {hw/virtio/virtio-pci.c +1
-1-return container_of (d, VirtIOPCIProxy, pci_dev.qdev); +return VIRTIO_PCI (d); }
Maybe you can replace each to_virtio_pci_proxy directly with VIRTIO_PCI?
Quoted 11 lines
/* DeviceState to VirtIOPCIProxy. Note: used on datapath,
hw/virtio/virtio-pci.c +1
-1@@ -106,7 +106,7 @@ static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d)*/ static inline VirtIOPCIProxy *to_virtio_pci_proxy_fast (DeviceState *d) { -return container_of (d, VirtIOPCIProxy, pci_dev.qdev); +return VIRTIO_PCI (d); }static void virtio_pci_notify (DeviceState *d,uint16_t vector)
Re: [Qemu-devel] [RFT PATCH v1 12/30] virtio/virtio-pci: QOM casting sweep
Hi Frederic,
Quoted 14 lines · Frederic Konrad
Hi,
Quoted 7 lines · On 11/06/2013 08:49, [email protected] wrote:
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of
container_of()and direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>[...]
Quoted 9 lines
hw/virtio/virtio-pci.c static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev); · line 102
Quoted 5 lines
static inline VirtIOPCIProxy *to_virtio_pci_proxy(DeviceState *d) {hw/virtio/virtio-pci.c +1
-1-return container_of (d, VirtIOPCIProxy, pci_dev.qdev); +return VIRTIO_PCI (d); }Maybe you can replace each
to_virtio_pci_proxydirectly withVIRTIO_PCI?
I'm going to drop this one V2 for the moment and revisit is later. Its more complicated, given the replications between the fast and slow versions and needs a little more research (and a mini series of its own).
Regards,
Peter
PATCH 13/30 virtio/vmware_vga: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style casting.
---
hw/display/vmware_vga.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/display/vmware_vga.c +8 -5
@@ -81,6 +81,11 @@ struct vmsvga_state_s {int redraw_fifo_first, redraw_fifo_last; }; +#define TYPE_VM_SVGA "vmware-svga" + +#define VM_SVGA (obj) \ + OBJECT_CHECK(struct pci_vmsvga_state_s, (obj), TYPE_VM_SVGA) +struct pci_vmsvga_state_s {PCIDevice card;struct vmsvga_state_s chip;
@@ -1092,8 +1097,7 @@ static void vmsvga_update_display(void *opaque)static void vmsvga_reset (DeviceState *dev) { -struct pci_vmsvga_state_s *pci = - DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev); +struct pci_vmsvga_state_s *pci =VM_SVGA (dev);struct vmsvga_state_s *s = &pci->chip; s->index =0 ;
@@ -1246,8 +1250,7 @@ static const MemoryRegionOps vmsvga_io_ops = {static int pci_vmsvga_initfn (PCIDevice *dev) { -struct pci_vmsvga_state_s *s = - DO_UPCAST(struct pci_vmsvga_state_s, card, dev); +struct pci_vmsvga_state_s *s =VM_SVGA (dev); s->card.config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ s->card.config[PCI_LATENCY_TIMER ] =0x40 ;/* Latency timer */
@@ -1299,7 +1302,7 @@ static void vmsvga_class_init(ObjectClass *klass, void *data) }static const TypeInfo vmsvga_info = { - .name ="vmware-svga" , + .name =TYPE_VM_SVGA , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (struct pci_vmsvga_state_s ), .class_init = vmsvga_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 14/30 misc/ivshmem: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/misc/ivshmem.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
hw/misc/ivshmem.c +11 -7
@@ -48,6 +48,10 @@#define IVSHMEM_DPRINTF (fmt, ...)#endif +#define TYPE_IVSHMEM "ivshmem" +#define IVSHMEM (obj) \ + OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM) + typedef struct Peer { int nb_eventfds; EventNotifier *eventfds;
@@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) {memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));memory_region_add_subregion (&s->bar,0 , &s->ivshmem);/* region for shared memory */
@@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) incoming_fd, 0);memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, map_ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));IVSHMEM_DPRINTF ("guest h/w addr = %" PRIu64", size = %" PRIu64"\n" , s->ivshmem_offset, s->ivshmem_size);
@@ -534,7 +538,7 @@ static void ivshmem_use_msix(IVShmemState * s)static void ivshmem_reset (DeviceState *d) { -IVShmemState *s =DO_UPCAST (IVShmemState, dev.qdev, d); +IVShmemState *s =IVSHMEM (d); s->intrstatus =0 ;ivshmem_use_msix (s);
@@ -648,7 +652,7 @@ static int pci_ivshmem_init(PCIDevice *dev) s->ivshmem_size =ivshmem_get_size (s); } -register_savevm (&s->dev.qdev,"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, +register_savevm (DEVICE (dev),"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, dev);/* IRQFD requires MSI */
@@ -779,10 +783,10 @@ static void pci_ivshmem_uninit(PCIDevice *dev)memory_region_destroy (&s->ivshmem_mmio);memory_region_del_subregion (&s->bar, &s->ivshmem); -vmstate_unregister_ram (&s->ivshmem, &s->dev.qdev); +vmstate_unregister_ram (&s->ivshmem,DEVICE (dev));memory_region_destroy (&s->ivshmem);memory_region_destroy (&s->bar); -unregister_savevm (&dev->qdev,"ivshmem" , s); +unregister_savevm (DEVICE (dev),"ivshmem" , s); }static Property ivshmem_properties[] = {
@@ -812,7 +816,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) }static const TypeInfo ivshmem_info = { - .name ="ivshmem" , + .name =TYPE_IVSHMEM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (IVShmemState), .class_init = ivshmem_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 15/30 xen/xen_platform: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
hw/xen/xen_platform.c +16 -12
@@ -62,6 +62,10 @@ typedef struct PCIXenPlatformState {int log_buffer_off; } PCIXenPlatformState; +#define TYPE_XEN_PLATFORM "xen-platform" +#define XEN_PLATFORM (obj) \ + OBJECT_CHECK(PCIXenPlatformState, (obj), TYPE_XEN_PLATFORM) +#define XEN_PLATFORM_IOPORT 0x10/* Send bytes to syslog */
@@ -88,7 +92,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_NETWORK_ETHERNET &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_free (&d->qdev); +qdev_free (DEVICE (d)); } }
@@ -103,7 +107,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_STORAGE_IDE &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_unplug (&(d->qdev),NULL ); +qdev_unplug (DEVICE (d),NULL ); } }
@@ -114,7 +118,7 @@ static void pci_unplug_disks(PCIBus *bus)static void platform_fixed_ioport_writew (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -164,7 +168,7 @@ static void platform_fixed_ioport_writel(void *opaque, uint32_t addr,static void platform_fixed_ioport_writeb (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */ {
@@ -187,7 +191,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t vstatic uint32_t platform_fixed_ioport_readw (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -206,7 +210,7 @@ static uint32_t platform_fixed_ioport_readw(void *opaque, uint32_t addr)static uint32_t platform_fixed_ioport_readb (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -222,7 +226,7 @@ static uint32_t platform_fixed_ioport_readb(void *opaque, uint32_t addr)static void platform_fixed_ioport_reset (void *opaque) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 ,0 ); }
@@ -292,7 +296,7 @@ static uint64_t xen_platform_ioport_readb(void *opaque, hwaddr addr,static void xen_platform_ioport_writeb (void *opaque,hwaddr addr,uint64_t val,unsigned int size) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */
@@ -349,7 +353,7 @@ static void platform_mmio_setup(PCIXenPlatformState *d)static int xen_platform_post_load (void *opaque,int version_id) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 , s->flags);
@@ -371,7 +375,7 @@ static const VMStateDescription vmstate_xen_platform = {static int xen_platform_initfn (PCIDevice *dev) { -PCIXenPlatformState *d =DO_UPCAST (PCIXenPlatformState, pci_dev, dev); +PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; pci_conf = d->pci_dev.config;
@@ -397,7 +401,7 @@ static int xen_platform_initfn(PCIDevice *dev)static void platform_reset (DeviceState *dev) { -PCIXenPlatformState *s =DO_UPCAST (PCIXenPlatformState, pci_dev.qdev, dev); +PCIXenPlatformState *s =XEN_PLATFORM (dev);platform_fixed_ioport_reset (s); }
@@ -420,7 +424,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data) }static const TypeInfo xen_platform_info = { - .name ="xen-platform" , + .name =TYPE_XEN_PLATFORM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIXenPlatformState), .class_init = xen_platform_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 16/30 isa/*: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macros. Remove usage of DO_UPCAST and direct -> style upcasting.
---
hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/isa/piix4.c | 4 ++-- hw/isa/vt82c686.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-)
hw/isa/i82378.c +4 -4
@@ -159,8 +159,7 @@ static void i82378_request_out0_irq(void *opaque, int irq, int level)static void i82378_request_pic_irq (void *opaque,int irq,int level) { -DeviceState *dev = opaque; -PCIDevice *pci =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pci =PCI_DEVICE (opaque);PCIi82378State *s =DO_UPCAST (PCIi82378State, pci_dev, pci);qemu_set_irq (s->state.i8259[irq], level);
@@ -210,6 +209,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)static int pci_i82378_init (PCIDevice *dev) {PCIi82378State *pci =DO_UPCAST (PCIi82378State, pci_dev, dev); +DeviceState *d =DEVICE (pci);I82378State *s = &pci->state;uint8_t *pci_conf;
@@ -233,9 +233,9 @@ static int pci_i82378_init(PCIDevice *dev)pci_set_long (pci_conf +PCI_BASE_ADDRESS_0 , pci->isa_io_base); isa_mem_base = pci->isa_mem_base; -isa_bus_new (&dev->qdev,pci_address_space_io (dev)); +isa_bus_new (d,pci_address_space_io (dev)); -i82378_init (&dev->qdev, s); +i82378_init (d, s);return 0 ; }
hw/isa/lpc_ich9.c +3 -3
@@ -277,7 +277,7 @@ void ich9_lpc_set_irq(void *opaque, int pirq, int level)*/ int ich9_lpc_map_irq (PCIDevice *pci_dev,int intx) { -BusState *bus =qdev_get_parent_bus (&pci_dev->qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (pci_dev));PCIBus *pci_bus =PCI_BUS (bus);PCIDevice *lpc_pdev = pci_bus->devices[PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC )];
@@ -364,7 +364,7 @@ void ich9_lpc_pm_init(PCIDevice *lpc_pci) sci_irq =qemu_allocate_irqs (ich9_set_sci, lpc,1 );ich9_pm_init (lpc_pci, &lpc->pm, sci_irq[0 ]); -ich9_lpc_reset (&lpc->d.qdev); +ich9_lpc_reset (DEVICE (lpc)); }/* APM */
@@ -529,7 +529,7 @@ static int ich9_lpc_initfn(PCIDevice *d)ICH9LPCState *lpc =ICH9_LPC_DEVICE (d);ISABus *isa_bus; - isa_bus =isa_bus_new (&d->qdev,get_system_io ()); + isa_bus =isa_bus_new (DEVICE (d),get_system_io ());pci_set_long (d->wmask +ICH9_LPC_PMBASE ,ICH9_LPC_PMBASE_BASE_ADDRESS_MASK );
hw/isa/piix4.c +2 -2
@@ -87,7 +87,7 @@ static int piix4_initfn(PCIDevice *dev) {PIIX4State *d =DO_UPCAST (PIIX4State, dev, dev); -isa_bus_new (&d->dev.qdev,pci_address_space_io (dev)); +isa_bus_new (DEVICE (dev),pci_address_space_io (dev)); piix4_dev = &d->dev;qemu_register_reset (piix4_reset, d);return 0 ;
@@ -98,7 +98,7 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)PCIDevice *d; d =pci_create_simple_multifunction (bus, devfn, true,"PIIX4" ); - *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); + *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" ));return d->devfn; }
hw/isa/vt82c686.c +7 -7
@@ -266,7 +266,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)PCIDevice *dev; dev =pci_create (bus, devfn,"VT82C686B_AC97" ); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev)); }static void via_ac97_class_init (ObjectClass *klass,void *data)
@@ -307,7 +307,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)PCIDevice *dev; dev =pci_create (bus, devfn,"VT82C686B_MC97" ); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev)); }static void via_mc97_class_init (ObjectClass *klass,void *data)
@@ -349,7 +349,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev) pci_conf[0x90 ] = s->smb_io_base |1 ; pci_conf[0x91 ] = s->smb_io_base >>8 ; pci_conf[0xd2 ] =0x90 ; -pm_smbus_init (&s->dev.qdev, &s->smb); +pm_smbus_init (DEVICE (dev), &s->smb);memory_region_add_subregion (get_system_io (), s->smb_io_base, &s->smb.io);apm_init (dev, &s->apm,NULL , s);
@@ -372,11 +372,11 @@ i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,VT686PMState *s; dev =pci_create (bus, devfn,"VT82C686B_PM" ); -qdev_prop_set_uint32 (&dev->qdev,"smb_io_base" , smb_io_base); +qdev_prop_set_uint32 (DEVICE (dev),"smb_io_base" , smb_io_base); s =DO_UPCAST (VT686PMState, dev, dev); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev));return s->smb.smbus; }
@@ -427,7 +427,7 @@ static int vt82c686b_initfn(PCIDevice *d)uint8_t *wmask;int i; -isa_bus_new (&d->qdev,pci_address_space_io (d)); +isa_bus_new (DEVICE (d),pci_address_space_io (d)); pci_conf = d->config;pci_config_set_prog_interface (pci_conf,0x0 );
@@ -450,7 +450,7 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn) d =pci_create_simple_multifunction (bus, devfn, true,"VT82C686B" ); -return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); +return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" )); }static void via_class_init (ObjectClass *klass,void *data)
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [RFT PATCH v1 16/30] isa/*: QOM casting sweep
Am 11.06.2013 08:52, schrieb [email protected]:
Quoted 13 lines
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macros. Remove usage of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/isa/piix4.c | 4 ++-- hw/isa/vt82c686.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-)
[...]
Quoted 4 lines
hw/isa/piix4.c +0
-0
[...]
hw/isa/piix4.c int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn) · line 101
Quoted 6 lines
hw/isa/piix4.c +1
-1@@ -98,7 +98,7 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)PCIDevice *d; d =pci_create_simple_multifunction (bus, devfn, true,"PIIX4" ); - *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); + *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" ));
Conflict, my ISABus patch does ISA_BUS() in addition:
http://patchwork.ozlabs.org/patch/249705/
Quoted 7 lines
hw/isa/piix4.c +0
-0return d->devfn; }hw/isa/vt82c686.c +0
-0
[...]
hw/isa/vt82c686.c ISABus *vt82c686b_init(PCIBus *bus, int devfn) · line 453
Quoted 6 lines
hw/isa/vt82c686.c +1
-1@@ -450,7 +450,7 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn) d =pci_create_simple_multifunction (bus, devfn, true,"VT82C686B" ); -return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); +return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" ));
Ditto.
hw/isa/vt82c686.c ISABus *vt82c686b_init(PCIBus *bus, int devfn) · line 456
Quoted 3 lines
hw/isa/vt82c686.c +0
-0}static void via_class_init (ObjectClass *klass,void *data)
Otherwise looks fine.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [RFT PATCH v1 16/30] isa/*: QOM casting sweep
Hi Andreas,
Quoted 38 lines · Andreas Färber
Am 11.06.2013 08:52, schrieb [email protected]:
Quoted 13 lines
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macros. Remove usage of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/isa/piix4.c | 4 ++-- hw/isa/vt82c686.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-)[...]
Quoted 4 lines
hw/isa/piix4.c +0
-0[...]
hw/isa/piix4.c int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn) · line 101
Quoted 6 lines
hw/isa/piix4.c +1
-1@@ -98,7 +98,7 @@ int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)PCIDevice *d; d =pci_create_simple_multifunction (bus, devfn, true,"PIIX4" ); - *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); + *isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" ));Conflict, my ISABus patch does
ISA_BUS()in addition:
http://patchwork.ozlabs.org/patch/249705/Quoted 7 lines
hw/isa/piix4.c +0
-0return d->devfn; }hw/isa/vt82c686.c +0
-0[...]
Quoted 9 lines
hw/isa/vt82c686.c ISABus *vt82c686b_init(PCIBus *bus, int devfn) · line 453
Quoted 6 lines
hw/isa/vt82c686.c +1
-1@@ -450,7 +450,7 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn) d =pci_create_simple_multifunction (bus, devfn, true,"VT82C686B" ); -return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&d->qdev,"isa.0" )); +return DO_UPCAST (ISABus, qbus,qdev_get_child_bus (DEVICE (d),"isa.0" ));Ditto.
All come out in the wash in the rebase.
Regards,
Peter
Quoted 12 lines
hw/isa/vt82c686.c ISABus *vt82c686b_init(PCIBus *bus, int devfn) · line 456
Quoted 3 lines
hw/isa/vt82c686.c +0
-0}static void via_class_init (ObjectClass *klass,void *data)Otherwise looks fine.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 17/30 pci/*: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of DO_UPCAST, container_of() and direct -> style upcasting.
---
hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- 4 files changed, 25 insertions(+), 22 deletions(-)
hw/pci/pci-hotplug.c +10 -8
@@ -129,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err; } -if (scsi_hot_add (mon, &dev->qdev, dinfo,1 ) !=0 ) { +if (scsi_hot_add (mon,DEVICE (dev), dinfo,1 ) !=0 ) { goto err; }break ;
@@ -193,11 +193,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,switch (type) {case IF_SCSI : dev =pci_create (bus, devfn,"lsi53c895a" ); -if (qdev_init (&dev->qdev) <0 ) +if (qdev_init (DEVICE (dev)) <0 ) { dev =NULL ; + }if (dev && dinfo) { -if (scsi_hot_add (mon, &dev->qdev, dinfo,0 ) !=0 ) { -qdev_unplug (&dev->qdev,NULL ); +if (scsi_hot_add (mon,DEVICE (dev), dinfo,0 ) !=0 ) { +qdev_unplug (DEVICE (dev),NULL ); dev =NULL ; } }
@@ -208,13 +209,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,return NULL ; } dev =pci_create (bus, devfn,"virtio-blk-pci" ); -if (qdev_prop_set_drive (&dev->qdev,"drive" , dinfo->bdrv) <0 ) { -qdev_free (&dev->qdev); +if (qdev_prop_set_drive (DEVICE (dev),"drive" , dinfo->bdrv) <0 ) { +qdev_free (DEVICE (dev)); dev =NULL ;break ; } -if (qdev_init (&dev->qdev) <0 ) +if (qdev_init (DEVICE (dev)) <0 ) { dev =NULL ; + }break ;default : dev =NULL ;
@@ -276,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } -qdev_unplug (&d->qdev, &local_err); +qdev_unplug (DEVICE (d), &local_err);if (error_is_set (&local_err)) {monitor_printf (mon,"%s\n" ,error_get_pretty (local_err));error_free (local_err);
hw/pci/pci.c +9 -8
@@ -177,7 +177,7 @@ void pci_device_reset(PCIDevice *dev) {int r; -qdev_reset_all (&dev->qdev); +qdev_reset_all (DEVICE (dev)); dev->irq_state =0 ;pci_update_irq_status (dev);
@@ -1449,6 +1449,7 @@ static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice *dev, PCIBus *bus,static PciDeviceInfo *qmp_query_pci_device (PCIDevice *dev,PCIBus *bus,int bus_num) { +DeviceState *d =DEVICE (dev);const pci_class_desc *desc;PciDeviceInfo *info;uint8_t type;
@@ -1470,7 +1471,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, info->id.vendor =pci_get_word (dev->config +PCI_VENDOR_ID ); info->id.device =pci_get_word (dev->config +PCI_DEVICE_ID ); info->regions =qmp_query_pci_regions (dev); - info->qdev_id =g_strdup (dev->qdev.id ? dev->qdev.id :"" ); + info->qdev_id =g_strdup (d->id ? d->id :"" );if (dev->config[PCI_INTERRUPT_PIN ] !=0 ) { info->has_irq = true;
@@ -1594,7 +1595,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, } pci_dev =pci_create (bus, devfn, pci_nic_names[i]); - dev = &pci_dev->qdev; + dev =DEVICE (pci_dev);qdev_set_nic_properties (dev, nd);if (qdev_init (dev) <0 )return NULL ;
@@ -1734,7 +1735,7 @@ static int pci_qdev_init(DeviceState *qdev) qdev->hotplugged ?PCI_HOTPLUG_ENABLED : PCI_COLDPLUG_ENABLED);if (rc !=0 ) { -int r =pci_unregister_device (&pci_dev->qdev); +int r =pci_unregister_device (DEVICE (pci_dev));assert (!r);return rc; }
@@ -1771,7 +1772,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, const char *name) {PCIDevice *dev =pci_create_multifunction (bus, devfn, multifunction, name); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev));return dev; }
@@ -1949,7 +1950,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) } pdev->has_rom = true;memory_region_init_ram (&pdev->rom, name, size); -vmstate_register_ram (&pdev->rom, &pdev->qdev); +vmstate_register_ram (&pdev->rom,DEVICE (pdev)); ptr =memory_region_get_ram_ptr (&pdev->rom);load_image (path, ptr);g_free (path);
@@ -1969,7 +1970,7 @@ static void pci_del_option_rom(PCIDevice *pdev)if (!pdev->has_rom)return ; -vmstate_unregister_ram (&pdev->rom, &pdev->qdev); +vmstate_unregister_ram (&pdev->rom,DEVICE (pdev));memory_region_destroy (&pdev->rom); pdev->has_rom = false; }
@@ -2129,7 +2130,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev)static char *pcibus_get_dev_path (DeviceState *dev) { -PCIDevice *d =container_of (dev, PCIDevice, qdev); +PCIDevice *d =PCI_DEVICE (dev);PCIDevice *t;int slot_depth;/* Path format: Domain:00:Slot.Function:Slot.Function....:Slot.Function.
hw/pci/pcie.c +2 -2
@@ -251,7 +251,7 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev, PCI_EXP_SLTSTA_PDS);pcie_cap_slot_event (d,PCI_EXP_HP_EV_PDC ); }else { -qdev_free (&pci_dev->qdev); +qdev_free (DEVICE (pci_dev));pci_word_test_and_clear_mask (exp_cap +PCI_EXP_SLTSTA ,PCI_EXP_SLTSTA_PDS );pcie_cap_slot_event (d,PCI_EXP_HP_EV_PDC );
@@ -306,7 +306,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) dev->exp.hpev_notified = false;pci_bus_hotplug (pci_bridge_get_sec_bus (DO_UPCAST (PCIBridge, dev, dev)), - pcie_cap_slot_hotplug, &dev->qdev); + pcie_cap_slot_hotplug,DEVICE (dev)); }void pcie_cap_slot_reset (PCIDevice *dev)
hw/pci/shpc.c +4 -4
@@ -252,9 +252,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot)for (devfn =PCI_DEVFN (pci_slot,0 ); devfn <=PCI_DEVFN (pci_slot,PCI_FUNC_MAX -1 ); ++devfn) { -PCIDevice *affected_dev = shpc->sec_bus->devices[devfn]; +DeviceState *affected_dev =DEVICE (shpc->sec_bus->devices[devfn]);if (affected_dev) { -qdev_free (&affected_dev->qdev); +qdev_free (affected_dev); } } }
@@ -497,7 +497,7 @@ static int shpc_device_hotplug(DeviceState *qdev, PCIDevice *affected_dev,int pci_slot =PCI_SLOT (affected_dev->devfn);uint8_t state;uint8_t led; -PCIDevice *d =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDevice *d =PCI_DEVICE (qdev);SHPCDevice *shpc = d->shpc;int slot =SHPC_PCI_TO_IDX (pci_slot);if (pci_slot <SHPC_IDX_TO_PCI (0 ) || slot >= shpc->nslots) {
@@ -616,7 +616,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion *bar, unsigned offset) SHPC_SIZEOF(d));shpc_cap_update_dword (d);memory_region_add_subregion (bar, offset, &shpc->mmio); -pci_bus_hotplug (sec_bus, shpc_device_hotplug, &d->qdev); +pci_bus_hotplug (sec_bus, shpc_device_hotplug,DEVICE (d)); d->cap_present |=QEMU_PCI_CAP_SHPC ;return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 18/30 pci-bridge/pci_bridge_dev: Don't use DO_UPCAST
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Just use the defined PCI_DEVICE cast macro.
---
hw/pci-bridge/pci_bridge_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-bridge/pci_bridge_dev.c +1 -1
@@ -104,7 +104,7 @@ static void pci_bridge_dev_write_config(PCIDevice *d,static void qdev_pci_bridge_dev_reset (DeviceState *qdev) { -PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDevice *dev =PCI_DEVICE (qdev);pci_bridge_reset (qdev);shpc_reset (dev);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 19/30 pci-bridge/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci/pci_bridge.c | 7 ++++--- 5 files changed, 8 insertions(+), 7 deletions(-)
hw/pci-bridge/i82801b11.c +1 -1
@@ -108,7 +108,7 @@ PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus)return NULL ; } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);snprintf (buf,sizeof (buf),"pci.%d" , sec_bus);pci_bridge_map_irq (br, buf, pci_swizzle_map_irq_fn);
hw/pci-bridge/ioh3420.c +1 -1
@@ -173,7 +173,7 @@ PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_prop_set_uint8 (qdev,"chassis" , chassis);
hw/pci-bridge/xio3130_downstream.c +1 -1
@@ -140,7 +140,7 @@ PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_prop_set_uint8 (qdev,"chassis" , chassis);
hw/pci-bridge/xio3130_upstream.c +1 -1
@@ -120,7 +120,7 @@ PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_init_nofail (qdev);
hw/pci/pci_bridge.c +4 -3
@@ -330,6 +330,7 @@ void pci_bridge_reset(DeviceState *qdev)/* default qdev initialization function for PCI-to-PCI bridge */ int pci_bridge_initfn (PCIDevice *dev,const char *typename) { +DeviceState *d =DEVICE (dev);PCIBus *parent = dev->bus;PCIBridge *br =DO_UPCAST (PCIBridge, dev, dev);PCIBus *sec_bus = &br->sec_bus;
@@ -359,11 +360,11 @@ int pci_bridge_initfn(PCIDevice *dev, const char *typename)* Since PCI Bridge devices have a single bus each, we don't need the index: * let users address the bus using the device name. */ -if (!br->bus_name && dev->qdev.id && *dev->qdev.id) { - br->bus_name = dev->qdev.id; +if (!br->bus_name && d->id && *d->id) { + br->bus_name = d->id; } -qbus_create_inplace (&sec_bus->qbus, typename, &dev->qdev, br->bus_name); +qbus_create_inplace (&sec_bus->qbus, typename, d, br->bus_name); sec_bus->parent_dev = dev; sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn; sec_bus->address_space_mem = &br->address_space_mem;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 20/30 misc/vfio: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/misc/vfio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/vfio.c +2 -2
@@ -3072,7 +3072,7 @@ static int vfio_initfn(PCIDevice *pdev) } } -add_boot_device_path (vdev->bootindex, &pdev->qdev,NULL ); +add_boot_device_path (vdev->bootindex,DEVICE (pdev),NULL );return 0 ;
@@ -3106,7 +3106,7 @@ static void vfio_exitfn(PCIDevice *pdev)static void vfio_pci_reset (DeviceState *dev) { -PCIDevice *pdev =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pdev =PCI_DEVICE (dev);VFIODevice *vdev =DO_UPCAST (VFIODevice, pdev, pdev);uint16_t cmd;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 21/30 net/eepro100: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/net/eepro100.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
hw/net/eepro100.c +8 -6
@@ -1842,13 +1842,14 @@ static void nic_cleanup(NetClientState *nc)static void pci_nic_uninit (PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);memory_region_destroy (&s->mmio_bar);memory_region_destroy (&s->io_bar);memory_region_destroy (&s->flash_bar); -vmstate_unregister (&pci_dev->qdev, s->vmstate, s); -eeprom93xx_free (&pci_dev->qdev, s->eeprom); +vmstate_unregister (d, s->vmstate, s); +eeprom93xx_free (d, s->eeprom);qemu_del_nic (s->nic); }
@@ -1862,6 +1863,7 @@ static NetClientInfo net_eepro100_info = {static int e100_nic_init (PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);E100PCIDeviceInfo *info =eepro100_get_class (s);
@@ -1873,7 +1875,7 @@ static int e100_nic_init(PCIDevice *pci_dev)/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom =eeprom93xx_new (&pci_dev->qdev,EEPROM_SIZE ); + s->eeprom =eeprom93xx_new (d,EEPROM_SIZE );/* Handler for memory-mapped I/O */ memory_region_init_io(&s->mmio_bar, &eepro100_ops, s, "eepro100-mmio",
@@ -1893,7 +1895,7 @@ static int e100_nic_init(PCIDevice *pci_dev)nic_reset (s); s->nic =qemu_new_nic (&net_eepro100_info, &s->conf, -object_get_typename (OBJECT (pci_dev)), pci_dev->qdev.id, s); +object_get_typename (OBJECT (pci_dev)), d->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->conf.macaddr.a);TRACE (OTHER ,logout ("%s\n" ,qemu_get_queue (s->nic)->info_str));
@@ -1903,9 +1905,9 @@ static int e100_nic_init(PCIDevice *pci_dev) s->vmstate =g_malloc (sizeof (vmstate_eepro100));memcpy (s->vmstate, &vmstate_eepro100,sizeof (vmstate_eepro100)); s->vmstate->name =qemu_get_queue (s->nic)->model; -vmstate_register (&pci_dev->qdev,-1 , s->vmstate, s); +vmstate_register (d,-1 , s->vmstate, s); -add_boot_device_path (s->conf.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->conf.bootindex, d,"/ethernet-phy@0" );return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 22/30 net/ne2000: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/net/ne2000.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/net/ne2000.c +4 -2
@@ -722,6 +722,8 @@ static NetClientInfo net_ne2000_info = {static int pci_ne2000_init (PCIDevice *pci_dev) {PCINE2000State *d =DO_UPCAST (PCINE2000State, dev, pci_dev); +DeviceState *ds =DEVICE (pci_dev); +NE2000State *s;uint8_t *pci_conf;
@@ -737,10 +739,10 @@ static int pci_ne2000_init(PCIDevice *pci_dev)ne2000_reset (s); s->nic =qemu_new_nic (&net_ne2000_info, &s->c, -object_get_typename (OBJECT (pci_dev)), pci_dev->qdev.id, s); +object_get_typename (OBJECT (pci_dev)), ds->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->c.macaddr.a); -add_boot_device_path (s->c.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->c.bootindex, ds,"/ethernet-phy@0" );return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 23/30 usb/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-)
hw/usb/hcd-ehci-pci.c +8 -5
@@ -197,6 +197,7 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int slot)const struct ehci_companions *comp;PCIDevice *ehci, *uhci;BusState *usbbus; +DeviceState *dev;const char *name;int i;
@@ -214,15 +215,17 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int slot) } ehci =pci_create_multifunction (bus,PCI_DEVFN (slot,7 ), true, name); -qdev_init_nofail (&ehci->qdev); - usbbus =QLIST_FIRST (&ehci->qdev.child_bus); + dev =DEVICE (ehci); +qdev_init_nofail (dev); + usbbus =QLIST_FIRST (&dev->child_bus);for (i =0 ; i <3 ; i++) { uhci =pci_create_multifunction (bus,PCI_DEVFN (slot, comp[i].func), true, comp[i].name); -qdev_prop_set_string (&uhci->qdev,"masterbus" , usbbus->name); -qdev_prop_set_uint32 (&uhci->qdev,"firstport" , comp[i].port); -qdev_init_nofail (&uhci->qdev); + dev =DEVICE (uhci); +qdev_prop_set_string (dev,"masterbus" , usbbus->name); +qdev_prop_set_uint32 (dev,"firstport" , comp[i].port); +qdev_init_nofail (dev); }return 0 ; }
hw/usb/hcd-ohci.c +1 -1
@@ -1857,7 +1857,7 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev) ohci->pci_dev.config[PCI_CLASS_PROG ] =0x10 ;/* OHCI */ ohci->pci_dev.config[PCI_INTERRUPT_PIN ] =0x01 ;/* interrupt pin A */ -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_dma_context (dev)) !=0 ) {return -1 ;
hw/usb/hcd-uhci.c +1 -1
@@ -1246,7 +1246,7 @@ static int usb_uhci_common_initfn(PCIDevice *dev)return -1 ; } }else { -usb_bus_new (&s->bus, &uhci_bus_ops, &s->dev.qdev); +usb_bus_new (&s->bus, &uhci_bus_ops,DEVICE (dev));for (i =0 ; i <NB_PORTS ; i++) {usb_register_port (&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,USB_SPEED_MASK_LOW |USB_SPEED_MASK_FULL );
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 24/30 watchdog/wdt_i6300esb: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/watchdog/wdt_i6300esb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/watchdog/wdt_i6300esb.c +1 -1
@@ -195,7 +195,7 @@ static void i6300esb_timer_expired(void *vp)if (d->reboot_enabled) { d->previous_reboot_flag =1 ;watchdog_perform_action ();/* This reboots, exits, etc */ -i6300esb_reset (&d->dev.qdev); +i6300esb_reset (DEVICE (d)); }/* In "free running mode" we start stage 1 again. */
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 25/30 scsi/vmw_pvscsi: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/scsi/vmw_pvscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +1 -1
@@ -1088,7 +1088,7 @@ pvscsi_init(PCIDevice *pci_dev)return -ENOMEM ; } -scsi_bus_new (&s->bus, &pci_dev->qdev, &pvscsi_scsi_info,NULL ); +scsi_bus_new (&s->bus,DEVICE (pci_dev), &pvscsi_scsi_info,NULL );pvscsi_reset_state (s);return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 26/30 i2c/smbus_ich9: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/i2c/smbus_ich9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/smbus_ich9.c +1 -1
@@ -82,7 +82,7 @@ static int ich9_smbus_initfn(PCIDevice *d)pci_set_byte (d->config +ICH9_SMB_HOSTC ,0 );/* TODO bar0, bar1: 64bit BAR support*/ -pm_smbus_init (&d->qdev, &s->smb); +pm_smbus_init (DEVICE (d), &s->smb);pci_register_bar (d,ICH9_SMB_SMB_BASE_BAR ,PCI_BASE_ADDRESS_SPACE_IO , &s->smb.io);return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 27/30 ide/cmd646: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/ide/cmd646.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ide/cmd646.c +4 -4
@@ -281,7 +281,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) irq =qemu_allocate_irqs (cmd646_set_irq, d,2 );for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init2 (&d->bus[i], irq[i]);bmdma_init (&d->bus[i], &d->bmdma[i], d);
@@ -290,7 +290,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) &d->bmdma[i].dma); } -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }
@@ -317,8 +317,8 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,PCIDevice *dev; dev =pci_create (bus,-1 ,"cmd646-ide" ); -qdev_prop_set_uint32 (&dev->qdev,"secondary" , secondary_ide_enabled); -qdev_init_nofail (&dev->qdev); +qdev_prop_set_uint32 (DEVICE (dev),"secondary" , secondary_ide_enabled); +qdev_init_nofail (DEVICE (dev));pci_ide_create_devs (dev, hd_table); }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 28/30 ide/via: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/ide/via.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ide/via.c +2 -2
@@ -158,7 +158,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));
@@ -183,7 +183,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);vt82c686b_init_ports (d);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 29/30 pci-host/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/pci-bridge/dec.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
hw/pci-bridge/dec.c +1 -1
@@ -88,7 +88,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) "dec-21154-p2p-bridge"); br =DO_UPCAST (PCIBridge, dev, dev);pci_bridge_map_irq (br,"DEC 21154 PCI-PCI bridge" , dec_map_irq); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev));return pci_bridge_get_sec_bus (br); }
hw/pci-host/apb.c +2 -2
@@ -467,7 +467,7 @@ PCIBus *pci_apb_init(hwaddr special_base, br =DO_UPCAST (PCIBridge, dev, pci_dev);pci_bridge_map_irq (br,"Advanced PCI Bus secondary bridge 1" , pci_apb_map_irq); -qdev_init_nofail (&pci_dev->qdev); +qdev_init_nofail (DEVICE (dev)); *bus2 =pci_bridge_get_sec_bus (br); pci_dev = pci_create_multifunction(d->bus, PCI_DEVFN(1, 1), true,
@@ -475,7 +475,7 @@ PCIBus *pci_apb_init(hwaddr special_base, br =DO_UPCAST (PCIBridge, dev, pci_dev);pci_bridge_map_irq (br,"Advanced PCI Bus secondary bridge 2" , pci_apb_map_irq); -qdev_init_nofail (&pci_dev->qdev); +qdev_init_nofail (DEVICE (pci_dev)); *bus3 =pci_bridge_get_sec_bus (br);return d->bus;
hw/pci-host/q35.c +2 -2
@@ -104,8 +104,8 @@ static const TypeInfo q35_host_info = {/* PCIe MMCFG */ static void mch_update_pciexbar (MCHPCIState *mch) { -PCIDevice *pci_dev = &mch->d; -BusState *bus =qdev_get_parent_bus (&pci_dev->qdev); +PCIDevice *pci_dev =PCI_DEVICE (mch); +BusState *bus =qdev_get_parent_bus (DEVICE (pci_dev));DeviceState *qdev = bus->parent;Q35PCIHost *s =Q35_HOST_DEVICE (qdev);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 30/30 i386/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-)
hw/i386/kvm/pci-assign.c +12 -9
@@ -491,7 +491,7 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, name, cur_region->size, virtbase);vmstate_register_ram (&pci_dev->v_addrs[i].real_iomem, - &pci_dev->dev.qdev); +DEVICE (&pci_dev->dev)); }assigned_dev_iomem_setup (&pci_dev->dev, i, cur_region->size);
@@ -817,6 +817,7 @@ fail:static int assign_device (AssignedDevice *dev) { +DeviceState *d =DEVICE (&dev->dev);uint32_t flags =KVM_DEV_ASSIGN_ENABLE_IOMMU ;int r;
@@ -830,7 +831,7 @@ static int assign_device(AssignedDevice *dev)if (!kvm_check_extension (kvm_state,KVM_CAP_IOMMU )) {error_report ("No IOMMU found. Unable to assign device \"%s\"" , - dev->dev.qdev.id); + d->id);return -ENODEV ; }
@@ -842,7 +843,7 @@ static int assign_device(AssignedDevice *dev) r =kvm_device_pci_assign (kvm_state, &dev->host, flags, &dev->dev_id);if (r <0 ) {error_report ("Failed to assign device \"%s\" : %s" , - dev->dev.qdev.id,strerror (-r)); + d->id,strerror (-r));switch (r) {case -EBUSY :
@@ -867,6 +868,7 @@ static bool check_irqchip_in_kernel(void)static int assign_intx (AssignedDevice *dev) { +DeviceState *d =DEVICE (&dev->dev);AssignedIRQType new_type;PCIINTxRoute intx_route;bool intx_host_msi;
@@ -942,7 +944,7 @@ retry: goto retry; }error_report ("Failed to assign irq for \"%s\": %s" , - dev->dev.qdev.id,strerror (-r)); + d->id,strerror (-r));error_report ("Perhaps you are assigning a device " "that shares an IRQ with another device?" );return r;
@@ -972,7 +974,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev) r =assign_intx (assigned_dev);if (r <0 ) { -qdev_unplug (&dev->qdev, &err); +qdev_unplug (DEVICE (dev), &err);assert (!err); } }
@@ -1675,7 +1677,7 @@ static const VMStateDescription vmstate_assigned_device = {static void reset_assigned_device (DeviceState *dev) { -PCIDevice *pci_dev =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pci_dev =PCI_DEVICE (dev);AssignedDevice *adev =DO_UPCAST (AssignedDevice, dev, pci_dev);char reset_file[64 ];const char reset[] ="1" ;
@@ -1731,6 +1733,7 @@ static void reset_assigned_device(DeviceState *dev)static int assigned_initfn (struct PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);AssignedDevice *dev =DO_UPCAST (AssignedDevice, dev, pci_dev);uint8_t e_intx;int r;
@@ -1769,7 +1772,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)if (get_real_device (dev, dev->host.domain, dev->host.bus, dev->host.slot, dev->host.function)) {error_report ("pci-assign: Error: Couldn't get real device (%s)!" , - dev->dev.qdev.id); + d->id); goto out; }
@@ -1811,7 +1814,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)assigned_dev_load_option_rom (dev); -add_boot_device_path (dev->bootindex, &pci_dev->qdev,NULL ); +add_boot_device_path (dev->bootindex, d,NULL );return 0 ;
@@ -1916,7 +1919,7 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)snprintf (name,sizeof (name),"%s.rom" ,object_get_typename (OBJECT (dev)));memory_region_init_ram (&dev->dev.rom, name, st.st_size); -vmstate_register_ram (&dev->dev.rom, &dev->dev.qdev); +vmstate_register_ram (&dev->dev.rom,DEVICE (&dev->dev)); ptr =memory_region_get_ram_ptr (&dev->dev.rom);memset (ptr,0xff , st.st_size);
hw/i386/pc.c +2 -2
@@ -1085,10 +1085,10 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)if (pci_bus) {PCIDevice *pcidev =pci_vga_init (pci_bus); - dev = pcidev ? &pcidev->qdev :NULL ; + dev =DEVICE (pcidev); }else if (isa_bus) {ISADevice *isadev =isa_vga_init (isa_bus); - dev = isadev ? &isadev->qdev :NULL ; + dev =DEVICE (isadev); }return dev; }
hw/i386/pc_piix.c +2 -2
@@ -191,8 +191,8 @@ static void pc_init1(MemoryRegion *system_memory, }else { dev =pci_piix3_ide_init (pci_bus, hd, piix3_devfn +1 ); } - idebus[0 ] =qdev_get_child_bus (&dev->qdev,"ide.0" ); - idebus[1 ] =qdev_get_child_bus (&dev->qdev,"ide.1" ); + idebus[0 ] =qdev_get_child_bus (DEVICE (dev),"ide.0" ); + idebus[1 ] =qdev_get_child_bus (DEVICE (dev),"ide.1" ); }else {for (i =0 ; i <MAX_IDE_BUS ; i++) {ISADevice *dev;
hw/i386/pc_q35.c +2 -2
@@ -179,8 +179,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)PCI_DEVFN (ICH9_SATA1_DEV ,ICH9_SATA1_FUNC ), true, "ich9-ahci"); - idebus[0 ] =qdev_get_child_bus (&ahci->qdev,"ide.0" ); - idebus[1 ] =qdev_get_child_bus (&ahci->qdev,"ide.1" ); + idebus[0 ] =qdev_get_child_bus (DEVICE (ahci),"ide.0" ); + idebus[1 ] =qdev_get_child_bus (DEVICE (ahci),"ide.1" );if (usb_enabled (false)) {/* Should we create 6 UHCI according to ich9 spec? */
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty