diff options
author | Simon Glass | 2020-10-03 09:25:22 -0600 |
---|---|---|
committer | Simon Glass | 2020-10-29 14:42:17 -0600 |
commit | a652d9c73a6eea1fdfb901c66178a4d804fac95d (patch) | |
tree | 85eaeea9428ceb50ce9579f87edf49e442447a22 /test | |
parent | 08c3b88dd145d3f7f06e7ad8458905bde7a286ef (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/test-main.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 38b7b1481a7..995988723ae 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -33,10 +33,8 @@ static int dm_test_init(struct unit_test_state *uts, bool of_live) 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 @@ static int dm_test_main(const char *test_name) 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 @@ static int dm_test_main(const char *test_name) /* 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 @@ static int dm_test_main(const char *test_name) 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); |