From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPl-00081k-9v for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNqPe-0008U4-RD for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45523 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPe-0008SY-J9 for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:06 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 12 Mar 2014 22:09:39 +0100 Message-Id: <1394658603-13650-8-git-send-email-afaerber@suse.de> In-Reply-To: <1394658603-13650-1-git-send-email-afaerber@suse.de> References: <1394658603-13650-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.0-rc0 07/31] misc/max111x: Create abstract max111x type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Peter Crosthwaite 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 Signed-off-by: Andreas F=C3=A4rber --- 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; =20 +#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] =3D value; } =20 -static void max1110_class_init(ObjectClass *klass, void *data) +static void max111x_class_init(ObjectClass *klass, void *data) { SSISlaveClass *k =3D SSI_SLAVE_CLASS(klass); =20 - k->init =3D max1110_init; k->transfer =3D max111x_transfer; } =20 -static const TypeInfo max1110_info =3D { - .name =3D "max1110", +static const TypeInfo max111x_info =3D { + .name =3D TYPE_MAX_111X, .parent =3D TYPE_SSI_SLAVE, .instance_size =3D sizeof(MAX111xState), + .class_init =3D max111x_class_init, + .abstract =3D true, +}; + +static void max1110_class_init(ObjectClass *klass, void *data) +{ + SSISlaveClass *k =3D SSI_SLAVE_CLASS(klass); + + k->init =3D max1110_init; +} + +static const TypeInfo max1110_info =3D { + .name =3D TYPE_MAX_1110, + .parent =3D TYPE_MAX_111X, .class_init =3D max1110_class_init, }; =20 @@ -175,18 +193,17 @@ static void max1111_class_init(ObjectClass *klass, = void *data) SSISlaveClass *k =3D SSI_SLAVE_CLASS(klass); =20 k->init =3D max1111_init; - k->transfer =3D max111x_transfer; } =20 static const TypeInfo max1111_info =3D { - .name =3D "max1111", - .parent =3D TYPE_SSI_SLAVE, - .instance_size =3D sizeof(MAX111xState), + .name =3D TYPE_MAX_1111, + .parent =3D TYPE_MAX_111X, .class_init =3D max1111_class_init, }; =20 static void max111x_register_types(void) { + type_register_static(&max111x_info); type_register_static(&max1110_info); type_register_static(&max1111_info); } --=20 1.8.4.5