dm: Avoid using #ifdef for CONFIG_OF_LIVE

At present this option results in a number of #ifdefs due to the presence
or absence of the global_data of_root member.

Add a few macros to global_data.h to work around this. Update the code
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 0726be6..de23161 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -61,7 +61,7 @@
 	for (entry = drv; entry != drv + n_ents; entry++) {
 		if (entry->of_match)
 			entry->of_match = (const struct udevice_id *)
-				((u32)entry->of_match + gd->reloc_off);
+				((ulong)entry->of_match + gd->reloc_off);
 		if (entry->bind)
 			entry->bind += gd->reloc_off;
 		if (entry->probe)
@@ -151,11 +151,9 @@
 	if (ret)
 		return ret;
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-# if CONFIG_IS_ENABLED(OF_LIVE)
-	if (of_live)
-		DM_ROOT_NON_CONST->node = np_to_ofnode(gd->of_root);
+	if (CONFIG_IS_ENABLED(OF_LIVE) && of_live)
+		DM_ROOT_NON_CONST->node = np_to_ofnode(gd_of_root());
 	else
-#endif
 		DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
 #endif
 	ret = device_probe(DM_ROOT_NON_CONST);
@@ -196,7 +194,7 @@
 	return ret;
 }
 
-#if CONFIG_IS_ENABLED(OF_LIVE)
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int dm_scan_fdt_live(struct udevice *parent,
 			    const struct device_node *node_parent,
 			    bool pre_reloc_only)
@@ -223,9 +221,7 @@
 
 	return ret;
 }
-#endif /* CONFIG_IS_ENABLED(OF_LIVE) */
 
-#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 /**
  * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
  *
@@ -272,24 +268,20 @@
 	if (!dev_of_valid(dev))
 		return 0;
 
-#if CONFIG_IS_ENABLED(OF_LIVE)
 	if (of_live_active())
 		return dm_scan_fdt_live(dev, dev_np(dev),
 				gd->flags & GD_FLG_RELOC ? false : true);
-	else
-#endif
+
 	return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev),
 				gd->flags & GD_FLG_RELOC ? false : true);
 }
 
 int dm_scan_fdt(const void *blob, bool pre_reloc_only)
 {
-#if CONFIG_IS_ENABLED(OF_LIVE)
 	if (of_live_active())
-		return dm_scan_fdt_live(gd->dm_root, gd->of_root,
+		return dm_scan_fdt_live(gd->dm_root, gd_of_root(),
 					pre_reloc_only);
-	else
-#endif
+
 	return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
 }
 
@@ -302,10 +294,9 @@
 	if (!ofnode_valid(node))
 		return 0;
 
-#if CONFIG_IS_ENABLED(OF_LIVE)
 	if (of_live_active())
 		return dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only);
-#endif
+
 	return dm_scan_fdt_node(gd->dm_root, blob, node.of_offset,
 				pre_reloc_only);
 }
@@ -352,7 +343,7 @@
 	dm_populate_phandle_data();
 #endif
 
-	ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE));
+	ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
 	if (ret) {
 		debug("dm_init() failed: %d\n", ret);
 		return ret;