Patchwork [v2,09/30] ide/piix: QOM casting sweep

login
register
mail settings
Submitter Peter Crosthwaite
Date June 24, 2013, 6:56 a.m.
Message ID <a961c763c52fd4b0b458aa47405b4d0fab446cd4.1372055322.git.peter.crosthwaite@xilinx.com>
Download mbox | patch
Permalink /patch/253667/
State New
Headers show

Comments

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

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

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

 hw/ide/piix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Andreas Färber - June 30, 2013, 8:25 a.m.
Am 24.06.2013 08:56, schrieb peter.crosthwaite@xilinx.com:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> 
> Use standard QOM cast macro. Remove usage of DO_UPCAST and
> direct -> style upcasting.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> 
>  hw/ide/piix.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ide/piix.c b/hw/ide/piix.c
> index bf2856f..d0fdea3 100644
> --- a/hw/ide/piix.c
> +++ b/hw/ide/piix.c
> @@ -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);

This misses the actual type. Any reason for that?

Andreas

>  
>      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;
>  }
>  
>
Andreas Färber - July 22, 2013, 4:20 p.m.
Am 30.06.2013 10:25, schrieb Andreas Färber:
> Am 24.06.2013 08:56, schrieb peter.crosthwaite@xilinx.com:
>> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>
>> Use standard QOM cast macro. Remove usage of DO_UPCAST and
>> direct -> style upcasting.
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>>
>>  hw/ide/piix.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/ide/piix.c b/hw/ide/piix.c
>> index bf2856f..d0fdea3 100644
>> --- a/hw/ide/piix.c
>> +++ b/hw/ide/piix.c
>> @@ -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);
> 
> This misses the actual type. Any reason for that?

Found the answer myself: PCIIDEState was more involved since it was used
by multiple types, so picked up this patch and posted a follow-up.

Andreas

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

Patch

diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index bf2856f..d0fdea3 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -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;
 }