From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLZG-0001Or-WD for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLZD-0001Rd-T6 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLZD-0001Qw-Jf for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:42:19 -0500 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 53971A89D for ; Mon, 27 Feb 2017 13:42:19 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 27 Feb 2017 17:41:43 +0400 Message-Id: <20170227134202.2991-3-marcandre.lureau@redhat.com> In-Reply-To: <20170227134202.2991-1-marcandre.lureau@redhat.com> References: <20170227134202.2991-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 02/21] mux: simplfy muxes_realize_done List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, eblake@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= mux_chr_event() already send events to all backends, rename it, export it, and use it from muxes_realize_done. This should help abstract away mux implementation. Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/char-mux.h | 2 +- chardev/char-mux.c | 11 ++++++++--- chardev/char.c | 9 ++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chardev/char-mux.h b/chardev/char-mux.h index 9a2fffce91..3f41dfcfd2 100644 --- a/chardev/char-mux.h +++ b/chardev/char-mux.h @@ -58,6 +58,6 @@ typedef struct MuxChardev { =20 void mux_chr_set_handlers(Chardev *chr, GMainContext *context); void mux_set_focus(Chardev *chr, int focus); -void mux_chr_send_event(MuxChardev *d, int mux_nr, int event); +void mux_chr_send_all_event(Chardev *chr, int event); =20 #endif /* CHAR_MUX_H */ diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 5547a36a0a..37d42c65c6 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -114,7 +114,7 @@ static void mux_print_help(Chardev *chr) } } =20 -void mux_chr_send_event(MuxChardev *d, int mux_nr, int event) +static void mux_chr_send_event(MuxChardev *d, int mux_nr, int event) { CharBackend *be =3D d->backends[mux_nr]; =20 @@ -222,9 +222,9 @@ static void mux_chr_read(void *opaque, const uint8_t = *buf, int size) =20 bool muxes_realized; =20 -static void mux_chr_event(void *opaque, int event) +void mux_chr_send_all_event(Chardev *chr, int event) { - MuxChardev *d =3D MUX_CHARDEV(opaque); + MuxChardev *d =3D MUX_CHARDEV(chr); int i; =20 if (!muxes_realized) { @@ -237,6 +237,11 @@ static void mux_chr_event(void *opaque, int event) } } =20 +static void mux_chr_event(void *opaque, int event) +{ + mux_chr_send_all_event(CHARDEV(opaque), event); +} + static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond) { MuxChardev *d =3D MUX_CHARDEV(s); diff --git a/chardev/char.c b/chardev/char.c index 0f9d42980d..4f253b3eca 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -451,22 +451,17 @@ static void muxes_realize_done(Notifier *notifier, = void *unused) { Chardev *chr; =20 + muxes_realized =3D true; QTAILQ_FOREACH(chr, &chardevs, next) { if (CHARDEV_IS_MUX(chr)) { - MuxChardev *d =3D MUX_CHARDEV(chr); - int i; - /* send OPENED to all already-attached FEs */ - for (i =3D 0; i < d->mux_cnt; i++) { - mux_chr_send_event(d, i, CHR_EVENT_OPENED); - } + mux_chr_send_all_event(CHARDEV(chr), CHR_EVENT_OPENED); /* mark mux as OPENED so any new FEs will immediately receiv= e * OPENED event */ qemu_chr_be_event(chr, CHR_EVENT_OPENED); } } - muxes_realized =3D true; } =20 static Notifier muxes_realize_notify =3D { --=20 2.12.0.rc2.3.gc93709801