From 1f0a3175eca42e7c93465b63bf1e88c6fc88cd43 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sun, 26 May 2013 15:30:28 +0200 Subject: of: Add of_alias_get function This is used to retrieve the name of the alias for a given devicenode. Signed-off-by: Sascha Hauer --- drivers/of/base.c | 13 +++++++++++++ include/of.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 8383549821..8101fb4566 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -212,6 +212,19 @@ int of_alias_get_id(struct device_node *np, const char *stem) } EXPORT_SYMBOL_GPL(of_alias_get_id); +const char *of_alias_get(struct device_node *np) +{ + struct property *pp; + + list_for_each_entry(pp, &of_aliases->properties, list) { + if (!strcmp(np->full_name, pp->value)) + return pp->name; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(of_alias_get); + u64 of_translate_address(struct device_node *node, const __be32 *in_addr) { struct property *p; diff --git a/include/of.h b/include/of.h index 4dcf37e140..ac4370aa3c 100644 --- a/include/of.h +++ b/include/of.h @@ -176,6 +176,7 @@ struct cdev; int of_parse_partitions(struct cdev *cdev, struct device_node *node); int of_alias_get_id(struct device_node *np, const char *stem); +const char *of_alias_get(struct device_node *np); int of_device_is_stdout_path(struct device_d *dev); const char *of_get_model(void); void *of_flatten_dtb(struct device_node *node); @@ -192,6 +193,11 @@ static inline int of_alias_get_id(struct device_node *np, const char *stem) return -ENOENT; } +static inline const char *of_alias_get(struct device_node *np) +{ + return NULL; +} + static inline int of_device_is_stdout_path(struct device_d *dev) { return 0; -- cgit v1.2.3