mirror of https://github.com/xemu-project/xemu.git
ipack: Convert to QOM realize
Acked-by: Alberto Garcia <agarcia@igalia.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
371468297c
commit
5c57090255
|
@ -34,37 +34,39 @@ void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
|
||||||
bus->set_irq = handler;
|
bus->set_irq = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipack_device_dev_init(DeviceState *qdev)
|
static void ipack_device_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
IPackBus *bus = IPACK_BUS(qdev_get_parent_bus(qdev));
|
IPackDevice *idev = IPACK_DEVICE(dev);
|
||||||
IPackDevice *dev = IPACK_DEVICE(qdev);
|
IPackBus *bus = IPACK_BUS(qdev_get_parent_bus(dev));
|
||||||
IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
|
IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
|
||||||
|
|
||||||
if (dev->slot < 0) {
|
if (idev->slot < 0) {
|
||||||
dev->slot = bus->free_slot;
|
idev->slot = bus->free_slot;
|
||||||
}
|
}
|
||||||
if (dev->slot >= bus->n_slots) {
|
if (idev->slot >= bus->n_slots) {
|
||||||
return -1;
|
error_setg(errp, "Only %" PRIu8 " slots available.", bus->n_slots);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
bus->free_slot = dev->slot + 1;
|
bus->free_slot = idev->slot + 1;
|
||||||
|
|
||||||
dev->irq = qemu_allocate_irqs(bus->set_irq, dev, 2);
|
idev->irq = qemu_allocate_irqs(bus->set_irq, idev, 2);
|
||||||
|
|
||||||
return k->init(dev);
|
k->realize(dev, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipack_device_dev_exit(DeviceState *qdev)
|
static void ipack_device_unrealize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
IPackDevice *dev = IPACK_DEVICE(qdev);
|
IPackDevice *idev = IPACK_DEVICE(dev);
|
||||||
IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
|
IPackDeviceClass *k = IPACK_DEVICE_GET_CLASS(dev);
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
if (k->exit) {
|
if (k->unrealize) {
|
||||||
k->exit(dev);
|
k->unrealize(dev, &err);
|
||||||
|
error_propagate(errp, err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_free_irqs(dev->irq);
|
qemu_free_irqs(idev->irq);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Property ipack_device_props[] = {
|
static Property ipack_device_props[] = {
|
||||||
|
@ -75,10 +77,11 @@ static Property ipack_device_props[] = {
|
||||||
static void ipack_device_class_init(ObjectClass *klass, void *data)
|
static void ipack_device_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *k = DEVICE_CLASS(klass);
|
DeviceClass *k = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
set_bit(DEVICE_CATEGORY_INPUT, k->categories);
|
set_bit(DEVICE_CATEGORY_INPUT, k->categories);
|
||||||
k->bus_type = TYPE_IPACK_BUS;
|
k->bus_type = TYPE_IPACK_BUS;
|
||||||
k->init = ipack_device_dev_init;
|
k->realize = ipack_device_realize;
|
||||||
k->exit = ipack_device_dev_exit;
|
k->unrealize = ipack_device_unrealize;
|
||||||
k->props = ipack_device_props;
|
k->props = ipack_device_props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,12 @@ typedef struct IPackDeviceClass IPackDeviceClass;
|
||||||
OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE)
|
OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE)
|
||||||
|
|
||||||
struct IPackDeviceClass {
|
struct IPackDeviceClass {
|
||||||
|
/*< private >*/
|
||||||
DeviceClass parent_class;
|
DeviceClass parent_class;
|
||||||
|
/*< public >*/
|
||||||
|
|
||||||
int (*init)(IPackDevice *dev);
|
DeviceRealize realize;
|
||||||
int (*exit)(IPackDevice *dev);
|
DeviceUnrealize unrealize;
|
||||||
|
|
||||||
uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
|
uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
|
||||||
void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
|
void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
|
||||||
|
|
|
@ -534,9 +534,9 @@ static void hostdev_event(void *opaque, int event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipoctal_init(IPackDevice *ip)
|
static void ipoctal_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
IPOctalState *s = IPOCTAL(ip);
|
IPOctalState *s = IPOCTAL(dev);
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < N_CHANNELS; i++) {
|
for (i = 0; i < N_CHANNELS; i++) {
|
||||||
|
@ -552,8 +552,6 @@ static int ipoctal_init(IPackDevice *ip)
|
||||||
DPRINTF("Could not redirect channel %u, no chardev set\n", i);
|
DPRINTF("Could not redirect channel %u, no chardev set\n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Property ipoctal_properties[] = {
|
static Property ipoctal_properties[] = {
|
||||||
|
@ -573,7 +571,7 @@ static void ipoctal_class_init(ObjectClass *klass, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
IPackDeviceClass *ic = IPACK_DEVICE_CLASS(klass);
|
IPackDeviceClass *ic = IPACK_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
ic->init = ipoctal_init;
|
ic->realize = ipoctal_realize;
|
||||||
ic->io_read = io_read;
|
ic->io_read = io_read;
|
||||||
ic->io_write = io_write;
|
ic->io_write = io_write;
|
||||||
ic->id_read = id_read;
|
ic->id_read = id_read;
|
||||||
|
|
Loading…
Reference in New Issue