diff options
author | Rob Herring <robh@kernel.org> | 2018-08-27 09:37:06 -0400 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-12-05 15:45:13 -0500 |
commit | b3e46d1a0590500335f0b95e669ad6d84b12b03a (patch) | |
tree | 03ae42679eab36e311870dffdafe1aa7870875a2 | |
parent | ae517053f003bc3739640acd8d77617b14bf45d2 (diff) |
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: Rob Herring <robh@kernel.org>
-rw-r--r-- | drivers/of/address.c | 2 | ||||
-rw-r--r-- | drivers/of/base.c | 7 | ||||
-rw-r--r-- | drivers/of/property.c | 10 | ||||
-rw-r--r-- | drivers/of/resolver.c | 4 | ||||
-rw-r--r-- | drivers/of/unittest.c | 4 |
5 files changed, 13 insertions, 14 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c index ae48e121b6e7..2270373b30ab 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c | |||
@@ -371,7 +371,7 @@ EXPORT_SYMBOL(of_pci_range_to_resource); | |||
371 | 371 | ||
372 | static int of_bus_isa_match(struct device_node *np) | 372 | static int of_bus_isa_match(struct device_node *np) |
373 | { | 373 | { |
374 | return !strcmp(np->name, "isa"); | 374 | return of_node_name_eq(np, "isa"); |
375 | } | 375 | } |
376 | 376 | ||
377 | static void of_bus_isa_count_cells(struct device_node *child, | 377 | static void of_bus_isa_count_cells(struct device_node *child, |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 57c837140a8b..998d032fcef9 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -496,7 +496,7 @@ static int __of_device_is_compatible(const struct device_node *device, | |||
496 | 496 | ||
497 | /* Matching name is a bit better than not */ | 497 | /* Matching name is a bit better than not */ |
498 | if (name && name[0]) { | 498 | if (name && name[0]) { |
499 | if (!device->name || of_node_cmp(name, device->name)) | 499 | if (!of_node_name_eq(device, name)) |
500 | return 0; | 500 | return 0; |
501 | score++; | 501 | score++; |
502 | } | 502 | } |
@@ -835,7 +835,7 @@ struct device_node *of_get_child_by_name(const struct device_node *node, | |||
835 | struct device_node *child; | 835 | struct device_node *child; |
836 | 836 | ||
837 | for_each_child_of_node(node, child) | 837 | for_each_child_of_node(node, child) |
838 | if (child->name && (of_node_cmp(child->name, name) == 0)) | 838 | if (of_node_name_eq(child, name)) |
839 | break; | 839 | break; |
840 | return child; | 840 | return child; |
841 | } | 841 | } |
@@ -961,8 +961,7 @@ struct device_node *of_find_node_by_name(struct device_node *from, | |||
961 | 961 | ||
962 | raw_spin_lock_irqsave(&devtree_lock, flags); | 962 | raw_spin_lock_irqsave(&devtree_lock, flags); |
963 | for_each_of_allnodes_from(from, np) | 963 | for_each_of_allnodes_from(from, np) |
964 | if (np->name && (of_node_cmp(np->name, name) == 0) | 964 | if (of_node_name_eq(np, name) && of_node_get(np)) |
965 | && of_node_get(np)) | ||
966 | break; | 965 | break; |
967 | of_node_put(from); | 966 | of_node_put(from); |
968 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 967 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
diff --git a/drivers/of/property.c b/drivers/of/property.c index f46828e3b082..08430031bd28 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c | |||
@@ -571,7 +571,7 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) | |||
571 | for_each_child_of_node(parent, port) { | 571 | for_each_child_of_node(parent, port) { |
572 | u32 port_id = 0; | 572 | u32 port_id = 0; |
573 | 573 | ||
574 | if (of_node_cmp(port->name, "port") != 0) | 574 | if (!of_node_name_eq(port, "port")) |
575 | continue; | 575 | continue; |
576 | of_property_read_u32(port, "reg", &port_id); | 576 | of_property_read_u32(port, "reg", &port_id); |
577 | if (id == port_id) | 577 | if (id == port_id) |
@@ -646,7 +646,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | |||
646 | port = of_get_next_child(parent, port); | 646 | port = of_get_next_child(parent, port); |
647 | if (!port) | 647 | if (!port) |
648 | return NULL; | 648 | return NULL; |
649 | } while (of_node_cmp(port->name, "port")); | 649 | } while (!of_node_name_eq(port, "port")); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | EXPORT_SYMBOL(of_graph_get_next_endpoint); | 652 | EXPORT_SYMBOL(of_graph_get_next_endpoint); |
@@ -715,7 +715,7 @@ struct device_node *of_graph_get_port_parent(struct device_node *node) | |||
715 | /* Walk 3 levels up only if there is 'ports' node. */ | 715 | /* Walk 3 levels up only if there is 'ports' node. */ |
716 | for (depth = 3; depth && node; depth--) { | 716 | for (depth = 3; depth && node; depth--) { |
717 | node = of_get_next_parent(node); | 717 | node = of_get_next_parent(node); |
718 | if (depth == 2 && of_node_cmp(node->name, "ports")) | 718 | if (depth == 2 && !of_node_name_eq(node, "ports")) |
719 | break; | 719 | break; |
720 | } | 720 | } |
721 | return node; | 721 | return node; |
@@ -893,7 +893,7 @@ of_fwnode_get_named_child_node(const struct fwnode_handle *fwnode, | |||
893 | struct device_node *child; | 893 | struct device_node *child; |
894 | 894 | ||
895 | for_each_available_child_of_node(node, child) | 895 | for_each_available_child_of_node(node, child) |
896 | if (!of_node_cmp(child->name, childname)) | 896 | if (of_node_name_eq(child, childname)) |
897 | return of_fwnode_handle(child); | 897 | return of_fwnode_handle(child); |
898 | 898 | ||
899 | return NULL; | 899 | return NULL; |
@@ -955,7 +955,7 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode) | |||
955 | return NULL; | 955 | return NULL; |
956 | 956 | ||
957 | /* Is this the "ports" node? If not, it's the port parent. */ | 957 | /* Is this the "ports" node? If not, it's the port parent. */ |
958 | if (of_node_cmp(np->name, "ports")) | 958 | if (!of_node_name_eq(np, "ports")) |
959 | return of_fwnode_handle(np); | 959 | return of_fwnode_handle(np); |
960 | 960 | ||
961 | return of_fwnode_handle(of_get_next_parent(np)); | 961 | return of_fwnode_handle(of_get_next_parent(np)); |
diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 7edfac6f1914..c1b67dd7cd6e 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c | |||
@@ -281,7 +281,7 @@ int of_resolve_phandles(struct device_node *overlay) | |||
281 | adjust_overlay_phandles(overlay, phandle_delta); | 281 | adjust_overlay_phandles(overlay, phandle_delta); |
282 | 282 | ||
283 | for_each_child_of_node(overlay, local_fixups) | 283 | for_each_child_of_node(overlay, local_fixups) |
284 | if (!of_node_cmp(local_fixups->name, "__local_fixups__")) | 284 | if (of_node_name_eq(local_fixups, "__local_fixups__")) |
285 | break; | 285 | break; |
286 | 286 | ||
287 | err = adjust_local_phandle_references(local_fixups, overlay, phandle_delta); | 287 | err = adjust_local_phandle_references(local_fixups, overlay, phandle_delta); |
@@ -291,7 +291,7 @@ int of_resolve_phandles(struct device_node *overlay) | |||
291 | overlay_fixups = NULL; | 291 | overlay_fixups = NULL; |
292 | 292 | ||
293 | for_each_child_of_node(overlay, child) { | 293 | for_each_child_of_node(overlay, child) { |
294 | if (!of_node_cmp(child->name, "__fixups__")) | 294 | if (of_node_name_eq(child, "__fixups__")) |
295 | overlay_fixups = child; | 295 | overlay_fixups = child; |
296 | } | 296 | } |
297 | 297 | ||
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 9a10a48eb6a1..84427384654d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -2393,7 +2393,7 @@ static __init void of_unittest_overlay_high_level(void) | |||
2393 | */ | 2393 | */ |
2394 | pprev = &overlay_base_root->child; | 2394 | pprev = &overlay_base_root->child; |
2395 | for (np = overlay_base_root->child; np; np = np->sibling) { | 2395 | for (np = overlay_base_root->child; np; np = np->sibling) { |
2396 | if (!of_node_cmp(np->name, "__local_fixups__")) { | 2396 | if (of_node_name_eq(np, "__local_fixups__")) { |
2397 | *pprev = np->sibling; | 2397 | *pprev = np->sibling; |
2398 | break; | 2398 | break; |
2399 | } | 2399 | } |
@@ -2406,7 +2406,7 @@ static __init void of_unittest_overlay_high_level(void) | |||
2406 | /* will have to graft properties from node into live tree */ | 2406 | /* will have to graft properties from node into live tree */ |
2407 | pprev = &overlay_base_root->child; | 2407 | pprev = &overlay_base_root->child; |
2408 | for (np = overlay_base_root->child; np; np = np->sibling) { | 2408 | for (np = overlay_base_root->child; np; np = np->sibling) { |
2409 | if (!of_node_cmp(np->name, "__symbols__")) { | 2409 | if (of_node_name_eq(np, "__symbols__")) { |
2410 | overlay_base_symbols = np; | 2410 | overlay_base_symbols = np; |
2411 | *pprev = np->sibling; | 2411 | *pprev = np->sibling; |
2412 | break; | 2412 | break; |