Skip to content

Commit

Permalink
misc/max111x: Create abstract max111x type
Browse files Browse the repository at this point in the history
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 <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
pete128 authored and afaerber committed Mar 12, 2014
1 parent d43269d commit 5ef4a1c
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions hw/misc/max111x.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
};

Expand All @@ -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);
}
Expand Down

0 comments on commit 5ef4a1c

Please sign in to comment.