From patchwork Wed May 25 10:58:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhao xiao qiang X-Patchwork-Id: 9135197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8384060221 for ; Wed, 25 May 2016 11:27:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7599828164 for ; Wed, 25 May 2016 11:27:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A4C4282D4; Wed, 25 May 2016 11:27:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1461728164 for ; Wed, 25 May 2016 11:27:06 +0000 (UTC) Received: from localhost ([::1]:59095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Wxt-0000VT-4J for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 07:27:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WWn-0000XJ-Q8 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5WWj-0002NB-KQ for qemu-devel@nongnu.org; Wed, 25 May 2016 06:59:04 -0400 Received: from m12-18.163.com ([220.181.12.18]:39499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WWi-0002K5-Md; Wed, 25 May 2016 06:59:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=HMGAecyOZw4zk3RQce LQfM6YJuPWV/vK5REsk0y2XjM=; b=UXIoGhSbEEbo3EV79i4NFEv4+zInSdPqSJ k0Cnv4MfOQn/fAixCG7rHOZgFGZP1KpAitVHG/K8uSG58KHfoK/CcBL2zGFD5Zgf 32R9TZI2cLB5sXg3Z7hLZ/FYb3FYc7oV/n4w1N3oIiaAJTuYLG6ecPVyTNDvKo8w U6BidAruI= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp14 (Coremail) with SMTP id EsCowECZp0pKhUVXzcaKAA--.5553S5; Wed, 25 May 2016 18:58:52 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 18:58:13 +0800 Message-Id: <1464173896-4088-4-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464173896-4088-1-git-send-email-zxq_yx_007@163.com> References: <1464173896-4088-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: EsCowECZp0pKhUVXzcaKAA--.5553S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFykGF1fGr4kZFy3Cw4xtFb_yoW8tr4UpF yDXF9xKrW7CrsrXFW3J3W0kF4UGF1rZw12kF17GwnruFy7G3Z5A3Z8KayY9Fy7urZ5ZFyY v3y7XFyDJF47t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jfVyxUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbBEAx0xlUL8osesAAAsn X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 220.181.12.18 Subject: [Qemu-devel] [PATCH 3/6] hw/char: QOM'ify digic-uart model X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, peter.maydell@linaro.org, crosthwaite.peter@gmail.com, alistair.francis@xilinx.com, qemu-arm@nongnu.org, antonynpavlov@gmail.com, pbonzini@redhat.com, edgar.iglesias@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP * drop qemu_char_get_next_serial and use chardev prop * change affected board code to use the new way Signed-off-by: xiaoqiang zhao --- hw/arm/digic.c | 2 ++ hw/char/digic-uart.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/arm/digic.c b/hw/arm/digic.c index e0f9730..d60ea39 100644 --- a/hw/arm/digic.c +++ b/hw/arm/digic.c @@ -23,6 +23,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/digic.h" +#include "sysemu/sysemu.h" #define DIGIC4_TIMER_BASE(n) (0xc0210000 + (n) * 0x100) @@ -84,6 +85,7 @@ static void digic_realize(DeviceState *dev, Error **errp) sysbus_mmio_map(sbd, 0, DIGIC4_TIMER_BASE(i)); } + qdev_prop_set_chr(DEVICE(&s->uart), "chardev", serial_hds[0]); object_property_set_bool(OBJECT(&s->uart), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index 0e44878..c7604e6 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -145,8 +145,6 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) { DigicUartState *s = DIGIC_UART(dev); - /* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr = qemu_char_get_next_serial(); if (s->chr) { qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s); } @@ -172,6 +170,11 @@ static const VMStateDescription vmstate_digic_uart = { } }; +static Property digic_uart_properties[] = { + DEFINE_PROP_CHR("chardev", DigicUartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + static void digic_uart_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -179,8 +182,7 @@ static void digic_uart_class_init(ObjectClass *klass, void *data) dc->realize = digic_uart_realize; dc->reset = digic_uart_reset; dc->vmsd = &vmstate_digic_uart; - /* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = digic_uart_properties; } static const TypeInfo digic_uart_info = {