diff mbox series

[V2,4/6] libxl: arm: Split make_virtio_mmio_node()

Message ID 65dfe45db3829990335c0c5307d4bcfb40647986.1652162646.git.viresh.kumar@linaro.org (mailing list archive)
State New, archived
Headers show
Series Virtio toolstack support for I2C and GPIO on Arm | expand

Commit Message

Viresh Kumar May 10, 2022, 6:04 a.m. UTC
make_virtio_mmio_node() creates the DT node for simple MMIO devices
currently, i.e. the ones that don't require any additional properties.

In order to allow using it for other complex device types, split the
functionality into two, one where the fdt node isn't closed and the
other one to create a simple DT node.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 tools/libs/light/libxl_arm.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 6b95ded82dc3..3a038d388cf0 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -872,8 +872,8 @@  static int make_vpci_node(libxl__gc *gc, void *fdt,
 }
 
 
-static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
-                                 uint64_t base, uint32_t irq)
+static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, uint64_t base,
+                                        uint32_t irq)
 {
     int res;
     gic_interrupt intr;
@@ -895,13 +895,18 @@  static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
     res = fdt_property_interrupts(gc, fdt, &intr, 1);
     if (res) return res;
 
-    res = fdt_property(fdt, "dma-coherent", NULL, 0);
-    if (res) return res;
+    return fdt_property(fdt, "dma-coherent", NULL, 0);
+}
 
-    res = fdt_end_node(fdt);
+static int make_virtio_mmio_node_simple(libxl__gc *gc, void *fdt, uint64_t base,
+                                        uint32_t irq)
+{
+    int res;
+
+    res = make_virtio_mmio_node_common(gc, fdt, base, irq);
     if (res) return res;
 
-    return 0;
+    return fdt_end_node(fdt);
 }
 
 static const struct arch_info *get_arch_info(libxl__gc *gc,
@@ -1216,7 +1221,7 @@  static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config,
             libxl_device_disk *disk = &d_config->disks[i];
 
             if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO)
-                FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq) );
+                FDT( make_virtio_mmio_node_simple(gc, fdt, disk->base, disk->irq) );
         }
 
         if (pfdt)