Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'dt' into next

+267 -292
+1 -1
arch/arm/mach-mxs/mach-mxs.c
··· 211 211 macaddr[4] = (val >> 8) & 0xff; 212 212 macaddr[5] = (val >> 0) & 0xff; 213 213 214 - prom_update_property(np, newmac); 214 + of_update_property(np, newmac); 215 215 } 216 216 } 217 217
-47
arch/powerpc/include/asm/pSeries_reconfig.h
··· 1 - #ifndef _PPC64_PSERIES_RECONFIG_H 2 - #define _PPC64_PSERIES_RECONFIG_H 3 - #ifdef __KERNEL__ 4 - 5 - #include <linux/notifier.h> 6 - 7 - /* 8 - * Use this API if your code needs to know about OF device nodes being 9 - * added or removed on pSeries systems. 10 - */ 11 - 12 - #define PSERIES_RECONFIG_ADD 0x0001 13 - #define PSERIES_RECONFIG_REMOVE 0x0002 14 - #define PSERIES_DRCONF_MEM_ADD 0x0003 15 - #define PSERIES_DRCONF_MEM_REMOVE 0x0004 16 - #define PSERIES_UPDATE_PROPERTY 0x0005 17 - 18 - /** 19 - * pSeries_reconfig_notify - Notifier value structure for OFDT property updates 20 - * 21 - * @node: Device tree node which owns the property being updated 22 - * @property: Updated property 23 - */ 24 - struct pSeries_reconfig_prop_update { 25 - struct device_node *node; 26 - struct property *property; 27 - }; 28 - 29 - #ifdef CONFIG_PPC_PSERIES 30 - extern int pSeries_reconfig_notifier_register(struct notifier_block *); 31 - extern void pSeries_reconfig_notifier_unregister(struct notifier_block *); 32 - extern int pSeries_reconfig_notify(unsigned long action, void *p); 33 - /* Not the best place to put this, will be fixed when we move some 34 - * of the rtas suspend-me stuff to pseries */ 35 - extern void pSeries_coalesce_init(void); 36 - #else /* !CONFIG_PPC_PSERIES */ 37 - static inline int pSeries_reconfig_notifier_register(struct notifier_block *nb) 38 - { 39 - return 0; 40 - } 41 - static inline void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) { } 42 - static inline void pSeries_coalesce_init(void) { } 43 - #endif /* CONFIG_PPC_PSERIES */ 44 - 45 - 46 - #endif /* __KERNEL__ */ 47 - #endif /* _PPC64_PSERIES_RECONFIG_H */
+16
arch/powerpc/include/asm/prom.h
··· 58 58 59 59 extern void of_instantiate_rtc(void); 60 60 61 + /* The of_drconf_cell struct defines the layout of the LMB array 62 + * specified in the device tree property 63 + * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory 64 + */ 65 + struct of_drconf_cell { 66 + u64 base_addr; 67 + u32 drc_index; 68 + u32 reserved; 69 + u32 aa_index; 70 + u32 flags; 71 + }; 72 + 73 + #define DRCONF_MEM_ASSIGNED 0x00000008 74 + #define DRCONF_MEM_AI_INVALID 0x00000040 75 + #define DRCONF_MEM_RESERVED 0x00000080 76 + 61 77 /* These includes are put at the bottom because they may contain things 62 78 * that are overridden by this file. Ideally they shouldn't be included 63 79 * by this file, but there are a bunch of .c files that currently depend
+5
arch/powerpc/include/asm/rtas.h
··· 353 353 return 1; 354 354 return 0; 355 355 } 356 + 357 + /* Not the best place to put pSeries_coalesce_init, will be fixed when we 358 + * move some of the rtas suspend-me stuff to pseries */ 359 + extern void pSeries_coalesce_init(void); 356 360 #else 357 361 static inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} 362 + static inline void pSeries_coalesce_init(void) { } 358 363 #endif 359 364 360 365 extern int call_rtas(const char *, int, int, unsigned long *, ...);
+7 -7
arch/powerpc/kernel/machine_kexec.c
··· 218 218 * be sure what's in them, so remove them. */ 219 219 prop = of_find_property(node, "linux,crashkernel-base", NULL); 220 220 if (prop) 221 - prom_remove_property(node, prop); 221 + of_remove_property(node, prop); 222 222 223 223 prop = of_find_property(node, "linux,crashkernel-size", NULL); 224 224 if (prop) 225 - prom_remove_property(node, prop); 225 + of_remove_property(node, prop); 226 226 227 227 if (crashk_res.start != 0) { 228 - prom_add_property(node, &crashk_base_prop); 228 + of_add_property(node, &crashk_base_prop); 229 229 crashk_size = resource_size(&crashk_res); 230 - prom_add_property(node, &crashk_size_prop); 230 + of_add_property(node, &crashk_size_prop); 231 231 } 232 232 233 233 /* 234 234 * memory_limit is required by the kexec-tools to limit the 235 235 * crash regions to the actual memory used. 236 236 */ 237 - prom_update_property(node, &memory_limit_prop); 237 + of_update_property(node, &memory_limit_prop); 238 238 } 239 239 240 240 static int __init kexec_setup(void) ··· 249 249 /* remove any stale properties so ours can be found */ 250 250 prop = of_find_property(node, kernel_end_prop.name, NULL); 251 251 if (prop) 252 - prom_remove_property(node, prop); 252 + of_remove_property(node, prop); 253 253 254 254 /* information needed by userspace when using default_machine_kexec */ 255 255 kernel_end = __pa(_end); 256 - prom_add_property(node, &kernel_end_prop); 256 + of_add_property(node, &kernel_end_prop); 257 257 258 258 export_crashk_values(node); 259 259
+4 -4
arch/powerpc/kernel/machine_kexec_64.c
··· 389 389 /* remove any stale propertys so ours can be found */ 390 390 prop = of_find_property(node, htab_base_prop.name, NULL); 391 391 if (prop) 392 - prom_remove_property(node, prop); 392 + of_remove_property(node, prop); 393 393 prop = of_find_property(node, htab_size_prop.name, NULL); 394 394 if (prop) 395 - prom_remove_property(node, prop); 395 + of_remove_property(node, prop); 396 396 397 397 htab_base = __pa(htab_address); 398 - prom_add_property(node, &htab_base_prop); 399 - prom_add_property(node, &htab_size_prop); 398 + of_add_property(node, &htab_base_prop); 399 + of_add_property(node, &htab_size_prop); 400 400 401 401 of_node_put(node); 402 402 return 0;
+1 -1
arch/powerpc/kernel/pci_32.c
··· 208 208 of_prop->name = "pci-OF-bus-map"; 209 209 of_prop->length = 256; 210 210 of_prop->value = &of_prop[1]; 211 - prom_add_property(dn, of_prop); 211 + of_add_property(dn, of_prop); 212 212 of_node_put(dn); 213 213 } 214 214 }
+3 -3
arch/powerpc/kernel/prom.c
··· 32 32 #include <linux/debugfs.h> 33 33 #include <linux/irq.h> 34 34 #include <linux/memblock.h> 35 + #include <linux/of.h> 35 36 36 37 #include <asm/prom.h> 37 38 #include <asm/rtas.h> ··· 50 49 #include <asm/btext.h> 51 50 #include <asm/sections.h> 52 51 #include <asm/machdep.h> 53 - #include <asm/pSeries_reconfig.h> 54 52 #include <asm/pci-bridge.h> 55 53 #include <asm/kexec.h> 56 54 #include <asm/opal.h> ··· 803 803 int err; 804 804 805 805 switch (action) { 806 - case PSERIES_RECONFIG_ADD: 806 + case OF_RECONFIG_ATTACH_NODE: 807 807 err = of_finish_dynamic_node(node); 808 808 if (err < 0) 809 809 printk(KERN_ERR "finish_node returned %d\n", err); ··· 822 822 823 823 static int __init prom_reconfig_setup(void) 824 824 { 825 - return pSeries_reconfig_notifier_register(&prom_reconfig_nb); 825 + return of_reconfig_notifier_register(&prom_reconfig_nb); 826 826 } 827 827 __initcall(prom_reconfig_setup); 828 828 #endif
-1
arch/powerpc/kernel/rtas.c
··· 42 42 #include <asm/time.h> 43 43 #include <asm/mmu.h> 44 44 #include <asm/topology.h> 45 - #include <asm/pSeries_reconfig.h> 46 45 47 46 struct rtas_t rtas = { 48 47 .lock = __ARCH_SPIN_LOCK_UNLOCKED
-12
arch/powerpc/mm/numa.c
··· 399 399 return result; 400 400 } 401 401 402 - struct of_drconf_cell { 403 - u64 base_addr; 404 - u32 drc_index; 405 - u32 reserved; 406 - u32 aa_index; 407 - u32 flags; 408 - }; 409 - 410 - #define DRCONF_MEM_ASSIGNED 0x00000008 411 - #define DRCONF_MEM_AI_INVALID 0x00000040 412 - #define DRCONF_MEM_RESERVED 0x00000080 413 - 414 402 /* 415 403 * Read the next memblock list entry from the ibm,dynamic-memory property 416 404 * and return the information in the provided of_drconf_cell structure.
+3 -3
arch/powerpc/platforms/85xx/p1022_ds.c
··· 539 539 }; 540 540 541 541 /* 542 - * prom_update_property() is called before 542 + * of_update_property() is called before 543 543 * kmalloc() is available, so the 'new' object 544 544 * should be allocated in the global area. 545 545 * The easiest way is to do that is to ··· 548 548 */ 549 549 pr_info("p1022ds: disabling %s node", 550 550 np2->full_name); 551 - prom_update_property(np2, &nor_status); 551 + of_update_property(np2, &nor_status); 552 552 of_node_put(np2); 553 553 } 554 554 ··· 564 564 565 565 pr_info("p1022ds: disabling %s node", 566 566 np2->full_name); 567 - prom_update_property(np2, &nand_status); 567 + of_update_property(np2, &nand_status); 568 568 of_node_put(np2); 569 569 } 570 570
+3 -3
arch/powerpc/platforms/ps3/os-area.c
··· 280 280 281 281 if (tmp) { 282 282 pr_debug("%s:%d found %s\n", __func__, __LINE__, prop->name); 283 - prom_remove_property(node, tmp); 283 + of_remove_property(node, tmp); 284 284 } 285 285 286 - result = prom_add_property(node, prop); 286 + result = of_add_property(node, prop); 287 287 288 288 if (result) 289 - pr_debug("%s:%d prom_set_property failed\n", __func__, 289 + pr_debug("%s:%d of_set_property failed\n", __func__, 290 290 __LINE__); 291 291 } 292 292
+6 -28
arch/powerpc/platforms/pseries/dlpar.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/kref.h> 15 15 #include <linux/notifier.h> 16 - #include <linux/proc_fs.h> 17 16 #include <linux/spinlock.h> 18 17 #include <linux/cpu.h> 19 18 #include <linux/slab.h> 19 + #include <linux/of.h> 20 20 #include "offline_states.h" 21 21 22 22 #include <asm/prom.h> 23 23 #include <asm/machdep.h> 24 24 #include <asm/uaccess.h> 25 25 #include <asm/rtas.h> 26 - #include <asm/pSeries_reconfig.h> 27 26 28 27 struct cc_workarea { 29 28 u32 drc_index; ··· 254 255 255 256 int dlpar_attach_node(struct device_node *dn) 256 257 { 257 - #ifdef CONFIG_PROC_DEVICETREE 258 - struct proc_dir_entry *ent; 259 - #endif 260 258 int rc; 261 259 262 260 of_node_set_flag(dn, OF_DYNAMIC); ··· 262 266 if (!dn->parent) 263 267 return -ENOMEM; 264 268 265 - rc = pSeries_reconfig_notify(PSERIES_RECONFIG_ADD, dn); 269 + rc = of_attach_node(dn); 266 270 if (rc) { 267 271 printk(KERN_ERR "Failed to add device node %s\n", 268 272 dn->full_name); 269 273 return rc; 270 274 } 271 - 272 - of_attach_node(dn); 273 - 274 - #ifdef CONFIG_PROC_DEVICETREE 275 - ent = proc_mkdir(strrchr(dn->full_name, '/') + 1, dn->parent->pde); 276 - if (ent) 277 - proc_device_tree_add_node(dn, ent); 278 - #endif 279 275 280 276 of_node_put(dn->parent); 281 277 return 0; ··· 275 287 276 288 int dlpar_detach_node(struct device_node *dn) 277 289 { 278 - #ifdef CONFIG_PROC_DEVICETREE 279 - struct device_node *parent = dn->parent; 280 - struct property *prop = dn->properties; 290 + int rc; 281 291 282 - while (prop) { 283 - remove_proc_entry(prop->name, dn->pde); 284 - prop = prop->next; 285 - } 292 + rc = of_detach_node(dn); 293 + if (rc) 294 + return rc; 286 295 287 - if (dn->pde) 288 - remove_proc_entry(dn->pde->name, parent->pde); 289 - #endif 290 - 291 - pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE, dn); 292 - of_detach_node(dn); 293 296 of_node_put(dn); /* Must decrement the refcount */ 294 - 295 297 return 0; 296 298 } 297 299
+4 -4
arch/powerpc/platforms/pseries/hotplug-cpu.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/sched.h> /* for idle_task_exit */ 25 25 #include <linux/cpu.h> 26 + #include <linux/of.h> 26 27 #include <asm/prom.h> 27 28 #include <asm/rtas.h> 28 29 #include <asm/firmware.h> 29 30 #include <asm/machdep.h> 30 31 #include <asm/vdso_datapage.h> 31 - #include <asm/pSeries_reconfig.h> 32 32 #include <asm/xics.h> 33 33 #include "plpar_wrappers.h" 34 34 #include "offline_states.h" ··· 333 333 int err = 0; 334 334 335 335 switch (action) { 336 - case PSERIES_RECONFIG_ADD: 336 + case OF_RECONFIG_ATTACH_NODE: 337 337 err = pseries_add_processor(node); 338 338 break; 339 - case PSERIES_RECONFIG_REMOVE: 339 + case OF_RECONFIG_DETACH_NODE: 340 340 pseries_remove_processor(node); 341 341 break; 342 342 } ··· 399 399 400 400 /* Processors can be added/removed only on LPAR */ 401 401 if (firmware_has_feature(FW_FEATURE_LPAR)) { 402 - pSeries_reconfig_notifier_register(&pseries_smp_nb); 402 + of_reconfig_notifier_register(&pseries_smp_nb); 403 403 cpu_maps_update_begin(); 404 404 if (cede_offline_enabled && parse_cede_parameters() == 0) { 405 405 default_offline_state = CPU_STATE_INACTIVE;
+43 -17
arch/powerpc/platforms/pseries/hotplug-memory.c
··· 16 16 17 17 #include <asm/firmware.h> 18 18 #include <asm/machdep.h> 19 - #include <asm/pSeries_reconfig.h> 20 19 #include <asm/sparsemem.h> 21 20 22 21 static unsigned long get_memblock_size(void) ··· 186 187 return (ret < 0) ? -EINVAL : 0; 187 188 } 188 189 189 - static int pseries_drconf_memory(unsigned long *base, unsigned int action) 190 + static int pseries_update_drconf_memory(struct of_prop_reconfig *pr) 190 191 { 192 + struct of_drconf_cell *new_drmem, *old_drmem; 191 193 unsigned long memblock_size; 192 - int rc; 194 + u32 entries; 195 + u32 *p; 196 + int i, rc = -EINVAL; 193 197 194 198 memblock_size = get_memblock_size(); 195 199 if (!memblock_size) 196 200 return -EINVAL; 197 201 198 - if (action == PSERIES_DRCONF_MEM_ADD) { 199 - rc = memblock_add(*base, memblock_size); 200 - rc = (rc < 0) ? -EINVAL : 0; 201 - } else if (action == PSERIES_DRCONF_MEM_REMOVE) { 202 - rc = pseries_remove_memblock(*base, memblock_size); 203 - } else { 204 - rc = -EINVAL; 202 + p = (u32 *)of_get_property(pr->dn, "ibm,dynamic-memory", NULL); 203 + if (!p) 204 + return -EINVAL; 205 + 206 + /* The first int of the property is the number of lmb's described 207 + * by the property. This is followed by an array of of_drconf_cell 208 + * entries. Get the niumber of entries and skip to the array of 209 + * of_drconf_cell's. 210 + */ 211 + entries = *p++; 212 + old_drmem = (struct of_drconf_cell *)p; 213 + 214 + p = (u32 *)pr->prop->value; 215 + p++; 216 + new_drmem = (struct of_drconf_cell *)p; 217 + 218 + for (i = 0; i < entries; i++) { 219 + if ((old_drmem[i].flags & DRCONF_MEM_ASSIGNED) && 220 + (!(new_drmem[i].flags & DRCONF_MEM_ASSIGNED))) { 221 + rc = pseries_remove_memblock(old_drmem[i].base_addr, 222 + memblock_size); 223 + break; 224 + } else if ((!(old_drmem[i].flags & DRCONF_MEM_ASSIGNED)) && 225 + (new_drmem[i].flags & DRCONF_MEM_ASSIGNED)) { 226 + rc = memblock_add(old_drmem[i].base_addr, 227 + memblock_size); 228 + rc = (rc < 0) ? -EINVAL : 0; 229 + break; 230 + } 205 231 } 206 232 207 233 return rc; 208 234 } 209 235 210 236 static int pseries_memory_notifier(struct notifier_block *nb, 211 - unsigned long action, void *node) 237 + unsigned long action, void *node) 212 238 { 239 + struct of_prop_reconfig *pr; 213 240 int err = 0; 214 241 215 242 switch (action) { 216 - case PSERIES_RECONFIG_ADD: 243 + case OF_RECONFIG_ATTACH_NODE: 217 244 err = pseries_add_memory(node); 218 245 break; 219 - case PSERIES_RECONFIG_REMOVE: 246 + case OF_RECONFIG_DETACH_NODE: 220 247 err = pseries_remove_memory(node); 221 248 break; 222 - case PSERIES_DRCONF_MEM_ADD: 223 - case PSERIES_DRCONF_MEM_REMOVE: 224 - err = pseries_drconf_memory(node, action); 249 + case OF_RECONFIG_UPDATE_PROPERTY: 250 + pr = (struct of_prop_reconfig *)node; 251 + if (!strcmp(pr->prop->name, "ibm,dynamic-memory")) 252 + err = pseries_update_drconf_memory(pr); 225 253 break; 226 254 } 227 255 return notifier_from_errno(err); ··· 261 235 static int __init pseries_memory_hotplug_init(void) 262 236 { 263 237 if (firmware_has_feature(FW_FEATURE_LPAR)) 264 - pSeries_reconfig_notifier_register(&pseries_mem_nb); 238 + of_reconfig_notifier_register(&pseries_mem_nb); 265 239 266 240 return 0; 267 241 }
+5 -5
arch/powerpc/platforms/pseries/iommu.c
··· 36 36 #include <linux/dma-mapping.h> 37 37 #include <linux/crash_dump.h> 38 38 #include <linux/memory.h> 39 + #include <linux/of.h> 39 40 #include <asm/io.h> 40 41 #include <asm/prom.h> 41 42 #include <asm/rtas.h> 42 43 #include <asm/iommu.h> 43 44 #include <asm/pci-bridge.h> 44 45 #include <asm/machdep.h> 45 - #include <asm/pSeries_reconfig.h> 46 46 #include <asm/firmware.h> 47 47 #include <asm/tce.h> 48 48 #include <asm/ppc-pci.h> ··· 760 760 __remove_ddw(np, ddw_avail, liobn); 761 761 762 762 delprop: 763 - ret = prom_remove_property(np, win64); 763 + ret = of_remove_property(np, win64); 764 764 if (ret) 765 765 pr_warning("%s: failed to remove direct window property: %d\n", 766 766 np->full_name, ret); ··· 1070 1070 goto out_free_window; 1071 1071 } 1072 1072 1073 - ret = prom_add_property(pdn, win64); 1073 + ret = of_add_property(pdn, win64); 1074 1074 if (ret) { 1075 1075 dev_err(&dev->dev, "unable to add dma window property for %s: %d", 1076 1076 pdn->full_name, ret); ··· 1294 1294 struct direct_window *window; 1295 1295 1296 1296 switch (action) { 1297 - case PSERIES_RECONFIG_REMOVE: 1297 + case OF_RECONFIG_DETACH_NODE: 1298 1298 if (pci && pci->iommu_table) 1299 1299 iommu_free_table(pci->iommu_table, np->full_name); 1300 1300 ··· 1357 1357 } 1358 1358 1359 1359 1360 - pSeries_reconfig_notifier_register(&iommu_reconfig_nb); 1360 + of_reconfig_notifier_register(&iommu_reconfig_nb); 1361 1361 register_memory_notifier(&iommu_mem_nb); 1362 1362 1363 1363 set_pci_dma_ops(&dma_iommu_ops);
+2 -2
arch/powerpc/platforms/pseries/mobility.c
··· 116 116 } 117 117 118 118 if (!more) { 119 - prom_update_property(dn, new_prop); 119 + of_update_property(dn, new_prop); 120 120 new_prop = NULL; 121 121 } 122 122 ··· 172 172 173 173 case 0x80000000: 174 174 prop = of_find_property(dn, prop_name, NULL); 175 - prom_remove_property(dn, prop); 175 + of_remove_property(dn, prop); 176 176 prop = NULL; 177 177 break; 178 178
+6 -113
arch/powerpc/platforms/pseries/reconfig.c
··· 16 16 #include <linux/notifier.h> 17 17 #include <linux/proc_fs.h> 18 18 #include <linux/slab.h> 19 + #include <linux/of.h> 19 20 20 21 #include <asm/prom.h> 21 22 #include <asm/machdep.h> 22 23 #include <asm/uaccess.h> 23 - #include <asm/pSeries_reconfig.h> 24 24 #include <asm/mmu.h> 25 - 26 - 27 - 28 - /* 29 - * Routines for "runtime" addition and removal of device tree nodes. 30 - */ 31 - #ifdef CONFIG_PROC_DEVICETREE 32 - /* 33 - * Add a node to /proc/device-tree. 34 - */ 35 - static void add_node_proc_entries(struct device_node *np) 36 - { 37 - struct proc_dir_entry *ent; 38 - 39 - ent = proc_mkdir(strrchr(np->full_name, '/') + 1, np->parent->pde); 40 - if (ent) 41 - proc_device_tree_add_node(np, ent); 42 - } 43 - 44 - static void remove_node_proc_entries(struct device_node *np) 45 - { 46 - struct property *pp = np->properties; 47 - struct device_node *parent = np->parent; 48 - 49 - while (pp) { 50 - remove_proc_entry(pp->name, np->pde); 51 - pp = pp->next; 52 - } 53 - if (np->pde) 54 - remove_proc_entry(np->pde->name, parent->pde); 55 - } 56 - #else /* !CONFIG_PROC_DEVICETREE */ 57 - static void add_node_proc_entries(struct device_node *np) 58 - { 59 - return; 60 - } 61 - 62 - static void remove_node_proc_entries(struct device_node *np) 63 - { 64 - return; 65 - } 66 - #endif /* CONFIG_PROC_DEVICETREE */ 67 25 68 26 /** 69 27 * derive_parent - basically like dirname(1) ··· 55 97 return parent; 56 98 } 57 99 58 - static BLOCKING_NOTIFIER_HEAD(pSeries_reconfig_chain); 59 - 60 - int pSeries_reconfig_notifier_register(struct notifier_block *nb) 61 - { 62 - return blocking_notifier_chain_register(&pSeries_reconfig_chain, nb); 63 - } 64 - EXPORT_SYMBOL_GPL(pSeries_reconfig_notifier_register); 65 - 66 - void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) 67 - { 68 - blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb); 69 - } 70 - EXPORT_SYMBOL_GPL(pSeries_reconfig_notifier_unregister); 71 - 72 - int pSeries_reconfig_notify(unsigned long action, void *p) 73 - { 74 - int err = blocking_notifier_call_chain(&pSeries_reconfig_chain, 75 - action, p); 76 - 77 - return notifier_to_errno(err); 78 - } 79 - 80 100 static int pSeries_reconfig_add_node(const char *path, struct property *proplist) 81 101 { 82 102 struct device_node *np; ··· 78 142 goto out_err; 79 143 } 80 144 81 - err = pSeries_reconfig_notify(PSERIES_RECONFIG_ADD, np); 145 + err = of_attach_node(np); 82 146 if (err) { 83 147 printk(KERN_ERR "Failed to add device node %s\n", path); 84 148 goto out_err; 85 149 } 86 - 87 - of_attach_node(np); 88 - 89 - add_node_proc_entries(np); 90 150 91 151 of_node_put(np->parent); 92 152 ··· 111 179 return -EBUSY; 112 180 } 113 181 114 - remove_node_proc_entries(np); 115 - 116 - pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE, np); 117 182 of_detach_node(np); 118 - 119 183 of_node_put(parent); 120 184 of_node_put(np); /* Must decrement the refcount */ 121 185 return 0; ··· 326 398 if (!prop) 327 399 return -ENOMEM; 328 400 329 - prom_add_property(np, prop); 401 + of_add_property(np, prop); 330 402 331 403 return 0; 332 404 } ··· 350 422 351 423 prop = of_find_property(np, buf, NULL); 352 424 353 - return prom_remove_property(np, prop); 425 + return of_remove_property(np, prop); 354 426 } 355 427 356 428 static int do_update_property(char *buf, size_t bufsize) 357 429 { 358 430 struct device_node *np; 359 - struct pSeries_reconfig_prop_update upd_value; 360 431 unsigned char *value; 361 432 char *name, *end, *next_prop; 362 - int rc, length; 433 + int length; 363 434 struct property *newprop; 364 435 buf = parse_node(buf, bufsize, &np); 365 436 end = buf + bufsize; ··· 380 453 if (!strcmp(name, "slb-size") || !strcmp(name, "ibm,slb-size")) 381 454 slb_set_size(*(int *)value); 382 455 383 - upd_value.node = np; 384 - upd_value.property = newprop; 385 - pSeries_reconfig_notify(PSERIES_UPDATE_PROPERTY, &upd_value); 386 - 387 - rc = prom_update_property(np, newprop); 388 - if (rc) 389 - return rc; 390 - 391 - /* For memory under the ibm,dynamic-reconfiguration-memory node 392 - * of the device tree, adding and removing memory is just an update 393 - * to the ibm,dynamic-memory property instead of adding/removing a 394 - * memory node in the device tree. For these cases we still need to 395 - * involve the notifier chain. 396 - */ 397 - if (!strcmp(name, "ibm,dynamic-memory")) { 398 - int action; 399 - 400 - next_prop = parse_next_property(next_prop, end, &name, 401 - &length, &value); 402 - if (!next_prop) 403 - return -EINVAL; 404 - 405 - if (!strcmp(name, "add")) 406 - action = PSERIES_DRCONF_MEM_ADD; 407 - else 408 - action = PSERIES_DRCONF_MEM_REMOVE; 409 - 410 - rc = pSeries_reconfig_notify(action, value); 411 - if (rc) { 412 - prom_update_property(np, newprop); 413 - return rc; 414 - } 415 - } 416 - 417 - return 0; 456 + return of_update_property(np, newprop); 418 457 } 419 458 420 459 /**
+3 -3
arch/powerpc/platforms/pseries/setup.c
··· 40 40 #include <linux/seq_file.h> 41 41 #include <linux/root_dev.h> 42 42 #include <linux/cpuidle.h> 43 + #include <linux/of.h> 43 44 44 45 #include <asm/mmu.h> 45 46 #include <asm/processor.h> ··· 64 63 #include <asm/smp.h> 65 64 #include <asm/firmware.h> 66 65 #include <asm/eeh.h> 67 - #include <asm/pSeries_reconfig.h> 68 66 69 67 #include "plpar_wrappers.h" 70 68 #include "pseries.h" ··· 258 258 int err = NOTIFY_OK; 259 259 260 260 switch (action) { 261 - case PSERIES_RECONFIG_ADD: 261 + case OF_RECONFIG_ATTACH_NODE: 262 262 pci = np->parent->data; 263 263 if (pci) { 264 264 update_dn_pci_info(np, pci->phb); ··· 389 389 /* Find and initialize PCI host bridges */ 390 390 init_pci_config_tokens(); 391 391 find_and_init_phbs(); 392 - pSeries_reconfig_notifier_register(&pci_dn_reconfig_nb); 392 + of_reconfig_notifier_register(&pci_dn_reconfig_nb); 393 393 394 394 pSeries_nvram_init(); 395 395
-1
arch/powerpc/platforms/pseries/smp.c
··· 38 38 #include <asm/cputable.h> 39 39 #include <asm/firmware.h> 40 40 #include <asm/rtas.h> 41 - #include <asm/pSeries_reconfig.h> 42 41 #include <asm/mpic.h> 43 42 #include <asm/vdso_datapage.h> 44 43 #include <asm/cputhreads.h>
+8 -12
drivers/crypto/nx/nx-842.c
··· 28 28 #include <linux/slab.h> 29 29 30 30 #include <asm/page.h> 31 - #include <asm/pSeries_reconfig.h> 32 31 #include <asm/vio.h> 33 32 34 33 #include "nx_csbcpb.h" /* struct nx_csbcpb */ ··· 1013 1014 * NOTIFY_BAD encoded with error number on failure, use 1014 1015 * notifier_to_errno() to decode this value 1015 1016 */ 1016 - static int nx842_OF_notifier(struct notifier_block *np, 1017 - unsigned long action, 1018 - void *update) 1017 + static int nx842_OF_notifier(struct notifier_block *np, unsigned long action, 1018 + void *update) 1019 1019 { 1020 - struct pSeries_reconfig_prop_update *upd; 1020 + struct of_prop_reconfig *upd = update; 1021 1021 struct nx842_devdata *local_devdata; 1022 1022 struct device_node *node = NULL; 1023 - 1024 - upd = (struct pSeries_reconfig_prop_update *)update; 1025 1023 1026 1024 rcu_read_lock(); 1027 1025 local_devdata = rcu_dereference(devdata); ··· 1026 1030 node = local_devdata->dev->of_node; 1027 1031 1028 1032 if (local_devdata && 1029 - action == PSERIES_UPDATE_PROPERTY && 1030 - !strcmp(upd->node->name, node->name)) { 1033 + action == OF_RECONFIG_UPDATE_PROPERTY && 1034 + !strcmp(upd->dn->name, node->name)) { 1031 1035 rcu_read_unlock(); 1032 - nx842_OF_upd(upd->property); 1036 + nx842_OF_upd(upd->prop); 1033 1037 } else 1034 1038 rcu_read_unlock(); 1035 1039 ··· 1178 1182 synchronize_rcu(); 1179 1183 kfree(old_devdata); 1180 1184 1181 - pSeries_reconfig_notifier_register(&nx842_of_nb); 1185 + of_reconfig_notifier_register(&nx842_of_nb); 1182 1186 1183 1187 ret = nx842_OF_upd(NULL); 1184 1188 if (ret && ret != -ENODEV) { ··· 1224 1228 spin_lock_irqsave(&devdata_mutex, flags); 1225 1229 old_devdata = rcu_dereference_check(devdata, 1226 1230 lockdep_is_held(&devdata_mutex)); 1227 - pSeries_reconfig_notifier_unregister(&nx842_of_nb); 1231 + of_reconfig_notifier_unregister(&nx842_of_nb); 1228 1232 rcu_assign_pointer(devdata, NULL); 1229 1233 spin_unlock_irqrestore(&devdata_mutex, flags); 1230 1234 synchronize_rcu();
-1
drivers/crypto/nx/nx.c
··· 33 33 #include <linux/scatterlist.h> 34 34 #include <linux/device.h> 35 35 #include <linux/of.h> 36 - #include <asm/pSeries_reconfig.h> 37 36 #include <asm/hvcall.h> 38 37 #include <asm/vio.h> 39 38
+1 -1
drivers/macintosh/smu.c
··· 997 997 "%02x !\n", id, hdr->id); 998 998 goto failure; 999 999 } 1000 - if (prom_add_property(smu->of_node, prop)) { 1000 + if (of_add_property(smu->of_node, prop)) { 1001 1001 printk(KERN_DEBUG "SMU: Failed creating sdb-partition-%02x " 1002 1002 "property !\n", id); 1003 1003 goto failure;
+125 -15
drivers/of/base.c
··· 1028 1028 } 1029 1029 EXPORT_SYMBOL(of_parse_phandle_with_args); 1030 1030 1031 + #if defined(CONFIG_OF_DYNAMIC) 1032 + static int of_property_notify(int action, struct device_node *np, 1033 + struct property *prop) 1034 + { 1035 + struct of_prop_reconfig pr; 1036 + 1037 + pr.dn = np; 1038 + pr.prop = prop; 1039 + return of_reconfig_notify(action, &pr); 1040 + } 1041 + #else 1042 + static int of_property_notify(int action, struct device_node *np, 1043 + struct property *prop) 1044 + { 1045 + return 0; 1046 + } 1047 + #endif 1048 + 1031 1049 /** 1032 - * prom_add_property - Add a property to a node 1050 + * of_add_property - Add a property to a node 1033 1051 */ 1034 - int prom_add_property(struct device_node *np, struct property *prop) 1052 + int of_add_property(struct device_node *np, struct property *prop) 1035 1053 { 1036 1054 struct property **next; 1037 1055 unsigned long flags; 1056 + int rc; 1057 + 1058 + rc = of_property_notify(OF_RECONFIG_ADD_PROPERTY, np, prop); 1059 + if (rc) 1060 + return rc; 1038 1061 1039 1062 prop->next = NULL; 1040 1063 write_lock_irqsave(&devtree_lock, flags); ··· 1083 1060 } 1084 1061 1085 1062 /** 1086 - * prom_remove_property - Remove a property from a node. 1063 + * of_remove_property - Remove a property from a node. 1087 1064 * 1088 1065 * Note that we don't actually remove it, since we have given out 1089 1066 * who-knows-how-many pointers to the data using get-property. 1090 1067 * Instead we just move the property to the "dead properties" 1091 1068 * list, so it won't be found any more. 1092 1069 */ 1093 - int prom_remove_property(struct device_node *np, struct property *prop) 1070 + int of_remove_property(struct device_node *np, struct property *prop) 1094 1071 { 1095 1072 struct property **next; 1096 1073 unsigned long flags; 1097 1074 int found = 0; 1075 + int rc; 1076 + 1077 + rc = of_property_notify(OF_RECONFIG_REMOVE_PROPERTY, np, prop); 1078 + if (rc) 1079 + return rc; 1098 1080 1099 1081 write_lock_irqsave(&devtree_lock, flags); 1100 1082 next = &np->properties; ··· 1129 1101 } 1130 1102 1131 1103 /* 1132 - * prom_update_property - Update a property in a node, if the property does 1104 + * of_update_property - Update a property in a node, if the property does 1133 1105 * not exist, add it. 1134 1106 * 1135 1107 * Note that we don't actually remove it, since we have given out ··· 1137 1109 * Instead we just move the property to the "dead properties" list, 1138 1110 * and add the new property to the property list 1139 1111 */ 1140 - int prom_update_property(struct device_node *np, 1141 - struct property *newprop) 1112 + int of_update_property(struct device_node *np, struct property *newprop) 1142 1113 { 1143 1114 struct property **next, *oldprop; 1144 1115 unsigned long flags; 1145 - int found = 0; 1116 + int rc, found = 0; 1117 + 1118 + rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop); 1119 + if (rc) 1120 + return rc; 1146 1121 1147 1122 if (!newprop->name) 1148 1123 return -EINVAL; 1149 1124 1150 1125 oldprop = of_find_property(np, newprop->name, NULL); 1151 1126 if (!oldprop) 1152 - return prom_add_property(np, newprop); 1127 + return of_add_property(np, newprop); 1153 1128 1154 1129 write_lock_irqsave(&devtree_lock, flags); 1155 1130 next = &np->properties; ··· 1191 1160 * device tree nodes. 1192 1161 */ 1193 1162 1163 + static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain); 1164 + 1165 + int of_reconfig_notifier_register(struct notifier_block *nb) 1166 + { 1167 + return blocking_notifier_chain_register(&of_reconfig_chain, nb); 1168 + } 1169 + 1170 + int of_reconfig_notifier_unregister(struct notifier_block *nb) 1171 + { 1172 + return blocking_notifier_chain_unregister(&of_reconfig_chain, nb); 1173 + } 1174 + 1175 + int of_reconfig_notify(unsigned long action, void *p) 1176 + { 1177 + int rc; 1178 + 1179 + rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p); 1180 + return notifier_to_errno(rc); 1181 + } 1182 + 1183 + #ifdef CONFIG_PROC_DEVICETREE 1184 + static void of_add_proc_dt_entry(struct device_node *dn) 1185 + { 1186 + struct proc_dir_entry *ent; 1187 + 1188 + ent = proc_mkdir(strrchr(dn->full_name, '/') + 1, dn->parent->pde); 1189 + if (ent) 1190 + proc_device_tree_add_node(dn, ent); 1191 + } 1192 + #else 1193 + static void of_add_proc_dt_entry(struct device_node *dn) 1194 + { 1195 + return; 1196 + } 1197 + #endif 1198 + 1194 1199 /** 1195 1200 * of_attach_node - Plug a device node into the tree and global list. 1196 1201 */ 1197 - void of_attach_node(struct device_node *np) 1202 + int of_attach_node(struct device_node *np) 1198 1203 { 1199 1204 unsigned long flags; 1205 + int rc; 1206 + 1207 + rc = of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, np); 1208 + if (rc) 1209 + return rc; 1200 1210 1201 1211 write_lock_irqsave(&devtree_lock, flags); 1202 1212 np->sibling = np->parent->child; ··· 1245 1173 np->parent->child = np; 1246 1174 allnodes = np; 1247 1175 write_unlock_irqrestore(&devtree_lock, flags); 1176 + 1177 + of_add_proc_dt_entry(np); 1178 + return 0; 1248 1179 } 1180 + 1181 + #ifdef CONFIG_PROC_DEVICETREE 1182 + static void of_remove_proc_dt_entry(struct device_node *dn) 1183 + { 1184 + struct device_node *parent = dn->parent; 1185 + struct property *prop = dn->properties; 1186 + 1187 + while (prop) { 1188 + remove_proc_entry(prop->name, dn->pde); 1189 + prop = prop->next; 1190 + } 1191 + 1192 + if (dn->pde) 1193 + remove_proc_entry(dn->pde->name, parent->pde); 1194 + } 1195 + #else 1196 + static void of_remove_proc_dt_entry(struct device_node *dn) 1197 + { 1198 + return; 1199 + } 1200 + #endif 1249 1201 1250 1202 /** 1251 1203 * of_detach_node - "Unplug" a node from the device tree. ··· 1277 1181 * The caller must hold a reference to the node. The memory associated with 1278 1182 * the node is not freed until its refcount goes to zero. 1279 1183 */ 1280 - void of_detach_node(struct device_node *np) 1184 + int of_detach_node(struct device_node *np) 1281 1185 { 1282 1186 struct device_node *parent; 1283 1187 unsigned long flags; 1188 + int rc = 0; 1189 + 1190 + rc = of_reconfig_notify(OF_RECONFIG_DETACH_NODE, np); 1191 + if (rc) 1192 + return rc; 1284 1193 1285 1194 write_lock_irqsave(&devtree_lock, flags); 1286 1195 1196 + if (of_node_check_flag(np, OF_DETACHED)) { 1197 + /* someone already detached it */ 1198 + write_unlock_irqrestore(&devtree_lock, flags); 1199 + return rc; 1200 + } 1201 + 1287 1202 parent = np->parent; 1288 - if (!parent) 1289 - goto out_unlock; 1203 + if (!parent) { 1204 + write_unlock_irqrestore(&devtree_lock, flags); 1205 + return rc; 1206 + } 1290 1207 1291 1208 if (allnodes == np) 1292 1209 allnodes = np->allnext; ··· 1324 1215 } 1325 1216 1326 1217 of_node_set_flag(np, OF_DETACHED); 1327 - 1328 - out_unlock: 1329 1218 write_unlock_irqrestore(&devtree_lock, flags); 1219 + 1220 + of_remove_proc_dt_entry(np); 1221 + return rc; 1330 1222 } 1331 1223 #endif /* defined(CONFIG_OF_DYNAMIC) */ 1332 1224
+21 -8
include/linux/of.h
··· 22 22 #include <linux/mod_devicetable.h> 23 23 #include <linux/spinlock.h> 24 24 #include <linux/topology.h> 25 + #include <linux/notifier.h> 25 26 26 27 #include <asm/byteorder.h> 27 28 #include <asm/errno.h> ··· 268 267 269 268 extern int of_machine_is_compatible(const char *compat); 270 269 271 - extern int prom_add_property(struct device_node* np, struct property* prop); 272 - extern int prom_remove_property(struct device_node *np, struct property *prop); 273 - extern int prom_update_property(struct device_node *np, 274 - struct property *newprop); 270 + extern int of_add_property(struct device_node *np, struct property *prop); 271 + extern int of_remove_property(struct device_node *np, struct property *prop); 272 + extern int of_update_property(struct device_node *np, struct property *newprop); 275 273 276 - #if defined(CONFIG_OF_DYNAMIC) 277 274 /* For updating the device tree at runtime */ 278 - extern void of_attach_node(struct device_node *); 279 - extern void of_detach_node(struct device_node *); 280 - #endif 275 + #define OF_RECONFIG_ATTACH_NODE 0x0001 276 + #define OF_RECONFIG_DETACH_NODE 0x0002 277 + #define OF_RECONFIG_ADD_PROPERTY 0x0003 278 + #define OF_RECONFIG_REMOVE_PROPERTY 0x0004 279 + #define OF_RECONFIG_UPDATE_PROPERTY 0x0005 280 + 281 + struct of_prop_reconfig { 282 + struct device_node *dn; 283 + struct property *prop; 284 + }; 285 + 286 + extern int of_reconfig_notifier_register(struct notifier_block *); 287 + extern int of_reconfig_notifier_unregister(struct notifier_block *); 288 + extern int of_reconfig_notify(unsigned long, void *); 289 + 290 + extern int of_attach_node(struct device_node *); 291 + extern int of_detach_node(struct device_node *); 281 292 282 293 #define of_match_ptr(_ptr) (_ptr) 283 294