From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCvjJ-0004kO-NY for qemu-devel@nongnu.org; Mon, 10 Feb 2014 13:37:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCvjA-0005qz-So for qemu-devel@nongnu.org; Mon, 10 Feb 2014 13:37:17 -0500 Received: from cantor2.suse.de ([195.135.220.15]:47159 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCvjA-0005pW-Fj for qemu-devel@nongnu.org; Mon, 10 Feb 2014 13:37:08 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 10 Feb 2014 19:36:30 +0100 Message-Id: <1392057426-31990-14-git-send-email-afaerber@suse.de> In-Reply-To: <1392057426-31990-1-git-send-email-afaerber@suse.de> References: <1392057426-31990-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 13/48] wm8750: QOM'ify List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Vassili Karpov (malc)" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gerd Hoffmann Replace usages of FROM_I2C_SLAVE() and direct parent field accesses with QOM cast macro. Rename parent field. Reviewed-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- hw/audio/wm8750.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 6b5a349..c18f245 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -23,8 +23,12 @@ typedef struct { int dac_hz; } WMRate; =20 -typedef struct { - I2CSlave i2c; +#define TYPE_WM8750 "wm8750" +#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750) + +typedef struct WM8750State { + I2CSlave parent_obj; + uint8_t i2c_data[2]; int i2c_len; QEMUSoundCard card; @@ -256,7 +260,8 @@ static void wm8750_clk_update(WM8750State *s, int ext= ) =20 static void wm8750_reset(I2CSlave *i2c) { - WM8750State *s =3D (WM8750State *) i2c; + WM8750State *s =3D WM8750(i2c); + s->rate =3D &wm_rate_table[0]; s->enable =3D 0; wm8750_clk_update(s, 1); @@ -299,7 +304,7 @@ static void wm8750_reset(I2CSlave *i2c) =20 static void wm8750_event(I2CSlave *i2c, enum i2c_event event) { - WM8750State *s =3D (WM8750State *) i2c; + WM8750State *s =3D WM8750(i2c); =20 switch (event) { case I2C_START_SEND: @@ -356,7 +361,7 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_even= t event) =20 static int wm8750_tx(I2CSlave *i2c, uint8_t data) { - WM8750State *s =3D (WM8750State *) i2c; + WM8750State *s =3D WM8750(i2c); uint8_t cmd; uint16_t value; =20 @@ -542,7 +547,7 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data) break; =20 case WM8750_RESET: /* Reset */ - wm8750_reset(&s->i2c); + wm8750_reset(I2C_SLAVE(s)); break; =20 #ifdef VERBOSE @@ -604,17 +609,17 @@ static const VMStateDescription vmstate_wm8750 =3D = { VMSTATE_UINT8(format, WM8750State), VMSTATE_UINT8(power, WM8750State), VMSTATE_UINT8(rate_vmstate, WM8750State), - VMSTATE_I2C_SLAVE(i2c, WM8750State), + VMSTATE_I2C_SLAVE(parent_obj, WM8750State), VMSTATE_END_OF_LIST() } }; =20 static int wm8750_init(I2CSlave *i2c) { - WM8750State *s =3D FROM_I2C_SLAVE(WM8750State, i2c); + WM8750State *s =3D WM8750(i2c); =20 AUD_register_card(CODEC, &s->card); - wm8750_reset(&s->i2c); + wm8750_reset(I2C_SLAVE(s)); =20 return 0; } @@ -622,8 +627,9 @@ static int wm8750_init(I2CSlave *i2c) #if 0 static void wm8750_fini(I2CSlave *i2c) { - WM8750State *s =3D (WM8750State *) i2c; - wm8750_reset(&s->i2c); + WM8750State *s =3D WM8750(i2c); + + wm8750_reset(I2C_SLAVE(s)); AUD_remove_card(&s->card); g_free(s); } @@ -632,7 +638,8 @@ static void wm8750_fini(I2CSlave *i2c) void wm8750_data_req_set(DeviceState *dev, void (*data_req)(void *, int, int), void *opaque) { - WM8750State *s =3D FROM_I2C_SLAVE(WM8750State, I2C_SLAVE(dev)); + WM8750State *s =3D WM8750(dev); + s->data_req =3D data_req; s->opaque =3D opaque; } @@ -702,7 +709,7 @@ static void wm8750_class_init(ObjectClass *klass, voi= d *data) } =20 static const TypeInfo wm8750_info =3D { - .name =3D "wm8750", + .name =3D TYPE_WM8750, .parent =3D TYPE_I2C_SLAVE, .instance_size =3D sizeof(WM8750State), .class_init =3D wm8750_class_init, --=20 1.8.4.5