]> xenbits.xensource.com Git - xen.git/commitdiff
libfdt: overlay: change overlay_get_target()
authorVikram Garhwal <vikram.garhwal@amd.com>
Wed, 6 Sep 2023 01:16:17 +0000 (18:16 -0700)
committerStefano Stabellini <stefano.stabellini@amd.com>
Wed, 6 Sep 2023 01:25:25 +0000 (18:25 -0700)
Rename overlay_get_target() to fdt_overlay_target_offset() and remove static
function type.

This is done to get the target path for the overlay nodes which is very useful
in many cases. For example, Xen hypervisor needs it when applying overlays
because Xen needs to do further processing of the overlay nodes, e.g. mapping of
resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.

Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Origin: git://git.kernel.org/pub/scm/utils/dtc/dtc.git 45f3d1a095dd

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Acked-by: Juline Grall <jgrall@amazon.com>
xen/common/libfdt/fdt_overlay.c
xen/common/libfdt/version.lds
xen/include/xen/libfdt/libfdt.h

index 7b95e2b6396f851275a6ac4e8fe509608890d7dc..acf0c4c2a610409ef7e4d63dbe68d4c317c7522d 100644 (file)
@@ -41,37 +41,22 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
        return fdt32_to_cpu(*val);
 }
 
-/**
- * overlay_get_target - retrieves the offset of a fragment's target
- * @fdt: Base device tree blob
- * @fdto: Device tree overlay blob
- * @fragment: node offset of the fragment in the overlay
- * @pathp: pointer which receives the path of the target (or NULL)
- *
- * overlay_get_target() retrieves the target offset in the base
- * device tree of a fragment, no matter how the actual targeting is
- * done (through a phandle or a path)
- *
- * returns:
- *      the targeted node offset in the base device tree
- *      Negative error code on error
- */
-static int overlay_get_target(const void *fdt, const void *fdto,
-                             int fragment, char const **pathp)
+int fdt_overlay_target_offset(const void *fdt, const void *fdto,
+                             int fragment_offset, char const **pathp)
 {
        uint32_t phandle;
        const char *path = NULL;
        int path_len = 0, ret;
 
        /* Try first to do a phandle based lookup */
-       phandle = overlay_get_target_phandle(fdto, fragment);
+       phandle = overlay_get_target_phandle(fdto, fragment_offset);
        if (phandle == (uint32_t)-1)
                return -FDT_ERR_BADPHANDLE;
 
        /* no phandle, try path */
        if (!phandle) {
                /* And then a path based lookup */
-               path = fdt_getprop(fdto, fragment, "target-path", &path_len);
+               path = fdt_getprop(fdto, fragment_offset, "target-path", &path_len);
                if (path)
                        ret = fdt_path_offset(fdt, path);
                else
@@ -638,7 +623,7 @@ static int overlay_merge(void *fdt, void *fdto)
                if (overlay < 0)
                        return overlay;
 
-               target = overlay_get_target(fdt, fdto, fragment, NULL);
+               target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL);
                if (target < 0)
                        return target;
 
@@ -781,7 +766,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
                        return -FDT_ERR_BADOVERLAY;
 
                /* get the target of the fragment */
-               ret = overlay_get_target(fdt, fdto, fragment, &target_path);
+               ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path);
                if (ret < 0)
                        return ret;
                target = ret;
@@ -803,7 +788,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
 
                if (!target_path) {
                        /* again in case setprop_placeholder changed it */
-                       ret = overlay_get_target(fdt, fdto, fragment, &target_path);
+                       ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path);
                        if (ret < 0)
                                return ret;
                        target = ret;
index 7ab85f1d9d8d4dc7d022044dcd5ca4242b00c9bc..cbce5d4a8bdc31ea01d89319ad3849d3389d32ed 100644 (file)
@@ -77,6 +77,7 @@ LIBFDT_1.2 {
                fdt_appendprop_addrrange;
                fdt_setprop_inplace_namelen_partial;
                fdt_create_with_flags;
+               fdt_overlay_target_offset;
        local:
                *;
 };
index c71689e2bea6b654f84ada5f0ce01a1de97300ae..fabddbee8cec5a28c1956ddc2ee13af7e70b3531 100644 (file)
@@ -2109,6 +2109,24 @@ int fdt_del_node(void *fdt, int nodeoffset);
  */
 int fdt_overlay_apply(void *fdt, void *fdto);
 
+/**
+ * fdt_overlay_target_offset - retrieves the offset of a fragment's target
+ * @fdt: Base device tree blob
+ * @fdto: Device tree overlay blob
+ * @fragment_offset: node offset of the fragment in the overlay
+ * @pathp: pointer which receives the path of the target (or NULL)
+ *
+ * fdt_overlay_target_offset() retrieves the target offset in the base
+ * device tree of a fragment, no matter how the actual targeting is
+ * done (through a phandle or a path)
+ *
+ * returns:
+ *      the targeted node offset in the base device tree
+ *      Negative error code on error
+ */
+int fdt_overlay_target_offset(const void *fdt, const void *fdto,
+                             int fragment_offset, char const **pathp);
+
 /**********************************************************************/
 /* Debugging / informational functions                                */
 /**********************************************************************/