The function qemu_chr_fe_init already treats be->fe_open as a bool and
if it acts like a bool it should be one. While we are at it make the
variable name more descriptive and add kdoc decorations.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <
20231211145959.93759-1-alex.bennee@linaro.org>
b->tag = tag;
b->chr = s;
return true;
b->tag = tag;
b->chr = s;
return true;
bool sync_state)
{
Chardev *s;
bool sync_state)
{
Chardev *s;
}
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
}
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
remove_fd_in_watch(s);
} else {
remove_fd_in_watch(s);
} else {
}
b->chr_can_read = fd_can_read;
b->chr_read = fd_read;
}
b->chr_can_read = fd_can_read;
b->chr_read = fd_read;
-void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
+void qemu_chr_fe_set_open(CharBackend *be, bool is_open)
{
Chardev *chr = be->chr;
{
Chardev *chr = be->chr;
- if (be->fe_open == fe_open) {
+ if (be->fe_is_open == is_open) {
+ be->fe_is_open = is_open;
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) {
- CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, fe_open);
+ CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, is_open);
value->label = g_strdup(chr->label);
value->filename = g_strdup(chr->filename);
value->label = g_strdup(chr->label);
value->filename = g_strdup(chr->filename);
- value->frontend_open = chr->be && chr->be->fe_open;
+ value->frontend_open = chr->be && chr->be->fe_is_open;
QAPI_LIST_PREPEND(*list, value);
QAPI_LIST_PREPEND(*list, value);
typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
typedef int BackendChangeHandler(void *opaque);
typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
typedef int BackendChangeHandler(void *opaque);
-/* This is the backend as seen by frontend, the actual backend is
- * Chardev */
+/**
+ * struct CharBackend - back end as seen by front end
+ * @fe_is_open: the front end is ready for IO
+ *
+ * The actual backend is Chardev
+ */
struct CharBackend {
Chardev *chr;
IOEventHandler *chr_event;
struct CharBackend {
Chardev *chr;
IOEventHandler *chr_event;
BackendChangeHandler *chr_be_change;
void *opaque;
int tag;
BackendChangeHandler *chr_be_change;
void *opaque;
int tag;
/**
* qemu_chr_fe_set_open:
/**
* qemu_chr_fe_set_open:
+ * @be: a CharBackend
+ * @is_open: the front end open status
- * Set character frontend open status. This is an indication that the
- * front end is ready (or not) to begin doing I/O.
- * Without associated Chardev, do nothing.
+ * This is an indication that the front end is ready (or not) to begin
+ * doing I/O. Without associated Chardev, do nothing.
-void qemu_chr_fe_set_open(CharBackend *be, int fe_open);
+void qemu_chr_fe_set_open(CharBackend *be, bool is_open);
/**
* qemu_chr_fe_printf:
/**
* qemu_chr_fe_printf: