Patchwork [v2,15/26] ahci: use realize for ahci

login
register
mail settings
Submitter Hu Tao
Date July 1, 2013, 10:18 a.m.
Message ID <cd8495ec0fc3706f3150b8a0ed5c6c688bf4534a.1372673778.git.hutao@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/256068/
State New
Headers show

Comments

Hu Tao - July 1, 2013, 10:18 a.m.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/ide/ahci.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
Andreas Färber - July 21, 2013, 9:13 a.m.
Am 01.07.2013 12:18, schrieb Hu Tao:
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/ide/ahci.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index 5dcd662..d92239b 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -1300,14 +1300,13 @@ static void sysbus_ahci_reset(DeviceState *dev)
>      ahci_reset(&s->ahci);
>  }
>  
> -static int sysbus_ahci_init(SysBusDevice *dev)
> +static void sysbus_ahci_realize(DeviceState *dev, Error **errp)
>  {
>      SysbusAHCIState *s = SYSBUS_AHCI(dev);
> -    ahci_init(&s->ahci, DEVICE(dev), NULL, s->num_ports);
> +    ahci_init(&s->ahci, dev, NULL, s->num_ports);

I prepared a local patch to rename ahci_init() to ahci_realize(), but
didn't find the time to investigate which parts could safely stay in an
ahci_init() called from instance_init, so postponing that.

Andreas

>  
> -    sysbus_init_mmio(dev, &s->ahci.mem);
> -    sysbus_init_irq(dev, &s->ahci.irq);
> -    return 0;
> +    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->ahci.mem);
> +    sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->ahci.irq);
>  }
>  
>  static Property sysbus_ahci_properties[] = {
> @@ -1317,10 +1316,9 @@ static Property sysbus_ahci_properties[] = {
>  
>  static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
>  {
> -    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
> -    sbc->init = sysbus_ahci_init;
> +    dc->realize = sysbus_ahci_realize;
>      dc->vmsd = &vmstate_sysbus_ahci;
>      dc->props = sysbus_ahci_properties;
>      dc->reset = sysbus_ahci_reset;
>

Patch

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 5dcd662..d92239b 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1300,14 +1300,13 @@  static void sysbus_ahci_reset(DeviceState *dev)
     ahci_reset(&s->ahci);
 }
 
-static int sysbus_ahci_init(SysBusDevice *dev)
+static void sysbus_ahci_realize(DeviceState *dev, Error **errp)
 {
     SysbusAHCIState *s = SYSBUS_AHCI(dev);
-    ahci_init(&s->ahci, DEVICE(dev), NULL, s->num_ports);
+    ahci_init(&s->ahci, dev, NULL, s->num_ports);
 
-    sysbus_init_mmio(dev, &s->ahci.mem);
-    sysbus_init_irq(dev, &s->ahci.irq);
-    return 0;
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->ahci.mem);
+    sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->ahci.irq);
 }
 
 static Property sysbus_ahci_properties[] = {
@@ -1317,10 +1316,9 @@  static Property sysbus_ahci_properties[] = {
 
 static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
 {
-    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    sbc->init = sysbus_ahci_init;
+    dc->realize = sysbus_ahci_realize;
     dc->vmsd = &vmstate_sysbus_ahci;
     dc->props = sysbus_ahci_properties;
     dc->reset = sysbus_ahci_reset;