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

Merge tag 'devicetree-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux into next

Pull DeviceTree updates from Rob Herring:
- Another round of clean-up of FDT related code in architecture code.
This removes knowledge of internal FDT details from most
architectures except powerpc.
- Conversion of kernel's custom FDT parsing code to use libfdt.
- DT based initialization for generic serial earlycon. The
introduction of generic serial earlycon support went in through the
tty tree.
- Improve the platform device naming for DT probed devices to ensure
unique naming and use parent names instead of a global index.
- Fix a race condition in of_update_property.
- Unify the various linker section OF match tables and fix several
function prototype errors.
- Update platform_get_irq_byname to work in deferred probe cases.
- 2 binding doc updates

* tag 'devicetree-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (58 commits)
of: handle NULL node in next_child iterators
of/irq: provide more wrappers for !CONFIG_OF
devicetree: bindings: Document micrel vendor prefix
dt: bindings: dwc2: fix required value for the phy-names property
of_pci_irq: kill useless variable in of_irq_parse_pci()
of/irq: do irq resolution in platform_get_irq_byname()
of: Add a testcase for of_find_node_by_path()
of: Make of_find_node_by_path() handle /aliases
of: Create unlocked version of for_each_child_of_node()
lib: add glibc style strchrnul() variant
of: Handle memory@0 node on PPC32 only
pci/of: Remove dead code
of: fix race between search and remove in of_update_property()
of: Use NULL for pointers
of: Stop naming platform_device using dcr address
of: Ensure unique names without sacrificing determinism
tty/serial: pl011: add DT based earlycon support
of/fdt: add FDT serial scanning for earlycon
of/fdt: add FDT address translation support
serial: earlycon: add DT support
...

+1004 -834
+1 -1
Documentation/devicetree/bindings/usb/dwc2.txt
··· 13 13 14 14 Optional properties: 15 15 - phys: phy provider specifier 16 - - phy-names: shall be "device" 16 + - phy-names: shall be "usb2-phy" 17 17 Refer to phy/phy-bindings.txt for generic phy consumer properties 18 18 19 19 Example:
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 77 77 lltc Linear Technology Corporation 78 78 marvell Marvell Technology Group Ltd. 79 79 maxim Maxim Integrated Products 80 + micrel Micrel Inc. 80 81 microchip Microchip Technology Inc. 81 82 mosaixtech Mosaix Technologies, Inc. 82 83 moxa Moxa
-1
arch/arc/include/asm/sections.h
··· 12 12 #include <asm-generic/sections.h> 13 13 14 14 extern char __arc_dccm_base[]; 15 - extern char __dtb_start[]; 16 15 17 16 #endif
+1 -1
arch/arc/kernel/devtree.c
··· 42 42 const struct machine_desc *mdesc; 43 43 unsigned long dt_root; 44 44 void *clk; 45 - unsigned long len; 45 + int len; 46 46 47 47 if (!early_init_dt_scan(dt)) 48 48 return NULL;
-2
arch/arm/include/asm/prom.h
··· 14 14 #ifdef CONFIG_OF 15 15 16 16 extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys); 17 - extern void arm_dt_memblock_reserve(void); 18 17 extern void __init arm_dt_init_cpu_maps(void); 19 18 20 19 #else /* CONFIG_OF */ ··· 23 24 return NULL; 24 25 } 25 26 26 - static inline void arm_dt_memblock_reserve(void) { } 27 27 static inline void arm_dt_init_cpu_maps(void) { } 28 28 29 29 #endif /* CONFIG_OF */
+8 -37
arch/arm/kernel/devtree.c
··· 32 32 arm_add_memory(base, size); 33 33 } 34 34 35 - void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 36 - { 37 - return memblock_virt_alloc(size, align); 38 - } 39 - 40 - void __init arm_dt_memblock_reserve(void) 41 - { 42 - u64 *reserve_map, base, size; 43 - 44 - if (!initial_boot_params) 45 - return; 46 - 47 - /* Reserve the dtb region */ 48 - memblock_reserve(virt_to_phys(initial_boot_params), 49 - be32_to_cpu(initial_boot_params->totalsize)); 50 - 51 - /* 52 - * Process the reserve map. This will probably overlap the initrd 53 - * and dtb locations which are already reserved, but overlaping 54 - * doesn't hurt anything 55 - */ 56 - reserve_map = ((void*)initial_boot_params) + 57 - be32_to_cpu(initial_boot_params->off_mem_rsvmap); 58 - while (1) { 59 - base = be64_to_cpup(reserve_map++); 60 - size = be64_to_cpup(reserve_map++); 61 - if (!size) 62 - break; 63 - memblock_reserve(base, size); 64 - } 65 - } 66 - 67 35 #ifdef CONFIG_SMP 68 - extern struct of_cpu_method __cpu_method_of_table_begin[]; 69 - extern struct of_cpu_method __cpu_method_of_table_end[]; 36 + extern struct of_cpu_method __cpu_method_of_table[]; 37 + 38 + static const struct of_cpu_method __cpu_method_of_table_sentinel 39 + __used __section(__cpu_method_of_table_end); 40 + 70 41 71 42 static int __init set_smp_ops_by_method(struct device_node *node) 72 43 { 73 44 const char *method; 74 - struct of_cpu_method *m = __cpu_method_of_table_begin; 45 + struct of_cpu_method *m = __cpu_method_of_table; 75 46 76 47 if (of_property_read_string(node, "enable-method", &method)) 77 48 return 0; 78 49 79 - for (; m < __cpu_method_of_table_end; m++) 50 + for (; m->method; m++) 80 51 if (!strcmp(m->method, method)) { 81 52 smp_set_ops(m->ops); 82 53 return 1; ··· 223 252 224 253 if (!mdesc) { 225 254 const char *prop; 226 - long size; 255 + int size; 227 256 unsigned long dt_root; 228 257 229 258 early_print("\nError: unrecognized/unsupported "
+1 -1
arch/arm/mach-exynos/exynos.c
··· 202 202 { 203 203 struct map_desc iodesc; 204 204 __be32 *reg; 205 - unsigned long len; 205 + int len; 206 206 207 207 if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") && 208 208 !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
+1 -3
arch/arm/mach-imx/clk-imx35.c
··· 289 289 return 0; 290 290 } 291 291 292 - static int __init mx35_clocks_init_dt(struct device_node *ccm_node) 292 + static void __init mx35_clocks_init_dt(struct device_node *ccm_node) 293 293 { 294 294 clk_data.clks = clk; 295 295 clk_data.clk_num = ARRAY_SIZE(clk); 296 296 of_clk_add_provider(ccm_node, of_clk_src_onecell_get, &clk_data); 297 297 298 298 mx35_clocks_init(); 299 - 300 - return 0; 301 299 } 302 300 CLK_OF_DECLARE(imx35, "fsl,imx35-ccm", mx35_clocks_init_dt);
-1
arch/arm/mm/init.c
··· 317 317 #endif 318 318 319 319 arm_mm_memblock_reserve(); 320 - arm_dt_memblock_reserve(); 321 320 322 321 /* reserve any platform specific memblock areas */ 323 322 if (mdesc->reserve)
+2 -2
arch/arm/plat-samsung/s5p-dev-mfc.c
··· 125 125 int __init s5p_fdt_alloc_mfc_mem(unsigned long node, const char *uname, 126 126 int depth, void *data) 127 127 { 128 - __be32 *prop; 129 - unsigned long len; 128 + const __be32 *prop; 129 + int len; 130 130 struct s5p_mfc_dt_meminfo mfc_mem; 131 131 132 132 if (!data)
-21
arch/arm64/mm/init.c
··· 126 126 127 127 void __init arm64_memblock_init(void) 128 128 { 129 - u64 *reserve_map, base, size; 130 - 131 129 /* Register the kernel text, kernel data and initrd with memblock */ 132 130 memblock_reserve(__pa(_text), _end - _text); 133 131 #ifdef CONFIG_BLK_DEV_INITRD ··· 139 141 */ 140 142 memblock_reserve(__pa(swapper_pg_dir), SWAPPER_DIR_SIZE); 141 143 memblock_reserve(__pa(idmap_pg_dir), IDMAP_DIR_SIZE); 142 - 143 - /* Reserve the dtb region */ 144 - memblock_reserve(virt_to_phys(initial_boot_params), 145 - be32_to_cpu(initial_boot_params->totalsize)); 146 - 147 - /* 148 - * Process the reserve map. This will probably overlap the initrd 149 - * and dtb locations which are already reserved, but overlapping 150 - * doesn't hurt anything 151 - */ 152 - reserve_map = ((void*)initial_boot_params) + 153 - be32_to_cpu(initial_boot_params->off_mem_rsvmap); 154 - while (1) { 155 - base = be64_to_cpup(reserve_map++); 156 - size = be64_to_cpup(reserve_map++); 157 - if (!size) 158 - break; 159 - memblock_reserve(base, size); 160 - } 161 144 162 145 early_init_fdt_scan_reserved_mem(); 163 146 dma_contiguous_reserve(0);
+2 -2
arch/c6x/kernel/setup.c
··· 265 265 */ 266 266 notrace void __init machine_init(unsigned long dt_ptr) 267 267 { 268 - struct boot_param_header *dtb = __va(dt_ptr); 269 - struct boot_param_header *fdt = (struct boot_param_header *)_fdt_start; 268 + const void *dtb = __va(dt_ptr); 269 + const void *fdt = _fdt_start; 270 270 271 271 /* interrupts must be masked */ 272 272 set_creg(IER, 2);
-4
arch/metag/kernel/setup.c
··· 105 105 106 106 extern char _heap_start[]; 107 107 108 - #ifdef CONFIG_METAG_BUILTIN_DTB 109 - extern u32 __dtb_start[]; 110 - #endif 111 - 112 108 #ifdef CONFIG_DA_CONSOLE 113 109 /* Our early channel based console driver */ 114 110 extern struct console dash_console;
+4 -35
arch/microblaze/kernel/prom.c
··· 43 43 #include <asm/pci-bridge.h> 44 44 45 45 #ifdef CONFIG_EARLY_PRINTK 46 - static char *stdout; 46 + static const char *stdout; 47 47 48 48 static int __init early_init_dt_scan_chosen_serial(unsigned long node, 49 49 const char *uname, int depth, void *data) 50 50 { 51 - unsigned long l; 52 - char *p; 51 + int l; 52 + const char *p; 53 53 54 54 pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname); 55 55 ··· 80 80 (strncmp(p, "xlnx,opb-uartlite", 17) == 0) || 81 81 (strncmp(p, "xlnx,axi-uartlite", 17) == 0) || 82 82 (strncmp(p, "xlnx,mdm", 8) == 0)) { 83 - unsigned int *addrp; 83 + const unsigned int *addrp; 84 84 85 85 *(u32 *)data = UARTLITE; 86 86 ··· 114 114 115 115 pr_debug(" <- early_init_devtree()\n"); 116 116 } 117 - 118 - /******* 119 - * 120 - * New implementation of the OF "find" APIs, return a refcounted 121 - * object, call of_node_put() when done. The device tree and list 122 - * are protected by a rw_lock. 123 - * 124 - * Note that property management will need some locking as well, 125 - * this isn't dealt with yet. 126 - * 127 - *******/ 128 - 129 - #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 130 - static struct debugfs_blob_wrapper flat_dt_blob; 131 - 132 - static int __init export_flat_device_tree(void) 133 - { 134 - struct dentry *d; 135 - 136 - flat_dt_blob.data = initial_boot_params; 137 - flat_dt_blob.size = initial_boot_params->totalsize; 138 - 139 - d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 140 - of_debugfs_root, &flat_dt_blob); 141 - if (!d) 142 - return 1; 143 - 144 - return 0; 145 - } 146 - device_initcall(export_flat_device_tree); 147 - #endif
+5 -15
arch/mips/cavium-octeon/setup.c
··· 1053 1053 int octeon_prune_device_tree(void); 1054 1054 1055 1055 extern const char __dtb_octeon_3xxx_begin; 1056 - extern const char __dtb_octeon_3xxx_end; 1057 1056 extern const char __dtb_octeon_68xx_begin; 1058 - extern const char __dtb_octeon_68xx_end; 1059 1057 void __init device_tree_init(void) 1060 1058 { 1061 - int dt_size; 1062 - struct boot_param_header *fdt; 1059 + const void *fdt; 1063 1060 bool do_prune; 1064 1061 1065 1062 if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) { 1066 1063 fdt = phys_to_virt(octeon_bootinfo->fdt_addr); 1067 1064 if (fdt_check_header(fdt)) 1068 1065 panic("Corrupt Device Tree passed to kernel."); 1069 - dt_size = be32_to_cpu(fdt->totalsize); 1070 1066 do_prune = false; 1071 1067 } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) { 1072 - fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin; 1073 - dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin; 1068 + fdt = &__dtb_octeon_68xx_begin; 1074 1069 do_prune = true; 1075 1070 } else { 1076 - fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin; 1077 - dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin; 1071 + fdt = &__dtb_octeon_3xxx_begin; 1078 1072 do_prune = true; 1079 1073 } 1080 1074 1081 - /* Copy the default tree from init memory. */ 1082 - initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8); 1083 - if (initial_boot_params == NULL) 1084 - panic("Could not allocate initial_boot_params"); 1085 - memcpy(initial_boot_params, fdt, dt_size); 1075 + initial_boot_params = (void *)fdt; 1086 1076 1087 1077 if (do_prune) { 1088 1078 octeon_prune_device_tree(); ··· 1080 1090 } else { 1081 1091 pr_info("Using passed Device Tree.\n"); 1082 1092 } 1083 - unflatten_device_tree(); 1093 + unflatten_and_copy_device_tree(); 1084 1094 } 1085 1095 1086 1096 static int __initdata disable_octeon_edac_p;
-4
arch/mips/include/asm/mips-boards/generic.h
··· 67 67 68 68 extern int mips_revision_sconid; 69 69 70 - #ifdef CONFIG_OF 71 - extern struct boot_param_header __dtb_start; 72 - #endif 73 - 74 70 #ifdef CONFIG_PCI 75 71 extern void mips_pcibios_init(void); 76 72 #else
+3 -3
arch/mips/include/asm/prom.h
··· 21 21 22 22 struct boot_param_header; 23 23 24 - extern void __dt_setup_arch(struct boot_param_header *bph); 24 + extern void __dt_setup_arch(void *bph); 25 25 26 26 #define dt_setup_arch(sym) \ 27 27 ({ \ 28 - extern struct boot_param_header __dtb_##sym##_begin; \ 28 + extern char __dtb_##sym##_begin[]; \ 29 29 \ 30 - __dt_setup_arch(&__dtb_##sym##_begin); \ 30 + __dt_setup_arch(__dtb_##sym##_begin); \ 31 31 }) 32 32 33 33 #else /* CONFIG_OF */
+1 -1
arch/mips/kernel/prom.c
··· 47 47 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); 48 48 } 49 49 50 - void __init __dt_setup_arch(struct boot_param_header *bph) 50 + void __init __dt_setup_arch(void *bph) 51 51 { 52 52 if (!early_init_dt_scan(bph)) 53 53 return;
+2 -13
arch/mips/lantiq/prom.c
··· 71 71 * Load the builtin devicetree. This causes the chosen node to be 72 72 * parsed resulting in our memory appearing 73 73 */ 74 - __dt_setup_arch(&__dtb_start); 74 + __dt_setup_arch(__dtb_start); 75 75 } 76 76 77 77 void __init device_tree_init(void) 78 78 { 79 - unsigned long base, size; 80 - 81 - if (!initial_boot_params) 82 - return; 83 - 84 - base = virt_to_phys((void *)initial_boot_params); 85 - size = be32_to_cpu(initial_boot_params->totalsize); 86 - 87 - /* Before we do anything, lets reserve the dt blob */ 88 - reserve_bootmem(base, size, BOOTMEM_DEFAULT); 89 - 90 - unflatten_device_tree(); 79 + unflatten_and_copy_device_tree(); 91 80 } 92 81 93 82 void __init prom_init(void)
-2
arch/mips/lantiq/prom.h
··· 26 26 extern void ltq_soc_detect(struct ltq_soc_info *i); 27 27 extern void ltq_soc_init(void); 28 28 29 - extern struct boot_param_header __dtb_start; 30 - 31 29 #endif
+4 -4
arch/mips/mti-sead3/sead3-setup.c
··· 69 69 if (!memsize) 70 70 return; 71 71 72 - offset = fdt_path_offset(&__dtb_start, "/memory"); 72 + offset = fdt_path_offset(__dtb_start, "/memory"); 73 73 if (offset > 0) { 74 74 uint64_t new_value; 75 75 /* 76 76 * reg contains 2 32-bits BE values, offset and size. We just 77 77 * want to replace the size value without affecting the offset 78 78 */ 79 - prop_value = fdt_getprop(&__dtb_start, offset, "reg", &prop_len); 79 + prop_value = fdt_getprop(__dtb_start, offset, "reg", &prop_len); 80 80 new_value = be64_to_cpu(*prop_value); 81 81 new_value = (new_value & ~0xffffffffllu) | memsize; 82 - fdt_setprop_inplace_u64(&__dtb_start, offset, "reg", new_value); 82 + fdt_setprop_inplace_u64(__dtb_start, offset, "reg", new_value); 83 83 } 84 84 } 85 85 ··· 92 92 * Load the builtin devicetree. This causes the chosen node to be 93 93 * parsed resulting in our memory appearing 94 94 */ 95 - __dt_setup_arch(&__dtb_start); 95 + __dt_setup_arch(__dtb_start); 96 96 } 97 97 98 98 void __init device_tree_init(void)
+2 -17
arch/mips/netlogic/xlp/dt.c
··· 42 42 #include <asm/prom.h> 43 43 44 44 extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], 45 - __dtb_xlp_fvp_begin[], __dtb_xlp_gvp_begin[], __dtb_start[]; 45 + __dtb_xlp_fvp_begin[], __dtb_xlp_gvp_begin[]; 46 46 static void *xlp_fdt_blob; 47 47 48 48 void __init *xlp_dt_init(void *fdtp) ··· 87 87 88 88 void __init device_tree_init(void) 89 89 { 90 - unsigned long base, size; 91 - struct boot_param_header *fdtp = xlp_fdt_blob; 92 - 93 - if (!fdtp) 94 - return; 95 - 96 - base = virt_to_phys(fdtp); 97 - size = be32_to_cpu(fdtp->totalsize); 98 - 99 - /* Before we do anything, lets reserve the dt blob */ 100 - reserve_bootmem(base, size, BOOTMEM_DEFAULT); 101 - 102 - unflatten_device_tree(); 103 - 104 - /* free the space reserved for the dt blob */ 105 - free_bootmem(base, size); 90 + unflatten_and_copy_device_tree(); 106 91 } 107 92 108 93 static struct of_device_id __initdata xlp_ids[] = {
+2 -27
arch/mips/ralink/of.c
··· 28 28 __iomem void *rt_sysc_membase; 29 29 __iomem void *rt_memc_membase; 30 30 31 - extern struct boot_param_header __dtb_start; 32 - 33 31 __iomem void *plat_of_remap_node(const char *node) 34 32 { 35 33 struct resource res; ··· 50 52 51 53 void __init device_tree_init(void) 52 54 { 53 - unsigned long base, size; 54 - void *fdt_copy; 55 - 56 - if (!initial_boot_params) 57 - return; 58 - 59 - base = virt_to_phys((void *)initial_boot_params); 60 - size = be32_to_cpu(initial_boot_params->totalsize); 61 - 62 - /* Before we do anything, lets reserve the dt blob */ 63 - reserve_bootmem(base, size, BOOTMEM_DEFAULT); 64 - 65 - /* The strings in the flattened tree are referenced directly by the 66 - * device tree, so copy the flattened device tree from init memory 67 - * to regular memory. 68 - */ 69 - fdt_copy = alloc_bootmem(size); 70 - memcpy(fdt_copy, initial_boot_params, size); 71 - initial_boot_params = fdt_copy; 72 - 73 - unflatten_device_tree(); 74 - 75 - /* free the space reserved for the dt blob */ 76 - free_bootmem(base, size); 55 + unflatten_and_copy_device_tree(); 77 56 } 78 57 79 58 void __init plat_mem_setup(void) ··· 61 86 * Load the builtin devicetree. This causes the chosen node to be 62 87 * parsed resulting in our memory appearing 63 88 */ 64 - __dt_setup_arch(&__dtb_start); 89 + __dt_setup_arch(__dtb_start); 65 90 66 91 if (soc_info.mem_size) 67 92 add_memory_region(soc_info.mem_base, soc_info.mem_size * SZ_1M,
-2
arch/openrisc/kernel/vmlinux.h
··· 5 5 extern char __initrd_start, __initrd_end; 6 6 #endif 7 7 8 - extern u32 __dtb_start[]; 9 - 10 8 #endif
-4
arch/powerpc/include/asm/dcr-mmio.h
··· 51 51 out_be32(host.token + ((host.base + dcr_n) * host.stride), value); 52 52 } 53 53 54 - extern u64 of_translate_dcr_address(struct device_node *dev, 55 - unsigned int dcr_n, 56 - unsigned int *stride); 57 - 58 54 #endif /* __KERNEL__ */ 59 55 #endif /* _ASM_POWERPC_DCR_MMIO_H */ 60 56
+39
arch/powerpc/include/asm/prom.h
··· 26 26 #include <linux/of_irq.h> 27 27 #include <linux/platform_device.h> 28 28 29 + #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ 30 + #define OF_DT_END_NODE 0x2 /* End node */ 31 + #define OF_DT_PROP 0x3 /* Property: name off, size, 32 + * content */ 33 + #define OF_DT_NOP 0x4 /* nop */ 34 + #define OF_DT_END 0x9 35 + 36 + #define OF_DT_VERSION 0x10 37 + 38 + /* 39 + * This is what gets passed to the kernel by prom_init or kexec 40 + * 41 + * The dt struct contains the device tree structure, full pathes and 42 + * property contents. The dt strings contain a separate block with just 43 + * the strings for the property names, and is fully page aligned and 44 + * self contained in a page, so that it can be kept around by the kernel, 45 + * each property name appears only once in this page (cheap compression) 46 + * 47 + * the mem_rsvmap contains a map of reserved ranges of physical memory, 48 + * passing it here instead of in the device-tree itself greatly simplifies 49 + * the job of everybody. It's just a list of u64 pairs (base/size) that 50 + * ends when size is 0 51 + */ 52 + struct boot_param_header { 53 + __be32 magic; /* magic word OF_DT_HEADER */ 54 + __be32 totalsize; /* total size of DT block */ 55 + __be32 off_dt_struct; /* offset to structure */ 56 + __be32 off_dt_strings; /* offset to strings */ 57 + __be32 off_mem_rsvmap; /* offset to memory reserve map */ 58 + __be32 version; /* format version */ 59 + __be32 last_comp_version; /* last compatible version */ 60 + /* version 2 fields below */ 61 + __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ 62 + /* version 3 fields below */ 63 + __be32 dt_strings_size; /* size of the DT strings block */ 64 + /* version 17 fields below */ 65 + __be32 dt_struct_size; /* size of the DT structure block */ 66 + }; 67 + 29 68 /* 30 69 * OF address retreival & translation 31 70 */
+1
arch/powerpc/kernel/Makefile
··· 2 2 # Makefile for the linux kernel. 3 3 # 4 4 5 + CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt 5 6 CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' 6 7 7 8 subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
+1 -1
arch/powerpc/kernel/epapr_paravirt.c
··· 36 36 int depth, void *data) 37 37 { 38 38 const u32 *insts; 39 - unsigned long len; 39 + int len; 40 40 int i; 41 41 42 42 insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
+2 -2
arch/powerpc/kernel/fadump.c
··· 55 55 int __init early_init_dt_scan_fw_dump(unsigned long node, 56 56 const char *uname, int depth, void *data) 57 57 { 58 - __be32 *sections; 58 + const __be32 *sections; 59 59 int i, num_sections; 60 - unsigned long size; 60 + int size; 61 61 const int *token; 62 62 63 63 if (depth != 1 || strcmp(uname, "rtas") != 0)
+21 -61
arch/powerpc/kernel/prom.c
··· 29 29 #include <linux/bitops.h> 30 30 #include <linux/export.h> 31 31 #include <linux/kexec.h> 32 - #include <linux/debugfs.h> 33 32 #include <linux/irq.h> 34 33 #include <linux/memblock.h> 35 34 #include <linux/of.h> 36 35 #include <linux/of_fdt.h> 36 + #include <linux/libfdt.h> 37 37 38 38 #include <asm/prom.h> 39 39 #include <asm/rtas.h> ··· 118 118 DBG("-> move_device_tree\n"); 119 119 120 120 start = __pa(initial_boot_params); 121 - size = be32_to_cpu(initial_boot_params->totalsize); 121 + size = fdt_totalsize(initial_boot_params); 122 122 123 123 if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) || 124 124 overlaps_crashkernel(start, size) || 125 125 overlaps_initrd(start, size)) { 126 126 p = __va(memblock_alloc(size, PAGE_SIZE)); 127 127 memcpy(p, initial_boot_params, size); 128 - initial_boot_params = (struct boot_param_header *)p; 128 + initial_boot_params = p; 129 129 DBG("Moved device tree to 0x%p\n", p); 130 130 } 131 131 ··· 163 163 {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0}, 164 164 }; 165 165 166 - static void __init scan_features(unsigned long node, unsigned char *ftrs, 166 + static void __init scan_features(unsigned long node, const unsigned char *ftrs, 167 167 unsigned long tablelen, 168 168 struct ibm_pa_feature *fp, 169 169 unsigned long ft_size) ··· 202 202 203 203 static void __init check_cpu_pa_features(unsigned long node) 204 204 { 205 - unsigned char *pa_ftrs; 206 - unsigned long tablelen; 205 + const unsigned char *pa_ftrs; 206 + int tablelen; 207 207 208 208 pa_ftrs = of_get_flat_dt_prop(node, "ibm,pa-features", &tablelen); 209 209 if (pa_ftrs == NULL) ··· 216 216 #ifdef CONFIG_PPC_STD_MMU_64 217 217 static void __init check_cpu_slb_size(unsigned long node) 218 218 { 219 - __be32 *slb_size_ptr; 219 + const __be32 *slb_size_ptr; 220 220 221 221 slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL); 222 222 if (slb_size_ptr != NULL) { ··· 257 257 static inline void identical_pvr_fixup(unsigned long node) 258 258 { 259 259 unsigned int pvr; 260 - char *model = of_get_flat_dt_prop(node, "model", NULL); 260 + const char *model = of_get_flat_dt_prop(node, "model", NULL); 261 261 262 262 /* 263 263 * Since 440GR(x)/440EP(x) processors have the same pvr, ··· 295 295 const char *uname, int depth, 296 296 void *data) 297 297 { 298 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 298 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 299 299 const __be32 *prop; 300 300 const __be32 *intserv; 301 301 int i, nthreads; 302 - unsigned long len; 302 + int len; 303 303 int found = -1; 304 304 int found_thread = 0; 305 305 ··· 325 325 * version 2 of the kexec param format adds the phys cpuid of 326 326 * booted proc. 327 327 */ 328 - if (be32_to_cpu(initial_boot_params->version) >= 2) { 328 + if (fdt_version(initial_boot_params) >= 2) { 329 329 if (be32_to_cpu(intserv[i]) == 330 - be32_to_cpu(initial_boot_params->boot_cpuid_phys)) { 330 + fdt_boot_cpuid_phys(initial_boot_params)) { 331 331 found = boot_cpu_count; 332 332 found_thread = i; 333 333 } ··· 392 392 int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname, 393 393 int depth, void *data) 394 394 { 395 - unsigned long *lprop; /* All these set by kernel, so no need to convert endian */ 395 + const unsigned long *lprop; /* All these set by kernel, so no need to convert endian */ 396 396 397 397 /* Use common scan routine to determine if this is the chosen node */ 398 398 if (early_init_dt_scan_chosen(node, uname, depth, data) == 0) ··· 443 443 */ 444 444 static int __init early_init_dt_scan_drconf_memory(unsigned long node) 445 445 { 446 - __be32 *dm, *ls, *usm; 447 - unsigned long l, n, flags; 446 + const __be32 *dm, *ls, *usm; 447 + int l; 448 + unsigned long n, flags; 448 449 u64 base, size, memblock_size; 449 450 unsigned int is_kexec_kdump = 0, rngs; 450 451 ··· 565 564 566 565 static void __init early_reserve_mem_dt(void) 567 566 { 568 - unsigned long i, len, dt_root; 567 + unsigned long i, dt_root; 568 + int len; 569 569 const __be32 *prop; 570 + 571 + early_init_fdt_scan_reserved_mem(); 570 572 571 573 dt_root = of_get_flat_dt_root(); 572 574 ··· 593 589 memblock_reserve(base, size); 594 590 } 595 591 } 596 - 597 - early_init_fdt_scan_reserved_mem(); 598 592 } 599 593 600 594 static void __init early_reserve_mem(void) 601 595 { 602 - u64 base, size; 603 596 __be64 *reserve_map; 604 - unsigned long self_base; 605 - unsigned long self_size; 606 597 607 598 reserve_map = (__be64 *)(((unsigned long)initial_boot_params) + 608 - be32_to_cpu(initial_boot_params->off_mem_rsvmap)); 609 - 610 - /* before we do anything, lets reserve the dt blob */ 611 - self_base = __pa((unsigned long)initial_boot_params); 612 - self_size = be32_to_cpu(initial_boot_params->totalsize); 613 - memblock_reserve(self_base, self_size); 599 + fdt_off_mem_rsvmap(initial_boot_params)); 614 600 615 601 /* Look for the new "reserved-regions" property in the DT */ 616 602 early_reserve_mem_dt(); ··· 630 636 size_32 = be32_to_cpup(reserve_map_32++); 631 637 if (size_32 == 0) 632 638 break; 633 - /* skip if the reservation is for the blob */ 634 - if (base_32 == self_base && size_32 == self_size) 635 - continue; 636 639 DBG("reserving: %x -> %x\n", base_32, size_32); 637 640 memblock_reserve(base_32, size_32); 638 641 } 639 642 return; 640 643 } 641 644 #endif 642 - DBG("Processing reserve map\n"); 643 - 644 - /* Handle the reserve map in the fdt blob if it exists */ 645 - while (1) { 646 - base = be64_to_cpup(reserve_map++); 647 - size = be64_to_cpup(reserve_map++); 648 - if (size == 0) 649 - break; 650 - DBG("reserving: %llx -> %llx\n", base, size); 651 - memblock_reserve(base, size); 652 - } 653 645 } 654 646 655 647 void __init early_init_devtree(void *params) ··· 902 922 { 903 923 return (int)phys_id == get_hard_smp_processor_id(cpu); 904 924 } 905 - 906 - #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 907 - static struct debugfs_blob_wrapper flat_dt_blob; 908 - 909 - static int __init export_flat_device_tree(void) 910 - { 911 - struct dentry *d; 912 - 913 - flat_dt_blob.data = initial_boot_params; 914 - flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize); 915 - 916 - d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 917 - powerpc_debugfs_root, &flat_dt_blob); 918 - if (!d) 919 - return 1; 920 - 921 - return 0; 922 - } 923 - __initcall(export_flat_device_tree); 924 - #endif
+1 -1
arch/powerpc/kernel/rtas.c
··· 1142 1142 int __init early_init_dt_scan_rtas(unsigned long node, 1143 1143 const char *uname, int depth, void *data) 1144 1144 { 1145 - u32 *basep, *entryp, *sizep; 1145 + const u32 *basep, *entryp, *sizep; 1146 1146 1147 1147 if (depth != 1 || strcmp(uname, "rtas") != 0) 1148 1148 return 0;
+11 -11
arch/powerpc/mm/hash_utils_64.c
··· 269 269 const char *uname, int depth, 270 270 void *data) 271 271 { 272 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 273 - __be32 *prop; 274 - unsigned long size = 0; 272 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 273 + const __be32 *prop; 274 + int size = 0; 275 275 276 276 /* We are scanning "cpu" nodes only */ 277 277 if (type == NULL || strcmp(type, "cpu") != 0) ··· 324 324 const char *uname, int depth, 325 325 void *data) 326 326 { 327 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 328 - __be32 *prop; 329 - unsigned long size = 0; 327 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 328 + const __be32 *prop; 329 + int size = 0; 330 330 331 331 /* We are scanning "cpu" nodes only */ 332 332 if (type == NULL || strcmp(type, "cpu") != 0) ··· 406 406 static int __init htab_dt_scan_hugepage_blocks(unsigned long node, 407 407 const char *uname, int depth, 408 408 void *data) { 409 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 410 - __be64 *addr_prop; 411 - __be32 *page_count_prop; 409 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 410 + const __be64 *addr_prop; 411 + const __be32 *page_count_prop; 412 412 unsigned int expected_pages; 413 413 long unsigned int phys_addr; 414 414 long unsigned int block_size; ··· 550 550 const char *uname, int depth, 551 551 void *data) 552 552 { 553 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 554 - __be32 *prop; 553 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 554 + const __be32 *prop; 555 555 556 556 /* We are scanning "cpu" nodes only */ 557 557 if (type == NULL || strcmp(type, "cpu") != 0)
+2 -2
arch/powerpc/platforms/52xx/efika.c
··· 199 199 200 200 static int __init efika_probe(void) 201 201 { 202 - char *model = of_get_flat_dt_prop(of_get_flat_dt_root(), 203 - "model", NULL); 202 + const char *model = of_get_flat_dt_prop(of_get_flat_dt_root(), 203 + "model", NULL); 204 204 205 205 if (model == NULL) 206 206 return 0;
+2 -2
arch/powerpc/platforms/chrp/setup.c
··· 574 574 575 575 static int __init chrp_probe(void) 576 576 { 577 - char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(), 578 - "device_type", NULL); 577 + const char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(), 578 + "device_type", NULL); 579 579 if (dtype == NULL) 580 580 return 0; 581 581 if (strcmp(dtype, "chrp"))
+6 -6
arch/powerpc/platforms/powernv/opal.c
··· 61 61 const char *uname, int depth, void *data) 62 62 { 63 63 const void *basep, *entryp, *sizep; 64 - unsigned long basesz, entrysz, runtimesz; 64 + int basesz, entrysz, runtimesz; 65 65 66 66 if (depth != 1 || strcmp(uname, "ibm,opal") != 0) 67 67 return 0; ··· 77 77 opal.entry = of_read_number(entryp, entrysz/4); 78 78 opal.size = of_read_number(sizep, runtimesz/4); 79 79 80 - pr_debug("OPAL Base = 0x%llx (basep=%p basesz=%ld)\n", 80 + pr_debug("OPAL Base = 0x%llx (basep=%p basesz=%d)\n", 81 81 opal.base, basep, basesz); 82 - pr_debug("OPAL Entry = 0x%llx (entryp=%p basesz=%ld)\n", 82 + pr_debug("OPAL Entry = 0x%llx (entryp=%p basesz=%d)\n", 83 83 opal.entry, entryp, entrysz); 84 - pr_debug("OPAL Entry = 0x%llx (sizep=%p runtimesz=%ld)\n", 84 + pr_debug("OPAL Entry = 0x%llx (sizep=%p runtimesz=%d)\n", 85 85 opal.size, sizep, runtimesz); 86 86 87 87 powerpc_firmware_features |= FW_FEATURE_OPAL; ··· 102 102 int __init early_init_dt_scan_recoverable_ranges(unsigned long node, 103 103 const char *uname, int depth, void *data) 104 104 { 105 - unsigned long i, psize, size; 105 + int i, psize, size; 106 106 const __be32 *prop; 107 107 108 108 if (depth != 1 || strcmp(uname, "ibm,opal") != 0) ··· 359 359 if ((be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_INPUT) == 0) 360 360 return 0; 361 361 len = cpu_to_be64(count); 362 - rc = opal_console_read(vtermno, &len, buf); 362 + rc = opal_console_read(vtermno, &len, buf); 363 363 if (rc == OPAL_SUCCESS) 364 364 return be64_to_cpu(len); 365 365 return 0;
+2 -2
arch/powerpc/platforms/pseries/setup.c
··· 665 665 void *data) 666 666 { 667 667 const char *prop; 668 - unsigned long len; 668 + int len; 669 669 static int hypertas_found; 670 670 static int vec5_found; 671 671 ··· 698 698 static int __init pSeries_probe(void) 699 699 { 700 700 unsigned long root = of_get_flat_dt_root(); 701 - char *dtype = of_get_flat_dt_prop(root, "device_type", NULL); 701 + const char *dtype = of_get_flat_dt_prop(root, "device_type", NULL); 702 702 703 703 if (dtype == NULL) 704 704 return 0;
+3 -3
arch/powerpc/sysdev/dcr.c
··· 152 152 153 153 #ifdef CONFIG_PPC_DCR_MMIO 154 154 155 - u64 of_translate_dcr_address(struct device_node *dev, 156 - unsigned int dcr_n, 157 - unsigned int *out_stride) 155 + static u64 of_translate_dcr_address(struct device_node *dev, 156 + unsigned int dcr_n, 157 + unsigned int *out_stride) 158 158 { 159 159 struct device_node *dp; 160 160 const u32 *p;
+5 -7
arch/x86/kernel/devicetree.c
··· 206 206 static void __init x86_flattree_get_config(void) 207 207 { 208 208 u32 size, map_len; 209 - struct boot_param_header *dt; 209 + void *dt; 210 210 211 211 if (!initial_dtb) 212 212 return; 213 213 214 - map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), 215 - (u64)sizeof(struct boot_param_header)); 214 + map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128); 216 215 217 - dt = early_memremap(initial_dtb, map_len); 218 - size = be32_to_cpu(dt->totalsize); 216 + initial_boot_params = dt = early_memremap(initial_dtb, map_len); 217 + size = of_get_flat_dt_size(); 219 218 if (map_len < size) { 220 219 early_iounmap(dt, map_len); 221 - dt = early_memremap(initial_dtb, size); 220 + initial_boot_params = dt = early_memremap(initial_dtb, size); 222 221 map_len = size; 223 222 } 224 223 225 - initial_boot_params = dt; 226 224 unflatten_and_copy_device_tree(); 227 225 early_iounmap(dt, map_len); 228 226 }
+1 -2
arch/xtensa/kernel/setup.c
··· 74 74 #endif 75 75 76 76 #ifdef CONFIG_OF 77 - extern u32 __dtb_start[]; 78 77 void *dtb_start = __dtb_start; 79 78 #endif 80 79 ··· 198 199 int depth, void *data) 199 200 { 200 201 const __be32 *ranges; 201 - unsigned long len; 202 + int len; 202 203 203 204 if (depth > 1) 204 205 return 0;
+5 -2
drivers/base/platform.c
··· 131 131 */ 132 132 int platform_get_irq_byname(struct platform_device *dev, const char *name) 133 133 { 134 - struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, 135 - name); 134 + struct resource *r; 136 135 136 + if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) 137 + return of_irq_get_byname(dev->dev.of_node, name); 138 + 139 + r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); 137 140 return r ? r->start : -ENXIO; 138 141 } 139 142 EXPORT_SYMBOL_GPL(platform_get_irq_byname);
+1 -2
drivers/clk/rockchip/clk-rockchip.c
··· 24 24 * Gate clocks 25 25 */ 26 26 27 - static void __init rk2928_gate_clk_init(struct device_node *node, 28 - void *data) 27 + static void __init rk2928_gate_clk_init(struct device_node *node) 29 28 { 30 29 struct clk_onecell_data *clk_data; 31 30 const char *clk_parent;
+2 -3
drivers/clk/sunxi/clk-sunxi.c
··· 1278 1278 const struct of_device_id *match; 1279 1279 void (*setup_function)(struct device_node *, const void *) = function; 1280 1280 1281 - for_each_matching_node(np, clk_match) { 1282 - match = of_match_node(clk_match, np); 1281 + for_each_matching_node_and_match(np, clk_match, &match) { 1283 1282 data = match->data; 1284 1283 setup_function(np, data); 1285 1284 } ··· 1309 1310 } 1310 1311 } 1311 1312 1312 - static void __init sunxi_init_clocks(void) 1313 + static void __init sunxi_init_clocks(struct device_node *np) 1313 1314 { 1314 1315 /* Register factor clocks */ 1315 1316 of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup);
+1 -1
drivers/clk/ti/gate.c
··· 221 221 { 222 222 _of_ti_gate_clk_setup(node, &omap_gate_clk_ops, NULL); 223 223 } 224 - CLK_OF_DECLARE(ti_gate_clk, "ti,gate-clock", of_ti_gate_clk_setup) 224 + CLK_OF_DECLARE(ti_gate_clk, "ti,gate-clock", of_ti_gate_clk_setup); 225 225 226 226 static void __init of_ti_wait_gate_clk_setup(struct device_node *node) 227 227 {
+1 -1
drivers/clocksource/clksrc-of.c
··· 27 27 { 28 28 struct device_node *np; 29 29 const struct of_device_id *match; 30 - clocksource_of_init_fn init_func; 30 + of_init_fn_1 init_func; 31 31 unsigned clocksources = 0; 32 32 33 33 for_each_matching_node_and_match(np, __clksrc_of_table, &match) {
+2 -2
drivers/irqchip/irq-mxs.c
··· 96 96 .xlate = irq_domain_xlate_onecell, 97 97 }; 98 98 99 - static void __init icoll_of_init(struct device_node *np, 99 + static int __init icoll_of_init(struct device_node *np, 100 100 struct device_node *interrupt_parent) 101 101 { 102 102 icoll_base = of_iomap(np, 0); ··· 110 110 111 111 icoll_domain = irq_domain_add_linear(np, ICOLL_NUM_IRQS, 112 112 &icoll_irq_domain_ops, NULL); 113 - WARN_ON(!icoll_domain); 113 + return icoll_domain ? 0 : -ENODEV; 114 114 } 115 115 IRQCHIP_DECLARE(mxs, "fsl,icoll", icoll_of_init);
+2 -4
drivers/irqchip/irq-s3c24xx.c
··· 1323 1323 }; 1324 1324 1325 1325 int __init s3c2410_init_intc_of(struct device_node *np, 1326 - struct device_node *interrupt_parent, 1327 - struct s3c24xx_irq_of_ctrl *ctrl, int num_ctrl) 1326 + struct device_node *interrupt_parent) 1328 1327 { 1329 1328 return s3c_init_intc_of(np, interrupt_parent, 1330 1329 s3c2410_ctrl, ARRAY_SIZE(s3c2410_ctrl)); ··· 1345 1346 }; 1346 1347 1347 1348 int __init s3c2416_init_intc_of(struct device_node *np, 1348 - struct device_node *interrupt_parent, 1349 - struct s3c24xx_irq_of_ctrl *ctrl, int num_ctrl) 1349 + struct device_node *interrupt_parent) 1350 1350 { 1351 1351 return s3c_init_intc_of(np, interrupt_parent, 1352 1352 s3c2416_ctrl, ARRAY_SIZE(s3c2416_ctrl));
+3 -3
drivers/irqchip/irqchip.c
··· 19 19 * special section. 20 20 */ 21 21 static const struct of_device_id 22 - irqchip_of_match_end __used __section(__irqchip_of_end); 22 + irqchip_of_match_end __used __section(__irqchip_of_table_end); 23 23 24 - extern struct of_device_id __irqchip_begin[]; 24 + extern struct of_device_id __irqchip_of_table[]; 25 25 26 26 void __init irqchip_init(void) 27 27 { 28 - of_irq_init(__irqchip_begin); 28 + of_irq_init(__irqchip_of_table); 29 29 }
+3 -4
drivers/irqchip/irqchip.h
··· 11 11 #ifndef _IRQCHIP_H 12 12 #define _IRQCHIP_H 13 13 14 + #include <linux/of.h> 15 + 14 16 /* 15 17 * This macro must be used by the different irqchip drivers to declare 16 18 * the association between their DT compatible string and their ··· 23 21 * @compstr: compatible string of the irqchip driver 24 22 * @fn: initialization function 25 23 */ 26 - #define IRQCHIP_DECLARE(name,compstr,fn) \ 27 - static const struct of_device_id irqchip_of_match_##name \ 28 - __used __section(__irqchip_of_table) \ 29 - = { .compatible = compstr, .data = fn } 24 + #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) 30 25 31 26 #endif
+1
drivers/of/Kconfig
··· 20 20 config OF_FLATTREE 21 21 bool 22 22 select DTC 23 + select LIBFDT 23 24 24 25 config OF_EARLY_FLATTREE 25 26 bool
+4
drivers/of/Makefile
··· 1 1 obj-y = base.o device.o platform.o 2 2 obj-$(CONFIG_OF_FLATTREE) += fdt.o 3 + obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o 3 4 obj-$(CONFIG_OF_PROMTREE) += pdt.o 4 5 obj-$(CONFIG_OF_ADDRESS) += address.o 5 6 obj-$(CONFIG_OF_IRQ) += irq.o ··· 11 10 obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o 12 11 obj-$(CONFIG_OF_MTD) += of_mtd.o 13 12 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o 13 + 14 + CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt 15 + CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
+1 -21
drivers/of/address.c
··· 498 498 /* Count address cells & copy address locally */ 499 499 bus->count_cells(dev, &na, &ns); 500 500 if (!OF_CHECK_COUNTS(na, ns)) { 501 - printk(KERN_ERR "prom_parse: Bad cell count for %s\n", 502 - of_node_full_name(dev)); 501 + pr_debug("OF: Bad cell count for %s\n", of_node_full_name(dev)); 503 502 goto bail; 504 503 } 505 504 memcpy(addr, in_addr, na * 4); ··· 562 563 return __of_translate_address(dev, in_addr, "dma-ranges"); 563 564 } 564 565 EXPORT_SYMBOL(of_translate_dma_address); 565 - 566 - bool of_can_translate_address(struct device_node *dev) 567 - { 568 - struct device_node *parent; 569 - struct of_bus *bus; 570 - int na, ns; 571 - 572 - parent = of_get_parent(dev); 573 - if (parent == NULL) 574 - return false; 575 - 576 - bus = of_match_bus(parent); 577 - bus->count_cells(dev, &na, &ns); 578 - 579 - of_node_put(parent); 580 - 581 - return OF_CHECK_COUNTS(na, ns); 582 - } 583 - EXPORT_SYMBOL(of_can_translate_address); 584 566 585 567 const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, 586 568 unsigned int *flags)
+96 -23
drivers/of/base.c
··· 695 695 } 696 696 EXPORT_SYMBOL(of_get_next_parent); 697 697 698 + static struct device_node *__of_get_next_child(const struct device_node *node, 699 + struct device_node *prev) 700 + { 701 + struct device_node *next; 702 + 703 + if (!node) 704 + return NULL; 705 + 706 + next = prev ? prev->sibling : node->child; 707 + for (; next; next = next->sibling) 708 + if (of_node_get(next)) 709 + break; 710 + of_node_put(prev); 711 + return next; 712 + } 713 + #define __for_each_child_of_node(parent, child) \ 714 + for (child = __of_get_next_child(parent, NULL); child != NULL; \ 715 + child = __of_get_next_child(parent, child)) 716 + 698 717 /** 699 718 * of_get_next_child - Iterate a node childs 700 719 * @node: parent node ··· 729 710 unsigned long flags; 730 711 731 712 raw_spin_lock_irqsave(&devtree_lock, flags); 732 - next = prev ? prev->sibling : node->child; 733 - for (; next; next = next->sibling) 734 - if (of_node_get(next)) 735 - break; 736 - of_node_put(prev); 713 + next = __of_get_next_child(node, prev); 737 714 raw_spin_unlock_irqrestore(&devtree_lock, flags); 738 715 return next; 739 716 } ··· 748 733 { 749 734 struct device_node *next; 750 735 unsigned long flags; 736 + 737 + if (!node) 738 + return NULL; 751 739 752 740 raw_spin_lock_irqsave(&devtree_lock, flags); 753 741 next = prev ? prev->sibling : node->child; ··· 789 771 } 790 772 EXPORT_SYMBOL(of_get_child_by_name); 791 773 774 + static struct device_node *__of_find_node_by_path(struct device_node *parent, 775 + const char *path) 776 + { 777 + struct device_node *child; 778 + int len = strchrnul(path, '/') - path; 779 + 780 + if (!len) 781 + return NULL; 782 + 783 + __for_each_child_of_node(parent, child) { 784 + const char *name = strrchr(child->full_name, '/'); 785 + if (WARN(!name, "malformed device_node %s\n", child->full_name)) 786 + continue; 787 + name++; 788 + if (strncmp(path, name, len) == 0 && (strlen(name) == len)) 789 + return child; 790 + } 791 + return NULL; 792 + } 793 + 792 794 /** 793 795 * of_find_node_by_path - Find a node matching a full OF path 794 - * @path: The full path to match 796 + * @path: Either the full path to match, or if the path does not 797 + * start with '/', the name of a property of the /aliases 798 + * node (an alias). In the case of an alias, the node 799 + * matching the alias' value will be returned. 800 + * 801 + * Valid paths: 802 + * /foo/bar Full path 803 + * foo Valid alias 804 + * foo/bar Valid alias + relative path 795 805 * 796 806 * Returns a node pointer with refcount incremented, use 797 807 * of_node_put() on it when done. 798 808 */ 799 809 struct device_node *of_find_node_by_path(const char *path) 800 810 { 801 - struct device_node *np = of_allnodes; 811 + struct device_node *np = NULL; 812 + struct property *pp; 802 813 unsigned long flags; 803 814 815 + if (strcmp(path, "/") == 0) 816 + return of_node_get(of_allnodes); 817 + 818 + /* The path could begin with an alias */ 819 + if (*path != '/') { 820 + char *p = strchrnul(path, '/'); 821 + int len = p - path; 822 + 823 + /* of_aliases must not be NULL */ 824 + if (!of_aliases) 825 + return NULL; 826 + 827 + for_each_property_of_node(of_aliases, pp) { 828 + if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { 829 + np = of_find_node_by_path(pp->value); 830 + break; 831 + } 832 + } 833 + if (!np) 834 + return NULL; 835 + path = p; 836 + } 837 + 838 + /* Step down the tree matching path components */ 804 839 raw_spin_lock_irqsave(&devtree_lock, flags); 805 - for (; np; np = np->allnext) { 806 - if (np->full_name && (of_node_cmp(np->full_name, path) == 0) 807 - && of_node_get(np)) 808 - break; 840 + if (!np) 841 + np = of_node_get(of_allnodes); 842 + while (np && *path == '/') { 843 + path++; /* Increment past '/' delimiter */ 844 + np = __of_find_node_by_path(np, path); 845 + path = strchrnul(path, '/'); 809 846 } 810 847 raw_spin_unlock_irqrestore(&devtree_lock, flags); 811 848 return np; ··· 1873 1800 { 1874 1801 struct property **next, *oldprop; 1875 1802 unsigned long flags; 1876 - int rc, found = 0; 1803 + int rc; 1877 1804 1878 1805 rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop); 1879 1806 if (rc) ··· 1882 1809 if (!newprop->name) 1883 1810 return -EINVAL; 1884 1811 1885 - oldprop = of_find_property(np, newprop->name, NULL); 1886 - if (!oldprop) 1887 - return of_add_property(np, newprop); 1888 - 1889 1812 raw_spin_lock_irqsave(&devtree_lock, flags); 1890 1813 next = &np->properties; 1891 - while (*next) { 1814 + oldprop = __of_find_property(np, newprop->name, NULL); 1815 + if (!oldprop) { 1816 + /* add the new node */ 1817 + rc = __of_add_property(np, newprop); 1818 + } else while (*next) { 1819 + /* replace the node */ 1892 1820 if (*next == oldprop) { 1893 - /* found the node */ 1894 1821 newprop->next = oldprop->next; 1895 1822 *next = newprop; 1896 1823 oldprop->next = np->deadprops; 1897 1824 np->deadprops = oldprop; 1898 - found = 1; 1899 1825 break; 1900 1826 } 1901 1827 next = &(*next)->next; 1902 1828 } 1903 1829 raw_spin_unlock_irqrestore(&devtree_lock, flags); 1904 - if (!found) 1905 - return -ENODEV; 1830 + if (rc) 1831 + return rc; 1906 1832 1907 1833 /* At early boot, bail out and defer setup to of_init() */ 1908 1834 if (!of_kset) 1909 - return found ? 0 : -ENODEV; 1835 + return 0; 1910 1836 1911 1837 /* Update the sysfs attribute */ 1912 - sysfs_remove_bin_file(&np->kobj, &oldprop->attr); 1838 + if (oldprop) 1839 + sysfs_remove_bin_file(&np->kobj, &oldprop->attr); 1913 1840 __of_add_property_sysfs(np, newprop); 1914 1841 1915 1842 return 0;
+192 -256
drivers/of/fdt.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/initrd.h> 14 14 #include <linux/memblock.h> 15 - #include <linux/module.h> 16 15 #include <linux/of.h> 17 16 #include <linux/of_fdt.h> 18 17 #include <linux/of_reserved_mem.h> ··· 19 20 #include <linux/string.h> 20 21 #include <linux/errno.h> 21 22 #include <linux/slab.h> 23 + #include <linux/libfdt.h> 24 + #include <linux/debugfs.h> 25 + #include <linux/serial_core.h> 22 26 23 27 #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ 24 - #ifdef CONFIG_PPC 25 - #include <asm/machdep.h> 26 - #endif /* CONFIG_PPC */ 27 - 28 28 #include <asm/page.h> 29 - 30 - char *of_fdt_get_string(struct boot_param_header *blob, u32 offset) 31 - { 32 - return ((char *)blob) + 33 - be32_to_cpu(blob->off_dt_strings) + offset; 34 - } 35 - 36 - /** 37 - * of_fdt_get_property - Given a node in the given flat blob, return 38 - * the property ptr 39 - */ 40 - void *of_fdt_get_property(struct boot_param_header *blob, 41 - unsigned long node, const char *name, 42 - unsigned long *size) 43 - { 44 - unsigned long p = node; 45 - 46 - do { 47 - u32 tag = be32_to_cpup((__be32 *)p); 48 - u32 sz, noff; 49 - const char *nstr; 50 - 51 - p += 4; 52 - if (tag == OF_DT_NOP) 53 - continue; 54 - if (tag != OF_DT_PROP) 55 - return NULL; 56 - 57 - sz = be32_to_cpup((__be32 *)p); 58 - noff = be32_to_cpup((__be32 *)(p + 4)); 59 - p += 8; 60 - if (be32_to_cpu(blob->version) < 0x10) 61 - p = ALIGN(p, sz >= 8 ? 8 : 4); 62 - 63 - nstr = of_fdt_get_string(blob, noff); 64 - if (nstr == NULL) { 65 - pr_warning("Can't find property index name !\n"); 66 - return NULL; 67 - } 68 - if (strcmp(name, nstr) == 0) { 69 - if (size) 70 - *size = sz; 71 - return (void *)p; 72 - } 73 - p += sz; 74 - p = ALIGN(p, 4); 75 - } while (1); 76 - } 77 29 78 30 /** 79 31 * of_fdt_is_compatible - Return true if given node from the given blob has ··· 36 86 * On match, returns a non-zero value with smaller values returned for more 37 87 * specific compatible values. 38 88 */ 39 - int of_fdt_is_compatible(struct boot_param_header *blob, 89 + int of_fdt_is_compatible(const void *blob, 40 90 unsigned long node, const char *compat) 41 91 { 42 92 const char *cp; 43 - unsigned long cplen, l, score = 0; 93 + int cplen; 94 + unsigned long l, score = 0; 44 95 45 - cp = of_fdt_get_property(blob, node, "compatible", &cplen); 96 + cp = fdt_getprop(blob, node, "compatible", &cplen); 46 97 if (cp == NULL) 47 98 return 0; 48 99 while (cplen > 0) { ··· 61 110 /** 62 111 * of_fdt_match - Return true if node matches a list of compatible values 63 112 */ 64 - int of_fdt_match(struct boot_param_header *blob, unsigned long node, 113 + int of_fdt_match(const void *blob, unsigned long node, 65 114 const char *const *compat) 66 115 { 67 116 unsigned int tmp, score = 0; ··· 100 149 * @allnextpp: pointer to ->allnext from last allocated device_node 101 150 * @fpsize: Size of the node path up at the current depth. 102 151 */ 103 - static void * unflatten_dt_node(struct boot_param_header *blob, 152 + static void * unflatten_dt_node(void *blob, 104 153 void *mem, 105 - void **p, 154 + int *poffset, 106 155 struct device_node *dad, 107 156 struct device_node ***allnextpp, 108 157 unsigned long fpsize) 109 158 { 159 + const __be32 *p; 110 160 struct device_node *np; 111 161 struct property *pp, **prev_pp = NULL; 112 - char *pathp; 113 - u32 tag; 162 + const char *pathp; 114 163 unsigned int l, allocl; 164 + static int depth = 0; 165 + int old_depth; 166 + int offset; 115 167 int has_name = 0; 116 168 int new_format = 0; 117 169 118 - tag = be32_to_cpup(*p); 119 - if (tag != OF_DT_BEGIN_NODE) { 120 - pr_err("Weird tag at start of node: %x\n", tag); 170 + pathp = fdt_get_name(blob, *poffset, &l); 171 + if (!pathp) 121 172 return mem; 122 - } 123 - *p += 4; 124 - pathp = *p; 125 - l = allocl = strlen(pathp) + 1; 126 - *p = PTR_ALIGN(*p + l, 4); 173 + 174 + allocl = l++; 127 175 128 176 /* version 0x10 has a more compact unit name here instead of the full 129 177 * path. we accumulate the full path size using "fpsize", we'll rebuild ··· 140 190 fpsize = 1; 141 191 allocl = 2; 142 192 l = 1; 143 - *pathp = '\0'; 193 + pathp = ""; 144 194 } else { 145 195 /* account for '/' and path size minus terminal 0 146 196 * already in 'l' ··· 187 237 } 188 238 } 189 239 /* process properties */ 190 - while (1) { 191 - u32 sz, noff; 192 - char *pname; 240 + for (offset = fdt_first_property_offset(blob, *poffset); 241 + (offset >= 0); 242 + (offset = fdt_next_property_offset(blob, offset))) { 243 + const char *pname; 244 + u32 sz; 193 245 194 - tag = be32_to_cpup(*p); 195 - if (tag == OF_DT_NOP) { 196 - *p += 4; 197 - continue; 198 - } 199 - if (tag != OF_DT_PROP) 246 + if (!(p = fdt_getprop_by_offset(blob, offset, &pname, &sz))) { 247 + offset = -FDT_ERR_INTERNAL; 200 248 break; 201 - *p += 4; 202 - sz = be32_to_cpup(*p); 203 - noff = be32_to_cpup(*p + 4); 204 - *p += 8; 205 - if (be32_to_cpu(blob->version) < 0x10) 206 - *p = PTR_ALIGN(*p, sz >= 8 ? 8 : 4); 249 + } 207 250 208 - pname = of_fdt_get_string(blob, noff); 209 251 if (pname == NULL) { 210 252 pr_info("Can't find property name in list !\n"); 211 253 break; 212 254 } 213 255 if (strcmp(pname, "name") == 0) 214 256 has_name = 1; 215 - l = strlen(pname) + 1; 216 257 pp = unflatten_dt_alloc(&mem, sizeof(struct property), 217 258 __alignof__(struct property)); 218 259 if (allnextpp) { ··· 215 274 if ((strcmp(pname, "phandle") == 0) || 216 275 (strcmp(pname, "linux,phandle") == 0)) { 217 276 if (np->phandle == 0) 218 - np->phandle = be32_to_cpup((__be32*)*p); 277 + np->phandle = be32_to_cpup(p); 219 278 } 220 279 /* And we process the "ibm,phandle" property 221 280 * used in pSeries dynamic device tree 222 281 * stuff */ 223 282 if (strcmp(pname, "ibm,phandle") == 0) 224 - np->phandle = be32_to_cpup((__be32 *)*p); 225 - pp->name = pname; 283 + np->phandle = be32_to_cpup(p); 284 + pp->name = (char *)pname; 226 285 pp->length = sz; 227 - pp->value = *p; 286 + pp->value = (__be32 *)p; 228 287 *prev_pp = pp; 229 288 prev_pp = &pp->next; 230 289 } 231 - *p = PTR_ALIGN((*p) + sz, 4); 232 290 } 233 291 /* with version 0x10 we may not have the name property, recreate 234 292 * it here from the unit name if absent 235 293 */ 236 294 if (!has_name) { 237 - char *p1 = pathp, *ps = pathp, *pa = NULL; 295 + const char *p1 = pathp, *ps = pathp, *pa = NULL; 238 296 int sz; 239 297 240 298 while (*p1) { ··· 270 330 if (!np->type) 271 331 np->type = "<NULL>"; 272 332 } 273 - while (tag == OF_DT_BEGIN_NODE || tag == OF_DT_NOP) { 274 - if (tag == OF_DT_NOP) 275 - *p += 4; 276 - else 277 - mem = unflatten_dt_node(blob, mem, p, np, allnextpp, 278 - fpsize); 279 - tag = be32_to_cpup(*p); 280 - } 281 - if (tag != OF_DT_END_NODE) { 282 - pr_err("Weird tag at end of node: %x\n", tag); 283 - return mem; 284 - } 285 - *p += 4; 333 + 334 + old_depth = depth; 335 + *poffset = fdt_next_node(blob, *poffset, &depth); 336 + if (depth < 0) 337 + depth = 0; 338 + while (*poffset > 0 && depth > old_depth) 339 + mem = unflatten_dt_node(blob, mem, poffset, np, allnextpp, 340 + fpsize); 341 + 342 + if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND) 343 + pr_err("unflatten: error %d processing FDT\n", *poffset); 344 + 286 345 return mem; 287 346 } 288 347 ··· 297 358 * @dt_alloc: An allocator that provides a virtual address to memory 298 359 * for the resulting tree 299 360 */ 300 - static void __unflatten_device_tree(struct boot_param_header *blob, 361 + static void __unflatten_device_tree(void *blob, 301 362 struct device_node **mynodes, 302 363 void * (*dt_alloc)(u64 size, u64 align)) 303 364 { 304 365 unsigned long size; 305 - void *start, *mem; 366 + int start; 367 + void *mem; 306 368 struct device_node **allnextp = mynodes; 307 369 308 370 pr_debug(" -> unflatten_device_tree()\n"); ··· 314 374 } 315 375 316 376 pr_debug("Unflattening device tree:\n"); 317 - pr_debug("magic: %08x\n", be32_to_cpu(blob->magic)); 318 - pr_debug("size: %08x\n", be32_to_cpu(blob->totalsize)); 319 - pr_debug("version: %08x\n", be32_to_cpu(blob->version)); 377 + pr_debug("magic: %08x\n", fdt_magic(blob)); 378 + pr_debug("size: %08x\n", fdt_totalsize(blob)); 379 + pr_debug("version: %08x\n", fdt_version(blob)); 320 380 321 - if (be32_to_cpu(blob->magic) != OF_DT_HEADER) { 381 + if (fdt_check_header(blob)) { 322 382 pr_err("Invalid device tree blob header\n"); 323 383 return; 324 384 } 325 385 326 386 /* First pass, scan for size */ 327 - start = ((void *)blob) + be32_to_cpu(blob->off_dt_struct); 328 - size = (unsigned long)unflatten_dt_node(blob, 0, &start, NULL, NULL, 0); 387 + start = 0; 388 + size = (unsigned long)unflatten_dt_node(blob, NULL, &start, NULL, NULL, 0); 329 389 size = ALIGN(size, 4); 330 390 331 391 pr_debug(" size is %lx, allocating...\n", size); ··· 339 399 pr_debug(" unflattening %p...\n", mem); 340 400 341 401 /* Second pass, do actual unflattening */ 342 - start = ((void *)blob) + be32_to_cpu(blob->off_dt_struct); 402 + start = 0; 343 403 unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0); 344 - if (be32_to_cpup(start) != OF_DT_END) 345 - pr_warning("Weird tag at end of tree: %08x\n", be32_to_cpup(start)); 346 404 if (be32_to_cpup(mem + size) != 0xdeadbeef) 347 405 pr_warning("End of tree marker overwritten: %08x\n", 348 406 be32_to_cpup(mem + size)); ··· 365 427 void of_fdt_unflatten_tree(unsigned long *blob, 366 428 struct device_node **mynodes) 367 429 { 368 - struct boot_param_header *device_tree = 369 - (struct boot_param_header *)blob; 370 - __unflatten_device_tree(device_tree, mynodes, &kernel_tree_alloc); 430 + __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); 371 431 } 372 432 EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); 373 433 ··· 373 437 int __initdata dt_root_addr_cells; 374 438 int __initdata dt_root_size_cells; 375 439 376 - struct boot_param_header *initial_boot_params; 440 + void *initial_boot_params; 377 441 378 442 #ifdef CONFIG_OF_EARLY_FLATTREE 379 443 ··· 385 449 { 386 450 int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); 387 451 phys_addr_t base, size; 388 - unsigned long len; 389 - __be32 *prop; 452 + int len; 453 + const __be32 *prop; 390 454 int nomap, first = 1; 391 455 392 456 prop = of_get_flat_dt_prop(node, "reg", &len); ··· 429 493 */ 430 494 static int __init __reserved_mem_check_root(unsigned long node) 431 495 { 432 - __be32 *prop; 496 + const __be32 *prop; 433 497 434 498 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); 435 499 if (!prop || be32_to_cpup(prop) != dt_root_size_cells) ··· 493 557 */ 494 558 void __init early_init_fdt_scan_reserved_mem(void) 495 559 { 560 + int n; 561 + u64 base, size; 562 + 496 563 if (!initial_boot_params) 497 564 return; 565 + 566 + /* Reserve the dtb region */ 567 + early_init_dt_reserve_memory_arch(__pa(initial_boot_params), 568 + fdt_totalsize(initial_boot_params), 569 + 0); 570 + 571 + /* Process header /memreserve/ fields */ 572 + for (n = 0; ; n++) { 573 + fdt_get_mem_rsv(initial_boot_params, n, &base, &size); 574 + if (!size) 575 + break; 576 + early_init_dt_reserve_memory_arch(base, size, 0); 577 + } 498 578 499 579 of_scan_flat_dt(__fdt_scan_reserved_mem, NULL); 500 580 fdt_init_reserved_mem(); ··· 530 578 void *data), 531 579 void *data) 532 580 { 533 - unsigned long p = ((unsigned long)initial_boot_params) + 534 - be32_to_cpu(initial_boot_params->off_dt_struct); 535 - int rc = 0; 536 - int depth = -1; 581 + const void *blob = initial_boot_params; 582 + const char *pathp; 583 + int offset, rc = 0, depth = -1; 537 584 538 - do { 539 - u32 tag = be32_to_cpup((__be32 *)p); 540 - const char *pathp; 585 + for (offset = fdt_next_node(blob, -1, &depth); 586 + offset >= 0 && depth >= 0 && !rc; 587 + offset = fdt_next_node(blob, offset, &depth)) { 541 588 542 - p += 4; 543 - if (tag == OF_DT_END_NODE) { 544 - depth--; 545 - continue; 546 - } 547 - if (tag == OF_DT_NOP) 548 - continue; 549 - if (tag == OF_DT_END) 550 - break; 551 - if (tag == OF_DT_PROP) { 552 - u32 sz = be32_to_cpup((__be32 *)p); 553 - p += 8; 554 - if (be32_to_cpu(initial_boot_params->version) < 0x10) 555 - p = ALIGN(p, sz >= 8 ? 8 : 4); 556 - p += sz; 557 - p = ALIGN(p, 4); 558 - continue; 559 - } 560 - if (tag != OF_DT_BEGIN_NODE) { 561 - pr_err("Invalid tag %x in flat device tree!\n", tag); 562 - return -EINVAL; 563 - } 564 - depth++; 565 - pathp = (char *)p; 566 - p = ALIGN(p + strlen(pathp) + 1, 4); 589 + pathp = fdt_get_name(blob, offset, NULL); 567 590 if (*pathp == '/') 568 591 pathp = kbasename(pathp); 569 - rc = it(p, pathp, depth, data); 570 - if (rc != 0) 571 - break; 572 - } while (1); 573 - 592 + rc = it(offset, pathp, depth, data); 593 + } 574 594 return rc; 575 595 } 576 596 ··· 551 627 */ 552 628 unsigned long __init of_get_flat_dt_root(void) 553 629 { 554 - unsigned long p = ((unsigned long)initial_boot_params) + 555 - be32_to_cpu(initial_boot_params->off_dt_struct); 630 + return 0; 631 + } 556 632 557 - while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) 558 - p += 4; 559 - BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); 560 - p += 4; 561 - return ALIGN(p + strlen((char *)p) + 1, 4); 633 + /** 634 + * of_get_flat_dt_size - Return the total size of the FDT 635 + */ 636 + int __init of_get_flat_dt_size(void) 637 + { 638 + return fdt_totalsize(initial_boot_params); 562 639 } 563 640 564 641 /** ··· 568 643 * This function can be used within scan_flattened_dt callback to get 569 644 * access to properties 570 645 */ 571 - void *__init of_get_flat_dt_prop(unsigned long node, const char *name, 572 - unsigned long *size) 646 + const void *__init of_get_flat_dt_prop(unsigned long node, const char *name, 647 + int *size) 573 648 { 574 - return of_fdt_get_property(initial_boot_params, node, name, size); 649 + return fdt_getprop(initial_boot_params, node, name, size); 575 650 } 576 651 577 652 /** ··· 600 675 int (*iterator)(unsigned long node, const char *uname, int depth, void *data); 601 676 void *data; 602 677 }; 603 - 604 - /** 605 - * fdt_scan_node_by_path - iterator for of_scan_flat_dt_by_path function 606 - */ 607 - static int __init fdt_scan_node_by_path(unsigned long node, const char *uname, 608 - int depth, void *data) 609 - { 610 - struct fdt_scan_status *st = data; 611 - 612 - /* 613 - * if scan at the requested fdt node has been completed, 614 - * return -ENXIO to abort further scanning 615 - */ 616 - if (depth <= st->depth) 617 - return -ENXIO; 618 - 619 - /* requested fdt node has been found, so call iterator function */ 620 - if (st->found) 621 - return st->iterator(node, uname, depth, st->data); 622 - 623 - /* check if scanning automata is entering next level of fdt nodes */ 624 - if (depth == st->depth + 1 && 625 - strncmp(st->name, uname, st->namelen) == 0 && 626 - uname[st->namelen] == 0) { 627 - st->depth += 1; 628 - if (st->name[st->namelen] == 0) { 629 - st->found = 1; 630 - } else { 631 - const char *next = st->name + st->namelen + 1; 632 - st->name = next; 633 - st->namelen = strcspn(next, "/"); 634 - } 635 - return 0; 636 - } 637 - 638 - /* scan next fdt node */ 639 - return 0; 640 - } 641 - 642 - /** 643 - * of_scan_flat_dt_by_path - scan flattened tree blob and call callback on each 644 - * child of the given path. 645 - * @path: path to start searching for children 646 - * @it: callback function 647 - * @data: context data pointer 648 - * 649 - * This function is used to scan the flattened device-tree starting from the 650 - * node given by path. It is used to extract information (like reserved 651 - * memory), which is required on ealy boot before we can unflatten the tree. 652 - */ 653 - int __init of_scan_flat_dt_by_path(const char *path, 654 - int (*it)(unsigned long node, const char *name, int depth, void *data), 655 - void *data) 656 - { 657 - struct fdt_scan_status st = {path, 0, -1, 0, it, data}; 658 - int ret = 0; 659 - 660 - if (initial_boot_params) 661 - ret = of_scan_flat_dt(fdt_scan_node_by_path, &st); 662 - 663 - if (!st.found) 664 - return -ENOENT; 665 - else if (ret == -ENXIO) /* scan has been completed */ 666 - return 0; 667 - else 668 - return ret; 669 - } 670 678 671 679 const char * __init of_flat_dt_get_machine_name(void) 672 680 { ··· 640 782 } 641 783 if (!best_data) { 642 784 const char *prop; 643 - long size; 785 + int size; 644 786 645 787 pr_err("\n unrecognized device tree list:\n[ "); 646 788 ··· 669 811 static void __init early_init_dt_check_for_initrd(unsigned long node) 670 812 { 671 813 u64 start, end; 672 - unsigned long len; 673 - __be32 *prop; 814 + int len; 815 + const __be32 *prop; 674 816 675 817 pr_debug("Looking for initrd properties... "); 676 818 ··· 697 839 } 698 840 #endif /* CONFIG_BLK_DEV_INITRD */ 699 841 842 + #ifdef CONFIG_SERIAL_EARLYCON 843 + extern struct of_device_id __earlycon_of_table[]; 844 + 845 + int __init early_init_dt_scan_chosen_serial(void) 846 + { 847 + int offset; 848 + const char *p; 849 + int l; 850 + const struct of_device_id *match = __earlycon_of_table; 851 + const void *fdt = initial_boot_params; 852 + 853 + offset = fdt_path_offset(fdt, "/chosen"); 854 + if (offset < 0) 855 + offset = fdt_path_offset(fdt, "/chosen@0"); 856 + if (offset < 0) 857 + return -ENOENT; 858 + 859 + p = fdt_getprop(fdt, offset, "stdout-path", &l); 860 + if (!p) 861 + p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); 862 + if (!p || !l) 863 + return -ENOENT; 864 + 865 + /* Get the node specified by stdout-path */ 866 + offset = fdt_path_offset(fdt, p); 867 + if (offset < 0) 868 + return -ENODEV; 869 + 870 + while (match->compatible) { 871 + unsigned long addr; 872 + if (fdt_node_check_compatible(fdt, offset, match->compatible)) { 873 + match++; 874 + continue; 875 + } 876 + 877 + addr = fdt_translate_address(fdt, offset); 878 + if (!addr) 879 + return -ENXIO; 880 + 881 + of_setup_earlycon(addr, match->data); 882 + return 0; 883 + } 884 + return -ENODEV; 885 + } 886 + 887 + static int __init setup_of_earlycon(char *buf) 888 + { 889 + if (buf) 890 + return 0; 891 + 892 + return early_init_dt_scan_chosen_serial(); 893 + } 894 + early_param("earlycon", setup_of_earlycon); 895 + #endif 896 + 700 897 /** 701 898 * early_init_dt_scan_root - fetch the top level address and size cells 702 899 */ 703 900 int __init early_init_dt_scan_root(unsigned long node, const char *uname, 704 901 int depth, void *data) 705 902 { 706 - __be32 *prop; 903 + const __be32 *prop; 707 904 708 905 if (depth != 0) 709 906 return 0; ··· 780 867 return 1; 781 868 } 782 869 783 - u64 __init dt_mem_next_cell(int s, __be32 **cellp) 870 + u64 __init dt_mem_next_cell(int s, const __be32 **cellp) 784 871 { 785 - __be32 *p = *cellp; 872 + const __be32 *p = *cellp; 786 873 787 874 *cellp = p + s; 788 875 return of_read_number(p, s); ··· 794 881 int __init early_init_dt_scan_memory(unsigned long node, const char *uname, 795 882 int depth, void *data) 796 883 { 797 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 798 - __be32 *reg, *endp; 799 - unsigned long l; 884 + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); 885 + const __be32 *reg, *endp; 886 + int l; 800 887 801 888 /* We are scanning "memory" nodes only */ 802 889 if (type == NULL) { ··· 804 891 * The longtrail doesn't have a device_type on the 805 892 * /memory node, so look for the node called /memory@0. 806 893 */ 807 - if (depth != 1 || strcmp(uname, "memory@0") != 0) 894 + if (!IS_ENABLED(CONFIG_PPC32) || depth != 1 || strcmp(uname, "memory@0") != 0) 808 895 return 0; 809 896 } else if (strcmp(type, "memory") != 0) 810 897 return 0; ··· 817 904 818 905 endp = reg + (l / sizeof(__be32)); 819 906 820 - pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", 907 + pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n", 821 908 uname, l, reg[0], reg[1], reg[2], reg[3]); 822 909 823 910 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { ··· 840 927 int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, 841 928 int depth, void *data) 842 929 { 843 - unsigned long l; 844 - char *p; 930 + int l; 931 + const char *p; 845 932 846 933 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); 847 934 ··· 916 1003 int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, 917 1004 phys_addr_t size, bool nomap) 918 1005 { 919 - pr_err("Reserved memory not supported, ignoring range 0x%llx - 0x%llx%s\n", 920 - base, size, nomap ? " (nomap)" : ""); 1006 + pr_err("Reserved memory not supported, ignoring range 0x%pa - 0x%pa%s\n", 1007 + &base, &size, nomap ? " (nomap)" : ""); 921 1008 return -ENOSYS; 922 1009 } 923 1010 #endif ··· 931 1018 initial_boot_params = params; 932 1019 933 1020 /* check device tree validity */ 934 - if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) { 1021 + if (fdt_check_header(params)) { 935 1022 initial_boot_params = NULL; 936 1023 return false; 937 1024 } ··· 986 1073 return; 987 1074 } 988 1075 989 - size = __be32_to_cpu(initial_boot_params->totalsize); 1076 + size = fdt_totalsize(initial_boot_params); 990 1077 dt = early_init_dt_alloc_memory_arch(size, 991 - __alignof__(struct boot_param_header)); 1078 + roundup_pow_of_two(FDT_V17_SIZE)); 992 1079 993 1080 if (dt) { 994 1081 memcpy(dt, initial_boot_params, size); ··· 996 1083 } 997 1084 unflatten_device_tree(); 998 1085 } 1086 + 1087 + #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 1088 + static struct debugfs_blob_wrapper flat_dt_blob; 1089 + 1090 + static int __init of_flat_dt_debugfs_export_fdt(void) 1091 + { 1092 + struct dentry *d = debugfs_create_dir("device-tree", NULL); 1093 + 1094 + if (!d) 1095 + return -ENOENT; 1096 + 1097 + flat_dt_blob.data = initial_boot_params; 1098 + flat_dt_blob.size = fdt_totalsize(initial_boot_params); 1099 + 1100 + d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 1101 + d, &flat_dt_blob); 1102 + if (!d) 1103 + return -ENOENT; 1104 + 1105 + return 0; 1106 + } 1107 + module_init(of_flat_dt_debugfs_export_fdt); 1108 + #endif 999 1109 1000 1110 #endif /* CONFIG_OF_EARLY_FLATTREE */
+241
drivers/of/fdt_address.c
··· 1 + /* 2 + * FDT Address translation based on u-boot fdt_support.c which in turn was 3 + * based on the kernel unflattened DT address translation code. 4 + * 5 + * (C) Copyright 2007 6 + * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com 7 + * 8 + * Copyright 2010-2011 Freescale Semiconductor, Inc. 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License as published by 12 + * the Free Software Foundation; either version 2, or (at your option) 13 + * any later version. 14 + */ 15 + #include <linux/kernel.h> 16 + #include <linux/libfdt.h> 17 + #include <linux/of.h> 18 + #include <linux/of_fdt.h> 19 + #include <linux/sizes.h> 20 + 21 + /* Max address size we deal with */ 22 + #define OF_MAX_ADDR_CELLS 4 23 + #define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ 24 + (ns) > 0) 25 + 26 + /* Debug utility */ 27 + #ifdef DEBUG 28 + static void __init of_dump_addr(const char *s, const __be32 *addr, int na) 29 + { 30 + pr_debug("%s", s); 31 + while(na--) 32 + pr_cont(" %08x", *(addr++)); 33 + pr_debug("\n"); 34 + } 35 + #else 36 + static void __init of_dump_addr(const char *s, const __be32 *addr, int na) { } 37 + #endif 38 + 39 + /* Callbacks for bus specific translators */ 40 + struct of_bus { 41 + void (*count_cells)(const void *blob, int parentoffset, 42 + int *addrc, int *sizec); 43 + u64 (*map)(__be32 *addr, const __be32 *range, 44 + int na, int ns, int pna); 45 + int (*translate)(__be32 *addr, u64 offset, int na); 46 + }; 47 + 48 + /* Default translator (generic bus) */ 49 + static void __init fdt_bus_default_count_cells(const void *blob, int parentoffset, 50 + int *addrc, int *sizec) 51 + { 52 + const __be32 *prop; 53 + 54 + if (addrc) { 55 + prop = fdt_getprop(blob, parentoffset, "#address-cells", NULL); 56 + if (prop) 57 + *addrc = be32_to_cpup(prop); 58 + else 59 + *addrc = dt_root_addr_cells; 60 + } 61 + 62 + if (sizec) { 63 + prop = fdt_getprop(blob, parentoffset, "#size-cells", NULL); 64 + if (prop) 65 + *sizec = be32_to_cpup(prop); 66 + else 67 + *sizec = dt_root_size_cells; 68 + } 69 + } 70 + 71 + static u64 __init fdt_bus_default_map(__be32 *addr, const __be32 *range, 72 + int na, int ns, int pna) 73 + { 74 + u64 cp, s, da; 75 + 76 + cp = of_read_number(range, na); 77 + s = of_read_number(range + na + pna, ns); 78 + da = of_read_number(addr, na); 79 + 80 + pr_debug("FDT: default map, cp=%llx, s=%llx, da=%llx\n", 81 + cp, s, da); 82 + 83 + if (da < cp || da >= (cp + s)) 84 + return OF_BAD_ADDR; 85 + return da - cp; 86 + } 87 + 88 + static int __init fdt_bus_default_translate(__be32 *addr, u64 offset, int na) 89 + { 90 + u64 a = of_read_number(addr, na); 91 + memset(addr, 0, na * 4); 92 + a += offset; 93 + if (na > 1) 94 + addr[na - 2] = cpu_to_fdt32(a >> 32); 95 + addr[na - 1] = cpu_to_fdt32(a & 0xffffffffu); 96 + 97 + return 0; 98 + } 99 + 100 + /* Array of bus specific translators */ 101 + static const struct of_bus of_busses[] __initconst = { 102 + /* Default */ 103 + { 104 + .count_cells = fdt_bus_default_count_cells, 105 + .map = fdt_bus_default_map, 106 + .translate = fdt_bus_default_translate, 107 + }, 108 + }; 109 + 110 + static int __init fdt_translate_one(const void *blob, int parent, 111 + const struct of_bus *bus, 112 + const struct of_bus *pbus, __be32 *addr, 113 + int na, int ns, int pna, const char *rprop) 114 + { 115 + const __be32 *ranges; 116 + int rlen; 117 + int rone; 118 + u64 offset = OF_BAD_ADDR; 119 + 120 + ranges = fdt_getprop(blob, parent, rprop, &rlen); 121 + if (!ranges) 122 + return 1; 123 + if (rlen == 0) { 124 + offset = of_read_number(addr, na); 125 + memset(addr, 0, pna * 4); 126 + pr_debug("FDT: empty ranges, 1:1 translation\n"); 127 + goto finish; 128 + } 129 + 130 + pr_debug("FDT: walking ranges...\n"); 131 + 132 + /* Now walk through the ranges */ 133 + rlen /= 4; 134 + rone = na + pna + ns; 135 + for (; rlen >= rone; rlen -= rone, ranges += rone) { 136 + offset = bus->map(addr, ranges, na, ns, pna); 137 + if (offset != OF_BAD_ADDR) 138 + break; 139 + } 140 + if (offset == OF_BAD_ADDR) { 141 + pr_debug("FDT: not found !\n"); 142 + return 1; 143 + } 144 + memcpy(addr, ranges + na, 4 * pna); 145 + 146 + finish: 147 + of_dump_addr("FDT: parent translation for:", addr, pna); 148 + pr_debug("FDT: with offset: %llx\n", offset); 149 + 150 + /* Translate it into parent bus space */ 151 + return pbus->translate(addr, offset, pna); 152 + } 153 + 154 + /* 155 + * Translate an address from the device-tree into a CPU physical address, 156 + * this walks up the tree and applies the various bus mappings on the 157 + * way. 158 + * 159 + * Note: We consider that crossing any level with #size-cells == 0 to mean 160 + * that translation is impossible (that is we are not dealing with a value 161 + * that can be mapped to a cpu physical address). This is not really specified 162 + * that way, but this is traditionally the way IBM at least do things 163 + */ 164 + u64 __init fdt_translate_address(const void *blob, int node_offset) 165 + { 166 + int parent, len; 167 + const struct of_bus *bus, *pbus; 168 + const __be32 *reg; 169 + __be32 addr[OF_MAX_ADDR_CELLS]; 170 + int na, ns, pna, pns; 171 + u64 result = OF_BAD_ADDR; 172 + 173 + pr_debug("FDT: ** translation for device %s **\n", 174 + fdt_get_name(blob, node_offset, NULL)); 175 + 176 + reg = fdt_getprop(blob, node_offset, "reg", &len); 177 + if (!reg) { 178 + pr_err("FDT: warning: device tree node '%s' has no address.\n", 179 + fdt_get_name(blob, node_offset, NULL)); 180 + goto bail; 181 + } 182 + 183 + /* Get parent & match bus type */ 184 + parent = fdt_parent_offset(blob, node_offset); 185 + if (parent < 0) 186 + goto bail; 187 + bus = &of_busses[0]; 188 + 189 + /* Cound address cells & copy address locally */ 190 + bus->count_cells(blob, parent, &na, &ns); 191 + if (!OF_CHECK_COUNTS(na, ns)) { 192 + pr_err("FDT: Bad cell count for %s\n", 193 + fdt_get_name(blob, node_offset, NULL)); 194 + goto bail; 195 + } 196 + memcpy(addr, reg, na * 4); 197 + 198 + pr_debug("FDT: bus (na=%d, ns=%d) on %s\n", 199 + na, ns, fdt_get_name(blob, parent, NULL)); 200 + of_dump_addr("OF: translating address:", addr, na); 201 + 202 + /* Translate */ 203 + for (;;) { 204 + /* Switch to parent bus */ 205 + node_offset = parent; 206 + parent = fdt_parent_offset(blob, node_offset); 207 + 208 + /* If root, we have finished */ 209 + if (parent < 0) { 210 + pr_debug("FDT: reached root node\n"); 211 + result = of_read_number(addr, na); 212 + break; 213 + } 214 + 215 + /* Get new parent bus and counts */ 216 + pbus = &of_busses[0]; 217 + pbus->count_cells(blob, parent, &pna, &pns); 218 + if (!OF_CHECK_COUNTS(pna, pns)) { 219 + pr_err("FDT: Bad cell count for %s\n", 220 + fdt_get_name(blob, node_offset, NULL)); 221 + break; 222 + } 223 + 224 + pr_debug("FDT: parent bus (na=%d, ns=%d) on %s\n", 225 + pna, pns, fdt_get_name(blob, parent, NULL)); 226 + 227 + /* Apply bus translation */ 228 + if (fdt_translate_one(blob, node_offset, bus, pbus, 229 + addr, na, ns, pna, "ranges")) 230 + break; 231 + 232 + /* Complete the move up one level */ 233 + na = pna; 234 + ns = pns; 235 + bus = pbus; 236 + 237 + of_dump_addr("FDT: one level translation:", addr, na); 238 + } 239 + bail: 240 + return result; 241 + }
+22
drivers/of/irq.c
··· 406 406 } 407 407 408 408 /** 409 + * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number 410 + * @dev: pointer to device tree node 411 + * @name: irq name 412 + * 413 + * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain 414 + * is not yet created, or error code in case of any other failure. 415 + */ 416 + int of_irq_get_byname(struct device_node *dev, const char *name) 417 + { 418 + int index; 419 + 420 + if (unlikely(!name)) 421 + return -EINVAL; 422 + 423 + index = of_property_match_string(dev, "interrupt-names", name); 424 + if (index < 0) 425 + return index; 426 + 427 + return of_irq_get(dev, index); 428 + } 429 + 430 + /** 409 431 * of_irq_count - Count the number of IRQs a node uses 410 432 * @dev: pointer to device tree node 411 433 */
+2 -6
drivers/of/of_pci_irq.c
··· 18 18 { 19 19 struct device_node *dn, *ppnode; 20 20 struct pci_dev *ppdev; 21 - u32 lspec; 22 - __be32 lspec_be; 23 21 __be32 laddr[3]; 24 22 u8 pin; 25 23 int rc; ··· 44 46 return -ENODEV; 45 47 46 48 /* Now we walk up the PCI tree */ 47 - lspec = pin; 48 49 for (;;) { 49 50 /* Get the pci_dev of our parent */ 50 51 ppdev = pdev->bus->self; ··· 77 80 /* We can only get here if we hit a P2P bridge with no node, 78 81 * let's do standard swizzling and try again 79 82 */ 80 - lspec = pci_swizzle_interrupt_pin(pdev, lspec); 83 + pin = pci_swizzle_interrupt_pin(pdev, pin); 81 84 pdev = ppdev; 82 85 } 83 86 84 87 out_irq->np = ppnode; 85 88 out_irq->args_count = 1; 86 - out_irq->args[0] = lspec; 87 - lspec_be = cpu_to_be32(lspec); 89 + out_irq->args[0] = pin; 88 90 laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8)); 89 91 laddr[1] = laddr[2] = cpu_to_be32(0); 90 92 return of_irq_parse_raw(laddr, out_irq);
+3 -3
drivers/of/of_reserved_mem.c
··· 95 95 int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); 96 96 phys_addr_t start = 0, end = 0; 97 97 phys_addr_t base = 0, align = 0, size; 98 - unsigned long len; 99 - __be32 *prop; 98 + int len; 99 + const __be32 *prop; 100 100 int nomap; 101 101 int ret; 102 102 ··· 188 188 if (!of_flat_dt_is_compatible(rmem->fdt_node, compat)) 189 189 continue; 190 190 191 - if (initfn(rmem, rmem->fdt_node, rmem->name) == 0) { 191 + if (initfn(rmem) == 0) { 192 192 pr_info("Reserved memory: initialized node %s, compatible id %s\n", 193 193 rmem->name, compat); 194 194 return 0;
+20 -56
drivers/of/platform.c
··· 51 51 } 52 52 EXPORT_SYMBOL(of_find_device_by_node); 53 53 54 - #if defined(CONFIG_PPC_DCR) 55 - #include <asm/dcr.h> 56 - #endif 57 - 58 54 #ifdef CONFIG_OF_ADDRESS 59 55 /* 60 56 * The following routines scan a subtree and registers a device for ··· 64 68 * of_device_make_bus_id - Use the device node data to assign a unique name 65 69 * @dev: pointer to device structure that is linked to a device tree node 66 70 * 67 - * This routine will first try using either the dcr-reg or the reg property 68 - * value to derive a unique name. As a last resort it will use the node 69 - * name followed by a unique number. 71 + * This routine will first try using the translated bus address to 72 + * derive a unique name. If it cannot, then it will prepend names from 73 + * parent nodes until a unique name can be derived. 70 74 */ 71 75 void of_device_make_bus_id(struct device *dev) 72 76 { 73 - static atomic_t bus_no_reg_magic; 74 77 struct device_node *node = dev->of_node; 75 78 const __be32 *reg; 76 79 u64 addr; 77 - const __be32 *addrp; 78 - int magic; 79 80 80 - #ifdef CONFIG_PPC_DCR 81 - /* 82 - * If it's a DCR based device, use 'd' for native DCRs 83 - * and 'D' for MMIO DCRs. 84 - */ 85 - reg = of_get_property(node, "dcr-reg", NULL); 86 - if (reg) { 87 - #ifdef CONFIG_PPC_DCR_NATIVE 88 - dev_set_name(dev, "d%x.%s", *reg, node->name); 89 - #else /* CONFIG_PPC_DCR_NATIVE */ 90 - u64 addr = of_translate_dcr_address(node, *reg, NULL); 91 - if (addr != OF_BAD_ADDR) { 92 - dev_set_name(dev, "D%llx.%s", 93 - (unsigned long long)addr, node->name); 81 + /* Construct the name, using parent nodes if necessary to ensure uniqueness */ 82 + while (node->parent) { 83 + /* 84 + * If the address can be translated, then that is as much 85 + * uniqueness as we need. Make it the first component and return 86 + */ 87 + reg = of_get_property(node, "reg", NULL); 88 + if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) { 89 + dev_set_name(dev, dev_name(dev) ? "%llx.%s:%s" : "%llx.%s", 90 + (unsigned long long)addr, node->name, 91 + dev_name(dev)); 94 92 return; 95 93 } 96 - #endif /* !CONFIG_PPC_DCR_NATIVE */ 97 - } 98 - #endif /* CONFIG_PPC_DCR */ 99 94 100 - /* 101 - * For MMIO, get the physical address 102 - */ 103 - reg = of_get_property(node, "reg", NULL); 104 - if (reg) { 105 - if (of_can_translate_address(node)) { 106 - addr = of_translate_address(node, reg); 107 - } else { 108 - addrp = of_get_address(node, 0, NULL, NULL); 109 - if (addrp) 110 - addr = of_read_number(addrp, 1); 111 - else 112 - addr = OF_BAD_ADDR; 113 - } 114 - if (addr != OF_BAD_ADDR) { 115 - dev_set_name(dev, "%llx.%s", 116 - (unsigned long long)addr, node->name); 117 - return; 118 - } 95 + /* format arguments only used if dev_name() resolves to NULL */ 96 + dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s", 97 + strrchr(node->full_name, '/') + 1, dev_name(dev)); 98 + node = node->parent; 119 99 } 120 - 121 - /* 122 - * No BusID, use the node name and add a globally incremented 123 - * counter (and pray...) 124 - */ 125 - magic = atomic_add_return(1, &bus_no_reg_magic); 126 - dev_set_name(dev, "%s.%d", node->name, magic - 1); 127 100 } 128 101 129 102 /** ··· 114 149 return NULL; 115 150 116 151 /* count the io and irq resources */ 117 - if (of_can_translate_address(np)) 118 - while (of_address_to_resource(np, num_reg, &temp_res) == 0) 119 - num_reg++; 152 + while (of_address_to_resource(np, num_reg, &temp_res) == 0) 153 + num_reg++; 120 154 num_irq = of_irq_count(np); 121 155 122 156 /* Populate the resource table */
+70 -10
drivers/of/selftest.c
··· 31 31 } \ 32 32 } 33 33 34 + static void __init of_selftest_find_node_by_name(void) 35 + { 36 + struct device_node *np; 37 + 38 + np = of_find_node_by_path("/testcase-data"); 39 + selftest(np && !strcmp("/testcase-data", np->full_name), 40 + "find /testcase-data failed\n"); 41 + of_node_put(np); 42 + 43 + /* Test if trailing '/' works */ 44 + np = of_find_node_by_path("/testcase-data/"); 45 + selftest(!np, "trailing '/' on /testcase-data/ should fail\n"); 46 + 47 + np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); 48 + selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 49 + "find /testcase-data/phandle-tests/consumer-a failed\n"); 50 + of_node_put(np); 51 + 52 + np = of_find_node_by_path("testcase-alias"); 53 + selftest(np && !strcmp("/testcase-data", np->full_name), 54 + "find testcase-alias failed\n"); 55 + of_node_put(np); 56 + 57 + /* Test if trailing '/' works on aliases */ 58 + np = of_find_node_by_path("testcase-alias/"); 59 + selftest(!np, "trailing '/' on testcase-alias/ should fail\n"); 60 + 61 + np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); 62 + selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), 63 + "find testcase-alias/phandle-tests/consumer-a failed\n"); 64 + of_node_put(np); 65 + 66 + np = of_find_node_by_path("/testcase-data/missing-path"); 67 + selftest(!np, "non-existent path returned node %s\n", np->full_name); 68 + of_node_put(np); 69 + 70 + np = of_find_node_by_path("missing-alias"); 71 + selftest(!np, "non-existent alias returned node %s\n", np->full_name); 72 + of_node_put(np); 73 + 74 + np = of_find_node_by_path("testcase-alias/missing-path"); 75 + selftest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); 76 + of_node_put(np); 77 + } 78 + 34 79 static void __init of_selftest_dynamic(void) 35 80 { 36 81 struct device_node *np; ··· 476 431 static void __init of_selftest_platform_populate(void) 477 432 { 478 433 int irq; 479 - struct device_node *np; 434 + struct device_node *np, *child; 480 435 struct platform_device *pdev; 436 + struct of_device_id match[] = { 437 + { .compatible = "test-device", }, 438 + {} 439 + }; 481 440 482 441 np = of_find_node_by_path("/testcase-data"); 483 442 of_platform_populate(np, of_default_bus_match_table, NULL, NULL); ··· 489 440 /* Test that a missing irq domain returns -EPROBE_DEFER */ 490 441 np = of_find_node_by_path("/testcase-data/testcase-device1"); 491 442 pdev = of_find_device_by_node(np); 492 - if (!pdev) 493 - selftest(0, "device 1 creation failed\n"); 443 + selftest(pdev, "device 1 creation failed\n"); 444 + 494 445 irq = platform_get_irq(pdev, 0); 495 - if (irq != -EPROBE_DEFER) 496 - selftest(0, "device deferred probe failed - %d\n", irq); 446 + selftest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq); 497 447 498 448 /* Test that a parsing failure does not return -EPROBE_DEFER */ 499 449 np = of_find_node_by_path("/testcase-data/testcase-device2"); 500 450 pdev = of_find_device_by_node(np); 501 - if (!pdev) 502 - selftest(0, "device 2 creation failed\n"); 451 + selftest(pdev, "device 2 creation failed\n"); 503 452 irq = platform_get_irq(pdev, 0); 504 - if (irq >= 0 || irq == -EPROBE_DEFER) 505 - selftest(0, "device parsing error failed - %d\n", irq); 453 + selftest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq); 506 454 507 - selftest(1, "passed"); 455 + np = of_find_node_by_path("/testcase-data/platform-tests"); 456 + if (!np) { 457 + pr_err("No testcase data in device tree\n"); 458 + return; 459 + } 460 + 461 + for_each_child_of_node(np, child) { 462 + struct device_node *grandchild; 463 + of_platform_populate(child, match, NULL, NULL); 464 + for_each_child_of_node(child, grandchild) 465 + selftest(of_find_device_by_node(grandchild), 466 + "Could not create device for node '%s'\n", 467 + grandchild->name); 468 + } 508 469 } 509 470 510 471 static int __init of_selftest(void) ··· 529 470 of_node_put(np); 530 471 531 472 pr_info("start of selftest - you will see error messages\n"); 473 + of_selftest_find_node_by_name(); 532 474 of_selftest_dynamic(); 533 475 of_selftest_parse_phandle_with_args(); 534 476 of_selftest_property_match_string();
+1
drivers/of/testcase-data/testcases.dtsi
··· 1 1 #include "tests-phandle.dtsi" 2 2 #include "tests-interrupts.dtsi" 3 3 #include "tests-match.dtsi" 4 + #include "tests-platform.dtsi"
+5 -1
drivers/of/testcase-data/tests-phandle.dtsi
··· 1 1 2 2 / { 3 - testcase-data { 3 + aliases { 4 + testcase-alias = &testcase; 5 + }; 6 + 7 + testcase: testcase-data { 4 8 security-password = "password"; 5 9 duplicate-name = "duplicate"; 6 10 duplicate-name { };
+35
drivers/of/testcase-data/tests-platform.dtsi
··· 1 + 2 + / { 3 + testcase-data { 4 + platform-tests { 5 + #address-cells = <1>; 6 + #size-cells = <0>; 7 + 8 + test-device@0 { 9 + compatible = "test-device"; 10 + reg = <0x0>; 11 + 12 + #address-cells = <1>; 13 + #size-cells = <0>; 14 + 15 + dev@100 { 16 + compatible = "test-sub-device"; 17 + reg = <0x100>; 18 + }; 19 + }; 20 + 21 + test-device@1 { 22 + compatible = "test-device"; 23 + reg = <0x1>; 24 + 25 + #address-cells = <1>; 26 + #size-cells = <0>; 27 + 28 + dev@100 { 29 + compatible = "test-sub-device"; 30 + reg = <0x100>; 31 + }; 32 + }; 33 + }; 34 + }; 35 + };
+1
drivers/tty/serial/amba-pl011.c
··· 2072 2072 return 0; 2073 2073 } 2074 2074 EARLYCON_DECLARE(pl011, pl011_early_console_setup); 2075 + OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup); 2075 2076 2076 2077 #else 2077 2078 #define AMBA_CONSOLE NULL
+28
drivers/tty/serial/earlycon.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/io.h> 17 17 #include <linux/serial_core.h> 18 + #include <linux/sizes.h> 19 + #include <linux/mod_devicetable.h> 18 20 19 21 #ifdef CONFIG_FIX_EARLYCON_MEM 20 22 #include <asm/fixmap.h> ··· 33 31 static struct earlycon_device early_console_dev = { 34 32 .con = &early_con, 35 33 }; 34 + 35 + static const struct of_device_id __earlycon_of_table_sentinel 36 + __used __section(__earlycon_of_table_end); 36 37 37 38 static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) 38 39 { ··· 143 138 return err; 144 139 if (!early_console_dev.con->write) 145 140 return -ENODEV; 141 + 142 + register_console(early_console_dev.con); 143 + return 0; 144 + } 145 + 146 + int __init of_setup_earlycon(unsigned long addr, 147 + int (*setup)(struct earlycon_device *, const char *)) 148 + { 149 + int err; 150 + struct uart_port *port = &early_console_dev.port; 151 + 152 + port->iotype = UPIO_MEM; 153 + port->mapbase = addr; 154 + port->uartclk = BASE_BAUD * 16; 155 + port->membase = earlycon_map(addr, SZ_4K); 156 + 157 + early_console_dev.con->data = &early_console_dev; 158 + err = setup(&early_console_dev, NULL); 159 + if (err < 0) 160 + return err; 161 + if (!early_console_dev.con->write) 162 + return -ENODEV; 163 + 146 164 147 165 register_console(early_console_dev.con); 148 166 return 0;
+16 -44
include/asm-generic/vmlinux.lds.h
··· 139 139 #define TRACE_SYSCALLS() 140 140 #endif 141 141 142 - #ifdef CONFIG_CLKSRC_OF 143 - #define CLKSRC_OF_TABLES() . = ALIGN(8); \ 144 - VMLINUX_SYMBOL(__clksrc_of_table) = .; \ 145 - *(__clksrc_of_table) \ 146 - *(__clksrc_of_table_end) 147 - #else 148 - #define CLKSRC_OF_TABLES() 149 - #endif 150 142 151 - #ifdef CONFIG_IRQCHIP 152 - #define IRQCHIP_OF_MATCH_TABLE() \ 143 + #define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name) 144 + #define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name) 145 + #define OF_TABLE(cfg, name) __OF_TABLE(config_enabled(cfg), name) 146 + #define _OF_TABLE_0(name) 147 + #define _OF_TABLE_1(name) \ 153 148 . = ALIGN(8); \ 154 - VMLINUX_SYMBOL(__irqchip_begin) = .; \ 155 - *(__irqchip_of_table) \ 156 - *(__irqchip_of_end) 157 - #else 158 - #define IRQCHIP_OF_MATCH_TABLE() 159 - #endif 149 + VMLINUX_SYMBOL(__##name##_of_table) = .; \ 150 + *(__##name##_of_table) \ 151 + *(__##name##_of_table_end) 160 152 161 - #ifdef CONFIG_COMMON_CLK 162 - #define CLK_OF_TABLES() . = ALIGN(8); \ 163 - VMLINUX_SYMBOL(__clk_of_table) = .; \ 164 - *(__clk_of_table) \ 165 - *(__clk_of_table_end) 166 - #else 167 - #define CLK_OF_TABLES() 168 - #endif 169 - 170 - #ifdef CONFIG_OF_RESERVED_MEM 171 - #define RESERVEDMEM_OF_TABLES() \ 172 - . = ALIGN(8); \ 173 - VMLINUX_SYMBOL(__reservedmem_of_table) = .; \ 174 - *(__reservedmem_of_table) \ 175 - *(__reservedmem_of_table_end) 176 - #else 177 - #define RESERVEDMEM_OF_TABLES() 178 - #endif 179 - 180 - #ifdef CONFIG_SMP 181 - #define CPU_METHOD_OF_TABLES() . = ALIGN(8); \ 182 - VMLINUX_SYMBOL(__cpu_method_of_table_begin) = .; \ 183 - *(__cpu_method_of_table) \ 184 - VMLINUX_SYMBOL(__cpu_method_of_table_end) = .; 185 - #else 186 - #define CPU_METHOD_OF_TABLES() 187 - #endif 153 + #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) 154 + #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) 155 + #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 156 + #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 157 + #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 158 + #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) 188 159 189 160 #define KERNEL_DTB() \ 190 161 STRUCT_ALIGN(); \ ··· 484 513 CLKSRC_OF_TABLES() \ 485 514 CPU_METHOD_OF_TABLES() \ 486 515 KERNEL_DTB() \ 487 - IRQCHIP_OF_MATCH_TABLE() 516 + IRQCHIP_OF_MATCH_TABLE() \ 517 + EARLYCON_OF_TABLES() 488 518 489 519 #define INIT_TEXT \ 490 520 *(.init.text) \
+1 -4
include/linux/clk-provider.h
··· 529 529 530 530 extern struct of_device_id __clk_of_table; 531 531 532 - #define CLK_OF_DECLARE(name, compat, fn) \ 533 - static const struct of_device_id __clk_of_table_##name \ 534 - __used __section(__clk_of_table) \ 535 - = { .compatible = compat, .data = fn }; 532 + #define CLK_OF_DECLARE(name, compat, fn) OF_DECLARE_1(clk, name, compat, fn) 536 533 537 534 #ifdef CONFIG_OF 538 535 int of_clk_add_provider(struct device_node *np,
+3 -13
include/linux/clocksource.h
··· 339 339 340 340 extern int clocksource_i8253_init(void); 341 341 342 - struct device_node; 343 - typedef void(*clocksource_of_init_fn)(struct device_node *); 342 + #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 343 + OF_DECLARE_1(clksrc, name, compat, fn) 344 + 344 345 #ifdef CONFIG_CLKSRC_OF 345 346 extern void clocksource_of_init(void); 346 - 347 - #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 348 - static const struct of_device_id __clksrc_of_table_##name \ 349 - __used __section(__clksrc_of_table) \ 350 - = { .compatible = compat, \ 351 - .data = (fn == (clocksource_of_init_fn)NULL) ? fn : fn } 352 347 #else 353 348 static inline void clocksource_of_init(void) {} 354 - #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 355 - static const struct of_device_id __clksrc_of_table_##name \ 356 - __attribute__((unused)) \ 357 - = { .compatible = compat, \ 358 - .data = (fn == (clocksource_of_init_fn)NULL) ? fn : fn } 359 349 #endif 360 350 361 351 #endif /* _LINUX_CLOCKSOURCE_H */
+22
include/linux/of.h
··· 764 764 return num; 765 765 } 766 766 767 + #ifdef CONFIG_OF 768 + #define _OF_DECLARE(table, name, compat, fn, fn_type) \ 769 + static const struct of_device_id __of_table_##name \ 770 + __used __section(__##table##_of_table) \ 771 + = { .compatible = compat, \ 772 + .data = (fn == (fn_type)NULL) ? fn : fn } 773 + #else 774 + #define _OF_DECLARE(table, name, compat, fn, fn_type) \ 775 + static const struct of_device_id __of_table_##name \ 776 + __attribute__((unused)) \ 777 + = { .compatible = compat, \ 778 + .data = (fn == (fn_type)NULL) ? fn : fn } 779 + #endif 780 + 781 + typedef int (*of_init_fn_2)(struct device_node *, struct device_node *); 782 + typedef void (*of_init_fn_1)(struct device_node *); 783 + 784 + #define OF_DECLARE_1(table, name, compat, fn) \ 785 + _OF_DECLARE(table, name, compat, fn, of_init_fn_1) 786 + #define OF_DECLARE_2(table, name, compat, fn) \ 787 + _OF_DECLARE(table, name, compat, fn, of_init_fn_2) 788 + 767 789 #endif /* _LINUX_OF_H */
-1
include/linux/of_address.h
··· 40 40 41 41 #ifdef CONFIG_OF_ADDRESS 42 42 extern u64 of_translate_address(struct device_node *np, const __be32 *addr); 43 - extern bool of_can_translate_address(struct device_node *dev); 44 43 extern int of_address_to_resource(struct device_node *dev, int index, 45 44 struct resource *r); 46 45 extern struct device_node *of_find_matching_node_by_address(
+14 -50
include/linux/of_fdt.h
··· 17 17 18 18 /* Definitions used by the flattened device tree */ 19 19 #define OF_DT_HEADER 0xd00dfeed /* marker */ 20 - #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ 21 - #define OF_DT_END_NODE 0x2 /* End node */ 22 - #define OF_DT_PROP 0x3 /* Property: name off, size, 23 - * content */ 24 - #define OF_DT_NOP 0x4 /* nop */ 25 - #define OF_DT_END 0x9 26 - 27 - #define OF_DT_VERSION 0x10 28 20 29 21 #ifndef __ASSEMBLY__ 30 - /* 31 - * This is what gets passed to the kernel by prom_init or kexec 32 - * 33 - * The dt struct contains the device tree structure, full pathes and 34 - * property contents. The dt strings contain a separate block with just 35 - * the strings for the property names, and is fully page aligned and 36 - * self contained in a page, so that it can be kept around by the kernel, 37 - * each property name appears only once in this page (cheap compression) 38 - * 39 - * the mem_rsvmap contains a map of reserved ranges of physical memory, 40 - * passing it here instead of in the device-tree itself greatly simplifies 41 - * the job of everybody. It's just a list of u64 pairs (base/size) that 42 - * ends when size is 0 43 - */ 44 - struct boot_param_header { 45 - __be32 magic; /* magic word OF_DT_HEADER */ 46 - __be32 totalsize; /* total size of DT block */ 47 - __be32 off_dt_struct; /* offset to structure */ 48 - __be32 off_dt_strings; /* offset to strings */ 49 - __be32 off_mem_rsvmap; /* offset to memory reserve map */ 50 - __be32 version; /* format version */ 51 - __be32 last_comp_version; /* last compatible version */ 52 - /* version 2 fields below */ 53 - __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ 54 - /* version 3 fields below */ 55 - __be32 dt_strings_size; /* size of the DT strings block */ 56 - /* version 17 fields below */ 57 - __be32 dt_struct_size; /* size of the DT structure block */ 58 - }; 59 22 60 23 #if defined(CONFIG_OF_FLATTREE) 61 24 62 25 struct device_node; 63 26 64 27 /* For scanning an arbitrary device-tree at any time */ 65 - extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset); 66 - extern void *of_fdt_get_property(struct boot_param_header *blob, 28 + extern char *of_fdt_get_string(const void *blob, u32 offset); 29 + extern void *of_fdt_get_property(const void *blob, 67 30 unsigned long node, 68 31 const char *name, 69 - unsigned long *size); 70 - extern int of_fdt_is_compatible(struct boot_param_header *blob, 32 + int *size); 33 + extern int of_fdt_is_compatible(const void *blob, 71 34 unsigned long node, 72 35 const char *compat); 73 - extern int of_fdt_match(struct boot_param_header *blob, unsigned long node, 36 + extern int of_fdt_match(const void *blob, unsigned long node, 74 37 const char *const *compat); 75 38 extern void of_fdt_unflatten_tree(unsigned long *blob, 76 39 struct device_node **mynodes); ··· 41 78 /* TBD: Temporary export of fdt globals - remove when code fully merged */ 42 79 extern int __initdata dt_root_addr_cells; 43 80 extern int __initdata dt_root_size_cells; 44 - extern struct boot_param_header *initial_boot_params; 81 + extern void *initial_boot_params; 82 + 83 + extern char __dtb_start[]; 84 + extern char __dtb_end[]; 45 85 46 86 /* For scanning the flat device-tree at boot time */ 47 - extern char *find_flat_dt_string(u32 offset); 48 87 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, 49 88 int depth, void *data), 50 89 void *data); 51 - extern void *of_get_flat_dt_prop(unsigned long node, const char *name, 52 - unsigned long *size); 90 + extern const void *of_get_flat_dt_prop(unsigned long node, const char *name, 91 + int *size); 53 92 extern int of_flat_dt_is_compatible(unsigned long node, const char *name); 54 93 extern int of_flat_dt_match(unsigned long node, const char *const *matches); 55 94 extern unsigned long of_get_flat_dt_root(void); 56 - extern int of_scan_flat_dt_by_path(const char *path, 57 - int (*it)(unsigned long node, const char *name, int depth, void *data), 58 - void *data); 95 + extern int of_get_flat_dt_size(void); 59 96 60 97 extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, 61 98 int depth, void *data); ··· 66 103 extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, 67 104 bool no_map); 68 105 extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); 69 - extern u64 dt_mem_next_cell(int s, __be32 **cellp); 106 + extern u64 dt_mem_next_cell(int s, const __be32 **cellp); 70 107 71 108 /* Early flat tree scan hooks */ 72 109 extern int early_init_dt_scan_root(unsigned long node, const char *uname, ··· 83 120 extern void unflatten_and_copy_device_tree(void); 84 121 extern void early_init_devtree(void *); 85 122 extern void early_get_first_memblock_info(void *, phys_addr_t *); 123 + extern u64 fdt_translate_address(const void *blob, int node_offset); 86 124 #else /* CONFIG_OF_FLATTREE */ 87 125 static inline void early_init_fdt_scan_reserved_mem(void) {} 88 126 static inline const char *of_flat_dt_get_machine_name(void) { return NULL; }
+5
include/linux/of_irq.h
··· 45 45 #ifdef CONFIG_OF_IRQ 46 46 extern int of_irq_count(struct device_node *dev); 47 47 extern int of_irq_get(struct device_node *dev, int index); 48 + extern int of_irq_get_byname(struct device_node *dev, const char *name); 48 49 #else 49 50 static inline int of_irq_count(struct device_node *dev) 50 51 { 51 52 return 0; 52 53 } 53 54 static inline int of_irq_get(struct device_node *dev, int index) 55 + { 56 + return 0; 57 + } 58 + static inline int of_irq_get_byname(struct device_node *dev, const char *name) 54 59 { 55 60 return 0; 56 61 }
+33 -3
include/linux/of_pci.h
··· 6 6 7 7 struct pci_dev; 8 8 struct of_phandle_args; 9 - int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); 10 - int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); 11 - 12 9 struct device_node; 10 + 11 + #ifdef CONFIG_OF 12 + int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq); 13 13 struct device_node *of_pci_find_child_device(struct device_node *parent, 14 14 unsigned int devfn); 15 15 int of_pci_get_devfn(struct device_node *np); 16 + int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); 16 17 int of_pci_parse_bus_range(struct device_node *node, struct resource *res); 18 + #else 19 + static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) 20 + { 21 + return 0; 22 + } 23 + 24 + static inline struct device_node *of_pci_find_child_device(struct device_node *parent, 25 + unsigned int devfn) 26 + { 27 + return NULL; 28 + } 29 + 30 + static inline int of_pci_get_devfn(struct device_node *np) 31 + { 32 + return -EINVAL; 33 + } 34 + 35 + static inline int 36 + of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) 37 + { 38 + return 0; 39 + } 40 + 41 + static inline int 42 + of_pci_parse_bus_range(struct device_node *node, struct resource *res) 43 + { 44 + return -EINVAL; 45 + } 46 + #endif 17 47 18 48 #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) 19 49 int of_pci_msi_chip_add(struct msi_chip *chip);
+4 -18
include/linux/of_reserved_mem.h
··· 21 21 struct device *dev); 22 22 }; 23 23 24 - typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem, 25 - unsigned long node, const char *uname); 24 + typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); 25 + 26 + #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ 27 + _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) 26 28 27 29 #ifdef CONFIG_OF_RESERVED_MEM 28 30 void fdt_init_reserved_mem(void); 29 31 void fdt_reserved_mem_save_node(unsigned long node, const char *uname, 30 32 phys_addr_t base, phys_addr_t size); 31 - 32 - #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ 33 - static const struct of_device_id __reservedmem_of_table_##name \ 34 - __used __section(__reservedmem_of_table) \ 35 - = { .compatible = compat, \ 36 - .data = (init == (reservedmem_of_init_fn)NULL) ? \ 37 - init : init } 38 - 39 33 #else 40 34 static inline void fdt_init_reserved_mem(void) { } 41 35 static inline void fdt_reserved_mem_save_node(unsigned long node, 42 36 const char *uname, phys_addr_t base, phys_addr_t size) { } 43 - 44 - #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ 45 - static const struct of_device_id __reservedmem_of_table_##name \ 46 - __attribute__((unused)) \ 47 - = { .compatible = compat, \ 48 - .data = (init == (reservedmem_of_init_fn)NULL) ? \ 49 - init : init } 50 - 51 37 #endif 52 38 53 39 #endif /* __OF_RESERVED_MEM_H */
+6
include/linux/serial_core.h
··· 294 294 int setup_earlycon(char *buf, const char *match, 295 295 int (*setup)(struct earlycon_device *, const char *)); 296 296 297 + extern int of_setup_earlycon(unsigned long addr, 298 + int (*setup)(struct earlycon_device *, const char *)); 299 + 297 300 #define EARLYCON_DECLARE(name, func) \ 298 301 static int __init name ## _setup_earlycon(char *buf) \ 299 302 { \ 300 303 return setup_earlycon(buf, __stringify(name), func); \ 301 304 } \ 302 305 early_param("earlycon", name ## _setup_earlycon); 306 + 307 + #define OF_EARLYCON_DECLARE(name, compat, fn) \ 308 + _OF_DECLARE(earlycon, name, compat, fn, void *) 303 309 304 310 struct uart_port *uart_get_console(struct uart_port *ports, int nr, 305 311 struct console *c);
+3
include/linux/string.h
··· 52 52 #ifndef __HAVE_ARCH_STRCHR 53 53 extern char * strchr(const char *,int); 54 54 #endif 55 + #ifndef __HAVE_ARCH_STRCHRNUL 56 + extern char * strchrnul(const char *,int); 57 + #endif 55 58 #ifndef __HAVE_ARCH_STRNCHR 56 59 extern char * strnchr(const char *, size_t, int); 57 60 #endif
+18
lib/string.c
··· 301 301 EXPORT_SYMBOL(strchr); 302 302 #endif 303 303 304 + #ifndef __HAVE_ARCH_STRCHRNUL 305 + /** 306 + * strchrnul - Find and return a character in a string, or end of string 307 + * @s: The string to be searched 308 + * @c: The character to search for 309 + * 310 + * Returns pointer to first occurrence of 'c' in s. If c is not found, then 311 + * return a pointer to the null byte at the end of s. 312 + */ 313 + char *strchrnul(const char *s, int c) 314 + { 315 + while (*s && *s != (char)c) 316 + s++; 317 + return (char *)s; 318 + } 319 + EXPORT_SYMBOL(strchrnul); 320 + #endif 321 + 304 322 #ifndef __HAVE_ARCH_STRRCHR 305 323 /** 306 324 * strrchr - Find the last occurrence of a character in a string