Patchwork [RFT,v1,16/30] isa/*: QOM casting sweep

login
register
mail settings
Submitter Peter Crosthwaite
Date June 11, 2013, 6:52 a.m.
Message ID <f5df8d363aa60000c9a29eb650fad9f7d8be4a1c.1370931825.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/250464/
State New
Headers show

Comments

Peter Crosthwaite - June 11, 2013, 6:52 a.m.
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Use standard QOM cast macros. Remove usage of DO_UPCAST and
direct -> style upcasting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 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(-)
Andreas Färber - June 11, 2013, 9:58 a.m.
Am 11.06.2013 08:52, schrieb peter.crosthwaite@xilinx.com:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Use standard QOM cast macros. Remove usage of DO_UPCAST and
> direct -> style upcasting.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> 
>  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(-)
[...]
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index d750413..1eb05b2 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
[...]
> @@ -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/

>      return d->devfn;
>  }
>  
> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> index 5261927..8ec0d84 100644
> --- a/hw/isa/vt82c686.c
> +++ b/hw/isa/vt82c686.c
[...]
> @@ -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.

>  }
>  
>  static void via_class_init(ObjectClass *klass, void *data)

Otherwise looks fine.

Andreas
Peter Crosthwaite - June 24, 2013, 4:55 a.m.
Hi Andreas,

On Tue, Jun 11, 2013 at 7:58 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 11.06.2013 08:52, schrieb peter.crosthwaite@xilinx.com:
>> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>
>> Use standard QOM cast macros. Remove usage of DO_UPCAST and
>> direct -> style upcasting.
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>>
>>  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(-)
> [...]
>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>> index d750413..1eb05b2 100644
>> --- a/hw/isa/piix4.c
>> +++ b/hw/isa/piix4.c
> [...]
>> @@ -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/
>
>>      return d->devfn;
>>  }
>>
>> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
>> index 5261927..8ec0d84 100644
>> --- a/hw/isa/vt82c686.c
>> +++ b/hw/isa/vt82c686.c
> [...]
>> @@ -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

>>  }
>>
>>  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

diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index cced9af..95a2d1c 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -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;
 }
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 667e882..497ced1 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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);
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index d750413..1eb05b2 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -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;
 }
 
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 5261927..8ec0d84 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -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)