From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3t0r-0003d3-UN for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:21:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3t0l-0002UR-Ta for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:21:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53380 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3t0l-0002UG-HZ for qemu-devel@nongnu.org; Mon, 29 Jul 2013 15:21:39 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 29 Jul 2013 21:18:44 +0200 Message-Id: <1375125630-24869-68-git-send-email-afaerber@suse.de> In-Reply-To: <1375125630-24869-1-git-send-email-afaerber@suse.de> References: <1375125630-24869-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 067/173] lm32_juart: QOM cast cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Walle , =?UTF-8?q?Andreas=20F=C3=A4rber?= Signed-off-by: Andreas F=C3=A4rber --- hw/char/lm32_juart.c | 19 +++++++++++-------- hw/lm32/lm32.h | 5 ++--- include/hw/char/lm32_juart.h | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c index 154511e..252fe46 100644 --- a/hw/char/lm32_juart.c +++ b/hw/char/lm32_juart.c @@ -38,8 +38,11 @@ enum { JRX_FULL =3D (1<<8), }; =20 +#define LM32_JUART(obj) OBJECT_CHECK(LM32JuartState, (obj), TYPE_LM32_JU= ART) + struct LM32JuartState { - SysBusDevice busdev; + SysBusDevice parent_obj; + CharDriverState *chr; =20 uint32_t jtx; @@ -49,7 +52,7 @@ typedef struct LM32JuartState LM32JuartState; =20 uint32_t lm32_juart_get_jtx(DeviceState *d) { - LM32JuartState *s =3D container_of(d, LM32JuartState, busdev.qdev); + LM32JuartState *s =3D LM32_JUART(d); =20 trace_lm32_juart_get_jtx(s->jtx); return s->jtx; @@ -57,7 +60,7 @@ uint32_t lm32_juart_get_jtx(DeviceState *d) =20 uint32_t lm32_juart_get_jrx(DeviceState *d) { - LM32JuartState *s =3D container_of(d, LM32JuartState, busdev.qdev); + LM32JuartState *s =3D LM32_JUART(d); =20 trace_lm32_juart_get_jrx(s->jrx); return s->jrx; @@ -65,7 +68,7 @@ uint32_t lm32_juart_get_jrx(DeviceState *d) =20 void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx) { - LM32JuartState *s =3D container_of(d, LM32JuartState, busdev.qdev); + LM32JuartState *s =3D LM32_JUART(d); unsigned char ch =3D jtx & 0xff; =20 trace_lm32_juart_set_jtx(s->jtx); @@ -78,7 +81,7 @@ void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx) =20 void lm32_juart_set_jrx(DeviceState *d, uint32_t jtx) { - LM32JuartState *s =3D container_of(d, LM32JuartState, busdev.qdev); + LM32JuartState *s =3D LM32_JUART(d); =20 trace_lm32_juart_set_jrx(s->jrx); s->jrx &=3D ~JRX_FULL; @@ -104,7 +107,7 @@ static void juart_event(void *opaque, int event) =20 static void juart_reset(DeviceState *d) { - LM32JuartState *s =3D container_of(d, LM32JuartState, busdev.qdev); + LM32JuartState *s =3D LM32_JUART(d); =20 s->jtx =3D 0; s->jrx =3D 0; @@ -112,7 +115,7 @@ static void juart_reset(DeviceState *d) =20 static int lm32_juart_init(SysBusDevice *dev) { - LM32JuartState *s =3D FROM_SYSBUS(typeof(*s), dev); + LM32JuartState *s =3D LM32_JUART(dev); =20 s->chr =3D qemu_char_get_next_serial(); if (s->chr) { @@ -145,7 +148,7 @@ static void lm32_juart_class_init(ObjectClass *klass,= void *data) } =20 static const TypeInfo lm32_juart_info =3D { - .name =3D "lm32-juart", + .name =3D TYPE_LM32_JUART, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(LM32JuartState), .class_init =3D lm32_juart_class_init, diff --git a/hw/lm32/lm32.h b/hw/lm32/lm32.h index 236686e..18aa6fd 100644 --- a/hw/lm32/lm32.h +++ b/hw/lm32/lm32.h @@ -1,8 +1,7 @@ #ifndef HW_LM32_H #define HW_LM32_H 1 =20 - -#include "qemu-common.h" +#include "hw/char/lm32_juart.h" =20 static inline DeviceState *lm32_pic_init(qemu_irq cpu_irq) { @@ -21,7 +20,7 @@ static inline DeviceState *lm32_juart_init(void) { DeviceState *dev; =20 - dev =3D qdev_create(NULL, "lm32-juart"); + dev =3D qdev_create(NULL, TYPE_LM32_JUART); qdev_init_nofail(dev); =20 return dev; diff --git a/include/hw/char/lm32_juart.h b/include/hw/char/lm32_juart.h index 1cd3148..70dc416 100644 --- a/include/hw/char/lm32_juart.h +++ b/include/hw/char/lm32_juart.h @@ -3,6 +3,8 @@ =20 #include "hw/qdev.h" =20 +#define TYPE_LM32_JUART "lm32-juart" + uint32_t lm32_juart_get_jtx(DeviceState *d); uint32_t lm32_juart_get_jrx(DeviceState *d); void lm32_juart_set_jtx(DeviceState *d, uint32_t jtx); --=20 1.8.1.4