diff mbox series

[08/26] hw/ppc: Avoid using Monitor in spapr_xive_pic_print_info()

Message ID 20240610062105.49848-9-philmd@linaro.org
State Superseded
Headers show
Series hw/ppc: Prefer HumanReadableText over Monitor | expand

Commit Message

Philippe Mathieu-Daudé June 10, 2024, 6:20 a.m. UTC
Replace Monitor API by HumanReadableText one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/intc/spapr_xive.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

Comments

Harsh Prateek Bora June 17, 2024, 12:50 p.m. UTC | #1
On 6/10/24 11:50, Philippe Mathieu-Daudé wrote:
> @@ -203,10 +201,8 @@ static void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon)
>                   spapr_xive_end_pic_print_info(xive, end, buf);
>               }
>   
> -            info = human_readable_text_from_str(buf);
> -            monitor_puts(mon, info->human_readable_text);
>           }
> -        monitor_printf(mon, "\n");
> +        g_string_append_c(buf, '\n');

Ok, I see caller specific changes are done in separate patches.
Ideally one call flow could be squashed into a single patch, which would
help avoid addition, followed by removal of common logic like above.
However, assuming that would be increasing the patch size, I understand
smaller patches are easier to review.

Thanks
Harsh

>       }
>   }
diff mbox series

Patch

diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index d571645e9e..9d0d5948ff 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -157,7 +157,7 @@  static void spapr_xive_end_pic_print_info(SpaprXive *xive, XiveEND *end,
 #define spapr_xive_in_kernel(xive) \
     (kvm_irqchip_in_kernel() && (xive)->fd != -1)
 
-static void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon)
+static void spapr_xive_pic_print_info(SpaprXive *xive, GString *buf)
 {
     XiveSource *xsrc = &xive->source;
     int i;
@@ -172,7 +172,7 @@  static void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon)
         }
     }
 
-    monitor_printf(mon, "  LISN         PQ    EISN     CPU/PRIO EQ\n");
+    g_string_append_printf(buf, "  LISN         PQ    EISN     CPU/PRIO EQ\n");
 
     for (i = 0; i < xive->nr_irqs; i++) {
         uint8_t pq = xive_source_esb_get(xsrc, i);
@@ -182,19 +182,17 @@  static void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon)
             continue;
         }
 
-        monitor_printf(mon, "  %08x %s %c%c%c %s %08x ", i,
-                       xive_source_irq_is_lsi(xsrc, i) ? "LSI" : "MSI",
-                       pq & XIVE_ESB_VAL_P ? 'P' : '-',
-                       pq & XIVE_ESB_VAL_Q ? 'Q' : '-',
-                       xive_source_is_asserted(xsrc, i) ? 'A' : ' ',
-                       xive_eas_is_masked(eas) ? "M" : " ",
-                       (int) xive_get_field64(EAS_END_DATA, eas->w));
+        g_string_append_printf(buf, "  %08x %s %c%c%c %s %08x ", i,
+                               xive_source_irq_is_lsi(xsrc, i) ? "LSI" : "MSI",
+                               pq & XIVE_ESB_VAL_P ? 'P' : '-',
+                               pq & XIVE_ESB_VAL_Q ? 'Q' : '-',
+                               xive_source_is_asserted(xsrc, i) ? 'A' : ' ',
+                               xive_eas_is_masked(eas) ? "M" : " ",
+                               (int) xive_get_field64(EAS_END_DATA, eas->w));
 
         if (!xive_eas_is_masked(eas)) {
             uint32_t end_idx = xive_get_field64(EAS_END_INDEX, eas->w);
             XiveEND *end;
-            g_autoptr(GString) buf = g_string_new("");
-            g_autoptr(HumanReadableText) info = NULL;
 
             assert(end_idx < xive->nr_ends);
             end = &xive->endt[end_idx];
@@ -203,10 +201,8 @@  static void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon)
                 spapr_xive_end_pic_print_info(xive, end, buf);
             }
 
-            info = human_readable_text_from_str(buf);
-            monitor_puts(mon, info->human_readable_text);
         }
-        monitor_printf(mon, "\n");
+        g_string_append_c(buf, '\n');
     }
 }
 
@@ -717,10 +713,10 @@  static void spapr_xive_print_info(SpaprInterruptController *intc, Monitor *mon)
 
         xive_tctx_pic_print_info(spapr_cpu_state(cpu)->tctx, buf);
     }
+    spapr_xive_pic_print_info(xive, buf);
+
     info = human_readable_text_from_str(buf);
     monitor_puts(mon, info->human_readable_text);
-
-    spapr_xive_pic_print_info(xive, mon);
 }
 
 static void spapr_xive_dt(SpaprInterruptController *intc, uint32_t nr_servers,