jazz_led: QOM cast cleanup

Introduce a type constant, use QOM casts and rename the parent field.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-07-25 00:35:51 +02:00
parent 0f31aa8625
commit 66c2de562f
1 changed files with 8 additions and 4 deletions

View File

@ -32,8 +32,12 @@ typedef enum {
REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2, REDRAW_NONE = 0, REDRAW_SEGMENTS = 1, REDRAW_BACKGROUND = 2,
} screen_state_t; } screen_state_t;
#define TYPE_JAZZ_LED "jazz-led"
#define JAZZ_LED(obj) OBJECT_CHECK(LedState, (obj), TYPE_JAZZ_LED)
typedef struct LedState { typedef struct LedState {
SysBusDevice busdev; SysBusDevice parent_obj;
MemoryRegion iomem; MemoryRegion iomem;
uint8_t segments; uint8_t segments;
QemuConsole *con; QemuConsole *con;
@ -262,7 +266,7 @@ static const GraphicHwOps jazz_led_ops = {
static int jazz_led_init(SysBusDevice *dev) static int jazz_led_init(SysBusDevice *dev)
{ {
LedState *s = FROM_SYSBUS(LedState, dev); LedState *s = JAZZ_LED(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &led_ops, s, "led", 1); memory_region_init_io(&s->iomem, OBJECT(s), &led_ops, s, "led", 1);
sysbus_init_mmio(dev, &s->iomem); sysbus_init_mmio(dev, &s->iomem);
@ -274,7 +278,7 @@ static int jazz_led_init(SysBusDevice *dev)
static void jazz_led_reset(DeviceState *d) static void jazz_led_reset(DeviceState *d)
{ {
LedState *s = DO_UPCAST(LedState, busdev.qdev, d); LedState *s = JAZZ_LED(d);
s->segments = 0; s->segments = 0;
s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND; s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND;
@ -293,7 +297,7 @@ static void jazz_led_class_init(ObjectClass *klass, void *data)
} }
static const TypeInfo jazz_led_info = { static const TypeInfo jazz_led_info = {
.name = "jazz-led", .name = TYPE_JAZZ_LED,
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(LedState), .instance_size = sizeof(LedState),
.class_init = jazz_led_class_init, .class_init = jazz_led_class_init,