修订版 | 23251fb82f2fda426901f8d6950276391e2446d8 (tree) |
---|---|
时间 | 2018-12-13 22:48:02 |
作者 | Mao Zhongyi <maozhongyi@cmss...> |
Commiter | Peter Maydell |
timer/grlib_gptimer: Convert sysbus init function to realize function
Use DeviceClass rather than SysBusDeviceClass in
grlib_gptimer_class_init().
Cc: chouteau@adacore.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>
Message-id: 20181130093852.20739-18-maozhongyi@cmss.chinamobile.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
@@ -347,10 +347,11 @@ static void grlib_gptimer_reset(DeviceState *d) | ||
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | -static int grlib_gptimer_init(SysBusDevice *dev) | |
350 | +static void grlib_gptimer_realize(DeviceState *dev, Error **errp) | |
351 | 351 | { |
352 | 352 | GPTimerUnit *unit = GRLIB_GPTIMER(dev); |
353 | 353 | unsigned int i; |
354 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | |
354 | 355 | |
355 | 356 | assert(unit->nr_timers > 0); |
356 | 357 | assert(unit->nr_timers <= GPTIMER_MAX_TIMERS); |
@@ -366,7 +367,7 @@ static int grlib_gptimer_init(SysBusDevice *dev) | ||
366 | 367 | timer->id = i; |
367 | 368 | |
368 | 369 | /* One IRQ line for each timer */ |
369 | - sysbus_init_irq(dev, &timer->irq); | |
370 | + sysbus_init_irq(sbd, &timer->irq); | |
370 | 371 | |
371 | 372 | ptimer_set_freq(timer->ptimer, unit->freq_hz); |
372 | 373 | } |
@@ -375,8 +376,7 @@ static int grlib_gptimer_init(SysBusDevice *dev) | ||
375 | 376 | unit, "gptimer", |
376 | 377 | UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers); |
377 | 378 | |
378 | - sysbus_init_mmio(dev, &unit->iomem); | |
379 | - return 0; | |
379 | + sysbus_init_mmio(sbd, &unit->iomem); | |
380 | 380 | } |
381 | 381 | |
382 | 382 | static Property grlib_gptimer_properties[] = { |
@@ -389,9 +389,8 @@ static Property grlib_gptimer_properties[] = { | ||
389 | 389 | static void grlib_gptimer_class_init(ObjectClass *klass, void *data) |
390 | 390 | { |
391 | 391 | DeviceClass *dc = DEVICE_CLASS(klass); |
392 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | |
393 | 392 | |
394 | - k->init = grlib_gptimer_init; | |
393 | + dc->realize = grlib_gptimer_realize; | |
395 | 394 | dc->reset = grlib_gptimer_reset; |
396 | 395 | dc->props = grlib_gptimer_properties; |
397 | 396 | } |