From patchwork Sat Oct 22 09:52:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 685373 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t1JcZ09Vvz9svs for ; Sat, 22 Oct 2016 21:26:38 +1100 (AEDT) Received: from localhost ([::1]:36448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxtVb-0004Mq-KN for incoming@patchwork.ozlabs.org; Sat, 22 Oct 2016 06:26:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxszm-0001wK-GM for qemu-devel@nongnu.org; Sat, 22 Oct 2016 05:53:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxszl-00047Y-Kj for qemu-devel@nongnu.org; Sat, 22 Oct 2016 05:53:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxszl-00046I-Ed for qemu-devel@nongnu.org; Sat, 22 Oct 2016 05:53:41 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA3DA3A279 for ; Sat, 22 Oct 2016 09:53:40 +0000 (UTC) Received: from localhost (ovpn-116-7.phx2.redhat.com [10.3.116.7]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9M9rcof015324; Sat, 22 Oct 2016 05:53:39 -0400 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Sat, 22 Oct 2016 12:52:45 +0300 Message-Id: <20161022095318.17775-6-marcandre.lureau@redhat.com> In-Reply-To: <20161022095318.17775-1-marcandre.lureau@redhat.com> References: <20161022095318.17775-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 22 Oct 2016 09:53:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/38] malta: replace chr init by CHR_EVENT_OPENED handler 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: pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The CharDriverState.init() callback was introduced in commit ceecf1d158. It is only called from text_console_do_init(), but it is no longer set since commit a61ae7f88 (init assignment has been removed by accident). It seems correct to use an event callback instead and print the console text on CHR_EVENT_OPENED. That way we can remove the single user of CharDriverState init(). Signed-off-by: Marc-André Lureau --- hw/mips/mips_malta.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index bae60be..3aec6d8 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -88,6 +88,7 @@ typedef struct { CharDriverState *display; char display_text[9]; SerialState *uart; + bool display_inited; } MaltaFPGAState; #define TYPE_MIPS_MALTA "mips-malta" @@ -530,17 +531,22 @@ static void malta_fpga_reset(void *opaque) snprintf(s->display_text, 9, " "); } -static void malta_fpga_led_init(CharDriverState *chr) +static void malta_fgpa_display_event(void *opaque, int event) { - qemu_chr_fe_printf(chr, "\e[HMalta LEDBAR\r\n"); - qemu_chr_fe_printf(chr, "+--------+\r\n"); - qemu_chr_fe_printf(chr, "+ +\r\n"); - qemu_chr_fe_printf(chr, "+--------+\r\n"); - qemu_chr_fe_printf(chr, "\n"); - qemu_chr_fe_printf(chr, "Malta ASCII\r\n"); - qemu_chr_fe_printf(chr, "+--------+\r\n"); - qemu_chr_fe_printf(chr, "+ +\r\n"); - qemu_chr_fe_printf(chr, "+--------+\r\n"); + MaltaFPGAState *s = opaque; + + if (event == CHR_EVENT_OPENED && !s->display_inited) { + qemu_chr_fe_printf(s->display, "\e[HMalta LEDBAR\r\n"); + qemu_chr_fe_printf(s->display, "+--------+\r\n"); + qemu_chr_fe_printf(s->display, "+ +\r\n"); + qemu_chr_fe_printf(s->display, "+--------+\r\n"); + qemu_chr_fe_printf(s->display, "\n"); + qemu_chr_fe_printf(s->display, "Malta ASCII\r\n"); + qemu_chr_fe_printf(s->display, "+--------+\r\n"); + qemu_chr_fe_printf(s->display, "+ +\r\n"); + qemu_chr_fe_printf(s->display, "+--------+\r\n"); + s->display_inited = true; + } } static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, @@ -560,7 +566,9 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, memory_region_add_subregion(address_space, base, &s->iomem_lo); memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi); - s->display = qemu_chr_new("fpga", "vc:320x200", malta_fpga_led_init); + s->display = qemu_chr_new("fpga", "vc:320x200", NULL); + qemu_chr_add_handlers(s->display, NULL, NULL, + malta_fgpa_display_event, s); s->uart = serial_mm_init(address_space, base + 0x900, 3, uart_irq, 230400, uart_chr, DEVICE_NATIVE_ENDIAN);