From patchwork Wed May 25 06:39:04 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: 9134873 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 AB89960221 for ; Wed, 25 May 2016 06:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ECDE282B9 for ; Wed, 25 May 2016 06:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93BCC282BE; Wed, 25 May 2016 06:40:19 +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 3D9C8282B9 for ; Wed, 25 May 2016 06:40:19 +0000 (UTC) Received: from localhost ([::1]:57687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5SUM-0008Qy-Bv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 02:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5SU0-0008PE-I3 for qemu-devel@nongnu.org; Wed, 25 May 2016 02:39:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5STr-0000KP-Rv for qemu-devel@nongnu.org; Wed, 25 May 2016 02:39:55 -0400 Received: from m12-11.163.com ([220.181.12.11]:40452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5STr-0000JF-8V for qemu-devel@nongnu.org; Wed, 25 May 2016 02:39:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=gHVTYrnnqzDWaB0pDf nj5zfYL9BNZDcYAezlz+mw4YE=; b=ByWhiCWKE7xzbczWvhuS/Fxg6BuWJnmMmE NI7beLVN/SQ5Xhri/SynUdcxFtVVTxBWc3ZTBKWvxrjfONbRVRFgHOVi7N9dCcOO r9KNeYyiq6yHHzBuVhC/P0QAAU2TSKhBoLLnkEzbDQ9SBWpQHoGTPc8fpfH1jWpM l0PTK9Gvo= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp7 (Coremail) with SMTP id C8CowAC34niLSEVXFUNKEA--.11746S7; Wed, 25 May 2016 14:39:17 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 14:39:04 +0800 Message-Id: <1464158344-12266-6-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464158344-12266-1-git-send-email-zxq_yx_007@163.com> References: <1464158344-12266-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: C8CowAC34niLSEVXFUNKEA--.11746S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFyDZFWrAr18Zr4DGw4rKrg_yoW5XFy5pF WxXFZ0krWxKF48XrW7Ar1q9F4UArn7tF17GFyIkw4IvFy7KrySqwnI9F4YyFyjqFWvvFZI qFyDZFyUta1Sgw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jxucNUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiTBZ0xlSIPTHXkAAAs- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.11 Subject: [Qemu-devel] [PATCH v6 5/5] hw/char: QOM'ify milkymist-uart.c 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: peter.maydell@linaro.org, agraf@suse.de, armbru@redhat.com, michael@walle.cc, edgar.iglesias@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP drop the qemu_char_get_next_serial and use chardev prop instead Signed-off-by: xiaoqiang zhao Tested-by: Michael Walle Acked-by: Michael Walle --- hw/char/milkymist-uart.c | 10 ++++++---- hw/lm32/milkymist-hw.h | 4 +++- hw/lm32/milkymist.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c index 03b36b2..72f8484 100644 --- a/hw/char/milkymist-uart.c +++ b/hw/char/milkymist-uart.c @@ -200,8 +200,6 @@ static void milkymist_uart_realize(DeviceState *dev, Error **errp) { MilkymistUartState *s = MILKYMIST_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); } @@ -229,6 +227,11 @@ static const VMStateDescription vmstate_milkymist_uart = { } }; +static Property milkymist_uart_properties[] = { + DEFINE_PROP_CHR("chardev", MilkymistUartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + static void milkymist_uart_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -236,8 +239,7 @@ static void milkymist_uart_class_init(ObjectClass *klass, void *data) dc->realize = milkymist_uart_realize; dc->reset = milkymist_uart_reset; dc->vmsd = &vmstate_milkymist_uart; - /* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = milkymist_uart_properties; } static const TypeInfo milkymist_uart_info = { diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h index f857d28..eb6a3a2 100644 --- a/hw/lm32/milkymist-hw.h +++ b/hw/lm32/milkymist-hw.h @@ -5,11 +5,13 @@ #include "net/net.h" static inline DeviceState *milkymist_uart_create(hwaddr base, - qemu_irq irq) + qemu_irq irq, + CharDriverState *chr) { DeviceState *dev; dev = qdev_create(NULL, "milkymist-uart"); + qdev_prop_set_chr(dev, "chardev", chr); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index ebd8a3c..5cae0f1 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -159,7 +159,7 @@ milkymist_init(MachineState *machine) } g_free(bios_filename); - milkymist_uart_create(0x60000000, irq[0]); + milkymist_uart_create(0x60000000, irq[0], serial_hds[0]); milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3], 80000000, 0x10014d31, 0x0000041f, 0x00000001); milkymist_hpdmc_create(0x60002000);