Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / drivers / core / lists.c
index 9adfa758bcaefc505beb9f9c93d8e4cfceeecf69..6fa5d1090ab0e0796bd3a1c820e8ebb7088dcccc 100644 (file)
@@ -74,11 +74,12 @@ 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);
+       return device_bind_driver_to_node(parent, drv_name, dev_name,
+                                         ofnode_null(), devp);
 }
 
 int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
-                              const char *dev_name, int node,
+                              const char *dev_name, ofnode node,
                               struct udevice **devp)
 {
        struct driver *drv;
@@ -89,14 +90,10 @@ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
                debug("Cannot find driver '%s'\n", drv_name);
                return -ENOENT;
        }
-       ret = device_bind(parent, drv, dev_name, NULL, node, devp);
-       if (ret) {
-               debug("Cannot create device named '%s' (err=%d)\n",
-                     dev_name, ret);
-               return ret;
-       }
+       ret = device_bind_with_driver_data(parent, drv, dev_name, 0 /* data */,
+                                          node, devp);
 
-       return 0;
+       return ret;
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
@@ -126,8 +123,7 @@ static int driver_check_compatible(const struct udevice_id *of_match,
        return -ENOENT;
 }
 
-int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
-                  struct udevice **devp)
+int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp)
 {
        struct driver *driver = ll_entry_start(struct driver, driver);
        const int n_ents = ll_entry_count(struct driver, driver);
@@ -142,17 +138,18 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
 
        if (devp)
                *devp = NULL;
-       name = fdt_get_name(blob, offset, NULL);
-       dm_dbg("bind node %s\n", name);
+       name = ofnode_get_name(node);
+       pr_debug("bind node %s\n", name);
 
-       compat_list = fdt_getprop(blob, offset, "compatible", &compat_length);
+       compat_list = ofnode_get_property(node, "compatible", &compat_length);
        if (!compat_list) {
                if (compat_length == -FDT_ERR_NOTFOUND) {
-                       dm_dbg("Device '%s' has no compatible string\n", name);
+                       pr_debug("Device '%s' has no compatible string\n",
+                                name);
                        return 0;
                }
 
-               dm_warn("Device tree error at offset %d\n", offset);
+               dm_warn("Device tree error at node '%s'\n", name);
                return compat_length;
        }
 
@@ -163,8 +160,8 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
         */
        for (i = 0; i < compat_length; i += strlen(compat) + 1) {
                compat = compat_list + i;
-               dm_dbg("   - attempt to match compatible string '%s'\n",
-                      compat);
+               pr_debug("   - attempt to match compatible string '%s'\n",
+                        compat);
 
                for (entry = driver; entry != driver + n_ents; entry++) {
                        ret = driver_check_compatible(entry->of_match, &id,
@@ -175,11 +172,11 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
                if (entry == driver + n_ents)
                        continue;
 
-               dm_dbg("   - found match at '%s'\n", entry->name);
+               pr_debug("   - found match at '%s'\n", entry->name);
                ret = device_bind_with_driver_data(parent, entry, name,
-                               id->data, offset_to_ofnode(offset), &dev);
+                                                  id->data, node, &dev);
                if (ret == -ENODEV) {
-                       dm_dbg("Driver '%s' refuses to bind\n", entry->name);
+                       pr_debug("Driver '%s' refuses to bind\n", entry->name);
                        continue;
                }
                if (ret) {
@@ -195,7 +192,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
        }
 
        if (!found && !result && ret != -ENODEV)
-               dm_dbg("No match for node '%s'\n", name);
+               pr_debug("No match for node '%s'\n", name);
 
        return result;
 }