Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "dt: add of_alias_scan and of_alias_get_id"

This reverts commit 750f463a749e28464151ad26938d11b07b1c43cb.

of_alias_* still needs work to be generalized for 'promtree' dt
platforms, and to no implicitly create entries for available ids.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

+2 -141
-130
drivers/of/base.c
··· 17 17 * as published by the Free Software Foundation; either version 18 18 * 2 of the License, or (at your option) any later version. 19 19 */ 20 - #include <linux/ctype.h> 21 20 #include <linux/module.h> 22 21 #include <linux/of.h> 23 22 #include <linux/spinlock.h> 24 23 #include <linux/slab.h> 25 24 #include <linux/proc_fs.h> 26 25 27 - /** 28 - * struct alias_prop - Alias property in 'aliases' node 29 - * @link: List node to link the structure in aliases_lookup list 30 - * @alias: Alias property name 31 - * @np: Pointer to device_node that the alias stands for 32 - * @id: Index value from end of alias name 33 - * @stem: Alias string without the index 34 - * 35 - * The structure represents one alias property of 'aliases' node as 36 - * an entry in aliases_lookup list. 37 - */ 38 - struct alias_prop { 39 - struct list_head link; 40 - const char *alias; 41 - struct device_node *np; 42 - int id; 43 - char stem[0]; 44 - }; 45 - 46 - static LIST_HEAD(aliases_lookup); 47 - 48 26 struct device_node *allnodes; 49 27 struct device_node *of_chosen; 50 - struct device_node *of_aliases; 51 - 52 - static DEFINE_MUTEX(of_aliases_mutex); 53 28 54 29 /* use when traversing tree through the allnext, child, sibling, 55 30 * or parent members of struct device_node. ··· 988 1013 } 989 1014 #endif /* defined(CONFIG_OF_DYNAMIC) */ 990 1015 991 - static void of_alias_add(struct alias_prop *ap, struct device_node *np, 992 - int id, const char *stem, int stem_len) 993 - { 994 - ap->id = id; 995 - ap->np = np; 996 - strncpy(ap->stem, stem, stem_len); 997 - ap->stem[stem_len] = 0; 998 - list_add_tail(&ap->link, &aliases_lookup); 999 - pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", 1000 - ap->alias, ap->stem, ap->id, np ? np->full_name : NULL); 1001 - } 1002 - 1003 - /** 1004 - * of_alias_scan() - Scan all properties of 'aliases' node 1005 - * 1006 - * The function scans all the properties of 'aliases' node and populate 1007 - * the global lookup table with the properties. It returns the 1008 - * number of alias_prop found, or error code in error case. 1009 - */ 1010 - __init void of_alias_scan(void) 1011 - { 1012 - struct property *pp; 1013 - 1014 - if (!of_aliases) 1015 - return; 1016 - 1017 - for_each_property(pp, of_aliases->properties) { 1018 - const char *start = pp->name; 1019 - const char *end = start + strlen(start); 1020 - struct device_node *np; 1021 - struct alias_prop *ap; 1022 - int id, len; 1023 - 1024 - /* Skip those we do not want to proceed */ 1025 - if (!strcmp(pp->name, "name") || 1026 - !strcmp(pp->name, "phandle") || 1027 - !strcmp(pp->name, "linux,phandle")) 1028 - continue; 1029 - 1030 - np = of_find_node_by_path(pp->value); 1031 - if (!np) 1032 - continue; 1033 - 1034 - /* walk alias backwards to extract the id and 'stem' string */ 1035 - while (isdigit(*(end-1)) && end > start) 1036 - end--; 1037 - len = end - start; 1038 - id = strlen(end) ? simple_strtoul(end, NULL, 10) : -1; 1039 - 1040 - /* Allocate an alias_prop with enough space for the stem */ 1041 - ap = early_init_dt_alloc_memory_arch(sizeof(*ap) + len + 1, 4); 1042 - if (!ap) 1043 - continue; 1044 - ap->alias = start; 1045 - of_alias_add(ap, np, id, start, len); 1046 - } 1047 - } 1048 - 1049 - /** 1050 - * of_alias_get_id() - Get alias id for the given device_node 1051 - * @np: Pointer to the given device_node 1052 - * @stem: Alias stem of the given device_node 1053 - * 1054 - * The function travels the lookup table to get alias id for the given 1055 - * device_node and alias stem. It returns the alias id if find it. 1056 - * If not, dynamically creates one in the lookup table and returns it, 1057 - * or returns error code if fail to create. 1058 - */ 1059 - int of_alias_get_id(struct device_node *np, const char *stem) 1060 - { 1061 - struct alias_prop *app; 1062 - int id = 0; 1063 - bool found = false; 1064 - 1065 - mutex_lock(&of_aliases_mutex); 1066 - list_for_each_entry(app, &aliases_lookup, link) { 1067 - if (strcmp(app->stem, stem) != 0) 1068 - continue; 1069 - 1070 - if (np == app->np) { 1071 - found = true; 1072 - id = app->id; 1073 - break; 1074 - } 1075 - 1076 - if (id <= app->id) 1077 - id = app->id + 1; 1078 - } 1079 - 1080 - /* If an id is not found, then allocate a new one */ 1081 - if (!found) { 1082 - app = kzalloc(sizeof(*app) + strlen(stem) + 1, 4); 1083 - if (!app) { 1084 - id = -ENODEV; 1085 - goto out; 1086 - } 1087 - of_alias_add(app, np, id, stem, strlen(stem)); 1088 - } 1089 - 1090 - out: 1091 - mutex_unlock(&of_aliases_mutex); 1092 - 1093 - return id; 1094 - } 1095 - EXPORT_SYMBOL_GPL(of_alias_get_id);
+1 -3
drivers/of/fdt.c
··· 707 707 __unflatten_device_tree(initial_boot_params, &allnodes, 708 708 early_init_dt_alloc_memory_arch); 709 709 710 - /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ 710 + /* Get pointer to OF "/chosen" node for use everywhere */ 711 711 of_chosen = of_find_node_by_path("/chosen"); 712 712 if (of_chosen == NULL) 713 713 of_chosen = of_find_node_by_path("/chosen@0"); 714 - of_aliases = of_find_node_by_path("/aliases"); 715 - of_alias_scan(); 716 714 } 717 715 718 716 #endif /* CONFIG_OF_EARLY_FLATTREE */
-8
include/linux/of.h
··· 68 68 /* Pointer for first entry in chain of all nodes. */ 69 69 extern struct device_node *allnodes; 70 70 extern struct device_node *of_chosen; 71 - extern struct device_node *of_aliases; 72 71 extern rwlock_t devtree_lock; 73 72 74 73 static inline bool of_have_populated_dt(void) ··· 209 210 extern const void *of_get_property(const struct device_node *node, 210 211 const char *name, 211 212 int *lenp); 212 - #define for_each_property(pp, properties) \ 213 - for (pp = properties; pp != NULL; pp = pp->next) 214 - 215 213 extern int of_n_addr_cells(struct device_node *np); 216 214 extern int of_n_size_cells(struct device_node *np); 217 215 extern const struct of_device_id *of_match_node( ··· 220 224 extern int of_parse_phandles_with_args(struct device_node *np, 221 225 const char *list_name, const char *cells_name, int index, 222 226 struct device_node **out_node, const void **out_args); 223 - 224 - extern void *early_init_dt_alloc_memory_arch(u64 size, u64 align); 225 - extern void of_alias_scan(void); 226 - extern int of_alias_get_id(struct device_node *np, const char *stem); 227 227 228 228 extern int of_machine_is_compatible(const char *compat); 229 229
+1
include/linux/of_fdt.h
··· 97 97 extern int early_init_dt_scan_memory(unsigned long node, const char *uname, 98 98 int depth, void *data); 99 99 extern void early_init_dt_add_memory_arch(u64 base, u64 size); 100 + extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); 100 101 extern u64 dt_mem_next_cell(int s, __be32 **cellp); 101 102 102 103 /*