diff mbox

[v2,02/14] hw/timer: QOM'ify etraxfs_timer

Message ID 1453863283-7562-3-git-send-email-zxq_yx_007@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

zhao xiao qiang Jan. 27, 2016, 2:54 a.m. UTC
assign etraxfs_timer_init to etraxfs_timer_info.instance_init
and drop the SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>
---
 hw/timer/etraxfs_timer.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Peter Maydell Feb. 15, 2016, 6:10 p.m. UTC | #1
On 27 January 2016 at 02:54, xiaoqiang zhao <zxq_yx_007@163.com> wrote:
> assign etraxfs_timer_init to etraxfs_timer_info.instance_init
> and drop the SysBusDeviceClass::init
>
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>

You should probably cc Edgar as the CRIS/etraxfs maintainer.

> ---
>  hw/timer/etraxfs_timer.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
> index aee4990..a3a6798 100644
> --- a/hw/timer/etraxfs_timer.c
> +++ b/hw/timer/etraxfs_timer.c
> @@ -314,9 +314,10 @@ static void etraxfs_timer_reset(void *opaque)
>      qemu_irq_lower(t->irq);
>  }
>
> -static int etraxfs_timer_init(SysBusDevice *dev)
> +static void etraxfs_timer_init(Object *obj)
>  {
> -    ETRAXTimerState *t = ETRAX_TIMER(dev);
> +    ETRAXTimerState *t = ETRAX_TIMER(obj);
> +    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
>
>      t->bh_t0 = qemu_bh_new(timer0_hit, t);
>      t->bh_t1 = qemu_bh_new(timer1_hit, t);
> @@ -332,20 +333,18 @@ static int etraxfs_timer_init(SysBusDevice *dev)
>                            "etraxfs-timer", 0x5c);
>      sysbus_init_mmio(dev, &t->mmio);
>      qemu_register_reset(etraxfs_timer_reset, t);

QOMification of this device should also include making
the reset function be set up in the class init rather
than with a manual call to qemu_register_reset().

> -    return 0;
>  }
>
>  static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
>  {
> -    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
> -
> -    sdc->init = etraxfs_timer_init;
> +    /* do nothing */
>  }

Again, please don't leave empty class init functions.

>  static const TypeInfo etraxfs_timer_info = {
>      .name          = TYPE_ETRAX_FS_TIMER,
>      .parent        = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(ETRAXTimerState),
> +    .instance_init = etraxfs_timer_init,
>      .class_init    = etraxfs_timer_class_init,
>  };

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index aee4990..a3a6798 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -314,9 +314,10 @@  static void etraxfs_timer_reset(void *opaque)
     qemu_irq_lower(t->irq);
 }
 
-static int etraxfs_timer_init(SysBusDevice *dev)
+static void etraxfs_timer_init(Object *obj)
 {
-    ETRAXTimerState *t = ETRAX_TIMER(dev);
+    ETRAXTimerState *t = ETRAX_TIMER(obj);
+    SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
     t->bh_t0 = qemu_bh_new(timer0_hit, t);
     t->bh_t1 = qemu_bh_new(timer1_hit, t);
@@ -332,20 +333,18 @@  static int etraxfs_timer_init(SysBusDevice *dev)
                           "etraxfs-timer", 0x5c);
     sysbus_init_mmio(dev, &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);
-
-    sdc->init = etraxfs_timer_init;
+    /* do nothing */
 }
 
 static const TypeInfo etraxfs_timer_info = {
     .name          = TYPE_ETRAX_FS_TIMER,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(ETRAXTimerState),
+    .instance_init = etraxfs_timer_init,
     .class_init    = etraxfs_timer_class_init,
 };