]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Add an ofnode function to get the devicetree root
authorSimon Glass <sjg@chromium.org>
Sun, 29 Nov 2020 00:50:07 +0000 (17:50 -0700)
committerSimon Glass <sjg@chromium.org>
Sun, 13 Dec 2020 14:58:18 +0000 (07:58 -0700)
This is needed in at least one place. Avoid the conditional code in root.c
by adding this inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/root.c
include/dm/ofnode.h

index 5f10d7a39c7e9fc0bf8d334cfe2ffa183fe07ee7..9ee65504e6e793ae5c6455fabb74aaf98f68f782 100644 (file)
@@ -147,12 +147,8 @@ int dm_init(bool of_live)
        ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
        if (ret)
                return ret;
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-       if (CONFIG_IS_ENABLED(OF_LIVE) && of_live)
-               DM_ROOT_NON_CONST->node = np_to_ofnode(gd_of_root());
-       else
-               DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
-#endif
+       if (CONFIG_IS_ENABLED(OF_CONTROL))
+               DM_ROOT_NON_CONST->node = ofnode_root();
        ret = device_probe(DM_ROOT_NON_CONST);
        if (ret)
                return ret;
index ee8c44a71ec3b3d31bf462331f6d1192ad5c5b6f..53f04ac91d064a0e00c1db6906678d174a0842e3 100644 (file)
@@ -218,6 +218,18 @@ static inline ofnode ofnode_null(void)
        return node;
 }
 
+static inline ofnode ofnode_root(void)
+{
+       ofnode node;
+
+       if (of_live_active())
+               node.np = gd_of_root();
+       else
+               node.of_offset = 0;
+
+       return node;
+}
+
 /**
  * ofnode_read_u32() - Read a 32-bit integer from a property
  *