qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 14/30] xen/xen_platform: QOM casting sweep


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH v2 14/30] xen/xen_platform: QOM casting sweep
Date: Sun, 30 Jun 2013 11:32:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

Am 24.06.2013 09:00, schrieb address@hidden:
> From: Peter Crosthwaite <address@hidden>
> 
> Define and use standard QOM cast macro. Remove usages of DO_UPCAST
> and direct -> style upcasting.
> 
> Signed-off-by: Peter Crosthwaite <address@hidden>
> ---
> 
>  hw/xen/xen_platform.c | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
> index b6c6793..f119c44 100644
> --- a/hw/xen/xen_platform.c
> +++ b/hw/xen/xen_platform.c
> @@ -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);

These are superfluous since PCIXenPlatformState is passed for both
MemoryRegionOps. Dropping these hunks.

Some usages of the parent field are still left behind.

Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Andreas

>  
>      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 v
>  
>  static 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,
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]