Patchwork [for-1.4?] usb/hcd-ehci-sysbus: Convert to QOM realizefn

login
register
mail settings
Submitter Andreas Färber
Date Jan. 26, 2013, 5:27 p.m.
Message ID <1359221235-26203-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/215919/
State New
Headers show

Comments

Andreas Färber - Jan. 26, 2013, 5:27 p.m.
The SysBus qdev initfn merely calls SysBusDeviceClass::init, so we can
replace it with a realizefn already. This avoids getting into any initfn
ambiguity with the upcoming Faraday EHCI implementation.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/usb/hcd-ehci-sysbus.c |   13 ++++++-------
 1 Datei geändert, 6 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
Peter Crosthwaite - Jan. 26, 2013, 6:18 p.m.
On Sat, Jan 26, 2013 at 9:27 AM, Andreas Färber <afaerber@suse.de> wrote:
> The SysBus qdev initfn merely calls SysBusDeviceClass::init, so we can
> replace it with a realizefn already. This avoids getting into any initfn
> ambiguity with the upcoming Faraday EHCI implementation.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

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

> ---
>  hw/usb/hcd-ehci-sysbus.c |   13 ++++++-------
>  1 Datei geändert, 6 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
>
> diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
> index b68a66a..e504703 100644
> --- a/hw/usb/hcd-ehci-sysbus.c
> +++ b/hw/usb/hcd-ehci-sysbus.c
> @@ -32,8 +32,9 @@ static Property ehci_sysbus_properties[] = {
>      DEFINE_PROP_END_OF_LIST(),
>  };
>
> -static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
> +static void usb_ehci_sysbus_realizefn(DeviceState *dev, Error **errp)
>  {
> +    SysBusDevice *d = SYS_BUS_DEVICE(dev);
>      EHCISysBusState *i = SYS_BUS_EHCI(dev);
>      SysBusEHCIClass *sec = SYS_BUS_EHCI_GET_CLASS(dev);
>      EHCIState *s = &i->ehci;
> @@ -42,18 +43,16 @@ static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
>      s->opregbase = sec->opregbase;
>      s->dma = &dma_context_memory;
>
> -    usb_ehci_initfn(s, DEVICE(dev));
> -    sysbus_init_irq(dev, &s->irq);
> -    sysbus_init_mmio(dev, &s->mem);
> -    return 0;
> +    usb_ehci_initfn(s, dev);
> +    sysbus_init_irq(d, &s->irq);
> +    sysbus_init_mmio(d, &s->mem);
>  }
>
>  static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> -    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>
> -    k->init = usb_ehci_sysbus_initfn;
> +    dc->realize = usb_ehci_sysbus_realizefn;
>      dc->vmsd = &vmstate_ehci_sysbus;
>      dc->props = ehci_sysbus_properties;
>  }
> --
> 1.7.10.4
>
>

Patch

diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index b68a66a..e504703 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -32,8 +32,9 @@  static Property ehci_sysbus_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
+static void usb_ehci_sysbus_realizefn(DeviceState *dev, Error **errp)
 {
+    SysBusDevice *d = SYS_BUS_DEVICE(dev);
     EHCISysBusState *i = SYS_BUS_EHCI(dev);
     SysBusEHCIClass *sec = SYS_BUS_EHCI_GET_CLASS(dev);
     EHCIState *s = &i->ehci;
@@ -42,18 +43,16 @@  static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
     s->opregbase = sec->opregbase;
     s->dma = &dma_context_memory;
 
-    usb_ehci_initfn(s, DEVICE(dev));
-    sysbus_init_irq(dev, &s->irq);
-    sysbus_init_mmio(dev, &s->mem);
-    return 0;
+    usb_ehci_initfn(s, dev);
+    sysbus_init_irq(d, &s->irq);
+    sysbus_init_mmio(d, &s->mem);
 }
 
 static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-    k->init = usb_ehci_sysbus_initfn;
+    dc->realize = usb_ehci_sysbus_realizefn;
     dc->vmsd = &vmstate_ehci_sysbus;
     dc->props = ehci_sysbus_properties;
 }