summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/of/address.c4
-rw-r--r--drivers/of/base.c18
-rw-r--r--drivers/of/device.c9
3 files changed, 19 insertions, 12 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 7ddbf0a1ab86..ae48e121b6e7 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -110,8 +110,8 @@ static int of_bus_pci_match(struct device_node *np)
110 * "vci" is for the /chaos bridge on 1st-gen PCI powermacs 110 * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
111 * "ht" is hypertransport 111 * "ht" is hypertransport
112 */ 112 */
113 return !strcmp(np->type, "pci") || !strcmp(np->type, "pciex") || 113 return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
114 !strcmp(np->type, "vci") || !strcmp(np->type, "ht"); 114 of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
115} 115}
116 116
117static void of_bus_pci_count_cells(struct device_node *np, 117static void of_bus_pci_count_cells(struct device_node *np,
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 09692c9b32a7..57c837140a8b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -79,6 +79,13 @@ bool of_node_name_prefix(const struct device_node *np, const char *prefix)
79} 79}
80EXPORT_SYMBOL(of_node_name_prefix); 80EXPORT_SYMBOL(of_node_name_prefix);
81 81
82static bool __of_node_is_type(const struct device_node *np, const char *type)
83{
84 const char *match = __of_get_property(np, "device_type", NULL);
85
86 return np && match && type && !strcmp(match, type);
87}
88
82int of_n_addr_cells(struct device_node *np) 89int of_n_addr_cells(struct device_node *np)
83{ 90{
84 u32 cells; 91 u32 cells;
@@ -482,7 +489,7 @@ static int __of_device_is_compatible(const struct device_node *device,
482 489
483 /* Matching type is better than matching name */ 490 /* Matching type is better than matching name */
484 if (type && type[0]) { 491 if (type && type[0]) {
485 if (!device->type || of_node_cmp(type, device->type)) 492 if (!__of_node_is_type(device, type))
486 return 0; 493 return 0;
487 score += 2; 494 score += 2;
488 } 495 }
@@ -775,7 +782,7 @@ struct device_node *of_get_next_cpu_node(struct device_node *prev)
775 } 782 }
776 for (; next; next = next->sibling) { 783 for (; next; next = next->sibling) {
777 if (!(of_node_name_eq(next, "cpu") || 784 if (!(of_node_name_eq(next, "cpu") ||
778 (next->type && !of_node_cmp(next->type, "cpu")))) 785 __of_node_is_type(next, "cpu")))
779 continue; 786 continue;
780 if (of_node_get(next)) 787 if (of_node_get(next))
781 break; 788 break;
@@ -983,8 +990,7 @@ struct device_node *of_find_node_by_type(struct device_node *from,
983 990
984 raw_spin_lock_irqsave(&devtree_lock, flags); 991 raw_spin_lock_irqsave(&devtree_lock, flags);
985 for_each_of_allnodes_from(from, np) 992 for_each_of_allnodes_from(from, np)
986 if (np->type && (of_node_cmp(np->type, type) == 0) 993 if (__of_node_is_type(np, type) && of_node_get(np))
987 && of_node_get(np))
988 break; 994 break;
989 of_node_put(from); 995 of_node_put(from);
990 raw_spin_unlock_irqrestore(&devtree_lock, flags); 996 raw_spin_unlock_irqrestore(&devtree_lock, flags);
@@ -2108,9 +2114,9 @@ struct device_node *of_find_next_cache_node(const struct device_node *np)
2108 /* OF on pmac has nodes instead of properties named "l2-cache" 2114 /* OF on pmac has nodes instead of properties named "l2-cache"
2109 * beneath CPU nodes. 2115 * beneath CPU nodes.
2110 */ 2116 */
2111 if (IS_ENABLED(CONFIG_PPC_PMAC) && !strcmp(np->type, "cpu")) 2117 if (IS_ENABLED(CONFIG_PPC_PMAC) && of_node_is_type(np, "cpu"))
2112 for_each_child_of_node(np, child) 2118 for_each_child_of_node(np, child)
2113 if (!strcmp(child->type, "cache")) 2119 if (of_node_is_type(child, "cache"))
2114 return child; 2120 return child;
2115 2121
2116 return NULL; 2122 return NULL;
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 0f27fad9fe94..8299f8055da7 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -209,7 +209,7 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len
209 /* Name & Type */ 209 /* Name & Type */
210 /* %p eats all alphanum characters, so %c must be used here */ 210 /* %p eats all alphanum characters, so %c must be used here */
211 csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', 211 csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
212 dev->of_node->type); 212 of_node_get_device_type(dev->of_node));
213 tsize = csize; 213 tsize = csize;
214 len -= csize; 214 len -= csize;
215 if (str) 215 if (str)
@@ -279,7 +279,7 @@ EXPORT_SYMBOL_GPL(of_device_modalias);
279 */ 279 */
280void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) 280void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
281{ 281{
282 const char *compat; 282 const char *compat, *type;
283 struct alias_prop *app; 283 struct alias_prop *app;
284 struct property *p; 284 struct property *p;
285 int seen = 0; 285 int seen = 0;
@@ -289,8 +289,9 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
289 289
290 add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); 290 add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node);
291 add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); 291 add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node);
292 if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0) 292 type = of_node_get_device_type(dev->of_node);
293 add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type); 293 if (type)
294 add_uevent_var(env, "OF_TYPE=%s", type);
294 295
295 /* Since the compatible field can contain pretty much anything 296 /* Since the compatible field can contain pretty much anything
296 * it's not really legal to split it out with commas. We split it 297 * it's not really legal to split it out with commas. We split it