Don't allow access to uclasses before they have been initialised.
Signed-off-by: Simon Glass <sjg@chromium.org>
You should see something like this:
<...U-Boot banner...>
- Running 16 driver model tests
+ Running 17 driver model tests
Test: dm_test_autobind
Test: dm_test_autoprobe
Test: dm_test_children
Test: dm_test_pre_reloc
Test: dm_test_remove
Test: dm_test_uclass
+ Test: dm_test_uclass_before_ready
Failures: 0
{
struct uclass *uc;
+ if (!gd->dm_root)
+ return NULL;
/*
* TODO(sjg@chromium.org): Optimise this, perhaps moving the found
* node to the start of the list, or creating a linear array mapping
return 0;
}
DM_TEST(dm_test_pre_reloc, 0);
+
+static int dm_test_uclass_before_ready(struct dm_test_state *dms)
+{
+ struct uclass *uc;
+
+ ut_assertok(uclass_get(UCLASS_TEST, &uc));
+
+ memset(gd, '\0', sizeof(*gd));
+ ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
+
+ return 0;
+}
+
+DM_TEST(dm_test_uclass_before_ready, 0);