From patchwork Thu Sep 10 08:58:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 41ED0B7334 for ; Thu, 10 Sep 2009 19:58:03 +1000 (EST) Received: from localhost ([127.0.0.1]:36893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlgPd-0004h3-5m for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 05:57:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlfV0-0005aT-So for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlfUt-0005Vh-Nj for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:24 -0400 Received: from [199.232.76.173] (port=49341 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlfUt-0005VR-Bv for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49329) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlfUs-0007Yf-N5 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 04:59:19 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A8xHmW022572 for ; Thu, 10 Sep 2009 04:59:17 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-74.ams2.redhat.com [10.36.9.74]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8A8x3Gw017259; Thu, 10 Sep 2009 04:59:12 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id D41DE700F6; Thu, 10 Sep 2009 10:58:56 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 10:58:55 +0200 Message-Id: <1252573135-27688-24-git-send-email-kraxel@redhat.com> In-Reply-To: <1252573135-27688-1-git-send-email-kraxel@redhat.com> References: <1252573135-27688-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 23/23] move mux focus field from CharDriverState to MuxDriver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that monitor stopped using focus we can make it internal to the mux driver. Signed-off-by: Gerd Hoffmann --- qemu-char.c | 27 ++++++++++++++------------- qemu-char.h | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 4a5d03b..4f29618 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -233,6 +233,7 @@ typedef struct { IOEventHandler *chr_event[MAX_MUX]; void *ext_opaque[MAX_MUX]; CharDriverState *drv; + int focus; int mux_cnt; int term_got_escape; int max_size; @@ -361,11 +362,11 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) break; case 'c': /* Switch to the next registered device */ - mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_OUT); - chr->focus++; - if (chr->focus >= d->mux_cnt) - chr->focus = 0; - mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN); + mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT); + d->focus++; + if (d->focus >= d->mux_cnt) + d->focus = 0; + mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN); break; case 't': d->timestamps = !d->timestamps; @@ -384,8 +385,8 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) static void mux_chr_accept_input(CharDriverState *chr) { - int m = chr->focus; MuxDriver *d = chr->opaque; + int m = d->focus; while (d->prod[m] != d->cons[m] && d->chr_can_read[m] && @@ -399,7 +400,7 @@ static int mux_chr_can_read(void *opaque) { CharDriverState *chr = opaque; MuxDriver *d = chr->opaque; - int m = chr->focus; + int m = d->focus; if ((d->prod[m] - d->cons[m]) < MUX_BUFFER_SIZE) return 1; @@ -412,7 +413,7 @@ static void mux_chr_read(void *opaque, const uint8_t *buf, int size) { CharDriverState *chr = opaque; MuxDriver *d = chr->opaque; - int m = chr->focus; + int m = d->focus; int i; mux_chr_accept_input (opaque); @@ -456,12 +457,12 @@ static void mux_chr_update_read_handler(CharDriverState *chr) qemu_chr_add_handlers(d->drv, mux_chr_can_read, mux_chr_read, mux_chr_event, chr); } - if (chr->focus != -1) { - mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_OUT); + if (d->focus != -1) { + mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT); } - chr->focus = d->mux_cnt; + d->focus = d->mux_cnt; d->mux_cnt++; - mux_chr_send_event(d, chr->focus, CHR_EVENT_MUX_IN); + mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN); } static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) @@ -474,7 +475,7 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) chr->opaque = d; d->drv = drv; - chr->focus = -1; + d->focus = -1; chr->chr_write = mux_chr_write; chr->chr_update_read_handler = mux_chr_update_read_handler; chr->chr_accept_input = mux_chr_accept_input; diff --git a/qemu-char.h b/qemu-char.h index 0bf8944..d12ab11 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -63,7 +63,6 @@ struct CharDriverState { void (*chr_close)(struct CharDriverState *chr); void (*chr_accept_input)(struct CharDriverState *chr); void *opaque; - int focus; QEMUBH *bh; char *label; char *filename;