]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/core/lists.c
dm: Export device_remove_children / device_unbind_children
[karo-tx-uboot.git] / drivers / core / lists.c
index 7a1d6604d42faa36c5a8f1eebe3eedb53870ccd8..2e52500ef25c7ee145c22240cae67356b212bf99 100644 (file)
@@ -25,9 +25,6 @@ struct driver *lists_driver_lookup_name(const char *name)
        const int n_ents = ll_entry_count(struct driver, driver);
        struct driver *entry;
 
-       if (!drv || !n_ents)
-               return NULL;
-
        for (entry = drv; entry != drv + n_ents; entry++) {
                if (!strcmp(name, entry->name))
                        return entry;
@@ -44,9 +41,6 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id)
        const int n_ents = ll_entry_count(struct uclass_driver, uclass);
        struct uclass_driver *entry;
 
-       if ((id == UCLASS_INVALID) || !uclass)
-               return NULL;
-
        for (entry = uclass; entry != uclass + n_ents; entry++) {
                if (entry->id == id)
                        return entry;
@@ -79,19 +73,26 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
 
 int device_bind_driver(struct udevice *parent, const char *drv_name,
                       const char *dev_name, struct udevice **devp)
+{
+       return device_bind_driver_to_node(parent, drv_name, dev_name, -1, devp);
+}
+
+int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
+                              const char *dev_name, int node,
+                              struct udevice **devp)
 {
        struct driver *drv;
        int ret;
 
        drv = lists_driver_lookup_name(drv_name);
        if (!drv) {
-               printf("Cannot find driver '%s'\n", drv_name);
+               debug("Cannot find driver '%s'\n", drv_name);
                return -ENOENT;
        }
-       ret = device_bind(parent, drv, dev_name, NULL, -1, devp);
+       ret = device_bind(parent, drv, dev_name, NULL, node, devp);
        if (ret) {
-               printf("Cannot create device named '%s' (err=%d)\n",
-                      dev_name, ret);
+               debug("Cannot create device named '%s' (err=%d)\n",
+                     dev_name, ret);
                return ret;
        }
 
@@ -164,8 +165,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
                        break;
                } else if (ret) {
                        dm_warn("Device tree error at offset %d\n", offset);
-                       if (!result || ret != -ENOENT)
-                               result = ret;
+                       result = ret;
                        break;
                }
 
@@ -175,7 +175,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
                        dm_warn("Error binding driver '%s'\n", entry->name);
                        return ret;
                } else {
-                       dev->of_id = id;
+                       dev->driver_data = id->data;
                        found = true;
                        if (devp)
                                *devp = dev;