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/test/dm/test-main.c b/test/dm/test-main.c
index 38b7b148..9959887 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -33,10 +33,8 @@
 	memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
 	state_reset_for_test(state_get_current());
 
-#ifdef CONFIG_OF_LIVE
 	/* Determine whether to make the live tree available */
-	gd->of_root = of_live ? uts->of_root : NULL;
-#endif
+	gd_set_of_root(of_live ? uts->of_root : NULL);
 	ut_assertok(dm_init(of_live));
 	dms->root = dm_root();
 
@@ -152,9 +150,7 @@
 		printf("Running %d driver model tests\n", n_ents);
 
 	found = 0;
-#ifdef CONFIG_OF_LIVE
-	uts->of_root = gd->of_root;
-#endif
+	uts->of_root = gd_of_root();
 	for (test = tests; test < tests + n_ents; test++) {
 		const char *name = test->name;
 		int runs;
@@ -167,7 +163,7 @@
 
 		/* Run with the live tree if possible */
 		runs = 0;
-		if (IS_ENABLED(CONFIG_OF_LIVE)) {
+		if (CONFIG_IS_ENABLED(OF_LIVE)) {
 			if (!(test->flags & UT_TESTF_FLAT_TREE)) {
 				ut_assertok(dm_do_test(uts, test, true));
 				runs++;
@@ -192,11 +188,9 @@
 		printf("Failures: %d\n", uts->fail_count);
 
 	/* Put everything back to normal so that sandbox works as expected */
-#ifdef CONFIG_OF_LIVE
-	gd->of_root = uts->of_root;
-#endif
+	gd_set_of_root(uts->of_root);
 	gd->dm_root = NULL;
-	ut_assertok(dm_init(IS_ENABLED(CONFIG_OF_LIVE)));
+	ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE)));
 	dm_scan_platdata(false);
 	dm_scan_fdt(gd->fdt_blob, false);