mirror of https://github.com/xemu-project/xemu.git
block/noenand: Convert sysbus init function to realize function
Use DeviceClass rather than SysBusDeviceClass in onenand_class_init(). Cc: kwolf@redhat.com Cc: mreitz@redhat.com Cc: qemu-block@nongnu.org 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-3-maozhongyi@cmss.chinamobile.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
7f7420a09f
commit
887c74ca19
|
@ -772,9 +772,9 @@ static const MemoryRegionOps onenand_ops = {
|
|||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
static int onenand_initfn(SysBusDevice *sbd)
|
||||
static void onenand_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DeviceState *dev = DEVICE(sbd);
|
||||
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
||||
OneNANDState *s = ONE_NAND(dev);
|
||||
uint32_t size = 1 << (24 + ((s->id.dev >> 4) & 7));
|
||||
void *ram;
|
||||
|
@ -794,14 +794,14 @@ static int onenand_initfn(SysBusDevice *sbd)
|
|||
0xff, size + (size >> 5));
|
||||
} else {
|
||||
if (blk_is_read_only(s->blk)) {
|
||||
error_report("Can't use a read-only drive");
|
||||
return -1;
|
||||
error_setg(errp, "Can't use a read-only drive");
|
||||
return;
|
||||
}
|
||||
blk_set_perm(s->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
|
||||
BLK_PERM_ALL, &local_err);
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
return -1;
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
s->blk_cur = s->blk;
|
||||
}
|
||||
|
@ -826,7 +826,6 @@ static int onenand_initfn(SysBusDevice *sbd)
|
|||
| ((s->id.dev & 0xff) << 8)
|
||||
| (s->id.ver & 0xff),
|
||||
&vmstate_onenand, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Property onenand_properties[] = {
|
||||
|
@ -841,9 +840,8 @@ static Property onenand_properties[] = {
|
|||
static void onenand_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
|
||||
|
||||
k->init = onenand_initfn;
|
||||
dc->realize = onenand_realize;
|
||||
dc->reset = onenand_system_reset;
|
||||
dc->props = onenand_properties;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue