From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWcp-0002AC-9u for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFWch-00061r-DB for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:19 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41644 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWch-00061e-3R for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:11 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AC5A9AC9C for ; Mon, 17 Feb 2014 22:25:10 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 17 Feb 2014 23:24:24 +0100 Message-Id: <1392675899-21210-15-git-send-email-afaerber@suse.de> In-Reply-To: <1392675899-21210-1-git-send-email-afaerber@suse.de> References: <1392675899-21210-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 v2 14/49] ssd0303: QOM'ify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Replace usages of FROM_I2C_SLAVE() with QOM cast macro. Rename parent field. Reviewed-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- hw/display/ssd0303.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c index beea5bf..89804e1 100644 --- a/hw/display/ssd0303.c +++ b/hw/display/ssd0303.c @@ -41,8 +41,12 @@ enum ssd0303_cmd { SSD0303_CMD_SKIP1 }; =20 +#define TYPE_SSD0303 "ssd0303" +#define SSD0303(obj) OBJECT_CHECK(ssd0303_state, (obj), TYPE_SSD0303) + typedef struct { - I2CSlave i2c; + I2CSlave parent_obj; + QemuConsole *con; int row; int col; @@ -65,8 +69,9 @@ static int ssd0303_recv(I2CSlave *i2c) =20 static int ssd0303_send(I2CSlave *i2c, uint8_t data) { - ssd0303_state *s =3D (ssd0303_state *)i2c; + ssd0303_state *s =3D SSD0303(i2c); enum ssd0303_cmd old_cmd_state; + switch (s->mode) { case SSD0303_IDLE: DPRINTF("byte 0x%02x\n", data); @@ -175,7 +180,8 @@ static int ssd0303_send(I2CSlave *i2c, uint8_t data) =20 static void ssd0303_event(I2CSlave *i2c, enum i2c_event event) { - ssd0303_state *s =3D (ssd0303_state *)i2c; + ssd0303_state *s =3D SSD0303(i2c); + switch (event) { case I2C_FINISH: s->mode =3D SSD0303_IDLE; @@ -279,7 +285,7 @@ static const VMStateDescription vmstate_ssd0303 =3D { VMSTATE_UINT32(mode, ssd0303_state), VMSTATE_UINT32(cmd_state, ssd0303_state), VMSTATE_BUFFER(framebuffer, ssd0303_state), - VMSTATE_I2C_SLAVE(i2c, ssd0303_state), + VMSTATE_I2C_SLAVE(parent_obj, ssd0303_state), VMSTATE_END_OF_LIST() } }; @@ -291,7 +297,7 @@ static const GraphicHwOps ssd0303_ops =3D { =20 static int ssd0303_init(I2CSlave *i2c) { - ssd0303_state *s =3D FROM_I2C_SLAVE(ssd0303_state, i2c); + ssd0303_state *s =3D SSD0303(i2c); =20 s->con =3D graphic_console_init(DEVICE(i2c), &ssd0303_ops, s); qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY); @@ -311,7 +317,7 @@ static void ssd0303_class_init(ObjectClass *klass, vo= id *data) } =20 static const TypeInfo ssd0303_info =3D { - .name =3D "ssd0303", + .name =3D TYPE_SSD0303, .parent =3D TYPE_I2C_SLAVE, .instance_size =3D sizeof(ssd0303_state), .class_init =3D ssd0303_class_init, --=20 1.8.4.5