]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Add helper to compare node names
authorKishon Vijay Abraham I <kishon@ti.com>
Wed, 21 Jul 2021 15:58:30 +0000 (21:28 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 27 Jul 2021 05:26:53 +0000 (10:56 +0530)
Add helper to compare node names.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20210721155849.20994-2-kishon@ti.com
drivers/core/ofnode.c
include/dm/ofnode.h

index dda6c76e834d6da67dd129e25025eb3261fb2a22..701b23e2c91285ffde9ec618c94074516f739d43 100644 (file)
 #include <linux/ioport.h>
 #include <asm/global_data.h>
 
+bool ofnode_name_eq(ofnode node, const char *name)
+{
+       const char *node_name;
+       size_t len;
+
+       assert(ofnode_valid(node));
+
+       node_name = ofnode_get_name(node);
+       len = strchrnul(node_name, '@') - node_name;
+
+       return (strlen(name) == len) && !strncmp(node_name, name, len);
+}
+
 int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
 {
        return ofnode_read_u32_index(node, propname, 0, outp);
index 3da05d8b2178e2b47dd382d478ce0eae1c0dbf29..4e1a8447e65ec07c41c00a35817dc2593f056289 100644 (file)
@@ -231,6 +231,16 @@ static inline ofnode ofnode_root(void)
        return node;
 }
 
+/**
+ * ofnode_name_eq() - Check if the node name is equivalent to a given name
+ *                    ignoring the unit address
+ *
+ * @node:      valid node reference that has to be compared
+ * @name:      name that has to be compared with the node name
+ * @return true if matches, false if it doesn't match
+ */
+bool ofnode_name_eq(ofnode node, const char *name);
+
 /**
  * ofnode_read_u32() - Read a 32-bit integer from a property
  *