Commit 5c19e952 authored by Sascha Hauer's avatar Sascha Hauer Committed by Greg Kroah-Hartman

OF: Add helper for matching against linux,stdout-path

devicetrees may have a linux,stdout-path property in the chosen
node describing the console device. This adds a helper function
to match a device against this property so a driver can call
add_preferred_console for a matching device.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Acked-by: default avatarRob Herring <rob.herring@calxeda.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a324e4de
...@@ -32,6 +32,7 @@ struct device_node *of_allnodes; ...@@ -32,6 +32,7 @@ struct device_node *of_allnodes;
EXPORT_SYMBOL(of_allnodes); EXPORT_SYMBOL(of_allnodes);
struct device_node *of_chosen; struct device_node *of_chosen;
struct device_node *of_aliases; struct device_node *of_aliases;
static struct device_node *of_stdout;
DEFINE_MUTEX(of_aliases_mutex); DEFINE_MUTEX(of_aliases_mutex);
...@@ -1595,6 +1596,15 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) ...@@ -1595,6 +1596,15 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
of_chosen = of_find_node_by_path("/chosen"); of_chosen = of_find_node_by_path("/chosen");
if (of_chosen == NULL) if (of_chosen == NULL)
of_chosen = of_find_node_by_path("/chosen@0"); of_chosen = of_find_node_by_path("/chosen@0");
if (of_chosen) {
const char *name;
name = of_get_property(of_chosen, "linux,stdout-path", NULL);
if (name)
of_stdout = of_find_node_by_path(name);
}
of_aliases = of_find_node_by_path("/aliases"); of_aliases = of_find_node_by_path("/aliases");
if (!of_aliases) if (!of_aliases)
return; return;
...@@ -1703,3 +1713,19 @@ const char *of_prop_next_string(struct property *prop, const char *cur) ...@@ -1703,3 +1713,19 @@ const char *of_prop_next_string(struct property *prop, const char *cur)
return curv; return curv;
} }
EXPORT_SYMBOL_GPL(of_prop_next_string); EXPORT_SYMBOL_GPL(of_prop_next_string);
/**
* of_device_is_stdout_path - check if a device node matches the
* linux,stdout-path property
*
* Check if this device node matches the linux,stdout-path property
* in the chosen node. return true if yes, false otherwise.
*/
int of_device_is_stdout_path(struct device_node *dn)
{
if (!of_stdout)
return false;
return of_stdout == dn;
}
EXPORT_SYMBOL_GPL(of_device_is_stdout_path);
...@@ -343,6 +343,8 @@ const char *of_prop_next_string(struct property *prop, const char *cur); ...@@ -343,6 +343,8 @@ const char *of_prop_next_string(struct property *prop, const char *cur);
s; \ s; \
s = of_prop_next_string(prop, s)) s = of_prop_next_string(prop, s))
int of_device_is_stdout_path(struct device_node *dn);
#else /* CONFIG_OF */ #else /* CONFIG_OF */
static inline const char* of_node_full_name(struct device_node *np) static inline const char* of_node_full_name(struct device_node *np)
...@@ -505,6 +507,11 @@ static inline int of_machine_is_compatible(const char *compat) ...@@ -505,6 +507,11 @@ static inline int of_machine_is_compatible(const char *compat)
return 0; return 0;
} }
static inline int of_device_is_stdout_path(struct device_node *dn)
{
return 0;
}
#define of_match_ptr(_ptr) NULL #define of_match_ptr(_ptr) NULL
#define of_match_node(_matches, _node) NULL #define of_match_node(_matches, _node) NULL
#define of_property_for_each_u32(np, propname, prop, p, u) \ #define of_property_for_each_u32(np, propname, prop, p, u) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment