diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-04 06:37:07 -1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-04 06:37:07 -1000 |
commit | 53d1e658df6e26d62500410719aaee2b82067c03 (patch) | |
tree | 80dc082c1f256c481f152a62c74605c8962251a6 | |
parent | 455ce9d8410d381f56a1676449a723ca1985b369 (diff) | |
parent | fe55c1844a1c106e9d9d3dd27cbfcf8caeb9e77e (diff) |
Merge branch 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6
* 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6:
Revert "dt: add of_alias_scan and of_alias_get_id"
dt: remove of_alias_get_id() reference
-rw-r--r-- | drivers/of/base.c | 130 | ||||
-rw-r--r-- | drivers/of/fdt.c | 4 | ||||
-rw-r--r-- | drivers/tty/serial/imx.c | 13 | ||||
-rw-r--r-- | include/linux/of.h | 8 | ||||
-rw-r--r-- | include/linux/of_fdt.h | 1 |
5 files changed, 6 insertions, 150 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index fb28b5af733..3ff22e32b60 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -17,39 +17,14 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ -#include <linux/ctype.h> #include <linux/module.h> #include <linux/of.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/proc_fs.h> -/** - * struct alias_prop - Alias property in 'aliases' node - * @link: List node to link the structure in aliases_lookup list - * @alias: Alias property name - * @np: Pointer to device_node that the alias stands for - * @id: Index value from end of alias name - * @stem: Alias string without the index - * - * The structure represents one alias property of 'aliases' node as - * an entry in aliases_lookup list. - */ -struct alias_prop { - struct list_head link; - const char *alias; - struct device_node *np; - int id; - char stem[0]; -}; - -static LIST_HEAD(aliases_lookup); - struct device_node *allnodes; struct device_node *of_chosen; -struct device_node *of_aliases; - -static DEFINE_MUTEX(of_aliases_mutex); /* use when traversing tree through the allnext, child, sibling, * or parent members of struct device_node. @@ -1013,108 +988,3 @@ out_unlock: } #endif /* defined(CONFIG_OF_DYNAMIC) */ -static void of_alias_add(struct alias_prop *ap, struct device_node *np, - int id, const char *stem, int stem_len) -{ - ap->id = id; - ap->np = np; - strncpy(ap->stem, stem, stem_len); - ap->stem[stem_len] = 0; - list_add_tail(&ap->link, &aliases_lookup); - pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", - ap->alias, ap->stem, ap->id, np ? np->full_name : NULL); -} - -/** - * of_alias_scan() - Scan all properties of 'aliases' node - * - * The function scans all the properties of 'aliases' node and populate - * the global lookup table with the properties. It returns the - * number of alias_prop found, or error code in error case. - */ -__init void of_alias_scan(void) -{ - struct property *pp; - - if (!of_aliases) - return; - - for_each_property(pp, of_aliases->properties) { - const char *start = pp->name; - const char *end = start + strlen(start); - struct device_node *np; - struct alias_prop *ap; - int id, len; - - /* Skip those we do not want to proceed */ - if (!strcmp(pp->name, "name") || - !strcmp(pp->name, "phandle") || - !strcmp(pp->name, "linux,phandle")) - continue; - - np = of_find_node_by_path(pp->value); - if (!np) - continue; - - /* walk alias backwards to extract the id and 'stem' string */ - while (isdigit(*(end-1)) && end > start) - end--; - len = end - start; - id = strlen(end) ? simple_strtoul(end, NULL, 10) : -1; - - /* Allocate an alias_prop with enough space for the stem */ - ap = early_init_dt_alloc_memory_arch(sizeof(*ap) + len + 1, 4); - if (!ap) - continue; - ap->alias = start; - of_alias_add(ap, np, id, start, len); - } -} - -/** - * of_alias_get_id() - Get alias id for the given device_node - * @np: Pointer to the given device_node - * @stem: Alias stem of the given device_node - * - * The function travels the lookup table to get alias id for the given - * device_node and alias stem. It returns the alias id if find it. - * If not, dynamically creates one in the lookup table and returns it, - * or returns error code if fail to create. - */ -int of_alias_get_id(struct device_node *np, const char *stem) -{ - struct alias_prop *app; - int id = 0; - bool found = false; - - mutex_lock(&of_aliases_mutex); - list_for_each_entry(app, &aliases_lookup, link) { - if (strcmp(app->stem, stem) != 0) - continue; - - if (np == app->np) { - found = true; - id = app->id; - break; - } - - if (id <= app->id) - id = app->id + 1; - } - - /* If an id is not found, then allocate a new one */ - if (!found) { - app = kzalloc(sizeof(*app) + strlen(stem) + 1, 4); - if (!app) { - id = -ENODEV; - goto out; - } - of_alias_add(app, np, id, stem, strlen(stem)); - } - - out: - mutex_unlock(&of_aliases_mutex); - - return id; -} -EXPORT_SYMBOL_GPL(of_alias_get_id); diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 13d6d3a96b3..65200af29c5 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -707,12 +707,10 @@ void __init unflatten_device_tree(void) __unflatten_device_tree(initial_boot_params, &allnodes, early_init_dt_alloc_memory_arch); - /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ + /* Get pointer to OF "/chosen" node for use everywhere */ of_chosen = of_find_node_by_path("/chosen"); if (of_chosen == NULL) of_chosen = of_find_node_by_path("/chosen@0"); - of_aliases = of_find_node_by_path("/aliases"); - of_alias_scan(); } #endif /* CONFIG_OF_EARLY_FLATTREE */ diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 827db765459..7e91b3d368c 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1286,22 +1286,17 @@ static int serial_imx_resume(struct platform_device *dev) static int serial_imx_probe_dt(struct imx_port *sport, struct platform_device *pdev) { + static int portnum = 0; struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(imx_uart_dt_ids, &pdev->dev); - int ret; if (!np) return -ENODEV; - ret = of_alias_get_id(np, "serial"); - if (ret < 0) { - pr_err("%s: failed to get alias id, errno %d\n", - __func__, ret); - return -ENODEV; - } else { - sport->port.line = ret; - } + sport->port.line = portnum++; + if (sport->port.line >= UART_NR) + return -EINVAL; if (of_get_property(np, "fsl,uart-has-rtscts", NULL)) sport->have_rtscts = 1; diff --git a/include/linux/of.h b/include/linux/of.h index bc3dc639954..0085bb01c04 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -68,7 +68,6 @@ struct device_node { /* Pointer for first entry in chain of all nodes. */ extern struct device_node *allnodes; extern struct device_node *of_chosen; -extern struct device_node *of_aliases; extern rwlock_t devtree_lock; static inline bool of_have_populated_dt(void) @@ -210,9 +209,6 @@ extern int of_device_is_available(const struct device_node *device); extern const void *of_get_property(const struct device_node *node, const char *name, int *lenp); -#define for_each_property(pp, properties) \ - for (pp = properties; pp != NULL; pp = pp->next) - extern int of_n_addr_cells(struct device_node *np); extern int of_n_size_cells(struct device_node *np); extern const struct of_device_id *of_match_node( @@ -225,10 +221,6 @@ extern int of_parse_phandles_with_args(struct device_node *np, const char *list_name, const char *cells_name, int index, struct device_node **out_node, const void **out_args); -extern void *early_init_dt_alloc_memory_arch(u64 size, u64 align); -extern void of_alias_scan(void); -extern int of_alias_get_id(struct device_node *np, const char *stem); - extern int of_machine_is_compatible(const char *compat); extern int prom_add_property(struct device_node* np, struct property* prop); diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index b74b74ffe0e..c84d900fbbb 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -97,6 +97,7 @@ extern void early_init_dt_check_for_initrd(unsigned long node); extern int early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data); extern void early_init_dt_add_memory_arch(u64 base, u64 size); +extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); extern u64 dt_mem_next_cell(int s, __be32 **cellp); /* |