[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL for-2.0-rc0 07/31] misc/max111x: Create abstract max1
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL for-2.0-rc0 07/31] misc/max111x: Create abstract max111x type |
Date: |
Wed, 12 Mar 2014 22:09:39 +0100 |
From: Peter Crosthwaite <address@hidden>
Create an abstract class that encompasses both max111x variants. This is
needed for QOM cast macro creation (and is the right thing to do
anyway). Macroify type-names in the process.
Signed-off-by: Peter Crosthwaite <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/misc/max111x.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c
index 28dfa0b..1b5da69 100644
--- a/hw/misc/max111x.c
+++ b/hw/misc/max111x.c
@@ -22,6 +22,11 @@ typedef struct {
int inputs, com;
} MAX111xState;
+#define TYPE_MAX_111X "max111x"
+
+#define TYPE_MAX_1110 "max1110"
+#define TYPE_MAX_1111 "max1111"
+
/* Control-byte bitfields */
#define CB_PD0 (1 << 0)
#define CB_PD1 (1 << 1)
@@ -155,18 +160,31 @@ void max111x_set_input(DeviceState *dev, int line,
uint8_t value)
s->input[line] = value;
}
-static void max1110_class_init(ObjectClass *klass, void *data)
+static void max111x_class_init(ObjectClass *klass, void *data)
{
SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
- k->init = max1110_init;
k->transfer = max111x_transfer;
}
-static const TypeInfo max1110_info = {
- .name = "max1110",
+static const TypeInfo max111x_info = {
+ .name = TYPE_MAX_111X,
.parent = TYPE_SSI_SLAVE,
.instance_size = sizeof(MAX111xState),
+ .class_init = max111x_class_init,
+ .abstract = true,
+};
+
+static void max1110_class_init(ObjectClass *klass, void *data)
+{
+ SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
+
+ k->init = max1110_init;
+}
+
+static const TypeInfo max1110_info = {
+ .name = TYPE_MAX_1110,
+ .parent = TYPE_MAX_111X,
.class_init = max1110_class_init,
};
@@ -175,18 +193,17 @@ static void max1111_class_init(ObjectClass *klass, void
*data)
SSISlaveClass *k = SSI_SLAVE_CLASS(klass);
k->init = max1111_init;
- k->transfer = max111x_transfer;
}
static const TypeInfo max1111_info = {
- .name = "max1111",
- .parent = TYPE_SSI_SLAVE,
- .instance_size = sizeof(MAX111xState),
+ .name = TYPE_MAX_1111,
+ .parent = TYPE_MAX_111X,
.class_init = max1111_class_init,
};
static void max111x_register_types(void)
{
+ type_register_static(&max111x_info);
type_register_static(&max1110_info);
type_register_static(&max1111_info);
}
--
1.8.4.5
- [Qemu-devel] [PULL for-2.0-rc0 00/31] QOM devices patch queue 2014-03-12, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 02/31] qdev: Set DeviceClass::hotpluggable default in class_init(), Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 04/31] qom: Avoid leaking str and bool properties on failure, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 07/31] misc/max111x: Create abstract max111x type,
Andreas Färber <=
- [Qemu-devel] [PULL for-2.0-rc0 05/31] ssi: Convert legacy SSI_SLAVE -> DEVICE casts, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 01/31] qdev: Fix bus dependency of DeviceState::hotpluggable getter, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 11/31] spapr-pci: Change the default PCI bus naming, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 12/31] qdev-monitor-test: Simplify using g_assert_cmpstr(), Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 13/31] qdev-monitor-test: Don't test human-readable error message, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 15/31] vl: Use MachineClass instead of global QEMUMachine list, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 08/31] misc/max111x: QOM casting sweep, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 09/31] ssi: Remove SSI_SLAVE_FROM_QDEV() macro, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 06/31] ssi: Convert legacy SSI_BUS -> BUS casts, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 03/31] qdev-monitor: Set properties after parent is assigned in device_add, Andreas Färber, 2014/03/12