[PATCH] powerpc: Fix Maple build

The changes to the device node structure broke Maple build. This fixes it.
Unfortunately I coudn't test as my Maple board appears to be dead.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by Benjamin Herrenschmidt and committed by Paul Mackerras 4c882b01 8385a6a3

+68 -41
-1
arch/powerpc/platforms/maple/pci.c
··· 316 316 char* disp_name; 317 317 int *bus_range; 318 318 int primary = 1; 319 - struct property *of_prop; 320 319 321 320 DBG("Adding PCI host bridge %s\n", dev->full_name); 322 321
+50 -35
arch/powerpc/platforms/maple/setup.c
··· 71 71 #define DBG(fmt...) 72 72 #endif 73 73 74 + static unsigned long maple_find_nvram_base(void) 75 + { 76 + struct device_node *rtcs; 77 + unsigned long result = 0; 78 + 79 + /* find NVRAM device */ 80 + rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111"); 81 + if (rtcs) { 82 + struct resource r; 83 + if (of_address_to_resource(rtcs, 0, &r)) { 84 + printk(KERN_EMERG "Maple: Unable to translate NVRAM" 85 + " address\n"); 86 + goto bail; 87 + } 88 + if (!(r.flags & IORESOURCE_IO)) { 89 + printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n"); 90 + goto bail; 91 + } 92 + result = r.start; 93 + } else 94 + printk(KERN_EMERG "Maple: Unable to find NVRAM\n"); 95 + bail: 96 + of_node_put(rtcs); 97 + return result; 98 + } 99 + 74 100 static void maple_restart(char *cmd) 75 101 { 76 102 unsigned int maple_nvram_base; 77 103 unsigned int maple_nvram_offset; 78 104 unsigned int maple_nvram_command; 79 - struct device_node *rtcs; 105 + struct device_node *sp; 80 106 81 - /* find NVRAM device */ 82 - rtcs = find_compatible_devices("nvram", "AMD8111"); 83 - if (rtcs && rtcs->addrs) { 84 - maple_nvram_base = rtcs->addrs[0].address; 85 - } else { 86 - printk(KERN_EMERG "Maple: Unable to find NVRAM\n"); 87 - printk(KERN_EMERG "Maple: Manual Restart Required\n"); 88 - return; 89 - } 107 + maple_nvram_base = maple_find_nvram_base(); 108 + if (maple_nvram_base == 0) 109 + goto fail; 90 110 91 111 /* find service processor device */ 92 - rtcs = find_devices("service-processor"); 93 - if (!rtcs) { 112 + sp = of_find_node_by_name(NULL, "service-processor"); 113 + if (!sp) { 94 114 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 95 - printk(KERN_EMERG "Maple: Manual Restart Required\n"); 96 - return; 115 + goto fail; 97 116 } 98 - maple_nvram_offset = *(unsigned int*) get_property(rtcs, 117 + maple_nvram_offset = *(unsigned int*) get_property(sp, 99 118 "restart-addr", NULL); 100 - maple_nvram_command = *(unsigned int*) get_property(rtcs, 119 + maple_nvram_command = *(unsigned int*) get_property(sp, 101 120 "restart-value", NULL); 121 + of_node_put(sp); 102 122 103 123 /* send command */ 104 124 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 105 125 for (;;) ; 126 + fail: 127 + printk(KERN_EMERG "Maple: Manual Restart Required\n"); 106 128 } 107 129 108 130 static void maple_power_off(void) ··· 132 110 unsigned int maple_nvram_base; 133 111 unsigned int maple_nvram_offset; 134 112 unsigned int maple_nvram_command; 135 - struct device_node *rtcs; 113 + struct device_node *sp; 136 114 137 - /* find NVRAM device */ 138 - rtcs = find_compatible_devices("nvram", "AMD8111"); 139 - if (rtcs && rtcs->addrs) { 140 - maple_nvram_base = rtcs->addrs[0].address; 141 - } else { 142 - printk(KERN_EMERG "Maple: Unable to find NVRAM\n"); 143 - printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 144 - return; 145 - } 115 + maple_nvram_base = maple_find_nvram_base(); 116 + if (maple_nvram_base == 0) 117 + goto fail; 146 118 147 119 /* find service processor device */ 148 - rtcs = find_devices("service-processor"); 149 - if (!rtcs) { 120 + sp = of_find_node_by_name(NULL, "service-processor"); 121 + if (!sp) { 150 122 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 151 - printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 152 - return; 123 + goto fail; 153 124 } 154 - maple_nvram_offset = *(unsigned int*) get_property(rtcs, 125 + maple_nvram_offset = *(unsigned int*) get_property(sp, 155 126 "power-off-addr", NULL); 156 - maple_nvram_command = *(unsigned int*) get_property(rtcs, 127 + maple_nvram_command = *(unsigned int*) get_property(sp, 157 128 "power-off-value", NULL); 129 + of_node_put(sp); 158 130 159 131 /* send command */ 160 132 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 161 133 for (;;) ; 134 + fail: 135 + printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 162 136 } 163 137 164 138 static void maple_halt(void) ··· 197 179 */ 198 180 static void __init maple_init_early(void) 199 181 { 200 - unsigned int default_speed; 201 - u64 physport; 202 - 203 182 DBG(" -> maple_init_early\n"); 204 183 205 184 /* Initialize hash table, from now on, we can take hash faults
+18 -5
arch/powerpc/platforms/maple/time.c
··· 168 168 struct rtc_time tm; 169 169 struct device_node *rtcs; 170 170 171 - rtcs = find_compatible_devices("rtc", "pnpPNP,b00"); 172 - if (rtcs && rtcs->addrs) { 173 - maple_rtc_addr = rtcs->addrs[0].address; 174 - printk(KERN_INFO "Maple: Found RTC at 0x%x\n", maple_rtc_addr); 175 - } else { 171 + rtcs = of_find_compatible_node(NULL, "rtc", "pnpPNP,b00"); 172 + if (rtcs) { 173 + struct resource r; 174 + if (of_address_to_resource(rtcs, 0, &r)) { 175 + printk(KERN_EMERG "Maple: Unable to translate RTC" 176 + " address\n"); 177 + goto bail; 178 + } 179 + if (!(r.flags & IORESOURCE_IO)) { 180 + printk(KERN_EMERG "Maple: RTC address isn't PIO!\n"); 181 + goto bail; 182 + } 183 + maple_rtc_addr = r.start; 184 + printk(KERN_INFO "Maple: Found RTC at IO 0x%x\n", 185 + maple_rtc_addr); 186 + } 187 + bail: 188 + if (maple_rtc_addr == 0) { 176 189 maple_rtc_addr = RTC_PORT(0); /* legacy address */ 177 190 printk(KERN_INFO "Maple: No device node for RTC, assuming " 178 191 "legacy address (0x%x)\n", maple_rtc_addr);