[Qemu-devel] [PATCH v2 16/21] timer/etraxfs_timer: Convert sysbus init function to realize function

Mao Zhongyi posted 21 patches 7 years, 2 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 16/21] timer/etraxfs_timer: Convert sysbus init function to realize function
Posted by Mao Zhongyi 7 years, 2 months ago
Use DeviceClass rather than SysBusDeviceClass in
etraxfs_timer_class_init().

Cc: edgar.iglesias@gmail.com

Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
 hw/timer/etraxfs_timer.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index d13bc30b2d..2280914b1d 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -315,9 +315,10 @@ static void etraxfs_timer_reset(void *opaque)
     qemu_irq_lower(t->irq);
 }
 
-static int etraxfs_timer_init(SysBusDevice *dev)
+static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
 {
     ETRAXTimerState *t = ETRAX_TIMER(dev);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
     t->bh_t0 = qemu_bh_new(timer0_hit, t);
     t->bh_t1 = qemu_bh_new(timer1_hit, t);
@@ -326,21 +327,20 @@ static int etraxfs_timer_init(SysBusDevice *dev)
     t->ptimer_t1 = ptimer_init(t->bh_t1, PTIMER_POLICY_DEFAULT);
     t->ptimer_wd = ptimer_init(t->bh_wd, PTIMER_POLICY_DEFAULT);
 
-    sysbus_init_irq(dev, &t->irq);
-    sysbus_init_irq(dev, &t->nmi);
+    sysbus_init_irq(sbd, &t->irq);
+    sysbus_init_irq(sbd, &t->nmi);
 
     memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
                           "etraxfs-timer", 0x5c);
-    sysbus_init_mmio(dev, &t->mmio);
+    sysbus_init_mmio(sbd, &t->mmio);
     qemu_register_reset(etraxfs_timer_reset, t);
-    return 0;
 }
 
 static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
 {
-    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    sdc->init = etraxfs_timer_init;
+    dc->realize = etraxfs_timer_realize;
 }
 
 static const TypeInfo etraxfs_timer_info = {
-- 
2.17.1




Re: [Qemu-devel] [PATCH v2 16/21] timer/etraxfs_timer: Convert sysbus init function to realize function
Posted by Philippe Mathieu-Daudé 7 years, 2 months ago
On 23/11/18 16:30, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> etraxfs_timer_class_init().
> 
> Cc: edgar.iglesias@gmail.com
> 
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  hw/timer/etraxfs_timer.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
> index d13bc30b2d..2280914b1d 100644
> --- a/hw/timer/etraxfs_timer.c
> +++ b/hw/timer/etraxfs_timer.c
> @@ -315,9 +315,10 @@ static void etraxfs_timer_reset(void *opaque)
>      qemu_irq_lower(t->irq);
>  }
>  
> -static int etraxfs_timer_init(SysBusDevice *dev)
> +static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
>  {
>      ETRAXTimerState *t = ETRAX_TIMER(dev);
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>  
>      t->bh_t0 = qemu_bh_new(timer0_hit, t);
>      t->bh_t1 = qemu_bh_new(timer1_hit, t);
> @@ -326,21 +327,20 @@ static int etraxfs_timer_init(SysBusDevice *dev)
>      t->ptimer_t1 = ptimer_init(t->bh_t1, PTIMER_POLICY_DEFAULT);
>      t->ptimer_wd = ptimer_init(t->bh_wd, PTIMER_POLICY_DEFAULT);
>  
> -    sysbus_init_irq(dev, &t->irq);
> -    sysbus_init_irq(dev, &t->nmi);
> +    sysbus_init_irq(sbd, &t->irq);
> +    sysbus_init_irq(sbd, &t->nmi);
>  
>      memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
>                            "etraxfs-timer", 0x5c);
> -    sysbus_init_mmio(dev, &t->mmio);
> +    sysbus_init_mmio(sbd, &t->mmio);
>      qemu_register_reset(etraxfs_timer_reset, t);
> -    return 0;
>  }
>  
>  static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>  {
> -    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
>  
> -    sdc->init = etraxfs_timer_init;
> +    dc->realize = etraxfs_timer_realize;
>  }
>  
>  static const TypeInfo etraxfs_timer_info = {
> 

Re: [Qemu-devel] [PATCH v2 16/21] timer/etraxfs_timer: Convert sysbus init function to realize function
Posted by Edgar E. Iglesias 7 years, 2 months ago
On Fri, Nov 23, 2018 at 11:30:35PM +0800, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> etraxfs_timer_class_init().
> 
> Cc: edgar.iglesias@gmail.com
> 
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>


Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> ---
>  hw/timer/etraxfs_timer.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
> index d13bc30b2d..2280914b1d 100644
> --- a/hw/timer/etraxfs_timer.c
> +++ b/hw/timer/etraxfs_timer.c
> @@ -315,9 +315,10 @@ static void etraxfs_timer_reset(void *opaque)
>      qemu_irq_lower(t->irq);
>  }
>  
> -static int etraxfs_timer_init(SysBusDevice *dev)
> +static void etraxfs_timer_realize(DeviceState *dev, Error **errp)
>  {
>      ETRAXTimerState *t = ETRAX_TIMER(dev);
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>  
>      t->bh_t0 = qemu_bh_new(timer0_hit, t);
>      t->bh_t1 = qemu_bh_new(timer1_hit, t);
> @@ -326,21 +327,20 @@ static int etraxfs_timer_init(SysBusDevice *dev)
>      t->ptimer_t1 = ptimer_init(t->bh_t1, PTIMER_POLICY_DEFAULT);
>      t->ptimer_wd = ptimer_init(t->bh_wd, PTIMER_POLICY_DEFAULT);
>  
> -    sysbus_init_irq(dev, &t->irq);
> -    sysbus_init_irq(dev, &t->nmi);
> +    sysbus_init_irq(sbd, &t->irq);
> +    sysbus_init_irq(sbd, &t->nmi);
>  
>      memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
>                            "etraxfs-timer", 0x5c);
> -    sysbus_init_mmio(dev, &t->mmio);
> +    sysbus_init_mmio(sbd, &t->mmio);
>      qemu_register_reset(etraxfs_timer_reset, t);
> -    return 0;
>  }
>  
>  static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>  {
> -    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
>  
> -    sdc->init = etraxfs_timer_init;
> +    dc->realize = etraxfs_timer_realize;
>  }
>  
>  static const TypeInfo etraxfs_timer_info = {
> -- 
> 2.17.1
> 
> 
>