Received: from eggs.gnu.org ([2001:4830:134:3::10]:58235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1PoW-0002SV-Ir for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1PoU-0003nm-3b for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:48 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45747 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1PoT-0003ne-R2 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 19:46:46 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 23 Jul 2013 01:45:45 +0200 Message-Id: <1374536796-13983-5-git-send-email-afaerber@suse.de> In-Reply-To: <1374536796-13983-1-git-send-email-afaerber@suse.de> References: <1374536796-13983-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 04/55] net/rtl8139: QOM Upcast Sweep 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 Define and use standard QOM cast macro. Remove usages of DO_UPCAST() and direct -> style upcasting. Signed-off-by: Peter Crosthwaite Signed-off-by: Andreas F=C3=A4rber --- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index a00ff58..7f89d5a 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -92,6 +92,11 @@ static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const cha= r *fmt, ...) } #endif =20 +#define TYPE_RTL8139 "rtl8139" + +#define RTL8139(obj) \ + OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139) + /* Symbolic offsets to registers. */ enum RTL8139_registers { MAC0 =3D 0, /* Ethernet hardware address. */ @@ -1197,7 +1202,7 @@ static void rtl8139_reset_rxring(RTL8139State *s, u= int32_t bufferSize) =20 static void rtl8139_reset(DeviceState *d) { - RTL8139State *s =3D container_of(d, RTL8139State, dev.qdev); + RTL8139State *s =3D RTL8139(d); int i; =20 /* restore MAC address */ @@ -1364,6 +1369,8 @@ static const VMStateDescription vmstate_tally_count= ers =3D { =20 static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val) { + DeviceState *d =3D DEVICE(s); + val &=3D 0xff; =20 DPRINTF("ChipCmd write val=3D0x%08x\n", val); @@ -1371,7 +1378,7 @@ static void rtl8139_ChipCmd_write(RTL8139State *s, = uint32_t val) if (val & CmdReset) { DPRINTF("ChipCmd reset\n"); - rtl8139_reset(&s->dev.qdev); + rtl8139_reset(d); } if (val & CmdRxEnb) { @@ -1525,6 +1532,8 @@ static uint32_t rtl8139_BasicModeStatus_read(RTL813= 9State *s) =20 static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val) { + DeviceState *d =3D DEVICE(s); + val &=3D 0xff; =20 DPRINTF("Cfg9346 write val=3D0x%02x\n", val); @@ -1544,7 +1553,7 @@ static void rtl8139_Cfg9346_write(RTL8139State *s, = uint32_t val) } else if (opmode =3D=3D 0x40) { /* Reset. */ val =3D 0; - rtl8139_reset(&s->dev.qdev); + rtl8139_reset(d); } =20 s->Cfg9346 =3D val; @@ -3439,7 +3448,7 @@ static void rtl8139_cleanup(NetClientState *nc) =20 static void pci_rtl8139_uninit(PCIDevice *dev) { - RTL8139State *s =3D DO_UPCAST(RTL8139State, dev, dev); + RTL8139State *s =3D RTL8139(dev); =20 memory_region_destroy(&s->bar_io); memory_region_destroy(&s->bar_mem); @@ -3477,7 +3486,8 @@ static NetClientInfo net_rtl8139_info =3D { =20 static int pci_rtl8139_init(PCIDevice *dev) { - RTL8139State * s =3D DO_UPCAST(RTL8139State, dev, dev); + RTL8139State *s =3D RTL8139(dev); + DeviceState *d =3D DEVICE(dev); uint8_t *pci_conf; =20 pci_conf =3D s->dev.config; @@ -3507,7 +3517,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->eeprom.contents[9] =3D s->conf.macaddr.a[4] | s->conf.macaddr.a[5= ] << 8; =20 s->nic =3D qemu_new_nic(&net_rtl8139_info, &s->conf, - object_get_typename(OBJECT(dev)), dev->qdev.id= , s); + object_get_typename(OBJECT(dev)), d->id, s); qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 s->cplus_txbuffer =3D NULL; @@ -3518,7 +3528,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->timer =3D qemu_new_timer_ns(vm_clock, rtl8139_timer, s); rtl8139_set_next_tctr_time(s, qemu_get_clock_ns(vm_clock)); =20 - add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet-phy@0= "); + add_boot_device_path(s->conf.bootindex, d, "/ethernet-phy@0"); =20 return 0; } @@ -3546,7 +3556,7 @@ static void rtl8139_class_init(ObjectClass *klass, = void *data) } =20 static const TypeInfo rtl8139_info =3D { - .name =3D "rtl8139", + .name =3D TYPE_RTL8139, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(RTL8139State), .class_init =3D rtl8139_class_init, --=20 1.8.1.4