From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
"Joel Stanley" <joel@jms.id.au>,
"Markus Armbruster" <armbru@redhat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Laurent Vivier" <lvivier@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Amit Shah" <amit@kernel.org>,
qemu-riscv@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
qemu-arm@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 4/4] hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE
Date: Wed, 5 Jul 2023 15:31:39 +0200 [thread overview]
Message-ID: <20230705133139.54419-5-philmd@linaro.org> (raw)
In-Reply-To: <20230705133139.54419-1-philmd@linaro.org>
GLib recommend to use G_SOURCE_REMOVE / G_SOURCE_CONTINUE
for GSourceFunc callbacks. Our FEWatchFunc is a GSourceFunc
returning such value. Use such definitions which are
"more memorable" [*].
[*] https://docs.gtk.org/glib/callback.SourceFunc.html#return-value
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/cadence_uart.c | 8 ++++----
hw/char/cmsdk-apb-uart.c | 6 +++---
hw/char/ibex_uart.c | 8 ++++----
hw/char/nrf51_uart.c | 4 ++--
hw/char/serial.c | 2 +-
hw/char/virtio-console.c | 2 +-
hw/usb/redirect.c | 2 +-
monitor/monitor.c | 2 +-
net/vhost-user.c | 2 +-
9 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 807e398541..eff0304a18 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -307,11 +307,11 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
/* instant drain the fifo when there's no back-end */
if (!qemu_chr_fe_backend_connected(&s->chr)) {
s->tx_count = 0;
- return FALSE;
+ return G_SOURCE_REMOVE;
}
if (!s->tx_count) {
- return FALSE;
+ return G_SOURCE_REMOVE;
}
ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count);
@@ -326,12 +326,12 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond,
cadence_uart_xmit, s);
if (!r) {
s->tx_count = 0;
- return FALSE;
+ return G_SOURCE_REMOVE;
}
}
uart_update_status(s);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void uart_write_tx_fifo(CadenceUARTState *s, const uint8_t *buf,
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
index f8dc89ee3d..d466cd93de 100644
--- a/hw/char/cmsdk-apb-uart.c
+++ b/hw/char/cmsdk-apb-uart.c
@@ -199,7 +199,7 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
s->watch_tag = 0;
if (!(s->ctrl & R_CTRL_TX_EN_MASK) || !(s->state & R_STATE_TXFULL_MASK)) {
- return FALSE;
+ return G_SOURCE_REMOVE;
}
ret = qemu_chr_fe_write(&s->chr, &s->txbuf, 1);
@@ -215,7 +215,7 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
}
/* Transmit pending */
trace_cmsdk_apb_uart_tx_pending();
- return FALSE;
+ return G_SOURCE_REMOVE;
}
buffer_drained:
@@ -227,7 +227,7 @@ buffer_drained:
s->intstatus |= R_INTSTATUS_TX_MASK;
}
cmsdk_apb_uart_update(s);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void uart_cancel_transmit(CMSDKAPBUART *s)
diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c
index f70adb5308..51708c0836 100644
--- a/hw/char/ibex_uart.c
+++ b/hw/char/ibex_uart.c
@@ -147,7 +147,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
/* instant drain the fifo when there's no back-end */
if (!qemu_chr_fe_backend_connected(&s->chr)) {
s->tx_level = 0;
- return FALSE;
+ return G_SOURCE_REMOVE;
}
if (!s->tx_level) {
@@ -156,7 +156,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
s->uart_intr_state |= R_INTR_STATE_TX_EMPTY_MASK;
s->uart_intr_state &= ~R_INTR_STATE_TX_WATERMARK_MASK;
ibex_uart_update_irqs(s);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level);
@@ -171,7 +171,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
ibex_uart_xmit, s);
if (!r) {
s->tx_level = 0;
- return FALSE;
+ return G_SOURCE_REMOVE;
}
}
@@ -192,7 +192,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond,
}
ibex_uart_update_irqs(s);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf,
diff --git a/hw/char/nrf51_uart.c b/hw/char/nrf51_uart.c
index 3c6f982de9..dfe2276d71 100644
--- a/hw/char/nrf51_uart.c
+++ b/hw/char/nrf51_uart.c
@@ -93,13 +93,13 @@ static gboolean uart_transmit(void *do_not_use, GIOCondition cond, void *opaque)
*/
goto buffer_drained;
}
- return FALSE;
+ return G_SOURCE_REMOVE;
}
buffer_drained:
s->reg[R_UART_TXDRDY] = 1;
s->pending_tx_byte = false;
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void uart_cancel_transmit(NRF51UARTState *s)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 270e1b1094..f3094f860f 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -226,7 +226,7 @@ static gboolean serial_watch_cb(void *do_not_use, GIOCondition cond,
SerialState *s = opaque;
s->watch_tag = 0;
serial_xmit(s);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void serial_xmit(SerialState *s)
diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index dd5a02e339..dbe0b28e60 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -45,7 +45,7 @@ static gboolean chr_write_unblocked(void *do_not_use, GIOCondition cond,
vcon->watch = 0;
virtio_serial_throttle_port(VIRTIO_SERIAL_PORT(vcon), false);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
/* Callback function that's called when the guest sends us data */
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 39fbaaab16..4bbf8afb33 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -278,7 +278,7 @@ static gboolean usbredir_write_unblocked(void *do_not_use, GIOCondition cond,
dev->watch = 0;
usbredirparser_do_write(dev->parser);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static int usbredir_write(void *priv, uint8_t *data, int count)
diff --git a/monitor/monitor.c b/monitor/monitor.c
index dc352f9e9d..941f87815a 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -144,7 +144,7 @@ static gboolean monitor_unblocked(void *do_not_use, GIOCondition cond,
QEMU_LOCK_GUARD(&mon->mon_lock);
mon->out_watch = 0;
monitor_flush_locked(mon);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
/* Caller must hold mon->mon_lock */
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 5993e4afca..12555518e8 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -239,7 +239,7 @@ static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
qemu_chr_fe_disconnect(&s->chr);
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
static void net_vhost_user_event(void *opaque, QEMUChrEvent event);
--
2.38.1
next prev parent reply other threads:[~2023-07-05 13:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 13:31 [PATCH 0/4] chardev/char-fe: Document FEWatchFunc and use G_SOURCE_CONTINUE/REMOVE Philippe Mathieu-Daudé
2023-07-05 13:31 ` [PATCH 1/4] io/channel: Explicit QIOChannel doc is based on GLib's IOChannel Philippe Mathieu-Daudé
2023-07-05 14:52 ` Daniel P. Berrangé
2023-07-05 13:31 ` [PATCH 2/4] chardev/char-fe: Clarify qemu_chr_fe_add_watch 'condition' arg is a mask Philippe Mathieu-Daudé
2023-07-10 11:19 ` Marc-André Lureau
2023-07-10 13:42 ` Philippe Mathieu-Daudé
2023-07-05 13:31 ` [PATCH 3/4] chardev/char-fe: Document FEWatchFunc typedef Philippe Mathieu-Daudé
2023-07-10 11:22 ` Marc-André Lureau
2023-07-05 13:31 ` Philippe Mathieu-Daudé [this message]
2023-07-10 11:23 ` [PATCH 4/4] hw/char: Have FEWatchFunc handlers return G_SOURCE_CONTINUE/REMOVE Marc-André Lureau
2023-07-10 11:11 ` [PATCH 0/4] chardev/char-fe: Document FEWatchFunc and use G_SOURCE_CONTINUE/REMOVE Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230705133139.54419-5-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alistair@alistair23.me \
--cc=amit@kernel.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=edgar.iglesias@gmail.com \
--cc=jasowang@redhat.com \
--cc=joel@jms.id.au \
--cc=kraxel@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).