]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Update lists_bind_fdt() to use ofnode
authorSimon Glass <sjg@chromium.org>
Fri, 19 May 2017 02:09:06 +0000 (20:09 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:08 +0000 (07:03 -0600)
Adjust this function to use an ofnode instead of an offset, so it can be
used with livetree. This involves updating all callers.

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

index 9adfa758bcaefc505beb9f9c93d8e4cfceeecf69..facf276474bfd867c8312d752af9ab7a69a23579 100644 (file)
@@ -126,8 +126,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 +141,18 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
 
        if (devp)
                *devp = NULL;
-       name = fdt_get_name(blob, offset, NULL);
+       name = ofnode_get_name(node);
        dm_dbg("bind node %s\n", name);
 
-       compat_list = fdt_getprop(blob, offset, "compatible", &compat_length);
+       compat_list = (const char *)ofnode_read_prop(node, "compatible",
+                                                    &compat_length);
        if (!compat_list) {
                if (compat_length == -FDT_ERR_NOTFOUND) {
                        dm_dbg("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;
        }
 
@@ -177,7 +177,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
 
                dm_dbg("   - 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);
                        continue;
index 570b4d855fac59a66f1039be36bd20647537b844..0c00a4e051e328fe302f5b0051a6f9b39bf10ba7 100644 (file)
@@ -235,7 +235,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
                        dm_dbg("   - ignoring disabled device\n");
                        continue;
                }
-               err = lists_bind_fdt(parent, blob, offset, NULL);
+               err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL);
                if (err && !ret) {
                        ret = err;
                        debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),
index c2b9c5f12f5791ee6e255d053d811be74b517bf2..a9c4f89e1a0901f31dfb4a85bba36fc6d6993b58 100644 (file)
@@ -74,7 +74,8 @@ static void serial_find_console_or_panic(void)
                 * bind it anyway.
                 */
                if (node > 0 &&
-                   !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
+                   !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
+                                   &dev)) {
                        if (!device_probe(dev)) {
                                gd->cur_serial_dev = dev;
                                return;
index 1caf3cd2887a4b8fcb639d90c0288c6ae3e731ce..ec10b282882f1681eab70b6f78169bcb942fd19f 100644 (file)
@@ -103,7 +103,8 @@ int notrace dm_timer_init(void)
                         * relocation, bind it anyway.
                         */
                        if (node > 0 &&
-                           !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
+                           !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
+                                           &dev)) {
                                ret = device_probe(dev);
                                if (ret)
                                        return ret;
index 4513d6a311a7e80daebd6bb1bd32a0e2e92701d3..f55c41991b9fb44fcfcd6f4dc884e8f78552a560 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef _DM_LISTS_H_
 #define _DM_LISTS_H_
 
+#include <dm/ofnode.h>
 #include <dm/uclass-id.h>
 
 /**
@@ -51,14 +52,12 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
  * @parent as its parent.
  *
  * @parent: parent device (root)
- * @blob: device tree blob
- * @offset: offset of this device tree node
+ * @node: device tree node to bind
  * @devp: if non-NULL, returns a pointer to the bound device
  * @return 0 if device was bound, -EINVAL if the device tree is invalid,
  * other -ve value on error
  */
-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);
 
 /**
  * device_bind_driver() - bind a device to a driver