diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-16 13:36:39 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-01-27 10:50:47 -0600 |
commit | cd6c4cf28b529aaee0367256d37f349e3b125818 (patch) | |
tree | a13e1eee93c85362ef4ce4c33cc3608412c64f7a /hw | |
parent | ba7c05205c4ba2fd08096b0083fc1e5decf3c342 (diff) |
ssi: convert to QEMU Object Model
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ads7846.c | 17 | ||||
-rw-r--r-- | hw/max111x.c | 34 | ||||
-rw-r--r-- | hw/spitz.c | 39 | ||||
-rw-r--r-- | hw/ssd0323.c | 17 | ||||
-rw-r--r-- | hw/ssi-sd.c | 17 | ||||
-rw-r--r-- | hw/ssi.c | 23 | ||||
-rw-r--r-- | hw/ssi.h | 18 | ||||
-rw-r--r-- | hw/stellaris.c | 17 | ||||
-rw-r--r-- | hw/tosa.c | 19 | ||||
-rw-r--r-- | hw/z2.c | 19 |
10 files changed, 150 insertions, 70 deletions
diff --git a/hw/ads7846.c b/hw/ads7846.c index de3f7af127..c1b894e13a 100644 --- a/hw/ads7846.c +++ b/hw/ads7846.c @@ -153,11 +153,18 @@ static int ads7846_init(SSISlave *dev) return 0; } -static SSISlaveInfo ads7846_info = { - .qdev.name ="ads7846", - .qdev.size = sizeof(ADS7846State), - .init = ads7846_init, - .transfer = ads7846_transfer +static void ads7846_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = ads7846_init; + k->transfer = ads7846_transfer; +} + +static DeviceInfo ads7846_info = { + .name = "ads7846", + .size = sizeof(ADS7846State), + .class_init = ads7846_class_init, }; static void ads7846_register_devices(void) diff --git a/hw/max111x.c b/hw/max111x.c index fc79814bf8..db17842e14 100644 --- a/hw/max111x.c +++ b/hw/max111x.c @@ -153,18 +153,32 @@ void max111x_set_input(DeviceState *dev, int line, uint8_t value) s->input[line] = value; } -static SSISlaveInfo max1110_info = { - .qdev.name = "max1110", - .qdev.size = sizeof(MAX111xState), - .init = max1110_init, - .transfer = max111x_transfer +static void max1110_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = max1110_init; + k->transfer = max111x_transfer; +} + +static DeviceInfo max1110_info = { + .name = "max1110", + .size = sizeof(MAX111xState), + .class_init = max1110_class_init, }; -static SSISlaveInfo max1111_info = { - .qdev.name = "max1111", - .qdev.size = sizeof(MAX111xState), - .init = max1111_init, - .transfer = max111x_transfer +static void max1111_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = max1111_init; + k->transfer = max111x_transfer; +} + +static DeviceInfo max1111_info = { + .name = "max1111", + .size = sizeof(MAX111xState), + .class_init = max1111_class_init, }; static void max111x_register_devices(void) diff --git a/hw/spitz.c b/hw/spitz.c index 9d129c22b9..0f63139704 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -1070,12 +1070,20 @@ static const VMStateDescription vmstate_corgi_ssp_regs = { } }; -static SSISlaveInfo corgi_ssp_info = { - .qdev.name = "corgi-ssp", - .qdev.size = sizeof(CorgiSSPState), - .qdev.vmsd = &vmstate_corgi_ssp_regs, - .init = corgi_ssp_init, - .transfer = corgi_ssp_transfer +static void corgi_ssp_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = corgi_ssp_init; + k->transfer = corgi_ssp_transfer; +} + + +static DeviceInfo corgi_ssp_info = { + .name = "corgi-ssp", + .size = sizeof(CorgiSSPState), + .vmsd = &vmstate_corgi_ssp_regs, + .class_init = corgi_ssp_class_init, }; static const VMStateDescription vmstate_spitz_lcdtg_regs = { @@ -1090,12 +1098,19 @@ static const VMStateDescription vmstate_spitz_lcdtg_regs = { } }; -static SSISlaveInfo spitz_lcdtg_info = { - .qdev.name = "spitz-lcdtg", - .qdev.size = sizeof(SpitzLCDTG), - .qdev.vmsd = &vmstate_spitz_lcdtg_regs, - .init = spitz_lcdtg_init, - .transfer = spitz_lcdtg_transfer +static void spitz_lcdtg_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = spitz_lcdtg_init; + k->transfer = spitz_lcdtg_transfer; +} + +static DeviceInfo spitz_lcdtg_info = { + .name = "spitz-lcdtg", + .size = sizeof(SpitzLCDTG), + .vmsd = &vmstate_spitz_lcdtg_regs, + .class_init = spitz_lcdtg_class_init, }; static void spitz_register_devices(void) diff --git a/hw/ssd0323.c b/hw/ssd0323.c index 1eb3823fed..8e2fac87aa 100644 --- a/hw/ssd0323.c +++ b/hw/ssd0323.c @@ -340,11 +340,18 @@ static int ssd0323_init(SSISlave *dev) return 0; } -static SSISlaveInfo ssd0323_info = { - .qdev.name = "ssd0323", - .qdev.size = sizeof(ssd0323_state), - .init = ssd0323_init, - .transfer = ssd0323_transfer +static void ssd0323_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = ssd0323_init; + k->transfer = ssd0323_transfer; +} + +static DeviceInfo ssd0323_info = { + .name = "ssd0323", + .size = sizeof(ssd0323_state), + .class_init = ssd0323_class_init, }; static void ssd03232_register_devices(void) diff --git a/hw/ssi-sd.c b/hw/ssi-sd.c index 2d89cfe522..2738cf9d77 100644 --- a/hw/ssi-sd.c +++ b/hw/ssi-sd.c @@ -244,11 +244,18 @@ static int ssi_sd_init(SSISlave *dev) return 0; } -static SSISlaveInfo ssi_sd_info = { - .qdev.name = "ssi-sd", - .qdev.size = sizeof(ssi_sd_state), - .init = ssi_sd_init, - .transfer = ssi_sd_transfer +static void ssi_sd_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = ssi_sd_init; + k->transfer = ssi_sd_transfer; +} + +static DeviceInfo ssi_sd_info = { + .name = "ssi-sd", + .size = sizeof(ssi_sd_state), + .class_init = ssi_sd_class_init, }; static void ssi_sd_register_devices(void) @@ -23,8 +23,8 @@ static struct BusInfo ssi_bus_info = { static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info) { - SSISlaveInfo *info = container_of(base_info, SSISlaveInfo, qdev); - SSISlave *s = SSI_SLAVE_FROM_QDEV(dev); + SSISlave *s = SSI_SLAVE(dev); + SSISlaveClass *ssc = SSI_SLAVE_GET_CLASS(s); SSIBus *bus; bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev)); @@ -33,16 +33,15 @@ static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info) hw_error("Too many devices on SSI bus"); } - s->info = info; - return info->init(s); + return ssc->init(s); } -void ssi_register_slave(SSISlaveInfo *info) +void ssi_register_slave(DeviceInfo *info) { - assert(info->qdev.size >= sizeof(SSISlave)); - info->qdev.init = ssi_slave_init; - info->qdev.bus_info = &ssi_bus_info; - qdev_register(&info->qdev); + assert(info->size >= sizeof(SSISlave)); + info->init = ssi_slave_init; + info->bus_info = &ssi_bus_info; + qdev_register(info); } DeviceState *ssi_create_slave(SSIBus *bus, const char *name) @@ -64,10 +63,12 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { DeviceState *dev; SSISlave *slave; + SSISlaveClass *ssc; dev = QTAILQ_FIRST(&bus->qbus.children); if (!dev) { return 0; } - slave = SSI_SLAVE_FROM_QDEV(dev); - return slave->info->transfer(slave, val); + slave = SSI_SLAVE(dev); + ssc = SSI_SLAVE_GET_CLASS(slave); + return ssc->transfer(slave, val); } @@ -15,22 +15,30 @@ typedef struct SSISlave SSISlave; +#define TYPE_SSI_SLAVE "ssi-slave" +#define SSI_SLAVE(obj) \ + OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE) +#define SSI_SLAVE_CLASS(klass) \ + OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE) +#define SSI_SLAVE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE) + /* Slave devices. */ -typedef struct { - DeviceInfo qdev; +typedef struct SSISlaveClass { + DeviceClass parent_class; + int (*init)(SSISlave *dev); uint32_t (*transfer)(SSISlave *dev, uint32_t val); -} SSISlaveInfo; +} SSISlaveClass; struct SSISlave { DeviceState qdev; - SSISlaveInfo *info; }; #define SSI_SLAVE_FROM_QDEV(dev) DO_UPCAST(SSISlave, qdev, dev) #define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev) -void ssi_register_slave(SSISlaveInfo *info); +void ssi_register_slave(DeviceInfo *info); DeviceState *ssi_create_slave(SSIBus *bus, const char *name); diff --git a/hw/stellaris.c b/hw/stellaris.c index 7a73074982..a1620cbc28 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -1394,11 +1394,18 @@ static void stellaris_machine_init(void) machine_init(stellaris_machine_init); -static SSISlaveInfo stellaris_ssi_bus_info = { - .qdev.name = "evb6965-ssi", - .qdev.size = sizeof(stellaris_ssi_bus_state), - .init = stellaris_ssi_bus_init, - .transfer = stellaris_ssi_bus_transfer +static void stellaris_ssi_bus_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = stellaris_ssi_bus_init; + k->transfer = stellaris_ssi_bus_transfer; +} + +static DeviceInfo stellaris_ssi_bus_info = { + .name = "evb6965-ssi", + .size = sizeof(stellaris_ssi_bus_state), + .class_init = stellaris_ssi_bus_class_init, }; static void stellaris_register_devices(void) @@ -266,13 +266,20 @@ static I2CSlaveInfo tosa_dac_info = { .event = tosa_dac_event, .recv = tosa_dac_recv, .send = tosa_dac_send -}; + }; + +static void tosa_ssp_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = tosa_ssp_init; + k->transfer = tosa_ssp_tansfer; +} -static SSISlaveInfo tosa_ssp_info = { - .qdev.name = "tosa-ssp", - .qdev.size = sizeof(SSISlave), - .init = tosa_ssp_init, - .transfer = tosa_ssp_tansfer +static DeviceInfo tosa_ssp_info = { + .name = "tosa-ssp", + .size = sizeof(SSISlave), + .class_init = tosa_ssp_class_init, }; static void tosa_register_devices(void) @@ -174,12 +174,19 @@ static VMStateDescription vmstate_zipit_lcd_state = { } }; -static SSISlaveInfo zipit_lcd_info = { - .qdev.name = "zipit-lcd", - .qdev.size = sizeof(ZipitLCD), - .qdev.vmsd = &vmstate_zipit_lcd_state, - .init = zipit_lcd_init, - .transfer = zipit_lcd_transfer +static void zipit_lcd_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k = SSI_SLAVE_CLASS(klass); + + k->init = zipit_lcd_init; + k->transfer = zipit_lcd_transfer; +} + +static DeviceInfo zipit_lcd_info = { + .name = "zipit-lcd", + .size = sizeof(ZipitLCD), + .vmsd = &vmstate_zipit_lcd_state, + .class_init = zipit_lcd_class_init, }; typedef struct { |