On 23/11/18 16:30, Mao Zhongyi wrote:
> Use DeviceClass rather than SysBusDeviceClass in
> grlib_gptimer_class_init().
> 
> Cc: chout...@adacore.com
> 
> Signed-off-by: Mao Zhongyi <maozhon...@cmss.chinamobile.com>
> Signed-off-by: Zhang Shengju <zhangshen...@cmss.chinamobile.com>

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

> ---
>  hw/timer/grlib_gptimer.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
> index 4ed96e970a..183eddc073 100644
> --- a/hw/timer/grlib_gptimer.c
> +++ b/hw/timer/grlib_gptimer.c
> @@ -347,10 +347,11 @@ static void grlib_gptimer_reset(DeviceState *d)
>      }
>  }
>  
> -static int grlib_gptimer_init(SysBusDevice *dev)
> +static void grlib_gptimer_realize(DeviceState *dev, Error **errp)
>  {
>      GPTimerUnit  *unit = GRLIB_GPTIMER(dev);
>      unsigned int  i;
> +    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>  
>      assert(unit->nr_timers > 0);
>      assert(unit->nr_timers <= GPTIMER_MAX_TIMERS);
> @@ -366,7 +367,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
>          timer->id     = i;
>  
>          /* One IRQ line for each timer */
> -        sysbus_init_irq(dev, &timer->irq);
> +        sysbus_init_irq(sbd, &timer->irq);
>  
>          ptimer_set_freq(timer->ptimer, unit->freq_hz);
>      }
> @@ -375,8 +376,7 @@ static int grlib_gptimer_init(SysBusDevice *dev)
>                            unit, "gptimer",
>                            UNIT_REG_SIZE + GPTIMER_REG_SIZE * 
> unit->nr_timers);
>  
> -    sysbus_init_mmio(dev, &unit->iomem);
> -    return 0;
> +    sysbus_init_mmio(sbd, &unit->iomem);
>  }
>  
>  static Property grlib_gptimer_properties[] = {
> @@ -389,9 +389,8 @@ static Property grlib_gptimer_properties[] = {
>  static void grlib_gptimer_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> -    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>  
> -    k->init = grlib_gptimer_init;
> +    dc->realize = grlib_gptimer_realize;
>      dc->reset = grlib_gptimer_reset;
>      dc->props = grlib_gptimer_properties;
>  }
> 

Reply via email to