Commit b3e46d1a authored by Rob Herring's avatar Rob Herring

of: Use of_node_name_eq for node name comparisons

Convert string compares of DT node names to use of_node_name_eq helper
instead. This removes direct access to the node name pointer.

Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent ae517053
...@@ -371,7 +371,7 @@ EXPORT_SYMBOL(of_pci_range_to_resource); ...@@ -371,7 +371,7 @@ EXPORT_SYMBOL(of_pci_range_to_resource);
static int of_bus_isa_match(struct device_node *np) static int of_bus_isa_match(struct device_node *np)
{ {
return !strcmp(np->name, "isa"); return of_node_name_eq(np, "isa");
} }
static void of_bus_isa_count_cells(struct device_node *child, static void of_bus_isa_count_cells(struct device_node *child,
......
...@@ -496,7 +496,7 @@ static int __of_device_is_compatible(const struct device_node *device, ...@@ -496,7 +496,7 @@ static int __of_device_is_compatible(const struct device_node *device,
/* Matching name is a bit better than not */ /* Matching name is a bit better than not */
if (name && name[0]) { if (name && name[0]) {
if (!device->name || of_node_cmp(name, device->name)) if (!of_node_name_eq(device, name))
return 0; return 0;
score++; score++;
} }
...@@ -835,7 +835,7 @@ struct device_node *of_get_child_by_name(const struct device_node *node, ...@@ -835,7 +835,7 @@ struct device_node *of_get_child_by_name(const struct device_node *node,
struct device_node *child; struct device_node *child;
for_each_child_of_node(node, child) for_each_child_of_node(node, child)
if (child->name && (of_node_cmp(child->name, name) == 0)) if (of_node_name_eq(child, name))
break; break;
return child; return child;
} }
...@@ -961,8 +961,7 @@ struct device_node *of_find_node_by_name(struct device_node *from, ...@@ -961,8 +961,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
raw_spin_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
for_each_of_allnodes_from(from, np) for_each_of_allnodes_from(from, np)
if (np->name && (of_node_cmp(np->name, name) == 0) if (of_node_name_eq(np, name) && of_node_get(np))
&& of_node_get(np))
break; break;
of_node_put(from); of_node_put(from);
raw_spin_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
......
...@@ -571,7 +571,7 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) ...@@ -571,7 +571,7 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id)
for_each_child_of_node(parent, port) { for_each_child_of_node(parent, port) {
u32 port_id = 0; u32 port_id = 0;
if (of_node_cmp(port->name, "port") != 0) if (!of_node_name_eq(port, "port"))
continue; continue;
of_property_read_u32(port, "reg", &port_id); of_property_read_u32(port, "reg", &port_id);
if (id == port_id) if (id == port_id)
...@@ -646,7 +646,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, ...@@ -646,7 +646,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
port = of_get_next_child(parent, port); port = of_get_next_child(parent, port);
if (!port) if (!port)
return NULL; return NULL;
} while (of_node_cmp(port->name, "port")); } while (!of_node_name_eq(port, "port"));
} }
} }
EXPORT_SYMBOL(of_graph_get_next_endpoint); EXPORT_SYMBOL(of_graph_get_next_endpoint);
...@@ -715,7 +715,7 @@ struct device_node *of_graph_get_port_parent(struct device_node *node) ...@@ -715,7 +715,7 @@ struct device_node *of_graph_get_port_parent(struct device_node *node)
/* Walk 3 levels up only if there is 'ports' node. */ /* Walk 3 levels up only if there is 'ports' node. */
for (depth = 3; depth && node; depth--) { for (depth = 3; depth && node; depth--) {
node = of_get_next_parent(node); node = of_get_next_parent(node);
if (depth == 2 && of_node_cmp(node->name, "ports")) if (depth == 2 && !of_node_name_eq(node, "ports"))
break; break;
} }
return node; return node;
...@@ -893,7 +893,7 @@ of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode, ...@@ -893,7 +893,7 @@ of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
struct device_node *child; struct device_node *child;
for_each_available_child_of_node(node, child) for_each_available_child_of_node(node, child)
if (!of_node_cmp(child->name, childname)) if (of_node_name_eq(child, childname))
return of_fwnode_handle(child); return of_fwnode_handle(child);
return NULL; return NULL;
...@@ -955,7 +955,7 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode) ...@@ -955,7 +955,7 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode)
return NULL; return NULL;
/* Is this the "ports" node? If not, it's the port parent. */ /* Is this the "ports" node? If not, it's the port parent. */
if (of_node_cmp(np->name, "ports")) if (!of_node_name_eq(np, "ports"))
return of_fwnode_handle(np); return of_fwnode_handle(np);
return of_fwnode_handle(of_get_next_parent(np)); return of_fwnode_handle(of_get_next_parent(np));
......
...@@ -281,7 +281,7 @@ int of_resolve_phandles(struct device_node *overlay) ...@@ -281,7 +281,7 @@ int of_resolve_phandles(struct device_node *overlay)
adjust_overlay_phandles(overlay, phandle_delta); adjust_overlay_phandles(overlay, phandle_delta);
for_each_child_of_node(overlay, local_fixups) for_each_child_of_node(overlay, local_fixups)
if (!of_node_cmp(local_fixups->name, "__local_fixups__")) if (of_node_name_eq(local_fixups, "__local_fixups__"))
break; break;
err = adjust_local_phandle_references(local_fixups, overlay, phandle_delta); err = adjust_local_phandle_references(local_fixups, overlay, phandle_delta);
...@@ -291,7 +291,7 @@ int of_resolve_phandles(struct device_node *overlay) ...@@ -291,7 +291,7 @@ int of_resolve_phandles(struct device_node *overlay)
overlay_fixups = NULL; overlay_fixups = NULL;
for_each_child_of_node(overlay, child) { for_each_child_of_node(overlay, child) {
if (!of_node_cmp(child->name, "__fixups__")) if (of_node_name_eq(child, "__fixups__"))
overlay_fixups = child; overlay_fixups = child;
} }
......
...@@ -2393,7 +2393,7 @@ static __init void of_unittest_overlay_high_level(void) ...@@ -2393,7 +2393,7 @@ static __init void of_unittest_overlay_high_level(void)
*/ */
pprev = &overlay_base_root->child; pprev = &overlay_base_root->child;
for (np = overlay_base_root->child; np; np = np->sibling) { for (np = overlay_base_root->child; np; np = np->sibling) {
if (!of_node_cmp(np->name, "__local_fixups__")) { if (of_node_name_eq(np, "__local_fixups__")) {
*pprev = np->sibling; *pprev = np->sibling;
break; break;
} }
...@@ -2406,7 +2406,7 @@ static __init void of_unittest_overlay_high_level(void) ...@@ -2406,7 +2406,7 @@ static __init void of_unittest_overlay_high_level(void)
/* will have to graft properties from node into live tree */ /* will have to graft properties from node into live tree */
pprev = &overlay_base_root->child; pprev = &overlay_base_root->child;
for (np = overlay_base_root->child; np; np = np->sibling) { for (np = overlay_base_root->child; np; np = np->sibling) {
if (!of_node_cmp(np->name, "__symbols__")) { if (of_node_name_eq(np, "__symbols__")) {
overlay_base_symbols = np; overlay_base_symbols = np;
*pprev = np->sibling; *pprev = np->sibling;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment