From patchwork Wed May 25 10:58:14 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: 9135203 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 A106F60221 for ; Wed, 25 May 2016 11:35:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 887B2282BB for ; Wed, 25 May 2016 11:35:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BE0C282D7; Wed, 25 May 2016 11:35:49 +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 13BD0282BB for ; Wed, 25 May 2016 11:35:48 +0000 (UTC) Received: from localhost ([::1]:59143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5X6J-0008G9-NP for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 07:35:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WWt-0000eC-Uh for qemu-devel@nongnu.org; Wed, 25 May 2016 06:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5WWj-0002Nw-Sn for qemu-devel@nongnu.org; Wed, 25 May 2016 06:59:11 -0400 Received: from m12-18.163.com ([220.181.12.18]:39503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WWj-0002K8-9e; 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=lkqs7rl8xqESmc0DoW CT2bUua25z5/4c8TlWFxDb0Hc=; b=qTkgzGWbGJiU+xfHg3DH56bks1tzgGqmBB /tcdTJmPKr1WjgkPmQpAoem6fyRxB0v8xIQFcnHWmglqxZoqxvwVUvETBy5W5M5l QXqeES5FkWK8f3o+9G5TVey6l4e9beSmppWHYKgNlImfiquxX022CWrA85YAOtze 4dasdF9r4= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp14 (Coremail) with SMTP id EsCowECZp0pKhUVXzcaKAA--.5553S6; Wed, 25 May 2016 18:58:52 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 18:58:14 +0800 Message-Id: <1464173896-4088-5-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--.5553S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFykGF1fGr4kur4UCFW3ZFb_yoW8tw15p3 W7GF47GrWa9asxXFW5GF409w18W3Wxury7Krn7Awn5uw1rWFy0qF9rKa1YkFWUGFWvya43 u3Z3WF13AFWxGaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jc4SrUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiqAx0xlc64AUQzAAAsC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 220.181.12.18 Subject: [Qemu-devel] [PATCH 4/6] hw/char: QOM'ify stm32f2xx_usart 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/stm32f205_soc.c | 1 + hw/char/stm32f2xx_usart.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c index 9c1dafb..9d5bcd4 100644 --- a/hw/arm/stm32f205_soc.c +++ b/hw/arm/stm32f205_soc.c @@ -107,6 +107,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) /* Attach UART (uses USART registers) and USART controllers */ for (i = 0; i < STM_NUM_USARTS; i++) { usartdev = DEVICE(&(s->usart[i])); + qdev_prop_set_chr(usartdev, "chardev", serial_hds[i]); object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 72305ec..9424abf 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -190,6 +190,11 @@ static const MemoryRegionOps stm32f2xx_usart_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static Property stm32f2xx_usart_properties[] = { + DEFINE_PROP_CHR("chardev", STM32F2XXUsartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + static void stm32f2xx_usart_init(Object *obj) { STM32F2XXUsartState *s = STM32F2XX_USART(obj); @@ -200,9 +205,6 @@ static void stm32f2xx_usart_init(Object *obj) TYPE_STM32F2XX_USART, 0x2000); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); - /* 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, stm32f2xx_usart_can_receive, stm32f2xx_usart_receive, NULL, s); @@ -214,8 +216,7 @@ static void stm32f2xx_usart_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->reset = stm32f2xx_usart_reset; - /* Reason: instance_init() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = stm32f2xx_usart_properties; } static const TypeInfo stm32f2xx_usart_info = {