]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: Adjust lists_bind_fdt() to return the bound device
authorSimon Glass <sjg@chromium.org>
Thu, 4 Sep 2014 22:27:25 +0000 (16:27 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 10 Sep 2014 18:59:59 +0000 (12:59 -0600)
Allow the caller to find out the device that was bound in response to this
call.

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

index 0f08bfd6ff2c16d74bdd319b70233e4f327242a7..699f94b435f213a0e78e91e4d2e854ae45473e7b 100644 (file)
@@ -118,7 +118,8 @@ static int driver_check_compatible(const void *blob, int offset,
        return -ENOENT;
 }
 
        return -ENOENT;
 }
 
-int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
+int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
+                  struct udevice **devp)
 {
        struct driver *driver = ll_entry_start(struct driver, driver);
        const int n_ents = ll_entry_count(struct driver, driver);
 {
        struct driver *driver = ll_entry_start(struct driver, driver);
        const int n_ents = ll_entry_count(struct driver, driver);
@@ -130,6 +131,8 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
        int ret = 0;
 
        dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL));
        int ret = 0;
 
        dm_dbg("bind node %s\n", fdt_get_name(blob, offset, NULL));
+       if (devp)
+               *devp = NULL;
        for (entry = driver; entry != driver + n_ents; entry++) {
                ret = driver_check_compatible(blob, offset, entry->of_match);
                name = fdt_get_name(blob, offset, NULL);
        for (entry = driver; entry != driver + n_ents; entry++) {
                ret = driver_check_compatible(blob, offset, entry->of_match);
                name = fdt_get_name(blob, offset, NULL);
@@ -149,10 +152,11 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset)
                ret = device_bind(parent, entry, name, NULL, offset, &dev);
                if (ret) {
                        dm_warn("Error binding driver '%s'\n", entry->name);
                ret = device_bind(parent, entry, name, NULL, offset, &dev);
                if (ret) {
                        dm_warn("Error binding driver '%s'\n", entry->name);
-                       if (!result || ret != -ENOENT)
-                               result = ret;
+                       return ret;
                } else {
                        found = true;
                } else {
                        found = true;
+                       if (devp)
+                               *devp = dev;
                }
                break;
        }
                }
                break;
        }
index 393dd98b9db248c2c5d8ef89d280d1568cb3d759..a328a4876f13ad68df6d5fddd8817df622d0195d 100644 (file)
@@ -91,7 +91,7 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
                if (pre_reloc_only &&
                    !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
                        continue;
                if (pre_reloc_only &&
                    !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
                        continue;
-               err = lists_bind_fdt(parent, blob, offset);
+               err = lists_bind_fdt(parent, blob, offset, NULL);
                if (err && !ret)
                        ret = err;
        }
                if (err && !ret)
                        ret = err;
        }
index 87a3af59c2e33b355fb4980debe11ecc854f6a1b..23568952467e6d5b685d84e2664561f5ca9ea942 100644 (file)
@@ -53,7 +53,11 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
  * @parent: parent driver (root)
  * @blob: device tree blob
  * @offset: offset of this device tree node
  * @parent: parent driver (root)
  * @blob: device tree blob
  * @offset: offset of this device tree node
+ * @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);
+int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
+                  struct udevice **devp);
 
 #endif
 
 #endif