]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: convert device_get_global_by_of_offset() to device_get_global_by_ofnode()
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Thu, 9 Aug 2018 14:17:44 +0000 (16:17 +0200)
committerMarek Vasut <marex@denx.de>
Tue, 21 Aug 2018 14:21:37 +0000 (16:21 +0200)
Also add device_find_global_by_ofnode() that also find a device based on
the OF node, but doesn't probe the device.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
arch/arm/mach-rockchip/rk3188-board-spl.c
arch/arm/mach-rockchip/rk3288-board-spl.c
drivers/core/device.c
include/dm/device.h

index 59c7e4d4db63cbacbc2d2ba6a4f58e0ac853a3f0..98ca971b88a99ddbb16b9606b211152daec96c73 100644 (file)
@@ -49,7 +49,7 @@ u32 spl_boot_device(void)
                debug("node=%d\n", node);
                goto fallback;
        }
-       ret = device_get_global_by_of_offset(node, &dev);
+       ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
        if (ret) {
                debug("device at node %s/%d not found: %d\n", bootdev, node,
                      ret);
index ea6a14af4f0907ebf19cceaf16b659242e6999fc..abd62e520fada7ff920ecf0fee9b463201062ab8 100644 (file)
@@ -51,7 +51,7 @@ u32 spl_boot_device(void)
                debug("node=%d\n", node);
                goto fallback;
        }
-       ret = device_get_global_by_of_offset(node, &dev);
+       ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
        if (ret) {
                debug("device at node %s/%d not found: %d\n", bootdev, node,
                      ret);
index 207d566b71d080b4b4667a85e738818d40265944..fd59fe1e0f5d74a21fd06a872dfe29153869781b 100644 (file)
@@ -594,16 +594,16 @@ int device_get_child_by_of_offset(struct udevice *parent, int node,
        return device_get_device_tail(dev, ret, devp);
 }
 
-static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
-                                                       int of_offset)
+static struct udevice *_device_find_global_by_ofnode(struct udevice *parent,
+                                                    ofnode ofnode)
 {
        struct udevice *dev, *found;
 
-       if (dev_of_offset(parent) == of_offset)
+       if (ofnode_equal(dev_ofnode(parent), ofnode))
                return parent;
 
        list_for_each_entry(dev, &parent->child_head, sibling_node) {
-               found = _device_find_global_by_of_offset(dev, of_offset);
+               found = _device_find_global_by_ofnode(dev, ofnode);
                if (found)
                        return found;
        }
@@ -611,11 +611,18 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
        return NULL;
 }
 
-int device_get_global_by_of_offset(int of_offset, struct udevice **devp)
+int device_find_global_by_ofnode(ofnode ofnode, struct udevice **devp)
+{
+       *devp = _device_find_global_by_ofnode(gd->dm_root, ofnode);
+
+       return *devp ? 0 : -ENOENT;
+}
+
+int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)
 {
        struct udevice *dev;
 
-       dev = _device_find_global_by_of_offset(gd->dm_root, of_offset);
+       dev = _device_find_global_by_ofnode(gd->dm_root, ofnode);
        return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
 }
 
index 49078bc6b360a881c42d8bc7f912261cace03551..3120b68fcc6308d98dbf47645365d3c4c1917557 100644 (file)
@@ -473,18 +473,33 @@ int device_get_child_by_of_offset(struct udevice *parent, int of_offset,
                                  struct udevice **devp);
 
 /**
- * device_get_global_by_of_offset() - Get a device based on FDT offset
+ * device_find_global_by_ofnode() - Get a device based on ofnode
  *
- * Locates a device by its device tree offset, searching globally throughout
+ * Locates a device by its device tree ofnode, searching globally throughout
+ * the all driver model devices.
+ *
+ * The device is NOT probed
+ *
+ * @node: Device tree ofnode to find
+ * @devp: Returns pointer to device if found, otherwise this is set to NULL
+ * @return 0 if OK, -ve on error
+ */
+
+int device_find_global_by_ofnode(ofnode node, struct udevice **devp);
+
+/**
+ * device_get_global_by_ofnode() - Get a device based on ofnode
+ *
+ * Locates a device by its device tree ofnode, searching globally throughout
  * the all driver model devices.
  *
  * The device is probed to activate it ready for use.
  *
- * @of_offset: Device tree offset to find
+ * @node: Device tree ofnode to find
  * @devp: Returns pointer to device if found, otherwise this is set to NULL
  * @return 0 if OK, -ve on error
  */
-int device_get_global_by_of_offset(int of_offset, struct udevice **devp);
+int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
 
 /**
  * device_find_first_child() - Find the first child of a device