Received: from eggs.gnu.org ([2001:4830:134:3::10]:46758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byfbo-0004Fq-W2 for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byfbl-0006SF-0w for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:13 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byfbk-0006Rj-Qq for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:08 -0400 Received: by mail-wm0-x241.google.com with SMTP id d128so9936112wmf.0 for ; Mon, 24 Oct 2016 06:48:08 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Oct 2016 15:47:09 +0200 Message-Id: <1477316855-42218-25-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> References: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 24/50] malta: replace chr init by CHR_EVENT_OPENED handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau 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 Message-Id: <20161022095318.17775-6-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- 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); -- 1.8.3.1