aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/boot/dts/versatile-ab.dts4
-rw-r--r--arch/powerpc/platforms/powermac/feature.c20
-rw-r--r--arch/powerpc/platforms/powermac/pci.c2
-rw-r--r--arch/powerpc/platforms/powermac/smp.c2
-rw-r--r--arch/powerpc/platforms/powermac/udbg_adb.c2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c3
-rw-r--r--drivers/cpufreq/pmac64-cpufreq.c3
-rw-r--r--drivers/edac/cell_edac.c3
-rw-r--r--drivers/of/base.c28
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c4
-rw-r--r--drivers/tty/ehv_bytechan.c43
-rw-r--r--drivers/tty/hvc/hvc_opal.c15
-rw-r--r--drivers/tty/hvc/hvc_vio.c29
-rw-r--r--drivers/tty/serial/pmac_zilog.c9
-rw-r--r--drivers/tty/serial/serial_core.c3
-rw-r--r--include/linux/of.h7
-rw-r--r--sound/ppc/pmac.c6
17 files changed, 64 insertions, 119 deletions
diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts
index e01e5a081def..88e94c5506a1 100644
--- a/arch/arm/boot/dts/versatile-ab.dts
+++ b/arch/arm/boot/dts/versatile-ab.dts
@@ -15,6 +15,10 @@
15 i2c0 = &i2c0; 15 i2c0 = &i2c0;
16 }; 16 };
17 17
18 chosen {
19 stdout-path = &uart0;
20 };
21
18 memory { 22 memory {
19 reg = <0x0 0x08000000>; 23 reg = <0x0 0x08000000>;
20 }; 24 };
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 63d82bbc05e9..39e1d163c427 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -2805,25 +2805,20 @@ set_initial_features(void)
2805 /* Enable GMAC for now for PCI probing. It will be disabled 2805 /* Enable GMAC for now for PCI probing. It will be disabled
2806 * later on after PCI probe 2806 * later on after PCI probe
2807 */ 2807 */
2808 np = of_find_node_by_name(NULL, "ethernet"); 2808 for_each_node_by_name(np, "ethernet")
2809 while(np) {
2810 if (of_device_is_compatible(np, "K2-GMAC")) 2809 if (of_device_is_compatible(np, "K2-GMAC"))
2811 g5_gmac_enable(np, 0, 1); 2810 g5_gmac_enable(np, 0, 1);
2812 np = of_find_node_by_name(np, "ethernet");
2813 }
2814 2811
2815 /* Enable FW before PCI probe. Will be disabled later on 2812 /* Enable FW before PCI probe. Will be disabled later on
2816 * Note: We should have a batter way to check that we are 2813 * Note: We should have a batter way to check that we are
2817 * dealing with uninorth internal cell and not a PCI cell 2814 * dealing with uninorth internal cell and not a PCI cell
2818 * on the external PCI. The code below works though. 2815 * on the external PCI. The code below works though.
2819 */ 2816 */
2820 np = of_find_node_by_name(NULL, "firewire"); 2817 for_each_node_by_name(np, "firewire") {
2821 while(np) {
2822 if (of_device_is_compatible(np, "pci106b,5811")) { 2818 if (of_device_is_compatible(np, "pci106b,5811")) {
2823 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED; 2819 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2824 g5_fw_enable(np, 0, 1); 2820 g5_fw_enable(np, 0, 1);
2825 } 2821 }
2826 np = of_find_node_by_name(np, "firewire");
2827 } 2822 }
2828 } 2823 }
2829#else /* CONFIG_POWER4 */ 2824#else /* CONFIG_POWER4 */
@@ -2834,13 +2829,11 @@ set_initial_features(void)
2834 /* Enable GMAC for now for PCI probing. It will be disabled 2829 /* Enable GMAC for now for PCI probing. It will be disabled
2835 * later on after PCI probe 2830 * later on after PCI probe
2836 */ 2831 */
2837 np = of_find_node_by_name(NULL, "ethernet"); 2832 for_each_node_by_name(np, "ethernet") {
2838 while(np) {
2839 if (np->parent 2833 if (np->parent
2840 && of_device_is_compatible(np->parent, "uni-north") 2834 && of_device_is_compatible(np->parent, "uni-north")
2841 && of_device_is_compatible(np, "gmac")) 2835 && of_device_is_compatible(np, "gmac"))
2842 core99_gmac_enable(np, 0, 1); 2836 core99_gmac_enable(np, 0, 1);
2843 np = of_find_node_by_name(np, "ethernet");
2844 } 2837 }
2845 2838
2846 /* Enable FW before PCI probe. Will be disabled later on 2839 /* Enable FW before PCI probe. Will be disabled later on
@@ -2848,8 +2841,7 @@ set_initial_features(void)
2848 * dealing with uninorth internal cell and not a PCI cell 2841 * dealing with uninorth internal cell and not a PCI cell
2849 * on the external PCI. The code below works though. 2842 * on the external PCI. The code below works though.
2850 */ 2843 */
2851 np = of_find_node_by_name(NULL, "firewire"); 2844 for_each_node_by_name(np, "firewire") {
2852 while(np) {
2853 if (np->parent 2845 if (np->parent
2854 && of_device_is_compatible(np->parent, "uni-north") 2846 && of_device_is_compatible(np->parent, "uni-north")
2855 && (of_device_is_compatible(np, "pci106b,18") || 2847 && (of_device_is_compatible(np, "pci106b,18") ||
@@ -2858,18 +2850,16 @@ set_initial_features(void)
2858 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED; 2850 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2859 core99_firewire_enable(np, 0, 1); 2851 core99_firewire_enable(np, 0, 1);
2860 } 2852 }
2861 np = of_find_node_by_name(np, "firewire");
2862 } 2853 }
2863 2854
2864 /* Enable ATA-100 before PCI probe. */ 2855 /* Enable ATA-100 before PCI probe. */
2865 np = of_find_node_by_name(NULL, "ata-6"); 2856 np = of_find_node_by_name(NULL, "ata-6");
2866 while(np) { 2857 for_each_node_by_name(np, "ata-6") {
2867 if (np->parent 2858 if (np->parent
2868 && of_device_is_compatible(np->parent, "uni-north") 2859 && of_device_is_compatible(np->parent, "uni-north")
2869 && of_device_is_compatible(np, "kauai-ata")) { 2860 && of_device_is_compatible(np, "kauai-ata")) {
2870 core99_ata100_enable(np, 1); 2861 core99_ata100_enable(np, 1);
2871 } 2862 }
2872 np = of_find_node_by_name(np, "ata-6");
2873 } 2863 }
2874 2864
2875 /* Switch airport off */ 2865 /* Switch airport off */
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index cf7009b8c7b6..7e868ccf3b0d 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -698,7 +698,7 @@ static void __init fixup_nec_usb2(void)
698{ 698{
699 struct device_node *nec; 699 struct device_node *nec;
700 700
701 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) { 701 for_each_node_by_name(nec, "usb") {
702 struct pci_controller *hose; 702 struct pci_controller *hose;
703 u32 data; 703 u32 data;
704 const u32 *prop; 704 const u32 *prop;
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 5cbd4d67d5c4..af094ae03dbb 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -577,7 +577,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
577 int ok; 577 int ok;
578 578
579 /* Look for the clock chip */ 579 /* Look for the clock chip */
580 while ((cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL) { 580 for_each_node_by_name(cc, "i2c-hwclock") {
581 p = of_get_parent(cc); 581 p = of_get_parent(cc);
582 ok = p && of_device_is_compatible(p, "uni-n-i2c"); 582 ok = p && of_device_is_compatible(p, "uni-n-i2c");
583 of_node_put(p); 583 of_node_put(p);
diff --git a/arch/powerpc/platforms/powermac/udbg_adb.c b/arch/powerpc/platforms/powermac/udbg_adb.c
index 44e0b55a2a02..366bd221edec 100644
--- a/arch/powerpc/platforms/powermac/udbg_adb.c
+++ b/arch/powerpc/platforms/powermac/udbg_adb.c
@@ -191,7 +191,7 @@ int __init udbg_adb_init(int force_btext)
191 * of type "adb". If not, we return a failure, but we keep the 191 * of type "adb". If not, we return a failure, but we keep the
192 * bext output set for now 192 * bext output set for now
193 */ 193 */
194 for (np = NULL; (np = of_find_node_by_name(np, "keyboard")) != NULL;) { 194 for_each_node_by_name(np, "keyboard") {
195 struct device_node *parent = of_get_parent(np); 195 struct device_node *parent = of_get_parent(np);
196 int found = (parent && strcmp(parent->type, "adb") == 0); 196 int found = (parent && strcmp(parent->type, "adb") == 0);
197 of_node_put(parent); 197 of_node_put(parent);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index f2f40e64658f..cd6b4cde0de3 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -232,8 +232,7 @@ static void __init pseries_discover_pic(void)
232 struct device_node *np; 232 struct device_node *np;
233 const char *typep; 233 const char *typep;
234 234
235 for (np = NULL; (np = of_find_node_by_name(np, 235 for_each_node_by_name(np, "interrupt-controller") {
236 "interrupt-controller"));) {
237 typep = of_get_property(np, "compatible", NULL); 236 typep = of_get_property(np, "compatible", NULL);
238 if (strstr(typep, "open-pic")) { 237 if (strstr(typep, "open-pic")) {
239 pSeries_mpic_node = of_node_get(np); 238 pSeries_mpic_node = of_node_get(np);
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 8bc422977b5b..4ff86878727f 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -499,8 +499,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode)
499 } 499 }
500 500
501 /* Lookup the i2c hwclock */ 501 /* Lookup the i2c hwclock */
502 for (hwclock = NULL; 502 for_each_node_by_name(hwclock, "i2c-hwclock") {
503 (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){
504 const char *loc = of_get_property(hwclock, 503 const char *loc = of_get_property(hwclock,
505 "hwctrl-location", NULL); 504 "hwctrl-location", NULL);
506 if (loc == NULL) 505 if (loc == NULL)
diff --git a/drivers/edac/cell_edac.c b/drivers/edac/cell_edac.c
index 374b57fc596d..a12c8552f6a6 100644
--- a/drivers/edac/cell_edac.c
+++ b/drivers/edac/cell_edac.c
@@ -134,8 +134,7 @@ static void cell_edac_init_csrows(struct mem_ctl_info *mci)
134 int j; 134 int j;
135 u32 nr_pages; 135 u32 nr_pages;
136 136
137 for (np = NULL; 137 for_each_node_by_name(np, "memory") {
138 (np = of_find_node_by_name(np, "memory")) != NULL;) {
139 struct resource r; 138 struct resource r;
140 139
141 /* We "know" that the Cell firmware only creates one entry 140 /* We "know" that the Cell firmware only creates one entry
diff --git a/drivers/of/base.c b/drivers/of/base.c
index b9864806e9b8..e4f95ba0a3eb 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -17,6 +17,7 @@
17 * as published by the Free Software Foundation; either version 17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version. 18 * 2 of the License, or (at your option) any later version.
19 */ 19 */
20#include <linux/console.h>
20#include <linux/ctype.h> 21#include <linux/ctype.h>
21#include <linux/cpu.h> 22#include <linux/cpu.h>
22#include <linux/module.h> 23#include <linux/module.h>
@@ -35,7 +36,7 @@ struct device_node *of_allnodes;
35EXPORT_SYMBOL(of_allnodes); 36EXPORT_SYMBOL(of_allnodes);
36struct device_node *of_chosen; 37struct device_node *of_chosen;
37struct device_node *of_aliases; 38struct device_node *of_aliases;
38static struct device_node *of_stdout; 39struct device_node *of_stdout;
39 40
40static struct kset *of_kset; 41static struct kset *of_kset;
41 42
@@ -2062,9 +2063,12 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
2062 of_chosen = of_find_node_by_path("/chosen@0"); 2063 of_chosen = of_find_node_by_path("/chosen@0");
2063 2064
2064 if (of_chosen) { 2065 if (of_chosen) {
2066 /* linux,stdout-path and /aliases/stdout are for legacy compatibility */
2065 const char *name = of_get_property(of_chosen, "stdout-path", NULL); 2067 const char *name = of_get_property(of_chosen, "stdout-path", NULL);
2066 if (!name) 2068 if (!name)
2067 name = of_get_property(of_chosen, "linux,stdout-path", NULL); 2069 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
2070 if (IS_ENABLED(CONFIG_PPC) && !name)
2071 name = of_get_property(of_aliases, "stdout", NULL);
2068 if (name) 2072 if (name)
2069 of_stdout = of_find_node_by_path(name); 2073 of_stdout = of_find_node_by_path(name);
2070 } 2074 }
@@ -2180,20 +2184,22 @@ const char *of_prop_next_string(struct property *prop, const char *cur)
2180EXPORT_SYMBOL_GPL(of_prop_next_string); 2184EXPORT_SYMBOL_GPL(of_prop_next_string);
2181 2185
2182/** 2186/**
2183 * of_device_is_stdout_path - check if a device node matches the 2187 * of_console_check() - Test and setup console for DT setup
2184 * linux,stdout-path property 2188 * @dn - Pointer to device node
2185 * 2189 * @name - Name to use for preferred console without index. ex. "ttyS"
2186 * Check if this device node matches the linux,stdout-path property 2190 * @index - Index to use for preferred console.
2187 * in the chosen node. return true if yes, false otherwise. 2191 *
2192 * Check if the given device node matches the stdout-path property in the
2193 * /chosen node. If it does then register it as the preferred console and return
2194 * TRUE. Otherwise return FALSE.
2188 */ 2195 */
2189int of_device_is_stdout_path(struct device_node *dn) 2196bool of_console_check(struct device_node *dn, char *name, int index)
2190{ 2197{
2191 if (!of_stdout) 2198 if (!dn || dn != of_stdout || console_set_on_cmdline)
2192 return false; 2199 return false;
2193 2200 return add_preferred_console(name, index, NULL);
2194 return of_stdout == dn;
2195} 2201}
2196EXPORT_SYMBOL_GPL(of_device_is_stdout_path); 2202EXPORT_SYMBOL_GPL(of_console_check);
2197 2203
2198/** 2204/**
2199 * of_find_next_cache_node - Find a node's subsidiary cache 2205 * of_find_next_cache_node - Find a node's subsidiary cache
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 93aa29f6d39c..f2945fa73d4f 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -375,11 +375,11 @@ static void __exit cleanup_slots(void)
375 375
376static int __init rpaphp_init(void) 376static int __init rpaphp_init(void)
377{ 377{
378 struct device_node *dn = NULL; 378 struct device_node *dn;
379 379
380 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 380 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
381 381
382 while ((dn = of_find_node_by_name(dn, "pci"))) 382 for_each_node_by_name(dn, "pci")
383 rpaphp_add_slot(dn); 383 rpaphp_add_slot(dn);
384 384
385 return 0; 385 return 0;
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index 0419b69e270f..4f485e88f60c 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -108,55 +108,23 @@ static void disable_tx_interrupt(struct ehv_bc_data *bc)
108 * 108 *
109 * The byte channel to be used for the console is specified via a "stdout" 109 * The byte channel to be used for the console is specified via a "stdout"
110 * property in the /chosen node. 110 * property in the /chosen node.
111 *
112 * For compatible with legacy device trees, we also look for a "stdout" alias.
113 */ 111 */
114static int find_console_handle(void) 112static int find_console_handle(void)
115{ 113{
116 struct device_node *np, *np2; 114 struct device_node *np = of_stdout;
117 const char *sprop = NULL; 115 const char *sprop = NULL;
118 const uint32_t *iprop; 116 const uint32_t *iprop;
119 117
120 np = of_find_node_by_path("/chosen");
121 if (np)
122 sprop = of_get_property(np, "stdout-path", NULL);
123
124 if (!np || !sprop) {
125 of_node_put(np);
126 np = of_find_node_by_name(NULL, "aliases");
127 if (np)
128 sprop = of_get_property(np, "stdout", NULL);
129 }
130
131 if (!sprop) {
132 of_node_put(np);
133 return 0;
134 }
135
136 /* We don't care what the aliased node is actually called. We only 118 /* We don't care what the aliased node is actually called. We only
137 * care if it's compatible with "epapr,hv-byte-channel", because that 119 * care if it's compatible with "epapr,hv-byte-channel", because that
138 * indicates that it's a byte channel node. We use a temporary 120 * indicates that it's a byte channel node.
139 * variable, 'np2', because we can't release 'np' until we're done with
140 * 'sprop'.
141 */ 121 */
142 np2 = of_find_node_by_path(sprop); 122 if (!np || !of_device_is_compatible(np, "epapr,hv-byte-channel"))
143 of_node_put(np);
144 np = np2;
145 if (!np) {
146 pr_warning("ehv-bc: stdout node '%s' does not exist\n", sprop);
147 return 0;
148 }
149
150 /* Is it a byte channel? */
151 if (!of_device_is_compatible(np, "epapr,hv-byte-channel")) {
152 of_node_put(np);
153 return 0; 123 return 0;
154 }
155 124
156 stdout_irq = irq_of_parse_and_map(np, 0); 125 stdout_irq = irq_of_parse_and_map(np, 0);
157 if (stdout_irq == NO_IRQ) { 126 if (stdout_irq == NO_IRQ) {
158 pr_err("ehv-bc: no 'interrupts' property in %s node\n", sprop); 127 pr_err("ehv-bc: no 'interrupts' property in %s node\n", np->full_name);
159 of_node_put(np);
160 return 0; 128 return 0;
161 } 129 }
162 130
@@ -167,12 +135,9 @@ static int find_console_handle(void)
167 if (!iprop) { 135 if (!iprop) {
168 pr_err("ehv-bc: no 'hv-handle' property in %s node\n", 136 pr_err("ehv-bc: no 'hv-handle' property in %s node\n",
169 np->name); 137 np->name);
170 of_node_put(np);
171 return 0; 138 return 0;
172 } 139 }
173 stdout_bc = be32_to_cpu(*iprop); 140 stdout_bc = be32_to_cpu(*iprop);
174
175 of_node_put(np);
176 return 1; 141 return 1;
177} 142}
178 143
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index a585079b4b38..a2cc5f834c63 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -342,22 +342,13 @@ static void udbg_init_opal_common(void)
342 342
343void __init hvc_opal_init_early(void) 343void __init hvc_opal_init_early(void)
344{ 344{
345 struct device_node *stdout_node = NULL; 345 struct device_node *stdout_node = of_node_get(of_stdout);
346 const __be32 *termno; 346 const __be32 *termno;
347 const char *name = NULL;
348 const struct hv_ops *ops; 347 const struct hv_ops *ops;
349 u32 index; 348 u32 index;
350 349
351 /* find the boot console from /chosen/stdout */ 350 /* If the console wasn't in /chosen, try /ibm,opal */
352 if (of_chosen) 351 if (!stdout_node) {
353 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
354 if (name) {
355 stdout_node = of_find_node_by_path(name);
356 if (!stdout_node) {
357 pr_err("hvc_opal: Failed to locate default console!\n");
358 return;
359 }
360 } else {
361 struct device_node *opal, *np; 352 struct device_node *opal, *np;
362 353
363 /* Current OPAL takeover doesn't provide the stdout 354 /* Current OPAL takeover doesn't provide the stdout
diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c
index b594abfbf21e..5618b5fc7500 100644
--- a/drivers/tty/hvc/hvc_vio.c
+++ b/drivers/tty/hvc/hvc_vio.c
@@ -404,42 +404,35 @@ module_exit(hvc_vio_exit);
404 404
405void __init hvc_vio_init_early(void) 405void __init hvc_vio_init_early(void)
406{ 406{
407 struct device_node *stdout_node;
408 const __be32 *termno; 407 const __be32 *termno;
409 const char *name; 408 const char *name;
410 const struct hv_ops *ops; 409 const struct hv_ops *ops;
411 410
412 /* find the boot console from /chosen/stdout */ 411 /* find the boot console from /chosen/stdout */
413 if (!of_chosen) 412 if (!of_stdout)
414 return; 413 return;
415 name = of_get_property(of_chosen, "linux,stdout-path", NULL); 414 name = of_get_property(of_stdout, "name", NULL);
416 if (name == NULL)
417 return;
418 stdout_node = of_find_node_by_path(name);
419 if (!stdout_node)
420 return;
421 name = of_get_property(stdout_node, "name", NULL);
422 if (!name) { 415 if (!name) {
423 printk(KERN_WARNING "stdout node missing 'name' property!\n"); 416 printk(KERN_WARNING "stdout node missing 'name' property!\n");
424 goto out; 417 return;
425 } 418 }
426 419
427 /* Check if it's a virtual terminal */ 420 /* Check if it's a virtual terminal */
428 if (strncmp(name, "vty", 3) != 0) 421 if (strncmp(name, "vty", 3) != 0)
429 goto out; 422 return;
430 termno = of_get_property(stdout_node, "reg", NULL); 423 termno = of_get_property(of_stdout, "reg", NULL);
431 if (termno == NULL) 424 if (termno == NULL)
432 goto out; 425 return;
433 hvterm_priv0.termno = of_read_number(termno, 1); 426 hvterm_priv0.termno = of_read_number(termno, 1);
434 spin_lock_init(&hvterm_priv0.buf_lock); 427 spin_lock_init(&hvterm_priv0.buf_lock);
435 hvterm_privs[0] = &hvterm_priv0; 428 hvterm_privs[0] = &hvterm_priv0;
436 429
437 /* Check the protocol */ 430 /* Check the protocol */
438 if (of_device_is_compatible(stdout_node, "hvterm1")) { 431 if (of_device_is_compatible(of_stdout, "hvterm1")) {
439 hvterm_priv0.proto = HV_PROTOCOL_RAW; 432 hvterm_priv0.proto = HV_PROTOCOL_RAW;
440 ops = &hvterm_raw_ops; 433 ops = &hvterm_raw_ops;
441 } 434 }
442 else if (of_device_is_compatible(stdout_node, "hvterm-protocol")) { 435 else if (of_device_is_compatible(of_stdout, "hvterm-protocol")) {
443 hvterm_priv0.proto = HV_PROTOCOL_HVSI; 436 hvterm_priv0.proto = HV_PROTOCOL_HVSI;
444 ops = &hvterm_hvsi_ops; 437 ops = &hvterm_hvsi_ops;
445 hvsilib_init(&hvterm_priv0.hvsi, hvc_get_chars, hvc_put_chars, 438 hvsilib_init(&hvterm_priv0.hvsi, hvc_get_chars, hvc_put_chars,
@@ -447,7 +440,7 @@ void __init hvc_vio_init_early(void)
447 /* HVSI, perform the handshake now */ 440 /* HVSI, perform the handshake now */
448 hvsilib_establish(&hvterm_priv0.hvsi); 441 hvsilib_establish(&hvterm_priv0.hvsi);
449 } else 442 } else
450 goto out; 443 return;
451 udbg_putc = udbg_hvc_putc; 444 udbg_putc = udbg_hvc_putc;
452 udbg_getc = udbg_hvc_getc; 445 udbg_getc = udbg_hvc_getc;
453 udbg_getc_poll = udbg_hvc_getc_poll; 446 udbg_getc_poll = udbg_hvc_getc_poll;
@@ -456,14 +449,12 @@ void __init hvc_vio_init_early(void)
456 * backend for HVSI, only do udbg 449 * backend for HVSI, only do udbg
457 */ 450 */
458 if (hvterm_priv0.proto == HV_PROTOCOL_HVSI) 451 if (hvterm_priv0.proto == HV_PROTOCOL_HVSI)
459 goto out; 452 return;
460#endif 453#endif
461 /* Check whether the user has requested a different console. */ 454 /* Check whether the user has requested a different console. */
462 if (!strstr(cmd_line, "console=")) 455 if (!strstr(cmd_line, "console="))
463 add_preferred_console("hvc", 0, NULL); 456 add_preferred_console("hvc", 0, NULL);
464 hvc_instantiate(0, 0, ops); 457 hvc_instantiate(0, 0, ops);
465out:
466 of_node_put(stdout_node);
467} 458}
468 459
469/* call this from early_init() for a working debug console on 460/* call this from early_init() for a working debug console on
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 8193635103ee..01e180bc6b5d 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1650,8 +1650,7 @@ static int __init pmz_probe(void)
1650 /* 1650 /*
1651 * Find all escc chips in the system 1651 * Find all escc chips in the system
1652 */ 1652 */
1653 node_p = of_find_node_by_name(NULL, "escc"); 1653 for_each_node_by_name(node_p, "escc") {
1654 while (node_p) {
1655 /* 1654 /*
1656 * First get channel A/B node pointers 1655 * First get channel A/B node pointers
1657 * 1656 *
@@ -1669,7 +1668,7 @@ static int __init pmz_probe(void)
1669 of_node_put(node_b); 1668 of_node_put(node_b);
1670 printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n", 1669 printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n",
1671 (!node_a) ? 'a' : 'b', node_p->full_name); 1670 (!node_a) ? 'a' : 'b', node_p->full_name);
1672 goto next; 1671 continue;
1673 } 1672 }
1674 1673
1675 /* 1674 /*
@@ -1696,11 +1695,9 @@ static int __init pmz_probe(void)
1696 of_node_put(node_b); 1695 of_node_put(node_b);
1697 memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port)); 1696 memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port));
1698 memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port)); 1697 memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port));
1699 goto next; 1698 continue;
1700 } 1699 }
1701 count += 2; 1700 count += 2;
1702next:
1703 node_p = of_find_node_by_name(node_p, "escc");
1704 } 1701 }
1705 pmz_ports_count = count; 1702 pmz_ports_count = count;
1706 1703
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index fbf6c5ad222f..3ce68f962c92 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/console.h> 28#include <linux/console.h>
29#include <linux/of.h>
29#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
30#include <linux/seq_file.h> 31#include <linux/seq_file.h>
31#include <linux/device.h> 32#include <linux/device.h>
@@ -2615,6 +2616,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
2615 spin_lock_init(&uport->lock); 2616 spin_lock_init(&uport->lock);
2616 lockdep_set_class(&uport->lock, &port_lock_key); 2617 lockdep_set_class(&uport->lock, &port_lock_key);
2617 } 2618 }
2619 if (uport->cons && uport->dev)
2620 of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
2618 2621
2619 uart_configure_port(drv, state, uport); 2622 uart_configure_port(drv, state, uport);
2620 2623
diff --git a/include/linux/of.h b/include/linux/of.h
index 196b34c1ef4e..f0d256273c83 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -113,6 +113,7 @@ static inline void of_node_put(struct device_node *node) { }
113extern struct device_node *of_allnodes; 113extern struct device_node *of_allnodes;
114extern struct device_node *of_chosen; 114extern struct device_node *of_chosen;
115extern struct device_node *of_aliases; 115extern struct device_node *of_aliases;
116extern struct device_node *of_stdout;
116extern raw_spinlock_t devtree_lock; 117extern raw_spinlock_t devtree_lock;
117 118
118static inline bool of_have_populated_dt(void) 119static inline bool of_have_populated_dt(void)
@@ -352,7 +353,7 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
352 */ 353 */
353const char *of_prop_next_string(struct property *prop, const char *cur); 354const char *of_prop_next_string(struct property *prop, const char *cur);
354 355
355int of_device_is_stdout_path(struct device_node *dn); 356bool of_console_check(struct device_node *dn, char *name, int index);
356 357
357#else /* CONFIG_OF */ 358#else /* CONFIG_OF */
358 359
@@ -564,9 +565,9 @@ static inline int of_machine_is_compatible(const char *compat)
564 return 0; 565 return 0;
565} 566}
566 567
567static inline int of_device_is_stdout_path(struct device_node *dn) 568static inline bool of_console_check(const struct device_node *dn, const char *name, int index)
568{ 569{
569 return 0; 570 return false;
570} 571}
571 572
572static inline const __be32 *of_prop_next_u32(struct property *prop, 573static inline const __be32 *of_prop_next_u32(struct property *prop,
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 7a43c0c38316..8a431bcb056c 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -992,9 +992,9 @@ static int snd_pmac_detect(struct snd_pmac *chip)
992 return -ENODEV; 992 return -ENODEV;
993 993
994 if (!sound) { 994 if (!sound) {
995 sound = of_find_node_by_name(NULL, "sound"); 995 for_each_node_by_name(sound, "sound")
996 while (sound && sound->parent != chip->node) 996 if (sound->parent == chip->node)
997 sound = of_find_node_by_name(sound, "sound"); 997 break;
998 } 998 }
999 if (! sound) { 999 if (! sound) {
1000 of_node_put(chip->node); 1000 of_node_put(chip->node);