修訂 | 296097f7dd27aca4b24e0699efb6379c0eb6ff40 (tree) |
---|---|
時間 | 2018-12-13 22:48:00 |
作者 | Mao Zhongyi <maozhongyi@cmss...> |
Commiter | Peter Maydell |
nvram/ds1225y: Convert sysbus init function to realize function
Use DeviceClass rather than SysBusDeviceClass in
nvram_sysbus_class_init().
Cc: pbonzini@redhat.com
Cc: marcandre.lureau@redhat.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-15-maozhongyi@cmss.chinamobile.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
@@ -25,6 +25,7 @@ | ||
25 | 25 | #include "qemu/osdep.h" |
26 | 26 | #include "hw/sysbus.h" |
27 | 27 | #include "trace.h" |
28 | +#include "qemu/error-report.h" | |
28 | 29 | |
29 | 30 | typedef struct { |
30 | 31 | MemoryRegion iomem; |
@@ -113,7 +114,7 @@ typedef struct { | ||
113 | 114 | NvRamState nvram; |
114 | 115 | } SysBusNvRamState; |
115 | 116 | |
116 | -static int nvram_sysbus_initfn(SysBusDevice *dev) | |
117 | +static void nvram_sysbus_realize(DeviceState *dev, Error **errp) | |
117 | 118 | { |
118 | 119 | SysBusNvRamState *sys = DS1225Y(dev); |
119 | 120 | NvRamState *s = &sys->nvram; |
@@ -123,20 +124,18 @@ static int nvram_sysbus_initfn(SysBusDevice *dev) | ||
123 | 124 | |
124 | 125 | memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s, |
125 | 126 | "nvram", s->chip_size); |
126 | - sysbus_init_mmio(dev, &s->iomem); | |
127 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | |
127 | 128 | |
128 | 129 | /* Read current file */ |
129 | 130 | file = s->filename ? fopen(s->filename, "rb") : NULL; |
130 | 131 | if (file) { |
131 | 132 | /* Read nvram contents */ |
132 | 133 | if (fread(s->contents, s->chip_size, 1, file) != 1) { |
133 | - printf("nvram_sysbus_initfn: short read\n"); | |
134 | + error_report("nvram_sysbus_realize: short read"); | |
134 | 135 | } |
135 | 136 | fclose(file); |
136 | 137 | } |
137 | 138 | nvram_post_load(s, 0); |
138 | - | |
139 | - return 0; | |
140 | 139 | } |
141 | 140 | |
142 | 141 | static Property nvram_sysbus_properties[] = { |
@@ -148,9 +147,8 @@ static Property nvram_sysbus_properties[] = { | ||
148 | 147 | static void nvram_sysbus_class_init(ObjectClass *klass, void *data) |
149 | 148 | { |
150 | 149 | DeviceClass *dc = DEVICE_CLASS(klass); |
151 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | |
152 | 150 | |
153 | - k->init = nvram_sysbus_initfn; | |
151 | + dc->realize = nvram_sysbus_realize; | |
154 | 152 | dc->vmsd = &vmstate_nvram; |
155 | 153 | dc->props = nvram_sysbus_properties; |
156 | 154 | } |