]> git.sur5r.net Git - u-boot/blobdiff - drivers/core/lists.c
dm: allow setting driver_data before/during bind
[u-boot] / drivers / core / lists.c
index 2e52500ef25c7ee145c22240cae67356b212bf99..0c277177909666e1dedfd12efbd6ca3b531549f1 100644 (file)
@@ -99,7 +99,7 @@ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
        return 0;
 }
 
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
 /**
  * driver_check_compatible() - Check if a driver is compatible with this node
  *
@@ -170,12 +170,17 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
                }
 
                dm_dbg("   - found match at '%s'\n", entry->name);
-               ret = device_bind(parent, entry, name, NULL, offset, &dev);
+               ret = device_bind_with_driver_data(parent, entry, name,
+                                                  id->data, offset, &dev);
+               if (ret == -ENODEV) {
+                       dm_dbg("Driver '%s' refuses to bind\n", entry->name);
+                       continue;
+               }
                if (ret) {
-                       dm_warn("Error binding driver '%s'\n", entry->name);
+                       dm_warn("Error binding driver '%s': %d\n", entry->name,
+                               ret);
                        return ret;
                } else {
-                       dev->driver_data = id->data;
                        found = true;
                        if (devp)
                                *devp = dev;