diff options
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 0a8aeb8523fe..adb8764861c0 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -714,16 +714,17 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, | |||
714 | const char *path) | 714 | const char *path) |
715 | { | 715 | { |
716 | struct device_node *child; | 716 | struct device_node *child; |
717 | int len = strchrnul(path, '/') - path; | 717 | int len; |
718 | int term; | 718 | const char *end; |
719 | 719 | ||
720 | end = strchr(path, ':'); | ||
721 | if (!end) | ||
722 | end = strchrnul(path, '/'); | ||
723 | |||
724 | len = end - path; | ||
720 | if (!len) | 725 | if (!len) |
721 | return NULL; | 726 | return NULL; |
722 | 727 | ||
723 | term = strchrnul(path, ':') - path; | ||
724 | if (term < len) | ||
725 | len = term; | ||
726 | |||
727 | __for_each_child_of_node(parent, child) { | 728 | __for_each_child_of_node(parent, child) { |
728 | const char *name = strrchr(child->full_name, '/'); | 729 | const char *name = strrchr(child->full_name, '/'); |
729 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) | 730 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) |
@@ -768,8 +769,12 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
768 | 769 | ||
769 | /* The path could begin with an alias */ | 770 | /* The path could begin with an alias */ |
770 | if (*path != '/') { | 771 | if (*path != '/') { |
771 | char *p = strchrnul(path, '/'); | 772 | int len; |
772 | int len = separator ? separator - path : p - path; | 773 | const char *p = separator; |
774 | |||
775 | if (!p) | ||
776 | p = strchrnul(path, '/'); | ||
777 | len = p - path; | ||
773 | 778 | ||
774 | /* of_aliases must not be NULL */ | 779 | /* of_aliases must not be NULL */ |
775 | if (!of_aliases) | 780 | if (!of_aliases) |
@@ -794,6 +799,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
794 | path++; /* Increment past '/' delimiter */ | 799 | path++; /* Increment past '/' delimiter */ |
795 | np = __of_find_node_by_path(np, path); | 800 | np = __of_find_node_by_path(np, path); |
796 | path = strchrnul(path, '/'); | 801 | path = strchrnul(path, '/'); |
802 | if (separator && separator < path) | ||
803 | break; | ||
797 | } | 804 | } |
798 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 805 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
799 | return np; | 806 | return np; |
@@ -1886,8 +1893,10 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) | |||
1886 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); | 1893 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); |
1887 | if (IS_ENABLED(CONFIG_PPC) && !name) | 1894 | if (IS_ENABLED(CONFIG_PPC) && !name) |
1888 | name = of_get_property(of_aliases, "stdout", NULL); | 1895 | name = of_get_property(of_aliases, "stdout", NULL); |
1889 | if (name) | 1896 | if (name) { |
1890 | of_stdout = of_find_node_opts_by_path(name, &of_stdout_options); | 1897 | of_stdout = of_find_node_opts_by_path(name, &of_stdout_options); |
1898 | add_preferred_console("stdout-path", 0, NULL); | ||
1899 | } | ||
1891 | } | 1900 | } |
1892 | 1901 | ||
1893 | if (!of_aliases) | 1902 | if (!of_aliases) |