dm: core: Adjust uclass setup with of-platdata
authorSimon Glass <sjg@chromium.org>
Mon, 15 Mar 2021 04:25:16 +0000 (17:25 +1300)
committerSimon Glass <sjg@chromium.org>
Mon, 22 Mar 2021 06:23:28 +0000 (19:23 +1300)
When OF_PLATDATA_INST is enabled we don't need to create the uclass list.
Instead we just need to point to the existing list. Update the code
accordingly.

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

index 9bc682c..3feadb7 100644 (file)
@@ -140,8 +140,12 @@ int dm_init(bool of_live)
                dm_warn("Virtual root driver already exists!\n");
                return -EINVAL;
        }
-       gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
-       INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
+       if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
+               gd->uclass_root = &uclass_head;
+       } else {
+               gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
+               INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
+       }
 
        if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
                fix_drivers();
index 89afbee..42510b1 100644 (file)
@@ -11,6 +11,9 @@
 
 struct udevice;
 
+/* Head of the uclass list if CONFIG_OF_PLATDATA_INST is enabled */
+extern struct list_head uclass_head;
+
 /**
  * dm_root() - Return pointer to the top of the driver tree
  *