From patchwork Fri Jun 7 12:58:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 249700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 56F052C0096 for ; Fri, 7 Jun 2013 22:59:00 +1000 (EST) Received: from localhost ([::1]:36769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFu-0000yh-4g for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 08:58:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFR-0000xW-8s for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkwFP-00084Z-P9 for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53773 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkwFP-00084D-Fk for qemu-devel@nongnu.org; Fri, 07 Jun 2013 08:58:27 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B1A2AA5556; Fri, 7 Jun 2013 14:58:26 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2013 14:58:12 +0200 Message-Id: <1370609900-21998-5-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370609900-21998-1-git-send-email-afaerber@suse.de> References: <1370609900-21998-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH v2 04/12] i8254: QOM'ify some more X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce type constant and avoid DO_UPCAST(). Prepares for PIT realizefn. Signed-off-by: Andreas Färber --- hw/timer/i8254.c | 4 ++-- include/hw/timer/i8254.h | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/timer/i8254.c b/hw/timer/i8254.c index 20c0c36..efbca19 100644 --- a/hw/timer/i8254.c +++ b/hw/timer/i8254.c @@ -265,7 +265,7 @@ static void pit_irq_timer(void *opaque) static void pit_reset(DeviceState *dev) { - PITCommonState *pit = DO_UPCAST(PITCommonState, dev.qdev, dev); + PITCommonState *pit = PIT_COMMON(dev); PITChannelState *s; pit_reset_common(pit); @@ -348,7 +348,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data) } static const TypeInfo pit_info = { - .name = "isa-pit", + .name = TYPE_I8254, .parent = TYPE_PIT_COMMON, .instance_size = sizeof(PITCommonState), .class_init = pit_class_initfn, diff --git a/include/hw/timer/i8254.h b/include/hw/timer/i8254.h index 75bb530..016f990 100644 --- a/include/hw/timer/i8254.h +++ b/include/hw/timer/i8254.h @@ -37,18 +37,22 @@ typedef struct PITChannelInfo { int out; } PITChannelInfo; +#define TYPE_I8254 "isa-pit" + static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) { - ISADevice *dev; + DeviceState *dev; + ISADevice *d; - dev = isa_create(bus, "isa-pit"); - qdev_prop_set_uint32(&dev->qdev, "iobase", base); - qdev_init_nofail(&dev->qdev); - qdev_connect_gpio_out(&dev->qdev, 0, - isa_irq >= 0 ? isa_get_irq(dev, isa_irq) : alt_irq); + d = isa_create(bus, TYPE_I8254); + dev = DEVICE(d); + qdev_prop_set_uint32(dev, "iobase", base); + qdev_init_nofail(dev); + qdev_connect_gpio_out(dev, 0, + isa_irq >= 0 ? isa_get_irq(d, isa_irq) : alt_irq); - return dev; + return d; } static inline ISADevice *kvm_pit_init(ISABus *bus, int base)