diff mbox series

[v4,1/8] chardev/char: rename `MuxChardev` struct to `MuxFeChardev`

Message ID 20241016102605.459395-2-r.peniaev@gmail.com
State New
Headers show
Series chardev: implement backend chardev multiplexing | expand

Commit Message

Roman Penyaev Oct. 16, 2024, 10:25 a.m. UTC
In the following patches backend multiplexer will be
introduced. This patch renames the structure and a
few mux macros to reflect that this mux is responsible
only for multiplexing of frontend devices.

This patch does the following:

  s/MuxChardev/MuxFeChardev/g
  s/CHARDEV_IS_MUX/CHARDEV_IS_MUX_FE/g
  s/MUX_CHARDEV/MUX_FE_CHARDEV/g
  s/TYPE_CHARDEV_MUX/TYPE_CHARDEV_MUX_FE/g

No json or string types are changed for the sake of
compatibility.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
---
 chardev/char-fe.c          | 10 +++++-----
 chardev/char-mux.c         | 36 ++++++++++++++++++------------------
 chardev/char.c             |  8 ++++----
 chardev/chardev-internal.h | 16 ++++++++--------
 include/chardev/char.h     |  2 +-
 5 files changed, 36 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 8ac6bebb6f74..7b1ae16c62a4 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -194,8 +194,8 @@  bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp)
     unsigned int tag = 0;
 
     if (s) {
-        if (CHARDEV_IS_MUX(s)) {
-            MuxChardev *d = MUX_CHARDEV(s);
+        if (CHARDEV_IS_MUX_FE(s)) {
+            MuxFeChardev *d = MUX_FE_CHARDEV(s);
 
             if (!mux_chr_attach_frontend(d, b, &tag, errp)) {
                 return false;
@@ -223,8 +223,8 @@  void qemu_chr_fe_deinit(CharBackend *b, bool del)
         if (b->chr->be == b) {
             b->chr->be = NULL;
         }
-        if (CHARDEV_IS_MUX(b->chr)) {
-            MuxChardev *d = MUX_CHARDEV(b->chr);
+        if (CHARDEV_IS_MUX_FE(b->chr)) {
+            MuxFeChardev *d = MUX_FE_CHARDEV(b->chr);
             mux_chr_detach_frontend(d, b->tag);
         }
         if (del) {
@@ -305,7 +305,7 @@  void qemu_chr_fe_take_focus(CharBackend *b)
         return;
     }
 
-    if (CHARDEV_IS_MUX(b->chr)) {
+    if (CHARDEV_IS_MUX_FE(b->chr)) {
         mux_set_focus(b->chr, b->tag);
     }
 }
diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index bda5c45e6058..dfaea5aefac3 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -44,7 +44,7 @@  static bool muxes_opened = true;
 /* Called with chr_write_lock held.  */
 static int mux_chr_write(Chardev *chr, const uint8_t *buf, int len)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
     int ret;
     if (!d->timestamps) {
         ret = qemu_chr_fe_write(&d->chr, buf, len);
@@ -125,7 +125,7 @@  static void mux_print_help(Chardev *chr)
     }
 }
 
-static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr,
+static void mux_chr_send_event(MuxFeChardev *d, unsigned int mux_nr,
                                QEMUChrEvent event)
 {
     CharBackend *be = d->backends[mux_nr];
@@ -137,14 +137,14 @@  static void mux_chr_send_event(MuxChardev *d, unsigned int mux_nr,
 
 static void mux_chr_be_event(Chardev *chr, QEMUChrEvent event)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
 
     if (d->focus != -1) {
         mux_chr_send_event(d, d->focus, event);
     }
 }
 
-static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
+static int mux_proc_byte(Chardev *chr, MuxFeChardev *d, int ch)
 {
     if (d->term_got_escape) {
         d->term_got_escape = false;
@@ -198,7 +198,7 @@  static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch)
 
 static void mux_chr_accept_input(Chardev *chr)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
     int m = d->focus;
     CharBackend *be = d->backends[m];
 
@@ -211,7 +211,7 @@  static void mux_chr_accept_input(Chardev *chr)
 
 static int mux_chr_can_read(void *opaque)
 {
-    MuxChardev *d = MUX_CHARDEV(opaque);
+    MuxFeChardev *d = MUX_FE_CHARDEV(opaque);
     int m = d->focus;
     CharBackend *be = d->backends[m];
 
@@ -229,7 +229,7 @@  static int mux_chr_can_read(void *opaque)
 static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
 {
     Chardev *chr = CHARDEV(opaque);
-    MuxChardev *d = MUX_CHARDEV(opaque);
+    MuxFeChardev *d = MUX_FE_CHARDEV(opaque);
     int m = d->focus;
     CharBackend *be = d->backends[m];
     int i;
@@ -250,7 +250,7 @@  static void mux_chr_read(void *opaque, const uint8_t *buf, int size)
 
 void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
     int bit;
 
     if (!muxes_opened) {
@@ -271,7 +271,7 @@  static void mux_chr_event(void *opaque, QEMUChrEvent event)
 
 static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond)
 {
-    MuxChardev *d = MUX_CHARDEV(s);
+    MuxFeChardev *d = MUX_FE_CHARDEV(s);
     Chardev *chr = qemu_chr_fe_get_driver(&d->chr);
     ChardevClass *cc = CHARDEV_GET_CLASS(chr);
 
@@ -284,7 +284,7 @@  static GSource *mux_chr_add_watch(Chardev *s, GIOCondition cond)
 
 static void char_mux_finalize(Object *obj)
 {
-    MuxChardev *d = MUX_CHARDEV(obj);
+    MuxFeChardev *d = MUX_FE_CHARDEV(obj);
     int bit;
 
     bit = -1;
@@ -299,7 +299,7 @@  static void char_mux_finalize(Object *obj)
 
 static void mux_chr_update_read_handlers(Chardev *chr)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
 
     /* Fix up the real driver with mux routines */
     qemu_chr_fe_set_handlers_full(&d->chr,
@@ -311,7 +311,7 @@  static void mux_chr_update_read_handlers(Chardev *chr)
                                   chr->gcontext, true, false);
 }
 
-bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
+bool mux_chr_attach_frontend(MuxFeChardev *d, CharBackend *b,
                              unsigned int *tag, Error **errp)
 {
     unsigned int bit;
@@ -332,7 +332,7 @@  bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
     return true;
 }
 
-bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
+bool mux_chr_detach_frontend(MuxFeChardev *d, unsigned int tag)
 {
     unsigned int bit;
 
@@ -349,7 +349,7 @@  bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag)
 
 void mux_set_focus(Chardev *chr, unsigned int focus)
 {
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
 
     assert(find_next_bit(&d->mux_bitset, MAX_MUX, focus) == focus);
 
@@ -369,7 +369,7 @@  static void qemu_chr_open_mux(Chardev *chr,
 {
     ChardevMux *mux = backend->u.mux.data;
     Chardev *drv;
-    MuxChardev *d = MUX_CHARDEV(chr);
+    MuxFeChardev *d = MUX_FE_CHARDEV(chr);
 
     drv = qemu_chr_find(mux->chardev);
     if (drv == NULL) {
@@ -434,7 +434,7 @@  static int chardev_options_parsed_cb(Object *child, void *opaque)
 {
     Chardev *chr = (Chardev *)child;
 
-    if (!chr->be_open && CHARDEV_IS_MUX(chr)) {
+    if (!chr->be_open && CHARDEV_IS_MUX_FE(chr)) {
         open_muxes(chr);
     }
 
@@ -462,10 +462,10 @@  static void char_mux_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo char_mux_type_info = {
-    .name = TYPE_CHARDEV_MUX,
+    .name = TYPE_CHARDEV_MUX_FE,
     .parent = TYPE_CHARDEV,
     .class_init = char_mux_class_init,
-    .instance_size = sizeof(MuxChardev),
+    .instance_size = sizeof(MuxFeChardev),
     .instance_finalize = char_mux_finalize,
 };
 
diff --git a/chardev/char.c b/chardev/char.c
index a1722aa076d9..e077773cdece 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -331,8 +331,8 @@  static const TypeInfo char_type_info = {
 
 static bool qemu_chr_is_busy(Chardev *s)
 {
-    if (CHARDEV_IS_MUX(s)) {
-        MuxChardev *d = MUX_CHARDEV(s);
+    if (CHARDEV_IS_MUX_FE(s)) {
+        MuxFeChardev *d = MUX_FE_CHARDEV(s);
         return d->mux_bitset != 0;
     } else {
         return s->be != NULL;
@@ -687,7 +687,7 @@  static Chardev *__qemu_chr_new_from_opts(QemuOpts *opts, GMainContext *context,
         backend->type = CHARDEV_BACKEND_KIND_MUX;
         backend->u.mux.data = g_new0(ChardevMux, 1);
         backend->u.mux.data->chardev = g_strdup(bid);
-        mux = qemu_chardev_new(id, TYPE_CHARDEV_MUX, backend, context, errp);
+        mux = qemu_chardev_new(id, TYPE_CHARDEV_MUX_FE, backend, context, errp);
         if (mux == NULL) {
             object_unparent(OBJECT(chr));
             chr = NULL;
@@ -1104,7 +1104,7 @@  ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
         return NULL;
     }
 
-    if (CHARDEV_IS_MUX(chr)) {
+    if (CHARDEV_IS_MUX_FE(chr)) {
         error_setg(errp, "Mux device hotswap not supported yet");
         return NULL;
     }
diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
index 853807f3cb88..321051bb9cc5 100644
--- a/chardev/chardev-internal.h
+++ b/chardev/chardev-internal.h
@@ -33,7 +33,7 @@ 
 #define MUX_BUFFER_SIZE 32 /* Must be a power of 2.  */
 #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1)
 
-struct MuxChardev {
+struct MuxFeChardev {
     Chardev parent;
     CharBackend *backends[MAX_MUX];
     CharBackend chr;
@@ -52,16 +52,16 @@  struct MuxChardev {
     bool linestart;
     int64_t timestamps_start;
 };
-typedef struct MuxChardev MuxChardev;
+typedef struct MuxFeChardev MuxFeChardev;
 
-DECLARE_INSTANCE_CHECKER(MuxChardev, MUX_CHARDEV,
-                         TYPE_CHARDEV_MUX)
-#define CHARDEV_IS_MUX(chr)                             \
-    object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX)
+DECLARE_INSTANCE_CHECKER(MuxFeChardev, MUX_FE_CHARDEV,
+                         TYPE_CHARDEV_MUX_FE)
+#define CHARDEV_IS_MUX_FE(chr)                             \
+    object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX_FE)
 
-bool mux_chr_attach_frontend(MuxChardev *d, CharBackend *b,
+bool mux_chr_attach_frontend(MuxFeChardev *d, CharBackend *b,
                              unsigned int *tag, Error **errp);
-bool mux_chr_detach_frontend(MuxChardev *d, unsigned int tag);
+bool mux_chr_detach_frontend(MuxFeChardev *d, unsigned int tag);
 void mux_set_focus(Chardev *chr, unsigned int focus);
 void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event);
 
diff --git a/include/chardev/char.h b/include/chardev/char.h
index 01df55f9e8c8..d9d23b6232db 100644
--- a/include/chardev/char.h
+++ b/include/chardev/char.h
@@ -231,7 +231,7 @@  int qemu_chr_wait_connected(Chardev *chr, Error **errp);
 OBJECT_DECLARE_TYPE(Chardev, ChardevClass, CHARDEV)
 
 #define TYPE_CHARDEV_NULL "chardev-null"
-#define TYPE_CHARDEV_MUX "chardev-mux"
+#define TYPE_CHARDEV_MUX_FE "chardev-mux"
 #define TYPE_CHARDEV_RINGBUF "chardev-ringbuf"
 #define TYPE_CHARDEV_PTY "chardev-pty"
 #define TYPE_CHARDEV_CONSOLE "chardev-console"