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

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

Pull Devicetree updates from Rob Herring:
"A bit bigger than normal as I've been busy this cycle.

There's a few things with dependencies and a few things subsystem
maintainers didn't pick up, so I'm taking them thru my tree.

The fixes from Johan didn't get into linux-next, but they've been
waiting for some time now and they are what's left of what subsystem
maintainers didn't pick up.

Summary:

- Sync dtc with upstream version v1.4.7-14-gc86da84d30e4

- Work to get rid of direct accesses to struct device_node name and
type pointers in preparation for removing them. New helpers for
parsing DT cpu nodes and conversions to use the helpers. printk
conversions to %pOFn for printing DT node names. Most went thru
subystem trees, so this is the remainder.

- Fixes to DT child node lookups to actually be restricted to child
nodes instead of treewide.

- Refactoring of dtb targets out of arch code. This makes the support
more uniform and enables building all dtbs on c6x, microblaze, and
powerpc.

- Various DT binding updates for Renesas r8a7744 SoC

- Vendor prefixes for Facebook, OLPC

- Restructuring of some ARM binding docs moving some peripheral
bindings out of board/SoC binding files

- New "secure-chosen" binding for secure world settings on ARM

- Dual licensing of 2 DT IRQ binding headers"

* tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (78 commits)
ARM: dt: relicense two DT binding IRQ headers
power: supply: twl4030-charger: fix OF sibling-node lookup
NFC: nfcmrvl_uart: fix OF child-node lookup
net: stmmac: dwmac-sun8i: fix OF child-node lookup
net: bcmgenet: fix OF child-node lookup
drm/msm: fix OF child-node lookup
drm/mediatek: fix OF sibling-node lookup
of: Add missing exports of node name compare functions
dt-bindings: Add OLPC vendor prefix
dt-bindings: misc: bk4: Add device tree binding for Liebherr's BK4 SPI bus
dt-bindings: thermal: samsung: Add SPDX license identifier
dt-bindings: clock: samsung: Add SPDX license identifiers
dt-bindings: timer: ostm: Add R7S9210 support
dt-bindings: phy: rcar-gen2: Add r8a7744 support
dt-bindings: can: rcar_can: Add r8a7744 support
dt-bindings: timer: renesas, cmt: Document r8a7744 CMT support
dt-bindings: watchdog: renesas-wdt: Document r8a7744 support
dt-bindings: thermal: rcar: Add device tree support for r8a7744
Documentation: dt: Add binding for /secure-chosen/stdout-path
dt-bindings: arm: zte: Move sysctrl bindings to their own doc
...

+1739 -1046
-72
Documentation/devicetree/bindings/arm/al,alpine.txt
··· 14 14 15 15 ... 16 16 } 17 - 18 - * CPU node: 19 - 20 - The Alpine platform includes cortex-a15 cores. 21 - enable-method: must be "al,alpine-smp" to allow smp [1] 22 - 23 - Example: 24 - 25 - cpus { 26 - #address-cells = <1>; 27 - #size-cells = <0>; 28 - enable-method = "al,alpine-smp"; 29 - 30 - cpu@0 { 31 - compatible = "arm,cortex-a15"; 32 - device_type = "cpu"; 33 - reg = <0>; 34 - }; 35 - 36 - cpu@1 { 37 - compatible = "arm,cortex-a15"; 38 - device_type = "cpu"; 39 - reg = <1>; 40 - }; 41 - 42 - cpu@2 { 43 - compatible = "arm,cortex-a15"; 44 - device_type = "cpu"; 45 - reg = <2>; 46 - }; 47 - 48 - cpu@3 { 49 - compatible = "arm,cortex-a15"; 50 - device_type = "cpu"; 51 - reg = <3>; 52 - }; 53 - }; 54 - 55 - 56 - * Alpine CPU resume registers 57 - 58 - The CPU resume register are used to define required resume address after 59 - reset. 60 - 61 - Properties: 62 - - compatible : Should contain "al,alpine-cpu-resume". 63 - - reg : Offset and length of the register set for the device 64 - 65 - Example: 66 - 67 - cpu_resume { 68 - compatible = "al,alpine-cpu-resume"; 69 - reg = <0xfbff5ed0 0x30>; 70 - }; 71 - 72 - * Alpine System-Fabric Service Registers 73 - 74 - The System-Fabric Service Registers allow various operation on CPU and 75 - system fabric, like powering CPUs off. 76 - 77 - Properties: 78 - - compatible : Should contain "al,alpine-sysfabric-service" and "syscon". 79 - - reg : Offset and length of the register set for the device 80 - 81 - Example: 82 - 83 - nb_service { 84 - compatible = "al,alpine-sysfabric-service", "syscon"; 85 - reg = <0xfb070000 0x10000>; 86 - }; 87 - 88 - [1] arm/cpu-enable-method/al,alpine-smp
-170
Documentation/devicetree/bindings/arm/atmel-at91.txt
··· 70 70 - "atmel,samv71q19" 71 71 - "atmel,samv71q20" 72 72 - "atmel,samv71q21" 73 - 74 - Chipid required properties: 75 - - compatible: Should be "atmel,sama5d2-chipid" 76 - - reg : Should contain registers location and length 77 - 78 - PIT Timer required properties: 79 - - compatible: Should be "atmel,at91sam9260-pit" 80 - - reg: Should contain registers location and length 81 - - interrupts: Should contain interrupt for the PIT which is the IRQ line 82 - shared across all System Controller members. 83 - 84 - System Timer (ST) required properties: 85 - - compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd" 86 - - reg: Should contain registers location and length 87 - - interrupts: Should contain interrupt for the ST which is the IRQ line 88 - shared across all System Controller members. 89 - - clocks: phandle to input clock. 90 - Its subnodes can be: 91 - - watchdog: compatible should be "atmel,at91rm9200-wdt" 92 - 93 - RSTC Reset Controller required properties: 94 - - compatible: Should be "atmel,<chip>-rstc". 95 - <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3" 96 - - reg: Should contain registers location and length 97 - - clocks: phandle to input clock. 98 - 99 - Example: 100 - 101 - rstc@fffffd00 { 102 - compatible = "atmel,at91sam9260-rstc"; 103 - reg = <0xfffffd00 0x10>; 104 - clocks = <&clk32k>; 105 - }; 106 - 107 - RAMC SDRAM/DDR Controller required properties: 108 - - compatible: Should be "atmel,at91rm9200-sdramc", "syscon" 109 - "atmel,at91sam9260-sdramc", 110 - "atmel,at91sam9g45-ddramc", 111 - "atmel,sama5d3-ddramc", 112 - - reg: Should contain registers location and length 113 - 114 - Examples: 115 - 116 - ramc0: ramc@ffffe800 { 117 - compatible = "atmel,at91sam9g45-ddramc"; 118 - reg = <0xffffe800 0x200>; 119 - }; 120 - 121 - SHDWC Shutdown Controller 122 - 123 - required properties: 124 - - compatible: Should be "atmel,<chip>-shdwc". 125 - <chip> can be "at91sam9260", "at91sam9rl" or "at91sam9x5". 126 - - reg: Should contain registers location and length 127 - - clocks: phandle to input clock. 128 - 129 - optional properties: 130 - - atmel,wakeup-mode: String, operation mode of the wakeup mode. 131 - Supported values are: "none", "high", "low", "any". 132 - - atmel,wakeup-counter: Counter on Wake-up 0 (between 0x0 and 0xf). 133 - 134 - optional at91sam9260 properties: 135 - - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. 136 - 137 - optional at91sam9rl properties: 138 - - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. 139 - - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. 140 - 141 - optional at91sam9x5 properties: 142 - - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. 143 - 144 - Example: 145 - 146 - shdwc@fffffd10 { 147 - compatible = "atmel,at91sam9260-shdwc"; 148 - reg = <0xfffffd10 0x10>; 149 - clocks = <&clk32k>; 150 - }; 151 - 152 - SHDWC SAMA5D2-Compatible Shutdown Controller 153 - 154 - 1) shdwc node 155 - 156 - required properties: 157 - - compatible: should be "atmel,sama5d2-shdwc". 158 - - reg: should contain registers location and length 159 - - clocks: phandle to input clock. 160 - - #address-cells: should be one. The cell is the wake-up input index. 161 - - #size-cells: should be zero. 162 - 163 - optional properties: 164 - 165 - - debounce-delay-us: minimum wake-up inputs debouncer period in 166 - microseconds. It's usually a board-related property. 167 - - atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up. 168 - 169 - The node contains child nodes for each wake-up input that the platform uses. 170 - 171 - 2) input nodes 172 - 173 - Wake-up input nodes are usually described in the "board" part of the Device 174 - Tree. Note also that input 0 is linked to the wake-up pin and is frequently 175 - used. 176 - 177 - Required properties: 178 - - reg: should contain the wake-up input index [0 - 15]. 179 - 180 - Optional properties: 181 - - atmel,wakeup-active-high: boolean, the corresponding wake-up input described 182 - by the child, forces the wake-up of the core power supply on a high level. 183 - The default is to be active low. 184 - 185 - Example: 186 - 187 - On the SoC side: 188 - shdwc@f8048010 { 189 - compatible = "atmel,sama5d2-shdwc"; 190 - reg = <0xf8048010 0x10>; 191 - clocks = <&clk32k>; 192 - #address-cells = <1>; 193 - #size-cells = <0>; 194 - atmel,wakeup-rtc-timer; 195 - }; 196 - 197 - On the board side: 198 - shdwc@f8048010 { 199 - debounce-delay-us = <976>; 200 - 201 - input@0 { 202 - reg = <0>; 203 - }; 204 - 205 - input@1 { 206 - reg = <1>; 207 - atmel,wakeup-active-high; 208 - }; 209 - }; 210 - 211 - Special Function Registers (SFR) 212 - 213 - Special Function Registers (SFR) manage specific aspects of the integrated 214 - memory, bridge implementations, processor and other functionality not controlled 215 - elsewhere. 216 - 217 - required properties: 218 - - compatible: Should be "atmel,<chip>-sfr", "syscon" or 219 - "atmel,<chip>-sfrbu", "syscon" 220 - <chip> can be "sama5d3", "sama5d4" or "sama5d2". 221 - - reg: Should contain registers location and length 222 - 223 - sfr@f0038000 { 224 - compatible = "atmel,sama5d3-sfr", "syscon"; 225 - reg = <0xf0038000 0x60>; 226 - }; 227 - 228 - Security Module (SECUMOD) 229 - 230 - The Security Module macrocell provides all necessary secure functions to avoid 231 - voltage, temperature, frequency and mechanical attacks on the chip. It also 232 - embeds secure memories that can be scrambled 233 - 234 - required properties: 235 - - compatible: Should be "atmel,<chip>-secumod", "syscon". 236 - <chip> can be "sama5d2". 237 - - reg: Should contain registers location and length 238 - 239 - secumod@fc040000 { 240 - compatible = "atmel,sama5d2-secumod", "syscon"; 241 - reg = <0xfc040000 0x100>; 242 - };
+171
Documentation/devicetree/bindings/arm/atmel-sysregs.txt
··· 1 + Atmel system registers 2 + 3 + Chipid required properties: 4 + - compatible: Should be "atmel,sama5d2-chipid" 5 + - reg : Should contain registers location and length 6 + 7 + PIT Timer required properties: 8 + - compatible: Should be "atmel,at91sam9260-pit" 9 + - reg: Should contain registers location and length 10 + - interrupts: Should contain interrupt for the PIT which is the IRQ line 11 + shared across all System Controller members. 12 + 13 + System Timer (ST) required properties: 14 + - compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd" 15 + - reg: Should contain registers location and length 16 + - interrupts: Should contain interrupt for the ST which is the IRQ line 17 + shared across all System Controller members. 18 + - clocks: phandle to input clock. 19 + Its subnodes can be: 20 + - watchdog: compatible should be "atmel,at91rm9200-wdt" 21 + 22 + RSTC Reset Controller required properties: 23 + - compatible: Should be "atmel,<chip>-rstc". 24 + <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3" 25 + - reg: Should contain registers location and length 26 + - clocks: phandle to input clock. 27 + 28 + Example: 29 + 30 + rstc@fffffd00 { 31 + compatible = "atmel,at91sam9260-rstc"; 32 + reg = <0xfffffd00 0x10>; 33 + clocks = <&clk32k>; 34 + }; 35 + 36 + RAMC SDRAM/DDR Controller required properties: 37 + - compatible: Should be "atmel,at91rm9200-sdramc", "syscon" 38 + "atmel,at91sam9260-sdramc", 39 + "atmel,at91sam9g45-ddramc", 40 + "atmel,sama5d3-ddramc", 41 + - reg: Should contain registers location and length 42 + 43 + Examples: 44 + 45 + ramc0: ramc@ffffe800 { 46 + compatible = "atmel,at91sam9g45-ddramc"; 47 + reg = <0xffffe800 0x200>; 48 + }; 49 + 50 + SHDWC Shutdown Controller 51 + 52 + required properties: 53 + - compatible: Should be "atmel,<chip>-shdwc". 54 + <chip> can be "at91sam9260", "at91sam9rl" or "at91sam9x5". 55 + - reg: Should contain registers location and length 56 + - clocks: phandle to input clock. 57 + 58 + optional properties: 59 + - atmel,wakeup-mode: String, operation mode of the wakeup mode. 60 + Supported values are: "none", "high", "low", "any". 61 + - atmel,wakeup-counter: Counter on Wake-up 0 (between 0x0 and 0xf). 62 + 63 + optional at91sam9260 properties: 64 + - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. 65 + 66 + optional at91sam9rl properties: 67 + - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. 68 + - atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up. 69 + 70 + optional at91sam9x5 properties: 71 + - atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up. 72 + 73 + Example: 74 + 75 + shdwc@fffffd10 { 76 + compatible = "atmel,at91sam9260-shdwc"; 77 + reg = <0xfffffd10 0x10>; 78 + clocks = <&clk32k>; 79 + }; 80 + 81 + SHDWC SAMA5D2-Compatible Shutdown Controller 82 + 83 + 1) shdwc node 84 + 85 + required properties: 86 + - compatible: should be "atmel,sama5d2-shdwc". 87 + - reg: should contain registers location and length 88 + - clocks: phandle to input clock. 89 + - #address-cells: should be one. The cell is the wake-up input index. 90 + - #size-cells: should be zero. 91 + 92 + optional properties: 93 + 94 + - debounce-delay-us: minimum wake-up inputs debouncer period in 95 + microseconds. It's usually a board-related property. 96 + - atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up. 97 + 98 + The node contains child nodes for each wake-up input that the platform uses. 99 + 100 + 2) input nodes 101 + 102 + Wake-up input nodes are usually described in the "board" part of the Device 103 + Tree. Note also that input 0 is linked to the wake-up pin and is frequently 104 + used. 105 + 106 + Required properties: 107 + - reg: should contain the wake-up input index [0 - 15]. 108 + 109 + Optional properties: 110 + - atmel,wakeup-active-high: boolean, the corresponding wake-up input described 111 + by the child, forces the wake-up of the core power supply on a high level. 112 + The default is to be active low. 113 + 114 + Example: 115 + 116 + On the SoC side: 117 + shdwc@f8048010 { 118 + compatible = "atmel,sama5d2-shdwc"; 119 + reg = <0xf8048010 0x10>; 120 + clocks = <&clk32k>; 121 + #address-cells = <1>; 122 + #size-cells = <0>; 123 + atmel,wakeup-rtc-timer; 124 + }; 125 + 126 + On the board side: 127 + shdwc@f8048010 { 128 + debounce-delay-us = <976>; 129 + 130 + input@0 { 131 + reg = <0>; 132 + }; 133 + 134 + input@1 { 135 + reg = <1>; 136 + atmel,wakeup-active-high; 137 + }; 138 + }; 139 + 140 + Special Function Registers (SFR) 141 + 142 + Special Function Registers (SFR) manage specific aspects of the integrated 143 + memory, bridge implementations, processor and other functionality not controlled 144 + elsewhere. 145 + 146 + required properties: 147 + - compatible: Should be "atmel,<chip>-sfr", "syscon" or 148 + "atmel,<chip>-sfrbu", "syscon" 149 + <chip> can be "sama5d3", "sama5d4" or "sama5d2". 150 + - reg: Should contain registers location and length 151 + 152 + sfr@f0038000 { 153 + compatible = "atmel,sama5d3-sfr", "syscon"; 154 + reg = <0xf0038000 0x60>; 155 + }; 156 + 157 + Security Module (SECUMOD) 158 + 159 + The Security Module macrocell provides all necessary secure functions to avoid 160 + voltage, temperature, frequency and mechanical attacks on the chip. It also 161 + embeds secure memories that can be scrambled 162 + 163 + required properties: 164 + - compatible: Should be "atmel,<chip>-secumod", "syscon". 165 + <chip> can be "sama5d2". 166 + - reg: Should contain registers location and length 167 + 168 + secumod@fc040000 { 169 + compatible = "atmel,sama5d2-secumod", "syscon"; 170 + reg = <0xfc040000 0x100>; 171 + };
+31 -3
Documentation/devicetree/bindings/arm/cpu-enable-method/al,alpine-smp
··· 14 14 15 15 Note: 16 16 This enable method requires valid nodes compatible with 17 - "al,alpine-cpu-resume" and "al,alpine-nb-service"[1]. 17 + "al,alpine-cpu-resume" and "al,alpine-nb-service". 18 + 19 + 20 + * Alpine CPU resume registers 21 + 22 + The CPU resume register are used to define required resume address after 23 + reset. 24 + 25 + Properties: 26 + - compatible : Should contain "al,alpine-cpu-resume". 27 + - reg : Offset and length of the register set for the device 28 + 29 + 30 + * Alpine System-Fabric Service Registers 31 + 32 + The System-Fabric Service Registers allow various operation on CPU and 33 + system fabric, like powering CPUs off. 34 + 35 + Properties: 36 + - compatible : Should contain "al,alpine-sysfabric-service" and "syscon". 37 + - reg : Offset and length of the register set for the device 38 + 18 39 19 40 Example: 20 41 ··· 69 48 }; 70 49 }; 71 50 72 - -- 73 - [1] arm/al,alpine.txt 51 + cpu_resume { 52 + compatible = "al,alpine-cpu-resume"; 53 + reg = <0xfbff5ed0 0x30>; 54 + }; 55 + 56 + nb_service { 57 + compatible = "al,alpine-sysfabric-service", "syscon"; 58 + reg = <0xfb070000 0x10000>; 59 + };
+2 -2
Documentation/devicetree/bindings/arm/cpus.txt
··· 276 276 Usage: optional 277 277 Value type: <prop-encoded-array> 278 278 Definition: A u32 value that represents the running time dynamic 279 - power coefficient in units of mW/MHz/uV^2. The 279 + power coefficient in units of uW/MHz/V^2. The 280 280 coefficient can either be calculated from power 281 281 measurements or derived by analysis. 282 282 ··· 287 287 288 288 Pdyn = dynamic-power-coefficient * V^2 * f 289 289 290 - where voltage is in uV, frequency is in MHz. 290 + where voltage is in V, frequency is in MHz. 291 291 292 292 Example 1 (dual-cluster big.LITTLE system 32-bit): 293 293
+19
Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt
··· 1 + Freescale DCFG 2 + 3 + DCFG is the device configuration unit, that provides general purpose 4 + configuration and status for the device. Such as setting the secondary 5 + core start address and release the secondary core from holdoff and startup. 6 + 7 + Required properties: 8 + - compatible: Should contain a chip-specific compatible string, 9 + Chip-specific strings are of the form "fsl,<chip>-dcfg", 10 + The following <chip>s are known to be supported: 11 + ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. 12 + 13 + - reg : should contain base address and length of DCFG memory-mapped registers 14 + 15 + Example: 16 + dcfg: dcfg@1ee0000 { 17 + compatible = "fsl,ls1021a-dcfg"; 18 + reg = <0x0 0x1ee0000 0x0 0x10000>; 19 + };
+19
Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-scfg.txt
··· 1 + Freescale SCFG 2 + 3 + SCFG is the supplemental configuration unit, that provides SoC specific 4 + configuration and status registers for the chip. Such as getting PEX port 5 + status. 6 + 7 + Required properties: 8 + - compatible: Should contain a chip-specific compatible string, 9 + Chip-specific strings are of the form "fsl,<chip>-scfg", 10 + The following <chip>s are known to be supported: 11 + ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. 12 + 13 + - reg: should contain base address and length of SCFG memory-mapped registers 14 + 15 + Example: 16 + scfg: scfg@1570000 { 17 + compatible = "fsl,ls1021a-scfg"; 18 + reg = <0x0 0x1570000 0x0 0x10000>; 19 + };
-39
Documentation/devicetree/bindings/arm/fsl.txt
··· 101 101 Required root node compatible properties: 102 102 - compatible = "fsl,ls1021a"; 103 103 104 - Freescale SoC-specific Device Tree Bindings 105 - ------------------------------------------- 106 - 107 - Freescale SCFG 108 - SCFG is the supplemental configuration unit, that provides SoC specific 109 - configuration and status registers for the chip. Such as getting PEX port 110 - status. 111 - Required properties: 112 - - compatible: Should contain a chip-specific compatible string, 113 - Chip-specific strings are of the form "fsl,<chip>-scfg", 114 - The following <chip>s are known to be supported: 115 - ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. 116 - 117 - - reg: should contain base address and length of SCFG memory-mapped registers 118 - 119 - Example: 120 - scfg: scfg@1570000 { 121 - compatible = "fsl,ls1021a-scfg"; 122 - reg = <0x0 0x1570000 0x0 0x10000>; 123 - }; 124 - 125 - Freescale DCFG 126 - DCFG is the device configuration unit, that provides general purpose 127 - configuration and status for the device. Such as setting the secondary 128 - core start address and release the secondary core from holdoff and startup. 129 - Required properties: 130 - - compatible: Should contain a chip-specific compatible string, 131 - Chip-specific strings are of the form "fsl,<chip>-dcfg", 132 - The following <chip>s are known to be supported: 133 - ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. 134 - 135 - - reg : should contain base address and length of DCFG memory-mapped registers 136 - 137 - Example: 138 - dcfg: dcfg@1ee0000 { 139 - compatible = "fsl,ls1021a-dcfg"; 140 - reg = <0x0 0x1ee0000 0x0 0x10000>; 141 - }; 142 - 143 104 Freescale ARMv8 based Layerscape SoC family Device Tree Bindings 144 105 ---------------------------------------------------------------- 145 106
+18 -1
Documentation/devicetree/bindings/arm/secure.txt
··· 32 32 secure- bindings only need to be used where both the Secure and Normal 33 33 world views need to be described in a single device tree. 34 34 35 - Valid Secure world properties: 35 + Valid Secure world properties 36 + ----------------------------- 36 37 37 38 - secure-status : specifies whether the device is present and usable 38 39 in the secure world. The combination of this with "status" allows ··· 52 51 status = "disabled"; secure-status = "okay"; /* S-only */ 53 52 status = "disabled"; /* disabled in both */ 54 53 status = "disabled"; secure-status = "disabled"; /* disabled in both */ 54 + 55 + The secure-chosen node 56 + ---------------------- 57 + 58 + Similar to the /chosen node which serves as a place for passing data 59 + between firmware and the operating system, the /secure-chosen node may 60 + be used to pass data to the Secure OS. Only the properties defined 61 + below may appear in the /secure-chosen node. 62 + 63 + - stdout-path : specifies the device to be used by the Secure OS for 64 + its console output. The syntax is the same as for /chosen/stdout-path. 65 + If the /secure-chosen node exists but the stdout-path property is not 66 + present, the Secure OS should not perform any console output. If 67 + /secure-chosen does not exist, the Secure OS should use the value of 68 + /chosen/stdout-path instead (that is, use the same device as the 69 + Normal world OS).
+30
Documentation/devicetree/bindings/arm/zte,sysctrl.txt
··· 1 + ZTE sysctrl Registers 2 + 3 + Registers for 'zte,zx296702' SoC: 4 + 5 + System management required properties: 6 + - compatible = "zte,sysctrl" 7 + 8 + Low power management required properties: 9 + - compatible = "zte,zx296702-pcu" 10 + 11 + Bus matrix required properties: 12 + - compatible = "zte,zx-bus-matrix" 13 + 14 + 15 + Registers for 'zte,zx296718' SoC: 16 + 17 + System management required properties: 18 + - compatible = "zte,zx296718-aon-sysctrl" 19 + - compatible = "zte,zx296718-sysctrl" 20 + 21 + Example: 22 + aon_sysctrl: aon-sysctrl@116000 { 23 + compatible = "zte,zx296718-aon-sysctrl", "syscon"; 24 + reg = <0x116000 0x1000>; 25 + }; 26 + 27 + sysctrl: sysctrl@1463000 { 28 + compatible = "zte,zx296718-sysctrl", "syscon"; 29 + reg = <0x1463000 0x1000>; 30 + };
+1 -26
Documentation/devicetree/bindings/arm/zte.txt
··· 1 1 ZTE platforms device tree bindings 2 - --------------------------------------- 3 2 3 + --------------------------------------- 4 4 - ZX296702 board: 5 5 Required root node properties: 6 6 - compatible = "zte,zx296702-ad1", "zte,zx296702" 7 - 8 - System management required properties: 9 - - compatible = "zte,sysctrl" 10 - 11 - Low power management required properties: 12 - - compatible = "zte,zx296702-pcu" 13 - 14 - Bus matrix required properties: 15 - - compatible = "zte,zx-bus-matrix" 16 - 17 7 18 8 --------------------------------------- 19 9 - ZX296718 SoC: ··· 12 22 13 23 ZX296718 EVB board: 14 24 - "zte,zx296718-evb" 15 - 16 - System management required properties: 17 - - compatible = "zte,zx296718-aon-sysctrl" 18 - - compatible = "zte,zx296718-sysctrl" 19 - 20 - Example: 21 - aon_sysctrl: aon-sysctrl@116000 { 22 - compatible = "zte,zx296718-aon-sysctrl", "syscon"; 23 - reg = <0x116000 0x1000>; 24 - }; 25 - 26 - sysctrl: sysctrl@1463000 { 27 - compatible = "zte,zx296718-sysctrl", "syscon"; 28 - reg = <0x1463000 0x1000>; 29 - };
+1 -1
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt
··· 24 24 25 25 Example: 26 26 27 - p1_sec_a: crypto@400,d2000000 { 27 + p1_sec_a: crypto@400d2000000 { 28 28 compatible = "hisilicon,hip07-sec"; 29 29 reg = <0x400 0xd0000000 0x0 0x10000 30 30 0x400 0xd2000000 0x0 0x10000
+2 -2
Documentation/devicetree/bindings/fpga/fpga-region.txt
··· 415 415 firmware-name = "base.rbf"; 416 416 417 417 fpga-bridge@4400 { 418 - compatible = "altr,freeze-bridge"; 418 + compatible = "altr,freeze-bridge-controller"; 419 419 reg = <0x4400 0x10>; 420 420 421 421 fpga_region1: fpga-region1 { ··· 427 427 }; 428 428 429 429 fpga-bridge@4420 { 430 - compatible = "altr,freeze-bridge"; 430 + compatible = "altr,freeze-bridge-controller"; 431 431 reg = <0x4420 0x10>; 432 432 433 433 fpga_region2: fpga-region2 {
+1 -1
Documentation/devicetree/bindings/i2c/i2c.txt
··· 84 84 used by the device. I2C core will assign "irq" interrupt (or the very first 85 85 interrupt if not using interrupt names) as primary interrupt for the slave. 86 86 87 - Alternatively, devices supporting SMbus Host Notify, and connected to 87 + Alternatively, devices supporting SMBus Host Notify, and connected to 88 88 adapters that support this feature, may use "host-notify" property. I2C 89 89 core will create a virtual interrupt for Host Notify and assign it as 90 90 primary interrupt for the slave.
+1 -1
Documentation/devicetree/bindings/mfd/arizona.txt
··· 76 76 Also see child specific device properties: 77 77 Regulator - ../regulator/arizona-regulator.txt 78 78 Extcon - ../extcon/extcon-arizona.txt 79 - Sound - ../sound/arizona.txt 79 + Sound - ../sound/wlf,arizona.txt 80 80 81 81 Example: 82 82
+26
Documentation/devicetree/bindings/misc/lwn-bk4.txt
··· 1 + * Liebherr's BK4 controller external SPI 2 + 3 + A device which handles data acquisition from compatible industrial 4 + peripherals. 5 + The SPI is used for data and management purposes in both master and 6 + slave modes. 7 + 8 + Required properties: 9 + 10 + - compatible : Should be "lwn,bk4" 11 + 12 + Required SPI properties: 13 + 14 + - reg : Should be address of the device chip select within 15 + the controller. 16 + 17 + - spi-max-frequency : Maximum SPI clocking speed of device in Hz, should be 18 + 30MHz at most for the Liebherr's BK4 external bus. 19 + 20 + Example: 21 + 22 + spidev0: spi@0 { 23 + compatible = "lwn,bk4"; 24 + spi-max-frequency = <30000000>; 25 + reg = <0>; 26 + };
+1
Documentation/devicetree/bindings/net/can/rcar_can.txt
··· 3 3 4 4 Required properties: 5 5 - compatible: "renesas,can-r8a7743" if CAN controller is a part of R8A7743 SoC. 6 + "renesas,can-r8a7744" if CAN controller is a part of R8A7744 SoC. 6 7 "renesas,can-r8a7745" if CAN controller is a part of R8A7745 SoC. 7 8 "renesas,can-r8a7778" if CAN controller is a part of R8A7778 SoC. 8 9 "renesas,can-r8a7779" if CAN controller is a part of R8A7779 SoC.
+1
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
··· 5 5 6 6 Required properties: 7 7 - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. 8 + "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC. 8 9 "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. 9 10 "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. 10 11 "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
+1 -1
Documentation/devicetree/bindings/reset/fsl,imx7-src.txt
··· 5 5 controller binding usage. 6 6 7 7 Required properties: 8 - - compatible: Should be "fsl,imx7-src", "syscon" 8 + - compatible: Should be "fsl,imx7d-src", "syscon" 9 9 - reg: should be register base and length as documented in the 10 10 datasheet 11 11 - interrupts: Should contain SRC interrupt
+2
Documentation/devicetree/bindings/timer/renesas,cmt.txt
··· 24 24 - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4. 25 25 - "renesas,r8a7743-cmt0" for the 32-bit CMT0 device included in r8a7743. 26 26 - "renesas,r8a7743-cmt1" for the 48-bit CMT1 device included in r8a7743. 27 + - "renesas,r8a7744-cmt0" for the 32-bit CMT0 device included in r8a7744. 28 + - "renesas,r8a7744-cmt1" for the 48-bit CMT1 device included in r8a7744. 27 29 - "renesas,r8a7745-cmt0" for the 32-bit CMT0 device included in r8a7745. 28 30 - "renesas,r8a7745-cmt1" for the 48-bit CMT1 device included in r8a7745. 29 31 - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790.
+2 -1
Documentation/devicetree/bindings/timer/renesas,ostm.txt
··· 9 9 Required Properties: 10 10 11 11 - compatible: must be one or more of the following: 12 - - "renesas,r7s72100-ostm" for the r7s72100 OSTM 12 + - "renesas,r7s72100-ostm" for the R7S72100 (RZ/A1) OSTM 13 + - "renesas,r7s9210-ostm" for the R7S9210 (RZ/A2) OSTM 13 14 - "renesas,ostm" for any OSTM 14 15 This is a fallback for the above renesas,*-ostm entries 15 16
+2
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 127 127 exar Exar Corporation 128 128 excito Excito 129 129 ezchip EZchip Semiconductor 130 + facebook Facebook 130 131 fairphone Fairphone B.V. 131 132 faraday Faraday Technology Corporation 132 133 fastrax Fastrax Oy ··· 276 275 okaya Okaya Electric America, Inc. 277 276 oki Oki Electric Industry Co., Ltd. 278 277 olimex OLIMEX Ltd. 278 + olpc One Laptop Per Child 279 279 onion Onion Corporation 280 280 onnn ON Semiconductor Corp. 281 281 ontat On Tat Industrial Company
+1
Documentation/devicetree/bindings/watchdog/renesas-wdt.txt
··· 6 6 version. 7 7 Examples with soctypes are: 8 8 - "renesas,r8a7743-wdt" (RZ/G1M) 9 + - "renesas,r8a7744-wdt" (RZ/G1N) 9 10 - "renesas,r8a7745-wdt" (RZ/G1E) 10 11 - "renesas,r8a774a1-wdt" (RZ/G2M) 11 12 - "renesas,r8a7790-wdt" (R-Car H2)
+36 -1
Makefile
··· 1063 1063 # Carefully list dependencies so we do not try to build scripts twice 1064 1064 # in parallel 1065 1065 PHONY += scripts 1066 - scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h) 1066 + scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) 1067 1067 $(Q)$(MAKE) $(build)=$(@) 1068 1068 1069 1069 # Things we need to do before we recursively start building the kernel ··· 1211 1211 -m $(objtree)/.config \ 1212 1212 $(srctree)/tools/testing/selftests/*/config 1213 1213 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 1214 + 1215 + # --------------------------------------------------------------------------- 1216 + # Devicetree files 1217 + 1218 + ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) 1219 + dtstree := arch/$(SRCARCH)/boot/dts 1220 + endif 1221 + 1222 + ifneq ($(dtstree),) 1223 + 1224 + %.dtb: prepare3 scripts_dtc 1225 + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ 1226 + 1227 + PHONY += dtbs dtbs_install 1228 + dtbs: prepare3 scripts_dtc 1229 + $(Q)$(MAKE) $(build)=$(dtstree) 1230 + 1231 + dtbs_install: 1232 + $(Q)$(MAKE) $(dtbinst)=$(dtstree) 1233 + 1234 + ifdef CONFIG_OF_EARLY_FLATTREE 1235 + all: dtbs 1236 + endif 1237 + 1238 + endif 1239 + 1240 + PHONY += scripts_dtc 1241 + scripts_dtc: scripts_basic 1242 + $(Q)$(MAKE) $(build)=scripts/dtc 1214 1243 1215 1244 # --------------------------------------------------------------------------- 1216 1245 # Modules ··· 1450 1421 @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing' 1451 1422 @echo ' .config.' 1452 1423 @echo '' 1424 + @$(if $(dtstree), \ 1425 + echo 'Devicetree:'; \ 1426 + echo '* dtbs - Build device tree blobs for enabled boards'; \ 1427 + echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ 1428 + echo '') 1429 + 1453 1430 @echo 'Userspace tools targets:' 1454 1431 @echo ' use "make tools/help"' 1455 1432 @echo ' or "cd tools; make help"'
-6
arch/arc/Makefile
··· 102 102 $(boot_targets): vmlinux 103 103 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 104 104 105 - %.dtb %.dtb.S %.dtb.o: scripts 106 - $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ 107 - 108 - dtbs: scripts 109 - $(Q)$(MAKE) $(build)=$(boot)/dts 110 - 111 105 archclean: 112 106 $(Q)$(MAKE) $(clean)=$(boot)
+1 -19
arch/arm/Makefile
··· 303 303 KBUILD_IMAGE := $(boot)/zImage 304 304 endif 305 305 306 - # Build the DT binary blobs if we have OF configured 307 - ifeq ($(CONFIG_USE_OF),y) 308 - KBUILD_DTBS := dtbs 309 - endif 310 - 311 - all: $(notdir $(KBUILD_IMAGE)) $(KBUILD_DTBS) 306 + all: $(notdir $(KBUILD_IMAGE)) 312 307 313 308 314 309 archheaders: ··· 330 335 $(INSTALL_TARGETS): 331 336 $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ 332 337 333 - %.dtb: | scripts 334 - $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@ 335 - 336 - PHONY += dtbs dtbs_install 337 - 338 - dtbs: prepare scripts 339 - $(Q)$(MAKE) $(build)=$(boot)/dts 340 - 341 - dtbs_install: 342 - $(Q)$(MAKE) $(dtbinst)=$(boot)/dts 343 - 344 338 PHONY += vdso_install 345 339 vdso_install: 346 340 ifeq ($(CONFIG_VDSO),y) ··· 351 367 echo ' uImage - U-Boot wrapped zImage' 352 368 echo ' bootpImage - Combined zImage and initial RAM disk' 353 369 echo ' (supply initrd image via make variable INITRD=<path>)' 354 - echo '* dtbs - Build device tree blobs for enabled boards' 355 - echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' 356 370 echo ' install - Install uncompressed kernel' 357 371 echo ' zinstall - Install compressed kernel' 358 372 echo ' uinstall - Install U-Boot wrapped compressed kernel'
+2
arch/arm/boot/compressed/libfdt_env.h
··· 6 6 #include <linux/string.h> 7 7 #include <asm/byteorder.h> 8 8 9 + #define INT_MAX ((int)(~0U>>1)) 10 + 9 11 typedef __be16 fdt16_t; 10 12 typedef __be32 fdt32_t; 11 13 typedef __be64 fdt64_t;
+1 -4
arch/arm/kernel/devtree.c
··· 87 87 if (!cpus) 88 88 return; 89 89 90 - for_each_child_of_node(cpus, cpu) { 90 + for_each_of_cpu_node(cpu) { 91 91 const __be32 *cell; 92 92 int prop_bytes; 93 93 u32 hwid; 94 - 95 - if (of_node_cmp(cpu->type, "cpu")) 96 - continue; 97 94 98 95 pr_debug(" * %pOF...\n", cpu); 99 96 /*
-6
arch/arm/kernel/topology.c
··· 94 94 __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), 95 95 GFP_NOWAIT); 96 96 97 - cn = of_find_node_by_path("/cpus"); 98 - if (!cn) { 99 - pr_err("No CPU information found in DT\n"); 100 - return; 101 - } 102 - 103 97 for_each_possible_cpu(cpu) { 104 98 const u32 *rate; 105 99 int len;
+2 -6
arch/arm/mach-shmobile/pm-rcar-gen2.c
··· 50 50 void __iomem *p; 51 51 u32 bar; 52 52 static int once; 53 - struct device_node *np, *cpus; 53 + struct device_node *np; 54 54 bool has_a7 = false; 55 55 bool has_a15 = false; 56 56 struct resource res; ··· 59 59 if (once++) 60 60 return; 61 61 62 - cpus = of_find_node_by_path("/cpus"); 63 - if (!cpus) 64 - return; 65 - 66 - for_each_child_of_node(cpus, np) { 62 + for_each_of_cpu_node(np) { 67 63 if (of_device_is_compatible(np, "arm,cortex-a15")) 68 64 has_a15 = true; 69 65 else if (of_device_is_compatible(np, "arm,cortex-a7"))
+1 -1
arch/arm/mach-shmobile/pm-rmobile.c
··· 202 202 const struct of_device_id *id; 203 203 204 204 /* PM domains containing CPUs */ 205 - for_each_node_by_type(np, "cpu") 205 + for_each_of_cpu_node(np) 206 206 add_special_pd(np, PD_CPU); 207 207 208 208 /* PM domain containing console */
+2 -8
arch/arm/mach-shmobile/timer.c
··· 22 22 23 23 void __init shmobile_init_delay(void) 24 24 { 25 - struct device_node *np, *cpus; 25 + struct device_node *np; 26 26 u32 max_freq = 0; 27 27 28 - cpus = of_find_node_by_path("/cpus"); 29 - if (!cpus) 30 - return; 31 - 32 - for_each_child_of_node(cpus, np) { 28 + for_each_of_cpu_node(np) { 33 29 u32 freq; 34 30 35 31 if (!of_property_read_u32(np, "clock-frequency", &freq)) 36 32 max_freq = max(max_freq, freq); 37 33 } 38 - 39 - of_node_put(cpus); 40 34 41 35 if (!max_freq) 42 36 return;
+1 -16
arch/arm64/Makefile
··· 113 113 # Default target when executing plain make 114 114 boot := arch/arm64/boot 115 115 KBUILD_IMAGE := $(boot)/Image.gz 116 - KBUILD_DTBS := dtbs 117 116 118 - all: Image.gz $(KBUILD_DTBS) 117 + all: Image.gz 119 118 120 119 121 120 Image: vmlinux ··· 126 127 zinstall install: 127 128 $(Q)$(MAKE) $(build)=$(boot) $@ 128 129 129 - %.dtb: scripts 130 - $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ 131 - 132 - PHONY += dtbs dtbs_install 133 - 134 - dtbs: prepare scripts 135 - $(Q)$(MAKE) $(build)=$(boot)/dts 136 - 137 - dtbs_install: 138 - $(Q)$(MAKE) $(dtbinst)=$(boot)/dts 139 - 140 130 PHONY += vdso_install 141 131 vdso_install: 142 132 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ ··· 133 145 # We use MRPROPER_FILES and CLEAN_FILES now 134 146 archclean: 135 147 $(Q)$(MAKE) $(clean)=$(boot) 136 - $(Q)$(MAKE) $(clean)=$(boot)/dts 137 148 138 149 # We need to generate vdso-offsets.h before compiling certain files in kernel/. 139 150 # In order to do that, we should use the archprepare target, but we can't since ··· 147 160 define archhelp 148 161 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' 149 162 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' 150 - echo '* dtbs - Build device tree blobs for enabled boards' 151 - echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' 152 163 echo ' install - Install uncompressed kernel' 153 164 echo ' zinstall - Install compressed kernel' 154 165 echo ' Install using (your) ~/bin/installkernel or'
+1 -1
arch/arm64/kernel/smp.c
··· 602 602 { 603 603 struct device_node *dn; 604 604 605 - for_each_node_by_type(dn, "cpu") { 605 + for_each_of_cpu_node(dn) { 606 606 u64 hwid = of_get_cpu_mpidr(dn); 607 607 608 608 if (hwid == INVALID_HWID)
-2
arch/c6x/Makefile
··· 40 40 DTB:=$(subst dtbImage.,,$(filter dtbImage.%, $(MAKECMDGOALS))) 41 41 export DTB 42 42 43 - ifneq ($(DTB),) 44 43 core-y += $(boot)/dts/ 45 - endif 46 44 47 45 # With make 3.82 we cannot mix normal and wildcard targets 48 46
+7 -10
arch/c6x/boot/dts/Makefile
··· 5 5 6 6 DTC_FLAGS ?= -p 1024 7 7 8 + dtb-$(CONFIG_SOC_TMS320C6455) += dsk6455.dtb 9 + dtb-$(CONFIG_SOC_TMS320C6457) += evmc6457.dtb 10 + dtb-$(CONFIG_SOC_TMS320C6472) += evmc6472.dtb 11 + dtb-$(CONFIG_SOC_TMS320C6474) += evmc6474.dtb 12 + dtb-$(CONFIG_SOC_TMS320C6678) += evmc6678.dtb 13 + 8 14 ifneq ($(DTB),) 9 - obj-y += linked_dtb.o 15 + obj-y += $(DTB).dtb.o 10 16 endif 11 - 12 - quiet_cmd_cp = CP $< $@$2 13 - cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false) 14 - 15 - # Generate builtin.dtb from $(DTB).dtb 16 - $(obj)/builtin.dtb: $(obj)/$(DTB).dtb 17 - $(call if_changed,cp) 18 - 19 - $(obj)/linked_dtb.o: $(obj)/builtin.dtb
-2
arch/c6x/boot/dts/linked_dtb.S
··· 1 - .section __fdt_blob,"a" 2 - .incbin "arch/c6x/boot/dts/builtin.dtb"
-1
arch/c6x/include/asm/sections.h
··· 8 8 extern char _vectors_end[]; 9 9 10 10 extern char _data_lma[]; 11 - extern char _fdt_start[], _fdt_end[]; 12 11 13 12 #endif /* _ASM_C6X_SECTIONS_H */
+5 -10
arch/c6x/kernel/setup.c
··· 96 96 unsigned long core_khz; 97 97 u64 tmp; 98 98 struct cpuinfo_c6x *p; 99 - struct device_node *node, *np; 99 + struct device_node *node; 100 100 101 101 p = &per_cpu(cpu_data, smp_processor_id()); 102 102 ··· 190 190 191 191 p->core_id = get_coreid(); 192 192 193 - node = of_find_node_by_name(NULL, "cpus"); 194 - if (node) { 195 - for_each_child_of_node(node, np) 196 - if (!strcmp("cpu", np->name)) 197 - ++c6x_num_cores; 198 - of_node_put(node); 199 - } 193 + for_each_of_cpu_node(node) 194 + ++c6x_num_cores; 200 195 201 196 node = of_find_node_by_name(NULL, "soc"); 202 197 if (node) { ··· 265 270 notrace void __init machine_init(unsigned long dt_ptr) 266 271 { 267 272 void *dtb = __va(dt_ptr); 268 - void *fdt = _fdt_start; 273 + void *fdt = __dtb_start; 269 274 270 275 /* interrupts must be masked */ 271 276 set_creg(IER, 2); ··· 358 363 memory_end >> PAGE_SHIFT); 359 364 memblock_reserve(memory_start, bootmap_size); 360 365 361 - unflatten_device_tree(); 366 + unflatten_and_copy_device_tree(); 362 367 363 368 c6x_cache_init(); 364 369
-10
arch/c6x/kernel/vmlinux.lds.S
··· 90 90 *(.switch) 91 91 } 92 92 93 - . = ALIGN (8) ; 94 - __fdt_blob : AT(ADDR(__fdt_blob) - LOAD_OFFSET) 95 - { 96 - _fdt_start = . ; /* place for fdt blob */ 97 - *(__fdt_blob) ; /* Any link-placed DTB */ 98 - BYTE(0); /* section always has contents */ 99 - . = _fdt_start + 0x4000; /* Pad up to 16kbyte */ 100 - _fdt_end = . ; 101 - } 102 - 103 93 _etext = .; 104 94 105 95 /*
+1 -10
arch/h8300/Makefile
··· 31 31 endif 32 32 33 33 core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ 34 - ifneq '$(CONFIG_H8300_BUILTIN_DTB)' '""' 35 - core-y += arch/h8300/boot/dts/ 36 - endif 34 + core-y += arch/$(ARCH)/boot/dts/ 37 35 38 36 libs-y += arch/$(ARCH)/lib/ 39 37 40 38 boot := arch/h8300/boot 41 - 42 - %.dtb %.dtb.S %.dtb.o: | scripts 43 - $(Q)$(MAKE) $(build)=arch/h8300/boot/dts arch/h8300/boot/dts/$@ 44 - 45 - PHONY += dtbs 46 - dtbs: scripts 47 - $(Q)$(MAKE) $(build)=arch/h8300/boot/dts 48 39 49 40 archmrproper: 50 41
+1 -3
arch/microblaze/Makefile
··· 65 65 # Are we making a simpleImage.<boardname> target? If so, crack out the boardname 66 66 DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 67 67 68 - ifneq ($(DTB),) 69 - core-y += $(boot)/dts/ 70 - endif 68 + core-y += $(boot)/dts/ 71 69 72 70 # defines filename extension depending memory management type 73 71 ifeq ($(CONFIG_MMU),)
+4
arch/microblaze/boot/dts/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # 3 3 4 + dtb-y := system.dtb 5 + 6 + ifneq ($(DTB),) 4 7 obj-y += linked_dtb.o 5 8 6 9 # Ensure system.dtb exists ··· 13 10 ifneq ($(DTB),system) 14 11 $(obj)/system.dtb: $(obj)/$(DTB).dtb 15 12 $(call if_changed,cp) 13 + endif 16 14 endif 17 15 18 16 quiet_cmd_cp = CP $< $@$2
+4 -2
arch/microblaze/kernel/cpu/cpuinfo.c
··· 89 89 90 90 void __init setup_cpuinfo(void) 91 91 { 92 - cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); 92 + cpu = of_get_cpu_node(0, NULL); 93 93 if (!cpu) 94 - pr_err("You don't have cpu!!!\n"); 94 + pr_err("You don't have cpu or are missing cpu reg property!!!\n"); 95 95 96 96 pr_info("%s: initialising\n", __func__); 97 97 ··· 117 117 if (cpuinfo.mmu_privins) 118 118 pr_warn("%s: Stream instructions enabled" 119 119 " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); 120 + 121 + of_node_put(cpu); 120 122 } 121 123 122 124 void __init setup_cpuinfo_clk(void)
+1 -14
arch/mips/Makefile
··· 407 407 CLEAN_FILES += vmlinux.32 vmlinux.64 408 408 409 409 # device-trees 410 - core-$(CONFIG_BUILTIN_DTB) += arch/mips/boot/dts/ 411 - 412 - %.dtb %.dtb.S %.dtb.o: | scripts 413 - $(Q)$(MAKE) $(build)=arch/mips/boot/dts arch/mips/boot/dts/$@ 414 - 415 - PHONY += dtbs 416 - dtbs: scripts 417 - $(Q)$(MAKE) $(build)=arch/mips/boot/dts 418 - 419 - PHONY += dtbs_install 420 - dtbs_install: 421 - $(Q)$(MAKE) $(dtbinst)=arch/mips/boot/dts 410 + core-y += arch/mips/boot/dts/ 422 411 423 412 archprepare: 424 413 ifdef CONFIG_MIPS32_N32 ··· 450 461 echo ' uImage.lzma - U-Boot image (lzma)' 451 462 echo ' uImage.lzo - U-Boot image (lzo)' 452 463 echo ' uzImage.bin - U-Boot image (self-extracting)' 453 - echo ' dtbs - Device-tree blobs for enabled boards' 454 - echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' 455 464 echo 456 465 echo ' These will be default as appropriate for a configured platform.' 457 466 echo
+1 -1
arch/nds32/Makefile
··· 47 47 endif 48 48 49 49 boot := arch/nds32/boot 50 - core-$(BUILTIN_DTB) += $(boot)/dts/ 50 + core-y += $(boot)/dts/ 51 51 52 52 .PHONY: FORCE 53 53
+1 -10
arch/nios2/Makefile
··· 49 49 PHONY += $(BOOT_TARGETS) install 50 50 KBUILD_IMAGE := $(nios2-boot)/vmImage 51 51 52 - ifneq ($(CONFIG_NIOS2_DTB_SOURCE),"") 53 - core-y += $(nios2-boot)/ 54 - endif 52 + core-y += $(nios2-boot)/dts/ 55 53 56 54 all: vmImage 57 55 58 56 archclean: 59 57 $(Q)$(MAKE) $(clean)=$(nios2-boot) 60 - 61 - %.dtb: | scripts 62 - $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ 63 - 64 - dtbs: 65 - $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ 66 58 67 59 $(BOOT_TARGETS): vmlinux 68 60 $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ ··· 68 76 echo ' (your) ~/bin/$(INSTALLKERNEL) or' 69 77 echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 70 78 echo ' install to $$(INSTALL_PATH)' 71 - echo ' dtbs - Build device tree blobs for enabled boards' 72 79 endef
-22
arch/nios2/boot/Makefile
··· 31 31 $(obj)/compressed/vmlinux: $(obj)/vmlinux.gz FORCE 32 32 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 33 33 34 - # Rule to build device tree blobs 35 - DTB_SRC := $(patsubst "%",%,$(CONFIG_NIOS2_DTB_SOURCE)) 36 - 37 - # Make sure the generated dtb gets removed during clean 38 - extra-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += system.dtb 39 - 40 - $(obj)/system.dtb: $(DTB_SRC) FORCE 41 - $(call cmd,dtc) 42 - 43 - # Ensure system.dtb exists 44 - $(obj)/linked_dtb.o: $(obj)/system.dtb 45 - 46 - obj-$(CONFIG_NIOS2_DTB_SOURCE_BOOL) += linked_dtb.o 47 - 48 - targets += $(dtb-y) 49 - 50 - # Rule to build device tree blobs with make command 51 - $(obj)/%.dtb: $(src)/dts/%.dts FORCE 52 - $(call if_changed_dep,dtc) 53 - 54 - $(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y)) 55 - 56 34 install: 57 35 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
+6
arch/nios2/boot/dts/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + obj-y := $(patsubst "%.dts",%.dtb.o,$(CONFIG_NIOS2_DTB_SOURCE)) 4 + 5 + dtstree := $(srctree)/$(src) 6 + dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
-19
arch/nios2/boot/linked_dtb.S
··· 1 - /* 2 - * Copyright (C) 2011 Thomas Chou <thomas@wytron.com.tw> 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License as published by 6 - * the Free Software Foundation; either version 2 of the License, or 7 - * (at your option) any later version. 8 - * 9 - * This program is distributed in the hope that it will be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 - * 17 - */ 18 - .section .dtb.init.rodata,"a" 19 - .incbin "arch/nios2/boot/system.dtb"
+3 -1
arch/nios2/kernel/cpuinfo.c
··· 47 47 const char *str; 48 48 int len; 49 49 50 - cpu = of_find_node_by_type(NULL, "cpu"); 50 + cpu = of_get_cpu_node(0, NULL); 51 51 if (!cpu) 52 52 panic("%s: No CPU found in devicetree!\n", __func__); 53 53 ··· 120 120 cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr"); 121 121 cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr"); 122 122 cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr"); 123 + 124 + of_node_put(cpu); 123 125 } 124 126 125 127 #ifdef CONFIG_PROC_FS
+2 -2
arch/nios2/kernel/time.c
··· 214 214 { 215 215 *base = of_iomap(np, 0); 216 216 if (!*base) { 217 - pr_crit("Unable to map reg for %s\n", np->name); 217 + pr_crit("Unable to map reg for %pOFn\n", np); 218 218 return -ENXIO; 219 219 } 220 220 221 221 if (of_property_read_u32(np, "clock-frequency", freq)) { 222 - pr_crit("Unable to get %s clock frequency\n", np->name); 222 + pr_crit("Unable to get %pOFn clock frequency\n", np); 223 223 return -EINVAL; 224 224 } 225 225
+1 -2
arch/openrisc/kernel/setup.c
··· 158 158 { 159 159 u32 hwid; 160 160 struct device_node *cpun; 161 - struct device_node *cpus = of_find_node_by_path("/cpus"); 162 161 163 - for_each_available_child_of_node(cpus, cpun) { 162 + for_each_of_cpu_node(cpun) { 164 163 if (of_property_read_u32(cpun, "reg", &hwid)) 165 164 continue; 166 165 if (hwid == cpu)
-3
arch/powerpc/Makefile
··· 293 293 bootwrapper_install: 294 294 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 295 295 296 - %.dtb: scripts 297 - $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 298 - 299 296 # Used to create 'merged defconfigs' 300 297 # To use it $(call) it with the first argument as the base defconfig 301 298 # and the second argument as a space separated list of .config files to merge,
+26 -29
arch/powerpc/boot/Makefile
··· 304 304 dtbImage.adder875-redboot 305 305 306 306 # Board ports in arch/powerpc/platform/52xx/Kconfig 307 - image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 lite5200.dtb 308 - image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b lite5200b.dtb 309 - image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 media5200.dtb 307 + image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200 308 + image-$(CONFIG_PPC_LITE5200) += cuImage.lite5200b 309 + image-$(CONFIG_PPC_MEDIA5200) += cuImage.media5200 310 310 311 311 # Board ports in arch/powerpc/platform/82xx/Kconfig 312 312 image-$(CONFIG_MPC8272_ADS) += cuImage.mpc8272ads ··· 381 381 $(call if_changed,wrap,$(subst $(obj)/zImage.,,$@)) 382 382 383 383 # dtbImage% - a dtbImage is a zImage with an embedded device tree blob 384 - $(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE 385 - $(call if_changed,wrap,$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 384 + $(obj)/dtbImage.initrd.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE 385 + $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 386 386 387 - $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/%.dtb FORCE 388 - $(call if_changed,wrap,$*,,$(obj)/$*.dtb) 387 + $(obj)/dtbImage.%: vmlinux $(wrapperbits) $(obj)/dts/%.dtb FORCE 388 + $(call if_changed,wrap,$*,,$(obj)/dts/$*.dtb) 389 389 390 390 # This cannot be in the root of $(src) as the zImage rule always adds a $(obj) 391 391 # prefix ··· 395 395 $(obj)/uImage: vmlinux $(wrapperbits) FORCE 396 396 $(call if_changed,wrap,uboot) 397 397 398 - $(obj)/uImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 399 - $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 398 + $(obj)/uImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 399 + $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 400 400 401 - $(obj)/uImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 402 - $(call if_changed,wrap,uboot-$*,,$(obj)/$*.dtb) 401 + $(obj)/uImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 402 + $(call if_changed,wrap,uboot-$*,,$(obj)/dts/$*.dtb) 403 403 404 - $(obj)/cuImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 405 - $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 404 + $(obj)/cuImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 405 + $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 406 406 407 - $(obj)/cuImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 408 - $(call if_changed,wrap,cuboot-$*,,$(obj)/$*.dtb) 407 + $(obj)/cuImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 408 + $(call if_changed,wrap,cuboot-$*,,$(obj)/dts/$*.dtb) 409 409 410 - $(obj)/simpleImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 411 - $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 410 + $(obj)/simpleImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 411 + $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 412 412 413 - $(obj)/simpleImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 414 - $(call if_changed,wrap,simpleboot-$*,,$(obj)/$*.dtb) 413 + $(obj)/simpleImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 414 + $(call if_changed,wrap,simpleboot-$*,,$(obj)/dts/$*.dtb) 415 415 416 - $(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 417 - $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb,$(obj)/ramdisk.image.gz) 416 + $(obj)/treeImage.initrd.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 417 + $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb,$(obj)/ramdisk.image.gz) 418 418 419 - $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) FORCE 420 - $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb) 419 + $(obj)/treeImage.%: vmlinux $(obj)/dts/%.dtb $(wrapperbits) FORCE 420 + $(call if_changed,wrap,treeboot-$*,,$(obj)/dts/$*.dtb) 421 421 422 - # Rule to build device tree blobs 423 - $(obj)/%.dtb: $(src)/dts/%.dts FORCE 424 - $(call if_changed_dep,dtc) 425 - 426 - $(obj)/%.dtb: $(src)/dts/fsl/%.dts FORCE 427 - $(call if_changed_dep,dtc) 422 + # Needed for the above targets to work with dts/fsl/ files 423 + $(obj)/dts/%.dtb: $(obj)/dts/fsl/%.dtb 424 + @cp $< $@ 428 425 429 426 # If there isn't a platform selected then just strip the vmlinux. 430 427 ifeq (,$(image-y))
+6
arch/powerpc/boot/dts/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + subdir-y += fsl 4 + 5 + dtstree := $(srctree)/$(src) 6 + dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+4
arch/powerpc/boot/dts/fsl/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + dtstree := $(srctree)/$(src) 4 + dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+2
arch/powerpc/boot/libfdt_env.h
··· 5 5 #include <types.h> 6 6 #include <string.h> 7 7 8 + #define INT_MAX ((int)(~0U>>1)) 9 + 8 10 #include "of.h" 9 11 10 12 typedef unsigned long uintptr_t;
+1 -1
arch/powerpc/platforms/4xx/soc.c
··· 200 200 u32 reset_type = DBCR0_RST_SYSTEM; 201 201 const u32 *prop; 202 202 203 - np = of_find_node_by_type(NULL, "cpu"); 203 + np = of_get_cpu_node(0, NULL); 204 204 if (np) { 205 205 prop = of_get_property(np, "reset-type", NULL); 206 206
+3 -2
arch/powerpc/platforms/8xx/m8xx_setup.c
··· 66 66 int found = 0; 67 67 68 68 /* The cpu node should have timebase and clock frequency properties */ 69 - cpu = of_find_node_by_type(NULL, "cpu"); 69 + cpu = of_get_cpu_node(0, NULL); 70 70 71 71 if (cpu) { 72 72 fp = of_get_property(cpu, name, NULL); ··· 147 147 * we have to enable the timebase). The decrementer interrupt 148 148 * is wired into the vector table, nothing to do here for that. 149 149 */ 150 - cpu = of_find_node_by_type(NULL, "cpu"); 150 + cpu = of_get_cpu_node(0, NULL); 151 151 virq= irq_of_parse_and_map(cpu, 0); 152 + of_node_put(cpu); 152 153 irq = virq_to_hw(virq); 153 154 154 155 sys_tmr2 = immr_map(im_sit);
+18 -33
arch/powerpc/platforms/powermac/feature.c
··· 1049 1049 unsigned long flags; 1050 1050 struct macio_chip *macio; 1051 1051 struct device_node *np; 1052 - struct device_node *cpus; 1053 1052 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, 1054 1053 KL_GPIO_RESET_CPU1, 1055 1054 KL_GPIO_RESET_CPU2, ··· 1058 1059 if (macio->type != macio_keylargo) 1059 1060 return -ENODEV; 1060 1061 1061 - cpus = of_find_node_by_path("/cpus"); 1062 - if (cpus == NULL) 1063 - return -ENODEV; 1064 - for (np = cpus->child; np != NULL; np = np->sibling) { 1062 + for_each_of_cpu_node(np) { 1065 1063 const u32 *num = of_get_property(np, "reg", NULL); 1066 1064 const u32 *rst = of_get_property(np, "soft-reset", NULL); 1067 1065 if (num == NULL || rst == NULL) ··· 1068 1072 break; 1069 1073 } 1070 1074 } 1071 - of_node_put(cpus); 1072 1075 if (np == NULL || reset_io == 0) 1073 1076 reset_io = dflt_reset_lines[param]; 1074 1077 ··· 1499 1504 unsigned long flags; 1500 1505 struct macio_chip *macio; 1501 1506 struct device_node *np; 1502 - struct device_node *cpus; 1503 1507 1504 1508 macio = &macio_chips[0]; 1505 1509 if (macio->type != macio_keylargo2 && macio->type != macio_shasta) 1506 1510 return -ENODEV; 1507 1511 1508 - cpus = of_find_node_by_path("/cpus"); 1509 - if (cpus == NULL) 1510 - return -ENODEV; 1511 - for (np = cpus->child; np != NULL; np = np->sibling) { 1512 + for_each_of_cpu_node(np) { 1512 1513 const u32 *num = of_get_property(np, "reg", NULL); 1513 1514 const u32 *rst = of_get_property(np, "soft-reset", NULL); 1514 1515 if (num == NULL || rst == NULL) ··· 1514 1523 break; 1515 1524 } 1516 1525 } 1517 - of_node_put(cpus); 1518 1526 if (np == NULL || reset_io == 0) 1519 1527 return -ENODEV; 1520 1528 ··· 2505 2515 * supposed to be set when not supported, but I'm not very confident 2506 2516 * that all Apple OF revs did it properly, I do it the paranoid way. 2507 2517 */ 2508 - while (uninorth_base && uninorth_rev > 3) { 2509 - struct device_node *cpus = of_find_node_by_path("/cpus"); 2518 + if (uninorth_base && uninorth_rev > 3) { 2510 2519 struct device_node *np; 2511 2520 2512 - if (!cpus || !cpus->child) { 2513 - printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); 2514 - of_node_put(cpus); 2515 - break; 2521 + for_each_of_cpu_node(np) { 2522 + int cpu_count = 1; 2523 + 2524 + /* Nap mode not supported on SMP */ 2525 + if (of_get_property(np, "flush-on-lock", NULL) || 2526 + (cpu_count > 1)) { 2527 + powersave_nap = 0; 2528 + of_node_put(np); 2529 + break; 2530 + } 2531 + 2532 + cpu_count++; 2533 + powersave_nap = 1; 2516 2534 } 2517 - np = cpus->child; 2518 - /* Nap mode not supported on SMP */ 2519 - if (np->sibling) { 2520 - of_node_put(cpus); 2521 - break; 2522 - } 2523 - /* Nap mode not supported if flush-on-lock property is present */ 2524 - if (of_get_property(np, "flush-on-lock", NULL)) { 2525 - of_node_put(cpus); 2526 - break; 2527 - } 2528 - of_node_put(cpus); 2529 - powersave_nap = 1; 2530 - printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); 2531 - break; 2532 2535 } 2536 + if (powersave_nap) 2537 + printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); 2533 2538 2534 2539 /* On CPUs that support it (750FX), lowspeed by default during 2535 2540 * NAP mode
+8 -7
arch/powerpc/platforms/powermac/setup.c
··· 243 243 { 244 244 /* Checks "l2cr-value" property in the registry */ 245 245 if (cpu_has_feature(CPU_FTR_L2CR)) { 246 - struct device_node *np = of_find_node_by_name(NULL, "cpus"); 247 - if (!np) 248 - np = of_find_node_by_type(NULL, "cpu"); 249 - if (np) { 246 + struct device_node *np; 247 + 248 + for_each_of_cpu_node(np) { 250 249 const unsigned int *l2cr = 251 250 of_get_property(np, "l2cr-value", NULL); 252 251 if (l2cr) { ··· 255 256 _set_L2CR(ppc_override_l2cr_value); 256 257 } 257 258 of_node_put(np); 259 + break; 258 260 } 259 261 } 260 262 ··· 279 279 /* Set loops_per_jiffy to a half-way reasonable value, 280 280 for use until calibrate_delay gets called. */ 281 281 loops_per_jiffy = 50000000 / HZ; 282 - cpu = of_find_node_by_type(NULL, "cpu"); 283 - if (cpu != NULL) { 282 + 283 + for_each_of_cpu_node(cpu) { 284 284 fp = of_get_property(cpu, "clock-frequency", NULL); 285 285 if (fp != NULL) { 286 286 if (pvr >= 0x30 && pvr < 0x80) ··· 292 292 else 293 293 /* 601, 603, etc. */ 294 294 loops_per_jiffy = *fp / (2 * HZ); 295 + of_node_put(cpu); 296 + break; 295 297 } 296 - of_node_put(cpu); 297 298 } 298 299 299 300 /* See if newworld or oldworld */
+1 -1
arch/sh/boards/of-generic.c
··· 64 64 65 65 init_cpu_possible(cpumask_of(0)); 66 66 67 - for_each_node_by_type(np, "cpu") { 67 + for_each_of_cpu_node(np) { 68 68 const __be32 *cell = of_get_property(np, "reg", NULL); 69 69 u64 id = -1; 70 70 if (cell) id = of_read_number(cell, of_n_addr_cells(np));
-3
arch/sparc/include/asm/prom.h
··· 24 24 #include <linux/atomic.h> 25 25 #include <linux/irqdomain.h> 26 26 27 - #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 28 - #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 29 - 30 27 #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) 31 28 #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) 32 29 #define of_node_cmp(s1, s2) strcmp((s1), (s2))
+1 -1
arch/x86/kernel/devicetree.c
··· 140 140 int ret; 141 141 142 142 version = GET_APIC_VERSION(apic_read(APIC_LVR)); 143 - for_each_node_by_type(dn, "cpu") { 143 + for_each_of_cpu_node(dn) { 144 144 ret = of_property_read_u32(dn, "reg", &apic_id); 145 145 if (ret < 0) { 146 146 pr_warn("%pOF: missing local APIC ID\n", dn);
+1 -11
arch/xtensa/Makefile
··· 80 80 head-y := arch/xtensa/kernel/head.o 81 81 core-y += arch/xtensa/kernel/ arch/xtensa/mm/ 82 82 core-y += $(buildvar) $(buildplf) 83 + core-y += arch/xtensa/boot/dts/ 83 84 84 85 libs-y += arch/xtensa/lib/ $(LIBGCC) 85 86 drivers-$(CONFIG_OPROFILE) += arch/xtensa/oprofile/ 86 - 87 - ifneq ($(CONFIG_BUILTIN_DTB),"") 88 - core-$(CONFIG_OF) += arch/xtensa/boot/dts/ 89 - endif 90 87 91 88 boot := arch/xtensa/boot 92 89 93 90 all Image zImage uImage: vmlinux 94 91 $(Q)$(MAKE) $(build)=$(boot) $@ 95 92 96 - %.dtb: 97 - $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ 98 - 99 - dtbs: scripts 100 - $(Q)$(MAKE) $(build)=$(boot)/dts 101 - 102 93 define archhelp 103 94 @echo '* Image - Kernel ELF image with reset vector' 104 95 @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' 105 96 @echo '* uImage - U-Boot wrapped image' 106 - @echo ' dtbs - Build device tree blobs for enabled boards' 107 97 endef
+3 -3
arch/xtensa/platforms/xtfpga/setup.c
··· 94 94 u32 freq; 95 95 96 96 if (!base) { 97 - pr_err("%s: invalid address\n", np->name); 97 + pr_err("%pOFn: invalid address\n", np); 98 98 return; 99 99 } 100 100 ··· 103 103 clk = clk_register_fixed_rate(NULL, np->name, NULL, 0, freq); 104 104 105 105 if (IS_ERR(clk)) { 106 - pr_err("%s: clk registration failed\n", np->name); 106 + pr_err("%pOFn: clk registration failed\n", np); 107 107 return; 108 108 } 109 109 110 110 if (of_clk_add_provider(np, of_clk_src_simple_get, clk)) { 111 - pr_err("%s: clk provider registration failed\n", np->name); 111 + pr_err("%pOFn: clk provider registration failed\n", np); 112 112 return; 113 113 } 114 114 }
+3 -3
drivers/bus/fsl-mc/fsl-mc-bus.c
··· 706 706 *ranges_start = of_get_property(mc_node, "ranges", &ranges_len); 707 707 if (!(*ranges_start) || !ranges_len) { 708 708 dev_warn(dev, 709 - "missing or empty ranges property for device tree node '%s'\n", 710 - mc_node->name); 709 + "missing or empty ranges property for device tree node '%pOFn'\n", 710 + mc_node); 711 711 return 0; 712 712 } 713 713 ··· 730 730 731 731 tuple_len = range_tuple_cell_count * sizeof(__be32); 732 732 if (ranges_len % tuple_len != 0) { 733 - dev_err(dev, "malformed ranges property '%s'\n", mc_node->name); 733 + dev_err(dev, "malformed ranges property '%pOFn'\n", mc_node); 734 734 return -EINVAL; 735 735 } 736 736
+1 -1
drivers/bus/mvebu-mbus.c
··· 1229 1229 tuple_len = (*cell_count) * sizeof(__be32); 1230 1230 1231 1231 if (ranges_len % tuple_len) { 1232 - pr_warn("malformed ranges entry '%s'\n", node->name); 1232 + pr_warn("malformed ranges entry '%pOFn'\n", node); 1233 1233 return -EINVAL; 1234 1234 } 1235 1235 return 0;
+2 -2
drivers/clk/mvebu/clk-cpu.c
··· 183 183 pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n", 184 184 __func__); 185 185 186 - for_each_node_by_type(dn, "cpu") 186 + for_each_of_cpu_node(dn) 187 187 ncpus++; 188 188 189 189 cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL); ··· 194 194 if (WARN_ON(!clks)) 195 195 goto clks_out; 196 196 197 - for_each_node_by_type(dn, "cpu") { 197 + for_each_of_cpu_node(dn) { 198 198 struct clk_init_data init; 199 199 struct clk *clk; 200 200 char *clk_name = kzalloc(5, GFP_KERNEL);
+2 -18
drivers/edac/cpc925_edac.c
··· 593 593 /******************** CPU err device********************************/ 594 594 static u32 cpc925_cpu_mask_disabled(void) 595 595 { 596 - struct device_node *cpus; 597 - struct device_node *cpunode = NULL; 596 + struct device_node *cpunode; 598 597 static u32 mask = 0; 599 598 600 599 /* use cached value if available */ ··· 602 603 603 604 mask = APIMASK_ADI0 | APIMASK_ADI1; 604 605 605 - cpus = of_find_node_by_path("/cpus"); 606 - if (cpus == NULL) { 607 - cpc925_printk(KERN_DEBUG, "No /cpus node !\n"); 608 - return 0; 609 - } 610 - 611 - while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) { 606 + for_each_of_cpu_node(cpunode) { 612 607 const u32 *reg = of_get_property(cpunode, "reg", NULL); 613 - 614 - if (strcmp(cpunode->type, "cpu")) { 615 - cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name); 616 - continue; 617 - } 618 - 619 608 if (reg == NULL || *reg > 2) { 620 609 cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode); 621 610 continue; ··· 619 632 cpc925_printk(KERN_WARNING, 620 633 "Assuming PI id is equal to CPU MPIC id!\n"); 621 634 } 622 - 623 - of_node_put(cpunode); 624 - of_node_put(cpus); 625 635 626 636 return mask; 627 637 }
+1 -1
drivers/firmware/scpi_pm_domain.c
··· 121 121 122 122 scpi_pd->domain = i; 123 123 scpi_pd->ops = scpi_ops; 124 - sprintf(scpi_pd->name, "%s.%d", np->name, i); 124 + sprintf(scpi_pd->name, "%pOFn.%d", np, i); 125 125 scpi_pd->genpd.name = scpi_pd->name; 126 126 scpi_pd->genpd.power_off = scpi_pd_power_off; 127 127 scpi_pd->genpd.power_on = scpi_pd_power_on;
+3 -2
drivers/gpu/drm/mediatek/mtk_hdmi.c
··· 1446 1446 } 1447 1447 1448 1448 /* The CEC module handles HDMI hotplug detection */ 1449 - cec_np = of_find_compatible_node(np->parent, NULL, 1450 - "mediatek,mt8173-cec"); 1449 + cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); 1451 1450 if (!cec_np) { 1452 1451 dev_err(dev, "Failed to find CEC node\n"); 1453 1452 return -EINVAL; ··· 1456 1457 if (!cec_pdev) { 1457 1458 dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", 1458 1459 cec_np); 1460 + of_node_put(cec_np); 1459 1461 return -EPROBE_DEFER; 1460 1462 } 1463 + of_node_put(cec_np); 1461 1464 hdmi->cec_dev = &cec_pdev->dev; 1462 1465 1463 1466 /*
+3 -2
drivers/gpu/drm/msm/adreno/adreno_gpu.c
··· 633 633 struct device_node *child, *node; 634 634 int ret; 635 635 636 - node = of_find_compatible_node(dev->of_node, NULL, 637 - "qcom,gpu-pwrlevels"); 636 + node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels"); 638 637 if (!node) { 639 638 dev_err(dev, "Could not find the GPU powerlevels\n"); 640 639 return -ENXIO; ··· 653 654 if (val != 27000000) 654 655 dev_pm_opp_add(dev, val, 0); 655 656 } 657 + 658 + of_node_put(node); 656 659 657 660 return 0; 658 661 }
+1 -1
drivers/iommu/fsl_pamu.c
··· 543 543 return ~(u32)0; 544 544 } 545 545 546 - for_each_node_by_type(node, "cpu") { 546 + for_each_of_cpu_node(node) { 547 547 prop = of_get_property(node, "reg", &len); 548 548 for (i = 0; i < len / sizeof(u32); i++) { 549 549 if (be32_to_cpup(&prop[i]) == vcpu) {
+1 -1
drivers/net/ethernet/broadcom/genet/bcmmii.c
··· 341 341 if (!compat) 342 342 return NULL; 343 343 344 - priv->mdio_dn = of_find_compatible_node(dn, NULL, compat); 344 + priv->mdio_dn = of_get_compatible_child(dn, compat); 345 345 kfree(compat); 346 346 if (!priv->mdio_dn) { 347 347 dev_err(kdev, "unable to find MDIO bus node\n");
+10 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 714 714 return -ENODEV; 715 715 } 716 716 717 - mdio_internal = of_find_compatible_node(mdio_mux, NULL, 717 + mdio_internal = of_get_compatible_child(mdio_mux, 718 718 "allwinner,sun8i-h3-mdio-internal"); 719 + of_node_put(mdio_mux); 719 720 if (!mdio_internal) { 720 721 dev_err(priv->device, "Cannot get internal_mdio node\n"); 721 722 return -ENODEV; ··· 730 729 gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL); 731 730 if (IS_ERR(gmac->rst_ephy)) { 732 731 ret = PTR_ERR(gmac->rst_ephy); 733 - if (ret == -EPROBE_DEFER) 732 + if (ret == -EPROBE_DEFER) { 733 + of_node_put(iphynode); 734 + of_node_put(mdio_internal); 734 735 return ret; 736 + } 735 737 continue; 736 738 } 737 739 dev_info(priv->device, "Found internal PHY node\n"); 740 + of_node_put(iphynode); 741 + of_node_put(mdio_internal); 738 742 return 0; 739 743 } 744 + 745 + of_node_put(mdio_internal); 740 746 return -ENODEV; 741 747 } 742 748
+2 -3
drivers/nfc/nfcmrvl/uart.c
··· 73 73 struct device_node *matched_node; 74 74 int ret; 75 75 76 - matched_node = of_find_compatible_node(node, NULL, "marvell,nfc-uart"); 76 + matched_node = of_get_compatible_child(node, "marvell,nfc-uart"); 77 77 if (!matched_node) { 78 - matched_node = of_find_compatible_node(node, NULL, 79 - "mrvl,nfc-uart"); 78 + matched_node = of_get_compatible_child(node, "mrvl,nfc-uart"); 80 79 if (!matched_node) 81 80 return -ENODEV; 82 81 }
+45 -2
drivers/of/base.c
··· 67 67 68 68 return (strlen(name) == len) && (strncmp(node_name, name, len) == 0); 69 69 } 70 + EXPORT_SYMBOL(of_node_name_eq); 70 71 71 72 bool of_node_name_prefix(const struct device_node *np, const char *prefix) 72 73 { ··· 76 75 77 76 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; 78 77 } 78 + EXPORT_SYMBOL(of_node_name_prefix); 79 79 80 80 int of_n_addr_cells(struct device_node *np) 81 81 { ··· 332 330 333 331 ac = of_n_addr_cells(cpun); 334 332 cell = of_get_property(cpun, prop_name, &prop_len); 333 + if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0)) 334 + return true; 335 335 if (!cell || !ac) 336 336 return false; 337 337 prop_len /= sizeof(*cell) * ac; ··· 394 390 { 395 391 struct device_node *cpun; 396 392 397 - for_each_node_by_type(cpun, "cpu") { 393 + for_each_of_cpu_node(cpun) { 398 394 if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) 399 395 return cpun; 400 396 } ··· 747 743 return next; 748 744 } 749 745 EXPORT_SYMBOL(of_get_next_available_child); 746 + 747 + /** 748 + * of_get_next_cpu_node - Iterate on cpu nodes 749 + * @prev: previous child of the /cpus node, or NULL to get first 750 + * 751 + * Returns a cpu node pointer with refcount incremented, use of_node_put() 752 + * on it when done. Returns NULL when prev is the last child. Decrements 753 + * the refcount of prev. 754 + */ 755 + struct device_node *of_get_next_cpu_node(struct device_node *prev) 756 + { 757 + struct device_node *next = NULL; 758 + unsigned long flags; 759 + struct device_node *node; 760 + 761 + if (!prev) 762 + node = of_find_node_by_path("/cpus"); 763 + 764 + raw_spin_lock_irqsave(&devtree_lock, flags); 765 + if (prev) 766 + next = prev->sibling; 767 + else if (node) { 768 + next = node->child; 769 + of_node_put(node); 770 + } 771 + for (; next; next = next->sibling) { 772 + if (!(of_node_name_eq(next, "cpu") || 773 + (next->type && !of_node_cmp(next->type, "cpu")))) 774 + continue; 775 + if (!__of_device_is_available(next)) 776 + continue; 777 + if (of_node_get(next)) 778 + break; 779 + } 780 + of_node_put(prev); 781 + raw_spin_unlock_irqrestore(&devtree_lock, flags); 782 + return next; 783 + } 784 + EXPORT_SYMBOL(of_get_next_cpu_node); 750 785 751 786 /** 752 787 * of_get_compatible_child - Find compatible child node ··· 2056 2013 /* OF on pmac has nodes instead of properties named "l2-cache" 2057 2014 * beneath CPU nodes. 2058 2015 */ 2059 - if (!strcmp(np->type, "cpu")) 2016 + if (IS_ENABLED(CONFIG_PPC_PMAC) && !strcmp(np->type, "cpu")) 2060 2017 for_each_child_of_node(np, child) 2061 2018 if (!strcmp(child->type, "cache")) 2062 2019 return child;
+3 -2
drivers/of/device.c
··· 207 207 return -ENODEV; 208 208 209 209 /* Name & Type */ 210 - csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name, 210 + /* %p eats all alphanum characters, so %c must be used here */ 211 + csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', 211 212 dev->of_node->type); 212 213 tsize = csize; 213 214 len -= csize; ··· 287 286 if ((!dev) || (!dev->of_node)) 288 287 return; 289 288 290 - add_uevent_var(env, "OF_NAME=%s", dev->of_node->name); 289 + add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); 291 290 add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); 292 291 if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0) 293 292 add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type);
+6 -6
drivers/of/of_mdio.c
··· 97 97 return rc; 98 98 } 99 99 100 - dev_dbg(&mdio->dev, "registered phy %s at address %i\n", 101 - child->name, addr); 100 + dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", 101 + child, addr); 102 102 return 0; 103 103 } 104 104 ··· 127 127 return rc; 128 128 } 129 129 130 - dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n", 131 - child->name, addr); 130 + dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", 131 + child, addr); 132 132 return 0; 133 133 } 134 134 ··· 263 263 continue; 264 264 265 265 /* be noisy to encourage people to set reg property */ 266 - dev_info(&mdio->dev, "scan phy %s at address %i\n", 267 - child->name, addr); 266 + dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", 267 + child, addr); 268 268 269 269 if (of_mdiobus_child_is_phy(child)) { 270 270 rc = of_mdiobus_register_phy(mdio, child, addr);
+4 -15
drivers/of/of_numa.c
··· 24 24 { 25 25 u32 nid; 26 26 int r; 27 - struct device_node *cpus; 28 - struct device_node *np = NULL; 27 + struct device_node *np; 29 28 30 - cpus = of_find_node_by_path("/cpus"); 31 - if (!cpus) 32 - return; 33 - 34 - for_each_child_of_node(cpus, np) { 35 - /* Skip things that are not CPUs */ 36 - if (of_node_cmp(np->type, "cpu") != 0) 37 - continue; 38 - 29 + for_each_of_cpu_node(np) { 39 30 r = of_property_read_u32(np, "numa-node-id", &nid); 40 31 if (r) 41 32 continue; ··· 37 46 else 38 47 node_set(nid, numa_nodes_parsed); 39 48 } 40 - 41 - of_node_put(cpus); 42 49 } 43 50 44 51 static int __init of_numa_parse_memory_nodes(void) ··· 152 163 np = of_get_next_parent(np); 153 164 } 154 165 if (np && r) 155 - pr_warn("Invalid \"numa-node-id\" property in node %s\n", 156 - np->name); 166 + pr_warn("Invalid \"numa-node-id\" property in node %pOFn\n", 167 + np); 157 168 of_node_put(np); 158 169 159 170 /*
+8
drivers/of/of_private.h
··· 27 27 char stem[0]; 28 28 }; 29 29 30 + #if defined(CONFIG_SPARC) 31 + #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 32 + #else 33 + #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 34 + #endif 35 + 36 + #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 37 + 30 38 extern struct mutex of_mutex; 31 39 extern struct list_head aliases_lookup; 32 40 extern struct kset *of_kset;
+2 -2
drivers/of/overlay.c
··· 425 425 for_each_child_of_node(overlay_node, child) { 426 426 ret = add_changeset_node(ovcs, target_node, child); 427 427 if (ret) { 428 - pr_debug("Failed to apply node @%pOF/%s, err=%d\n", 429 - target_node, child->name, ret); 428 + pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n", 429 + target_node, child, ret); 430 430 of_node_put(child); 431 431 return ret; 432 432 }
+4 -4
drivers/of/platform.c
··· 91 91 */ 92 92 reg = of_get_property(node, "reg", NULL); 93 93 if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) { 94 - dev_set_name(dev, dev_name(dev) ? "%llx.%s:%s" : "%llx.%s", 95 - (unsigned long long)addr, node->name, 94 + dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn", 95 + (unsigned long long)addr, node, 96 96 dev_name(dev)); 97 97 return; 98 98 } ··· 142 142 WARN_ON(rc); 143 143 } 144 144 if (of_irq_to_resource_table(np, res, num_irq) != num_irq) 145 - pr_debug("not all legacy IRQ resources mapped for %s\n", 146 - np->name); 145 + pr_debug("not all legacy IRQ resources mapped for %pOFn\n", 146 + np); 147 147 } 148 148 149 149 dev->dev.of_node = of_node_get(np);
+2 -2
drivers/of/unittest-data/overlay_15.dts
··· 20 20 #size-cells = <0>; 21 21 reg = <0>; 22 22 23 - test-mux-dev { 24 - reg = <32>; 23 + test-mux-dev@20 { 24 + reg = <0x20>; 25 25 compatible = "unittest-i2c-dev"; 26 26 status = "okay"; 27 27 };
+2 -2
drivers/of/unittest-data/tests-overlay.dtsi
··· 103 103 #size-cells = <0>; 104 104 reg = <0>; 105 105 106 - test-mux-dev { 107 - reg = <32>; 106 + test-mux-dev@20 { 107 + reg = <0x20>; 108 108 compatible = "unittest-i2c-dev"; 109 109 status = "okay"; 110 110 };
+18 -11
drivers/of/unittest.c
··· 212 212 213 213 for_each_child_of_node(np, child) { 214 214 if (child->parent != np) { 215 - pr_err("Child node %s links to wrong parent %s\n", 216 - child->name, np->name); 215 + pr_err("Child node %pOFn links to wrong parent %pOFn\n", 216 + child, np); 217 217 rc = -EINVAL; 218 218 goto put_child; 219 219 } ··· 299 299 300 300 of_unittest_printf_one(np, "%pOF", full_name); 301 301 of_unittest_printf_one(np, "%pOFf", full_name); 302 + of_unittest_printf_one(np, "%pOFn", "dev"); 303 + of_unittest_printf_one(np, "%2pOFn", "dev"); 304 + of_unittest_printf_one(np, "%5pOFn", " dev"); 305 + of_unittest_printf_one(np, "%pOFnc", "dev:test-sub-device"); 302 306 of_unittest_printf_one(np, "%pOFp", phandle_str); 303 307 of_unittest_printf_one(np, "%pOFP", "dev@100"); 304 308 of_unittest_printf_one(np, "ABC %pOFP ABC", "ABC dev@100 ABC"); ··· 1050 1046 for_each_child_of_node(np, child) { 1051 1047 for_each_child_of_node(child, grandchild) 1052 1048 unittest(of_find_device_by_node(grandchild), 1053 - "Could not create device for node '%s'\n", 1054 - grandchild->name); 1049 + "Could not create device for node '%pOFn'\n", 1050 + grandchild); 1055 1051 } 1056 1052 1057 1053 of_platform_depopulate(&test_bus->dev); 1058 1054 for_each_child_of_node(np, child) { 1059 1055 for_each_child_of_node(child, grandchild) 1060 1056 unittest(!of_find_device_by_node(grandchild), 1061 - "device didn't get destroyed '%s'\n", 1062 - grandchild->name); 1057 + "device didn't get destroyed '%pOFn'\n", 1058 + grandchild); 1063 1059 } 1064 1060 1065 1061 platform_device_unregister(test_bus); ··· 2361 2357 } 2362 2358 } 2363 2359 2364 - for (np = overlay_base_root->child; np; np = np->sibling) { 2365 - if (of_get_child_by_name(of_root, np->name)) { 2366 - unittest(0, "illegal node name in overlay_base %s", 2367 - np->name); 2368 - return; 2360 + for_each_child_of_node(overlay_base_root, np) { 2361 + struct device_node *base_child; 2362 + for_each_child_of_node(of_root, base_child) { 2363 + if (!strcmp(np->full_name, base_child->full_name)) { 2364 + unittest(0, "illegal node name in overlay_base %pOFn", 2365 + np); 2366 + return; 2367 + } 2369 2368 } 2370 2369 } 2371 2370
+3 -2
drivers/power/supply/twl4030_charger.c
··· 1022 1022 if (bci->dev->of_node) { 1023 1023 struct device_node *phynode; 1024 1024 1025 - phynode = of_find_compatible_node(bci->dev->of_node->parent, 1026 - NULL, "ti,twl4030-usb"); 1025 + phynode = of_get_compatible_child(bci->dev->of_node->parent, 1026 + "ti,twl4030-usb"); 1027 1027 if (phynode) { 1028 1028 bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; 1029 1029 bci->transceiver = devm_usb_get_phy_by_node( 1030 1030 bci->dev, phynode, &bci->usb_nb); 1031 + of_node_put(phynode); 1031 1032 if (IS_ERR(bci->transceiver)) { 1032 1033 ret = PTR_ERR(bci->transceiver); 1033 1034 if (ret == -EPROBE_DEFER)
+4 -4
drivers/soc/dove/pmu.c
··· 383 383 384 384 domains_node = of_get_child_by_name(np_pmu, "domains"); 385 385 if (!domains_node) { 386 - pr_err("%s: failed to find domains sub-node\n", np_pmu->name); 386 + pr_err("%pOFn: failed to find domains sub-node\n", np_pmu); 387 387 return 0; 388 388 } 389 389 ··· 396 396 pmu->pmc_base = of_iomap(pmu->of_node, 0); 397 397 pmu->pmu_base = of_iomap(pmu->of_node, 1); 398 398 if (!pmu->pmc_base || !pmu->pmu_base) { 399 - pr_err("%s: failed to map PMU\n", np_pmu->name); 399 + pr_err("%pOFn: failed to map PMU\n", np_pmu); 400 400 iounmap(pmu->pmu_base); 401 401 iounmap(pmu->pmc_base); 402 402 kfree(pmu); ··· 414 414 break; 415 415 416 416 domain->pmu = pmu; 417 - domain->base.name = kstrdup(np->name, GFP_KERNEL); 417 + domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np); 418 418 if (!domain->base.name) { 419 419 kfree(domain); 420 420 break; ··· 444 444 /* Loss of the interrupt controller is not a fatal error. */ 445 445 parent_irq = irq_of_parse_and_map(pmu->of_node, 0); 446 446 if (!parent_irq) { 447 - pr_err("%s: no interrupt specified\n", np_pmu->name); 447 + pr_err("%pOFn: no interrupt specified\n", np_pmu); 448 448 } else { 449 449 ret = dove_init_pmu_irq(pmu, parent_irq); 450 450 if (ret)
+2 -2
drivers/soc/fsl/qe/qe_tdm.c
··· 131 131 132 132 pdev = of_find_device_by_node(np2); 133 133 if (!pdev) { 134 - pr_err("%s: failed to lookup pdev\n", np2->name); 134 + pr_err("%pOFn: failed to lookup pdev\n", np2); 135 135 of_node_put(np2); 136 136 return -EINVAL; 137 137 } ··· 153 153 pdev = of_find_device_by_node(np2); 154 154 if (!pdev) { 155 155 ret = -EINVAL; 156 - pr_err("%s: failed to lookup pdev\n", np2->name); 156 + pr_err("%pOFn: failed to lookup pdev\n", np2); 157 157 of_node_put(np2); 158 158 goto err_miss_siram_property; 159 159 }
+1 -1
drivers/soc/qcom/apr.c
··· 219 219 adev->domain_id = id->domain_id; 220 220 adev->version = id->svc_version; 221 221 if (np) 222 - strncpy(adev->name, np->name, APR_NAME_SIZE); 222 + snprintf(adev->name, APR_NAME_SIZE, "%pOFn", np); 223 223 else 224 224 strncpy(adev->name, id->name, APR_NAME_SIZE); 225 225
+22 -22
drivers/soc/rockchip/pm_domains.c
··· 392 392 error = of_property_read_u32(node, "reg", &id); 393 393 if (error) { 394 394 dev_err(pmu->dev, 395 - "%s: failed to retrieve domain id (reg): %d\n", 396 - node->name, error); 395 + "%pOFn: failed to retrieve domain id (reg): %d\n", 396 + node, error); 397 397 return -EINVAL; 398 398 } 399 399 400 400 if (id >= pmu->info->num_domains) { 401 - dev_err(pmu->dev, "%s: invalid domain id %d\n", 402 - node->name, id); 401 + dev_err(pmu->dev, "%pOFn: invalid domain id %d\n", 402 + node, id); 403 403 return -EINVAL; 404 404 } 405 405 406 406 pd_info = &pmu->info->domain_info[id]; 407 407 if (!pd_info) { 408 - dev_err(pmu->dev, "%s: undefined domain id %d\n", 409 - node->name, id); 408 + dev_err(pmu->dev, "%pOFn: undefined domain id %d\n", 409 + node, id); 410 410 return -EINVAL; 411 411 } 412 412 ··· 424 424 if (!pd->clks) 425 425 return -ENOMEM; 426 426 } else { 427 - dev_dbg(pmu->dev, "%s: doesn't have clocks: %d\n", 428 - node->name, pd->num_clks); 427 + dev_dbg(pmu->dev, "%pOFn: doesn't have clocks: %d\n", 428 + node, pd->num_clks); 429 429 pd->num_clks = 0; 430 430 } 431 431 ··· 434 434 if (IS_ERR(pd->clks[i].clk)) { 435 435 error = PTR_ERR(pd->clks[i].clk); 436 436 dev_err(pmu->dev, 437 - "%s: failed to get clk at index %d: %d\n", 438 - node->name, i, error); 437 + "%pOFn: failed to get clk at index %d: %d\n", 438 + node, i, error); 439 439 return error; 440 440 } 441 441 } ··· 486 486 error = rockchip_pd_power(pd, true); 487 487 if (error) { 488 488 dev_err(pmu->dev, 489 - "failed to power on domain '%s': %d\n", 490 - node->name, error); 489 + "failed to power on domain '%pOFn': %d\n", 490 + node, error); 491 491 goto err_unprepare_clocks; 492 492 } 493 493 ··· 575 575 error = of_property_read_u32(parent, "reg", &idx); 576 576 if (error) { 577 577 dev_err(pmu->dev, 578 - "%s: failed to retrieve domain id (reg): %d\n", 579 - parent->name, error); 578 + "%pOFn: failed to retrieve domain id (reg): %d\n", 579 + parent, error); 580 580 goto err_out; 581 581 } 582 582 parent_domain = pmu->genpd_data.domains[idx]; 583 583 584 584 error = rockchip_pm_add_one_domain(pmu, np); 585 585 if (error) { 586 - dev_err(pmu->dev, "failed to handle node %s: %d\n", 587 - np->name, error); 586 + dev_err(pmu->dev, "failed to handle node %pOFn: %d\n", 587 + np, error); 588 588 goto err_out; 589 589 } 590 590 591 591 error = of_property_read_u32(np, "reg", &idx); 592 592 if (error) { 593 593 dev_err(pmu->dev, 594 - "%s: failed to retrieve domain id (reg): %d\n", 595 - np->name, error); 594 + "%pOFn: failed to retrieve domain id (reg): %d\n", 595 + np, error); 596 596 goto err_out; 597 597 } 598 598 child_domain = pmu->genpd_data.domains[idx]; ··· 683 683 for_each_available_child_of_node(np, node) { 684 684 error = rockchip_pm_add_one_domain(pmu, node); 685 685 if (error) { 686 - dev_err(dev, "failed to handle node %s: %d\n", 687 - node->name, error); 686 + dev_err(dev, "failed to handle node %pOFn: %d\n", 687 + node, error); 688 688 of_node_put(node); 689 689 goto err_out; 690 690 } 691 691 692 692 error = rockchip_pm_add_subdomain(pmu, node); 693 693 if (error < 0) { 694 - dev_err(dev, "failed to handle subdomain node %s: %d\n", 695 - node->name, error); 694 + dev_err(dev, "failed to handle subdomain node %pOFn: %d\n", 695 + node, error); 696 696 of_node_put(node); 697 697 goto err_out; 698 698 }
+6 -6
drivers/soc/tegra/pmc.c
··· 796 796 797 797 id = tegra_powergate_lookup(pmc, np->name); 798 798 if (id < 0) { 799 - pr_err("powergate lookup failed for %s: %d\n", np->name, id); 799 + pr_err("powergate lookup failed for %pOFn: %d\n", np, id); 800 800 goto free_mem; 801 801 } 802 802 ··· 816 816 817 817 err = tegra_powergate_of_get_clks(pg, np); 818 818 if (err < 0) { 819 - pr_err("failed to get clocks for %s: %d\n", np->name, err); 819 + pr_err("failed to get clocks for %pOFn: %d\n", np, err); 820 820 goto set_available; 821 821 } 822 822 823 823 err = tegra_powergate_of_get_resets(pg, np, off); 824 824 if (err < 0) { 825 - pr_err("failed to get resets for %s: %d\n", np->name, err); 825 + pr_err("failed to get resets for %pOFn: %d\n", np, err); 826 826 goto remove_clks; 827 827 } 828 828 ··· 851 851 852 852 err = pm_genpd_init(&pg->genpd, NULL, off); 853 853 if (err < 0) { 854 - pr_err("failed to initialise PM domain %s: %d\n", np->name, 854 + pr_err("failed to initialise PM domain %pOFn: %d\n", np, 855 855 err); 856 856 goto remove_resets; 857 857 } 858 858 859 859 err = of_genpd_add_provider_simple(np, &pg->genpd); 860 860 if (err < 0) { 861 - pr_err("failed to add PM domain provider for %s: %d\n", 862 - np->name, err); 861 + pr_err("failed to add PM domain provider for %pOFn: %d\n", 862 + np, err); 863 863 goto remove_genpd; 864 864 } 865 865
+4 -4
drivers/soc/ti/knav_dma.c
··· 544 544 545 545 ret = of_address_to_resource(node, index, &res); 546 546 if (ret) { 547 - dev_err(dev, "Can't translate of node(%s) address for index(%d)\n", 548 - node->name, index); 547 + dev_err(dev, "Can't translate of node(%pOFn) address for index(%d)\n", 548 + node, index); 549 549 return ERR_PTR(ret); 550 550 } 551 551 552 552 regs = devm_ioremap_resource(kdev->dev, &res); 553 553 if (IS_ERR(regs)) 554 - dev_err(dev, "Failed to map register base for index(%d) node(%s)\n", 555 - index, node->name); 554 + dev_err(dev, "Failed to map register base for index(%d) node(%pOFn)\n", 555 + index, node); 556 556 if (_size) 557 557 *_size = resource_size(&res); 558 558
+4 -4
drivers/soc/ti/knav_qmss_queue.c
··· 1382 1382 1383 1383 ret = of_address_to_resource(node, index, &res); 1384 1384 if (ret) { 1385 - dev_err(kdev->dev, "Can't translate of node(%s) address for index(%d)\n", 1386 - node->name, index); 1385 + dev_err(kdev->dev, "Can't translate of node(%pOFn) address for index(%d)\n", 1386 + node, index); 1387 1387 return ERR_PTR(ret); 1388 1388 } 1389 1389 1390 1390 regs = devm_ioremap_resource(kdev->dev, &res); 1391 1391 if (IS_ERR(regs)) 1392 - dev_err(kdev->dev, "Failed to map register base for index(%d) node(%s)\n", 1393 - index, node->name); 1392 + dev_err(kdev->dev, "Failed to map register base for index(%d) node(%pOFn)\n", 1393 + index, node); 1394 1394 return regs; 1395 1395 } 1396 1396
+1 -1
drivers/video/fbdev/fsl-diu-fb.c
··· 1925 1925 pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); 1926 1926 1927 1927 #ifdef CONFIG_NOT_COHERENT_CACHE 1928 - np = of_find_node_by_type(NULL, "cpu"); 1928 + np = of_get_cpu_node(0, NULL); 1929 1929 if (!np) { 1930 1930 pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); 1931 1931 return -ENODEV;
+1 -4
include/dt-bindings/clock/exynos3250.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 3 4 * Author: Tomasz Figa <t.figa@samsung.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 5 * 9 6 * Device Tree binding constants for Samsung Exynos3250 clock controllers. 10 7 */
+2 -5
include/dt-bindings/clock/exynos4.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Samsung Electronics Co., Ltd. 3 4 * Author: Andrzej Hajda <a.hajda@samsung.com> 4 5 * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 6 * Device Tree binding constants for Exynos4 clock controller. 10 - */ 7 + */ 11 8 12 9 #ifndef _DT_BINDINGS_CLOCK_EXYNOS_4_H 13 10 #define _DT_BINDINGS_CLOCK_EXYNOS_4_H
+2 -5
include/dt-bindings/clock/exynos5250.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Samsung Electronics Co., Ltd. 3 4 * Author: Andrzej Hajda <a.hajda@samsung.com> 4 5 * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 6 * Device Tree binding constants for Exynos5250 clock controller. 10 - */ 7 + */ 11 8 12 9 #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5250_H 13 10 #define _DT_BINDINGS_CLOCK_EXYNOS_5250_H
+2 -5
include/dt-bindings/clock/exynos5260-clk.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 3 4 * Author: Rahul Sharma <rahul.sharma@samsung.com> 4 5 * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 6 * Provides Constants for Exynos5260 clocks. 10 - */ 7 + */ 11 8 12 9 #ifndef _DT_BINDINGS_CLK_EXYNOS5260_H 13 10 #define _DT_BINDINGS_CLK_EXYNOS5260_H
+2 -5
include/dt-bindings/clock/exynos5410.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 3 4 * Copyright (c) 2016 Krzysztof Kozlowski 4 5 * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 6 * Device Tree binding constants for Exynos5421 clock controller. 10 - */ 7 + */ 11 8 12 9 #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5410_H 13 10 #define _DT_BINDINGS_CLOCK_EXYNOS_5410_H
+2 -5
include/dt-bindings/clock/exynos5420.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Samsung Electronics Co., Ltd. 3 4 * Author: Andrzej Hajda <a.hajda@samsung.com> 4 5 * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - * 9 6 * Device Tree binding constants for Exynos5420 clock controller. 10 - */ 7 + */ 11 8 12 9 #ifndef _DT_BINDINGS_CLOCK_EXYNOS_5420_H 13 10 #define _DT_BINDINGS_CLOCK_EXYNOS_5420_H
+1 -4
include/dt-bindings/clock/exynos5433.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 3 4 * Author: Chanwoo Choi <cw00.choi@samsung.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 5 */ 9 6 10 7 #ifndef _DT_BINDINGS_CLOCK_EXYNOS5433_H
+2 -5
include/dt-bindings/clock/exynos7-clk.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2014 Samsung Electronics Co., Ltd. 3 4 * Author: Naveen Krishna Ch <naveenkrishna.ch@gmail.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 8 - */ 5 + */ 9 6 10 7 #ifndef _DT_BINDINGS_CLOCK_EXYNOS7_H 11 8 #define _DT_BINDINGS_CLOCK_EXYNOS7_H
+1 -4
include/dt-bindings/clock/s3c2410.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 4 * 8 5 * Device Tree binding constants clock controllers of Samsung S3C2410 and later. 9 6 */
+1 -4
include/dt-bindings/clock/s3c2412.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 4 * 8 5 * Device Tree binding constants clock controllers of Samsung S3C2412. 9 6 */
+1 -4
include/dt-bindings/clock/s3c2443.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de> 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 as 6 - * published by the Free Software Foundation. 7 4 * 8 5 * Device Tree binding constants clock controllers of Samsung S3C2443 and later. 9 6 */
+1 -1
include/dt-bindings/interrupt-controller/arm-gic.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /* 3 3 * This header provides constants for the ARM GIC. 4 4 */
+1 -1
include/dt-bindings/interrupt-controller/irq.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /* 3 3 * This header provides constants for most IRQ bindings. 4 4 *
+1 -11
include/dt-bindings/thermal/thermal_exynos.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 1 2 /* 2 3 * thermal_exynos.h - Samsung EXYNOS TMU device tree definitions 3 4 * 4 5 * Copyright (C) 2014 Samsung Electronics 5 6 * Lukasz Majewski <l.majewski@samsung.com> 6 - * 7 - * This program is free software; you can redistribute it and/or modify 8 - * it under the terms of the GNU General Public License as published by 9 - * the Free Software Foundation; either version 2 of the License, or 10 - * (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, 13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - * GNU General Public License for more details. 16 - * 17 7 */ 18 8 19 9 #ifndef _EXYNOS_THERMAL_TMU_DT_H
+1
include/linux/libfdt_env.h
··· 2 2 #ifndef LIBFDT_ENV_H 3 3 #define LIBFDT_ENV_H 4 4 5 + #include <linux/kernel.h> /* For INT_MAX */ 5 6 #include <linux/string.h> 6 7 7 8 #include <asm/byteorder.h>
+12 -7
include/linux/of.h
··· 247 247 #include <asm/prom.h> 248 248 #endif 249 249 250 - /* Default #address and #size cells. Allow arch asm/prom.h to override */ 251 - #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) 252 - #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 253 - #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 254 - #endif 255 - 256 250 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) 257 251 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) 258 252 ··· 347 353 const char *name, 348 354 int *lenp); 349 355 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 356 + extern struct device_node *of_get_next_cpu_node(struct device_node *prev); 357 + 350 358 #define for_each_property_of_node(dn, pp) \ 351 359 for (pp = dn->properties; pp != NULL; pp = pp->next) 352 360 ··· 754 758 return NULL; 755 759 } 756 760 761 + static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) 762 + { 763 + return NULL; 764 + } 765 + 757 766 static inline int of_n_addr_cells(struct device_node *np) 758 767 { 759 768 return 0; ··· 1002 1001 1003 1002 static inline const char *of_node_get_device_type(const struct device_node *np) 1004 1003 { 1005 - return of_get_property(np, "type", NULL); 1004 + return of_get_property(np, "device_type", NULL); 1006 1005 } 1007 1006 1008 1007 static inline bool of_node_is_type(const struct device_node *np, const char *type) ··· 1228 1227 #define for_each_available_child_of_node(parent, child) \ 1229 1228 for (child = of_get_next_available_child(parent, NULL); child != NULL; \ 1230 1229 child = of_get_next_available_child(parent, child)) 1230 + 1231 + #define for_each_of_cpu_node(cpu) \ 1232 + for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ 1233 + cpu = of_get_next_cpu_node(cpu)) 1231 1234 1232 1235 #define for_each_node_with_property(dn, prop_name) \ 1233 1236 for (dn = of_find_node_with_property(NULL, prop_name); dn; \
+6 -1
lib/vsprintf.c
··· 1684 1684 fmt = "f"; 1685 1685 1686 1686 for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) { 1687 + int precision; 1687 1688 if (pass) { 1688 1689 if (buf < end) 1689 1690 *buf = ':'; ··· 1696 1695 buf = device_node_gen_full_name(dn, buf, end); 1697 1696 break; 1698 1697 case 'n': /* name */ 1699 - buf = string(buf, end, dn->name, str_spec); 1698 + p = kbasename(of_node_full_name(dn)); 1699 + precision = str_spec.precision; 1700 + str_spec.precision = strchrnul(p, '@') - p; 1701 + buf = string(buf, end, p, str_spec); 1702 + str_spec.precision = precision; 1700 1703 break; 1701 1704 case 'p': /* phandle */ 1702 1705 buf = number(buf, end, (unsigned int)dn->phandle, num_spec);
+1 -2
scripts/Makefile
··· 39 39 subdir-$(CONFIG_MODVERSIONS) += genksyms 40 40 subdir-y += mod 41 41 subdir-$(CONFIG_SECURITY_SELINUX) += selinux 42 - subdir-$(CONFIG_DTC) += dtc 43 42 subdir-$(CONFIG_GDB_SCRIPTS) += gdb 44 43 45 44 # Let clean descend into subdirs 46 - subdir- += basic kconfig package gcc-plugins 45 + subdir- += basic dtc kconfig package gcc-plugins
+1 -1
scripts/Makefile.lib
··· 283 283 284 284 quiet_cmd_dtc = DTC $@ 285 285 cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ 286 - $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 286 + $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 287 287 $(DTC) -O dtb -o $@ -b 0 \ 288 288 $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ 289 289 -d $(depfile).dtc.tmp $(dtc-tmp) ; \
+8 -1
scripts/dtc/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # scripts/dtc makefile 3 3 4 - hostprogs-y := dtc 4 + hostprogs-$(CONFIG_DTC) := dtc 5 5 always := $(hostprogs-y) 6 6 7 7 dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ ··· 10 10 11 11 # Source files need to get at the userspace version of libfdt_env.h to compile 12 12 HOST_EXTRACFLAGS := -I$(src)/libfdt 13 + 14 + ifeq ($(wildcard /usr/include/yaml.h),) 15 + HOST_EXTRACFLAGS += -DNO_YAML 16 + else 17 + dtc-objs += yamltree.o 18 + HOSTLDLIBS_dtc := -lyaml 19 + endif 13 20 14 21 # Generated files need one more search path to include headers in source tree 15 22 HOSTCFLAGS_dtc-lexer.lex.o := -I$(src)
+4
scripts/dtc/Makefile.dtc
··· 14 14 treesource.c \ 15 15 util.c 16 16 17 + ifneq ($(NO_YAML),1) 18 + DTC_SRCS += yamltree.c 19 + endif 20 + 17 21 DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c 18 22 DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o)
+143
scripts/dtc/checks.c
··· 962 962 } 963 963 WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge); 964 964 965 + static const struct bus_type i2c_bus = { 966 + .name = "i2c-bus", 967 + }; 968 + 969 + static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) 970 + { 971 + if (strprefixeq(node->name, node->basenamelen, "i2c-bus") || 972 + strprefixeq(node->name, node->basenamelen, "i2c-arb")) { 973 + node->bus = &i2c_bus; 974 + } else if (strprefixeq(node->name, node->basenamelen, "i2c")) { 975 + struct node *child; 976 + for_each_child(node, child) { 977 + if (strprefixeq(child->name, node->basenamelen, "i2c-bus")) 978 + return; 979 + } 980 + node->bus = &i2c_bus; 981 + } else 982 + return; 983 + 984 + if (!node->children) 985 + return; 986 + 987 + if (node_addr_cells(node) != 1) 988 + FAIL(c, dti, node, "incorrect #address-cells for I2C bus"); 989 + if (node_size_cells(node) != 0) 990 + FAIL(c, dti, node, "incorrect #size-cells for I2C bus"); 991 + 992 + } 993 + WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells); 994 + 995 + static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node) 996 + { 997 + struct property *prop; 998 + const char *unitname = get_unitname(node); 999 + char unit_addr[17]; 1000 + uint32_t reg = 0; 1001 + int len; 1002 + cell_t *cells = NULL; 1003 + 1004 + if (!node->parent || (node->parent->bus != &i2c_bus)) 1005 + return; 1006 + 1007 + prop = get_property(node, "reg"); 1008 + if (prop) 1009 + cells = (cell_t *)prop->val.val; 1010 + 1011 + if (!cells) { 1012 + FAIL(c, dti, node, "missing or empty reg property"); 1013 + return; 1014 + } 1015 + 1016 + reg = fdt32_to_cpu(*cells); 1017 + snprintf(unit_addr, sizeof(unit_addr), "%x", reg); 1018 + if (!streq(unitname, unit_addr)) 1019 + FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"", 1020 + unit_addr); 1021 + 1022 + for (len = prop->val.len; len > 0; len -= 4) { 1023 + reg = fdt32_to_cpu(*(cells++)); 1024 + if (reg > 0x3ff) 1025 + FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", 1026 + reg); 1027 + 1028 + } 1029 + } 1030 + WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, &reg_format, &i2c_bus_bridge); 1031 + 1032 + static const struct bus_type spi_bus = { 1033 + .name = "spi-bus", 1034 + }; 1035 + 1036 + static void check_spi_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) 1037 + { 1038 + 1039 + if (strprefixeq(node->name, node->basenamelen, "spi")) { 1040 + node->bus = &spi_bus; 1041 + } else { 1042 + /* Try to detect SPI buses which don't have proper node name */ 1043 + struct node *child; 1044 + 1045 + if (node_addr_cells(node) != 1 || node_size_cells(node) != 0) 1046 + return; 1047 + 1048 + for_each_child(node, child) { 1049 + struct property *prop; 1050 + for_each_property(child, prop) { 1051 + if (strprefixeq(prop->name, 4, "spi-")) { 1052 + node->bus = &spi_bus; 1053 + break; 1054 + } 1055 + } 1056 + if (node->bus == &spi_bus) 1057 + break; 1058 + } 1059 + 1060 + if (node->bus == &spi_bus && get_property(node, "reg")) 1061 + FAIL(c, dti, node, "node name for SPI buses should be 'spi'"); 1062 + } 1063 + if (node->bus != &spi_bus || !node->children) 1064 + return; 1065 + 1066 + if (node_addr_cells(node) != 1) 1067 + FAIL(c, dti, node, "incorrect #address-cells for SPI bus"); 1068 + if (node_size_cells(node) != 0) 1069 + FAIL(c, dti, node, "incorrect #size-cells for SPI bus"); 1070 + 1071 + } 1072 + WARNING(spi_bus_bridge, check_spi_bus_bridge, NULL, &addr_size_cells); 1073 + 1074 + static void check_spi_bus_reg(struct check *c, struct dt_info *dti, struct node *node) 1075 + { 1076 + struct property *prop; 1077 + const char *unitname = get_unitname(node); 1078 + char unit_addr[9]; 1079 + uint32_t reg = 0; 1080 + cell_t *cells = NULL; 1081 + 1082 + if (!node->parent || (node->parent->bus != &spi_bus)) 1083 + return; 1084 + 1085 + prop = get_property(node, "reg"); 1086 + if (prop) 1087 + cells = (cell_t *)prop->val.val; 1088 + 1089 + if (!cells) { 1090 + FAIL(c, dti, node, "missing or empty reg property"); 1091 + return; 1092 + } 1093 + 1094 + reg = fdt32_to_cpu(*cells); 1095 + snprintf(unit_addr, sizeof(unit_addr), "%x", reg); 1096 + if (!streq(unitname, unit_addr)) 1097 + FAIL(c, dti, node, "SPI bus unit address format error, expected \"%s\"", 1098 + unit_addr); 1099 + } 1100 + WARNING(spi_bus_reg, check_spi_bus_reg, NULL, &reg_format, &spi_bus_bridge); 1101 + 965 1102 static void check_unit_address_format(struct check *c, struct dt_info *dti, 966 1103 struct node *node) 967 1104 { ··· 1718 1581 1719 1582 &simple_bus_bridge, 1720 1583 &simple_bus_reg, 1584 + 1585 + &i2c_bus_bridge, 1586 + &i2c_bus_reg, 1587 + 1588 + &spi_bus_bridge, 1589 + &spi_bus_reg, 1721 1590 1722 1591 &avoid_default_addr_size, 1723 1592 &avoid_unnecessary_addr_size,
+3 -1
scripts/dtc/data.c
··· 74 74 struct data d; 75 75 char *q; 76 76 77 - d = data_grow_for(empty_data, len + 1); 77 + d = data_add_marker(empty_data, TYPE_STRING, NULL); 78 + d = data_grow_for(d, len + 1); 78 79 79 80 q = d.val; 80 81 while (i < len) { ··· 95 94 { 96 95 struct data d = empty_data; 97 96 97 + d = data_add_marker(d, TYPE_NONE, NULL); 98 98 while (!feof(f) && (d.len < maxlen)) { 99 99 size_t chunksize, ret; 100 100
+11 -5
scripts/dtc/dtc-parser.y
··· 287 287 } 288 288 | propdataprefix DT_REF 289 289 { 290 + $1 = data_add_marker($1, TYPE_STRING, $2); 290 291 $$ = data_add_marker($1, REF_PATH, $2); 291 292 } 292 293 | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')' ··· 341 340 DT_BITS DT_LITERAL '<' 342 341 { 343 342 unsigned long long bits; 343 + enum markertype type = TYPE_UINT32; 344 344 345 345 bits = $2; 346 346 347 - if ((bits != 8) && (bits != 16) && 348 - (bits != 32) && (bits != 64)) { 347 + switch (bits) { 348 + case 8: type = TYPE_UINT8; break; 349 + case 16: type = TYPE_UINT16; break; 350 + case 32: type = TYPE_UINT32; break; 351 + case 64: type = TYPE_UINT64; break; 352 + default: 349 353 ERROR(&@2, "Array elements must be" 350 354 " 8, 16, 32 or 64-bits"); 351 355 bits = 32; 352 356 } 353 357 354 - $$.data = empty_data; 358 + $$.data = data_add_marker(empty_data, type, NULL); 355 359 $$.bits = bits; 356 360 } 357 361 | '<' 358 362 { 359 - $$.data = empty_data; 363 + $$.data = data_add_marker(empty_data, TYPE_UINT32, NULL); 360 364 $$.bits = 32; 361 365 } 362 366 | arrayprefix integer_prim ··· 505 499 bytestring: 506 500 /* empty */ 507 501 { 508 - $$ = empty_data; 502 + $$ = data_add_marker(empty_data, TYPE_UINT8, NULL); 509 503 } 510 504 | bytestring DT_BYTE 511 505 {
+11
scripts/dtc/dtc.c
··· 95 95 "\n\tOutput formats are:\n" 96 96 "\t\tdts - device tree source text\n" 97 97 "\t\tdtb - device tree blob\n" 98 + #ifndef NO_YAML 99 + "\t\tyaml - device tree encoded as YAML\n" 100 + #endif 98 101 "\t\tasm - assembler source", 99 102 "\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)", 100 103 "\n\tOutput dependency file", ··· 131 128 return fallback; 132 129 if (!strcasecmp(s, ".dts")) 133 130 return "dts"; 131 + if (!strcasecmp(s, ".yaml")) 132 + return "yaml"; 134 133 if (!strcasecmp(s, ".dtb")) 135 134 return "dtb"; 136 135 return fallback; ··· 355 350 356 351 if (streq(outform, "dts")) { 357 352 dt_to_source(outf, dti); 353 + #ifndef NO_YAML 354 + } else if (streq(outform, "yaml")) { 355 + if (!streq(inform, "dts")) 356 + die("YAML output format requires dts input format\n"); 357 + dt_to_yaml(outf, dti); 358 + #endif 358 359 } else if (streq(outform, "dtb")) { 359 360 dt_to_blob(outf, dti, outversion); 360 361 } else if (streq(outform, "asm")) {
+13
scripts/dtc/dtc.h
··· 74 74 75 75 /* Data blobs */ 76 76 enum markertype { 77 + TYPE_NONE, 77 78 REF_PHANDLE, 78 79 REF_PATH, 79 80 LABEL, 81 + TYPE_UINT8, 82 + TYPE_UINT16, 83 + TYPE_UINT32, 84 + TYPE_UINT64, 85 + TYPE_STRING, 80 86 }; 87 + extern const char *markername(enum markertype markertype); 81 88 82 89 struct marker { 83 90 enum markertype type; ··· 107 100 #define for_each_marker_of_type(m, t) \ 108 101 for_each_marker(m) \ 109 102 if ((m)->type == (t)) 103 + 104 + size_t type_marker_length(struct marker *m); 110 105 111 106 void data_free(struct data d); 112 107 ··· 298 289 299 290 void dt_to_source(FILE *f, struct dt_info *dti); 300 291 struct dt_info *dt_from_source(const char *f); 292 + 293 + /* YAML source */ 294 + 295 + void dt_to_yaml(FILE *f, struct dt_info *dti); 301 296 302 297 /* FS trees */ 303 298
+1 -1
scripts/dtc/flattree.c
··· 393 393 padlen = 0; 394 394 if (quiet < 1) 395 395 fprintf(stderr, 396 - "Warning: blob size %d >= minimum size %d\n", 396 + "Warning: blob size %"PRIu32" >= minimum size %d\n", 397 397 fdt32_to_cpu(fdt.totalsize), minsize); 398 398 } 399 399 }
+79 -2
scripts/dtc/libfdt/fdt.c
··· 55 55 56 56 #include "libfdt_internal.h" 57 57 58 - int fdt_check_header(const void *fdt) 58 + /* 59 + * Minimal sanity check for a read-only tree. fdt_ro_probe_() checks 60 + * that the given buffer contains what appears to be a flattened 61 + * device tree with sane information in its header. 62 + */ 63 + int fdt_ro_probe_(const void *fdt) 59 64 { 60 65 if (fdt_magic(fdt) == FDT_MAGIC) { 61 66 /* Complete tree */ ··· 75 70 } else { 76 71 return -FDT_ERR_BADMAGIC; 77 72 } 73 + 74 + return 0; 75 + } 76 + 77 + static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off) 78 + { 79 + return (off >= hdrsize) && (off <= totalsize); 80 + } 81 + 82 + static int check_block_(uint32_t hdrsize, uint32_t totalsize, 83 + uint32_t base, uint32_t size) 84 + { 85 + if (!check_off_(hdrsize, totalsize, base)) 86 + return 0; /* block start out of bounds */ 87 + if ((base + size) < base) 88 + return 0; /* overflow */ 89 + if (!check_off_(hdrsize, totalsize, base + size)) 90 + return 0; /* block end out of bounds */ 91 + return 1; 92 + } 93 + 94 + size_t fdt_header_size_(uint32_t version) 95 + { 96 + if (version <= 1) 97 + return FDT_V1_SIZE; 98 + else if (version <= 2) 99 + return FDT_V2_SIZE; 100 + else if (version <= 3) 101 + return FDT_V3_SIZE; 102 + else if (version <= 16) 103 + return FDT_V16_SIZE; 104 + else 105 + return FDT_V17_SIZE; 106 + } 107 + 108 + int fdt_check_header(const void *fdt) 109 + { 110 + size_t hdrsize; 111 + 112 + if (fdt_magic(fdt) != FDT_MAGIC) 113 + return -FDT_ERR_BADMAGIC; 114 + hdrsize = fdt_header_size(fdt); 115 + if ((fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) 116 + || (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)) 117 + return -FDT_ERR_BADVERSION; 118 + if (fdt_version(fdt) < fdt_last_comp_version(fdt)) 119 + return -FDT_ERR_BADVERSION; 120 + 121 + if ((fdt_totalsize(fdt) < hdrsize) 122 + || (fdt_totalsize(fdt) > INT_MAX)) 123 + return -FDT_ERR_TRUNCATED; 124 + 125 + /* Bounds check memrsv block */ 126 + if (!check_off_(hdrsize, fdt_totalsize(fdt), fdt_off_mem_rsvmap(fdt))) 127 + return -FDT_ERR_TRUNCATED; 128 + 129 + /* Bounds check structure block */ 130 + if (fdt_version(fdt) < 17) { 131 + if (!check_off_(hdrsize, fdt_totalsize(fdt), 132 + fdt_off_dt_struct(fdt))) 133 + return -FDT_ERR_TRUNCATED; 134 + } else { 135 + if (!check_block_(hdrsize, fdt_totalsize(fdt), 136 + fdt_off_dt_struct(fdt), 137 + fdt_size_dt_struct(fdt))) 138 + return -FDT_ERR_TRUNCATED; 139 + } 140 + 141 + /* Bounds check strings block */ 142 + if (!check_block_(hdrsize, fdt_totalsize(fdt), 143 + fdt_off_dt_strings(fdt), fdt_size_dt_strings(fdt))) 144 + return -FDT_ERR_TRUNCATED; 78 145 79 146 return 0; 80 147 } ··· 321 244 322 245 int fdt_move(const void *fdt, void *buf, int bufsize) 323 246 { 324 - FDT_CHECK_HEADER(fdt); 247 + FDT_RO_PROBE(fdt); 325 248 326 249 if (fdt_totalsize(fdt) > bufsize) 327 250 return -FDT_ERR_NOSPACE;
+13 -22
scripts/dtc/libfdt/fdt_addresses.c
··· 1 1 /* 2 2 * libfdt - Flat Device Tree manipulation 3 3 * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au> 4 + * Copyright (C) 2018 embedded brains GmbH 4 5 * 5 6 * libfdt is dual licensed: you can use it either under the terms of 6 7 * the GPL, or the BSD license, at your option. ··· 56 55 57 56 #include "libfdt_internal.h" 58 57 59 - int fdt_address_cells(const void *fdt, int nodeoffset) 58 + static int fdt_cells(const void *fdt, int nodeoffset, const char *name) 60 59 { 61 - const fdt32_t *ac; 60 + const fdt32_t *c; 62 61 int val; 63 62 int len; 64 63 65 - ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); 66 - if (!ac) 64 + c = fdt_getprop(fdt, nodeoffset, name, &len); 65 + if (!c) 67 66 return 2; 68 67 69 - if (len != sizeof(*ac)) 68 + if (len != sizeof(*c)) 70 69 return -FDT_ERR_BADNCELLS; 71 70 72 - val = fdt32_to_cpu(*ac); 71 + val = fdt32_to_cpu(*c); 73 72 if ((val <= 0) || (val > FDT_MAX_NCELLS)) 74 73 return -FDT_ERR_BADNCELLS; 75 74 76 75 return val; 77 76 } 78 77 78 + int fdt_address_cells(const void *fdt, int nodeoffset) 79 + { 80 + return fdt_cells(fdt, nodeoffset, "#address-cells"); 81 + } 82 + 79 83 int fdt_size_cells(const void *fdt, int nodeoffset) 80 84 { 81 - const fdt32_t *sc; 82 - int val; 83 - int len; 84 - 85 - sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); 86 - if (!sc) 87 - return 2; 88 - 89 - if (len != sizeof(*sc)) 90 - return -FDT_ERR_BADNCELLS; 91 - 92 - val = fdt32_to_cpu(*sc); 93 - if ((val < 0) || (val > FDT_MAX_NCELLS)) 94 - return -FDT_ERR_BADNCELLS; 95 - 96 - return val; 85 + return fdt_cells(fdt, nodeoffset, "#size-cells"); 97 86 }
+3 -3
scripts/dtc/libfdt/fdt_overlay.c
··· 697 697 int len = 0, namelen; 698 698 const char *name; 699 699 700 - FDT_CHECK_HEADER(fdt); 700 + FDT_RO_PROBE(fdt); 701 701 702 702 for (;;) { 703 703 name = fdt_get_name(fdt, nodeoffset, &namelen); ··· 866 866 uint32_t delta = fdt_get_max_phandle(fdt); 867 867 int ret; 868 868 869 - FDT_CHECK_HEADER(fdt); 870 - FDT_CHECK_HEADER(fdto); 869 + FDT_RO_PROBE(fdt); 870 + FDT_RO_PROBE(fdto); 871 871 872 872 ret = overlay_adjust_local_phandles(fdto, delta); 873 873 if (ret)
+174 -25
scripts/dtc/libfdt/fdt_ro.c
··· 76 76 return 0; 77 77 } 78 78 79 + const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) 80 + { 81 + uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt); 82 + size_t len; 83 + int err; 84 + const char *s, *n; 85 + 86 + err = fdt_ro_probe_(fdt); 87 + if (err != 0) 88 + goto fail; 89 + 90 + err = -FDT_ERR_BADOFFSET; 91 + if (absoffset >= fdt_totalsize(fdt)) 92 + goto fail; 93 + len = fdt_totalsize(fdt) - absoffset; 94 + 95 + if (fdt_magic(fdt) == FDT_MAGIC) { 96 + if (stroffset < 0) 97 + goto fail; 98 + if (fdt_version(fdt) >= 17) { 99 + if (stroffset >= fdt_size_dt_strings(fdt)) 100 + goto fail; 101 + if ((fdt_size_dt_strings(fdt) - stroffset) < len) 102 + len = fdt_size_dt_strings(fdt) - stroffset; 103 + } 104 + } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { 105 + if ((stroffset >= 0) 106 + || (stroffset < -fdt_size_dt_strings(fdt))) 107 + goto fail; 108 + if ((-stroffset) < len) 109 + len = -stroffset; 110 + } else { 111 + err = -FDT_ERR_INTERNAL; 112 + goto fail; 113 + } 114 + 115 + s = (const char *)fdt + absoffset; 116 + n = memchr(s, '\0', len); 117 + if (!n) { 118 + /* missing terminating NULL */ 119 + err = -FDT_ERR_TRUNCATED; 120 + goto fail; 121 + } 122 + 123 + if (lenp) 124 + *lenp = n - s; 125 + return s; 126 + 127 + fail: 128 + if (lenp) 129 + *lenp = err; 130 + return NULL; 131 + } 132 + 79 133 const char *fdt_string(const void *fdt, int stroffset) 80 134 { 81 - return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; 135 + return fdt_get_string(fdt, stroffset, NULL); 82 136 } 83 137 84 138 static int fdt_string_eq_(const void *fdt, int stroffset, 85 139 const char *s, int len) 86 140 { 87 - const char *p = fdt_string(fdt, stroffset); 141 + int slen; 142 + const char *p = fdt_get_string(fdt, stroffset, &slen); 88 143 89 - return (strlen(p) == len) && (memcmp(p, s, len) == 0); 144 + return p && (slen == len) && (memcmp(p, s, len) == 0); 90 145 } 91 146 92 147 uint32_t fdt_get_max_phandle(const void *fdt) ··· 170 115 return 0; 171 116 } 172 117 118 + static const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n) 119 + { 120 + int offset = n * sizeof(struct fdt_reserve_entry); 121 + int absoffset = fdt_off_mem_rsvmap(fdt) + offset; 122 + 123 + if (absoffset < fdt_off_mem_rsvmap(fdt)) 124 + return NULL; 125 + if (absoffset > fdt_totalsize(fdt) - sizeof(struct fdt_reserve_entry)) 126 + return NULL; 127 + return fdt_mem_rsv_(fdt, n); 128 + } 129 + 173 130 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) 174 131 { 175 - FDT_CHECK_HEADER(fdt); 176 - *address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address); 177 - *size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size); 132 + const struct fdt_reserve_entry *re; 133 + 134 + FDT_RO_PROBE(fdt); 135 + re = fdt_mem_rsv(fdt, n); 136 + if (!re) 137 + return -FDT_ERR_BADOFFSET; 138 + 139 + *address = fdt64_ld(&re->address); 140 + *size = fdt64_ld(&re->size); 178 141 return 0; 179 142 } 180 143 181 144 int fdt_num_mem_rsv(const void *fdt) 182 145 { 183 - int i = 0; 146 + int i; 147 + const struct fdt_reserve_entry *re; 184 148 185 - while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0) 186 - i++; 187 - return i; 149 + for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) { 150 + if (fdt64_ld(&re->size) == 0) 151 + return i; 152 + } 153 + return -FDT_ERR_TRUNCATED; 188 154 } 189 155 190 156 static int nextprop_(const void *fdt, int offset) ··· 237 161 { 238 162 int depth; 239 163 240 - FDT_CHECK_HEADER(fdt); 164 + FDT_RO_PROBE(fdt); 241 165 242 166 for (depth = 0; 243 167 (offset >= 0) && (depth >= 0); ··· 263 187 const char *p = path; 264 188 int offset = 0; 265 189 266 - FDT_CHECK_HEADER(fdt); 190 + FDT_RO_PROBE(fdt); 267 191 268 192 /* see if we have an alias */ 269 193 if (*path != '/') { ··· 313 237 const char *nameptr; 314 238 int err; 315 239 316 - if (((err = fdt_check_header(fdt)) != 0) 240 + if (((err = fdt_ro_probe_(fdt)) != 0) 317 241 || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) 318 242 goto fail; 319 243 ··· 379 303 prop = fdt_offset_ptr_(fdt, offset); 380 304 381 305 if (lenp) 382 - *lenp = fdt32_to_cpu(prop->len); 306 + *lenp = fdt32_ld(&prop->len); 383 307 384 308 return prop; 385 309 } ··· 416 340 offset = -FDT_ERR_INTERNAL; 417 341 break; 418 342 } 419 - if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff), 343 + if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff), 420 344 name, namelen)) { 421 345 if (poffset) 422 346 *poffset = offset; ··· 469 393 470 394 /* Handle realignment */ 471 395 if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 && 472 - fdt32_to_cpu(prop->len) >= 8) 396 + fdt32_ld(&prop->len) >= 8) 473 397 return prop->data + 4; 474 398 return prop->data; 475 399 } ··· 482 406 prop = fdt_get_property_by_offset_(fdt, offset, lenp); 483 407 if (!prop) 484 408 return NULL; 485 - if (namep) 486 - *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); 409 + if (namep) { 410 + const char *name; 411 + int namelen; 412 + name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff), 413 + &namelen); 414 + if (!name) { 415 + if (lenp) 416 + *lenp = namelen; 417 + return NULL; 418 + } 419 + *namep = name; 420 + } 487 421 488 422 /* Handle realignment */ 489 423 if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 && 490 - fdt32_to_cpu(prop->len) >= 8) 424 + fdt32_ld(&prop->len) >= 8) 491 425 return prop->data + 4; 492 426 return prop->data; 493 427 } ··· 522 436 return 0; 523 437 } 524 438 525 - return fdt32_to_cpu(*php); 439 + return fdt32_ld(php); 526 440 } 527 441 528 442 const char *fdt_get_alias_namelen(const void *fdt, ··· 548 462 int offset, depth, namelen; 549 463 const char *name; 550 464 551 - FDT_CHECK_HEADER(fdt); 465 + FDT_RO_PROBE(fdt); 552 466 553 467 if (buflen < 2) 554 468 return -FDT_ERR_NOSPACE; ··· 600 514 int offset, depth; 601 515 int supernodeoffset = -FDT_ERR_INTERNAL; 602 516 603 - FDT_CHECK_HEADER(fdt); 517 + FDT_RO_PROBE(fdt); 604 518 605 519 if (supernodedepth < 0) 606 520 return -FDT_ERR_NOTFOUND; ··· 659 573 const void *val; 660 574 int len; 661 575 662 - FDT_CHECK_HEADER(fdt); 576 + FDT_RO_PROBE(fdt); 663 577 664 578 /* FIXME: The algorithm here is pretty horrible: we scan each 665 579 * property of a node in fdt_getprop(), then if that didn't ··· 685 599 if ((phandle == 0) || (phandle == -1)) 686 600 return -FDT_ERR_BADPHANDLE; 687 601 688 - FDT_CHECK_HEADER(fdt); 602 + FDT_RO_PROBE(fdt); 689 603 690 604 /* FIXME: The algorithm here is pretty horrible: we 691 605 * potentially scan each property of a node in ··· 838 752 { 839 753 int offset, err; 840 754 841 - FDT_CHECK_HEADER(fdt); 755 + FDT_RO_PROBE(fdt); 842 756 843 757 /* FIXME: The algorithm here is pretty horrible: we scan each 844 758 * property of a node in fdt_node_check_compatible(), then if ··· 856 770 } 857 771 858 772 return offset; /* error from fdt_next_node() */ 773 + } 774 + 775 + int fdt_check_full(const void *fdt, size_t bufsize) 776 + { 777 + int err; 778 + int num_memrsv; 779 + int offset, nextoffset = 0; 780 + uint32_t tag; 781 + unsigned depth = 0; 782 + const void *prop; 783 + const char *propname; 784 + 785 + if (bufsize < FDT_V1_SIZE) 786 + return -FDT_ERR_TRUNCATED; 787 + err = fdt_check_header(fdt); 788 + if (err != 0) 789 + return err; 790 + if (bufsize < fdt_totalsize(fdt)) 791 + return -FDT_ERR_TRUNCATED; 792 + 793 + num_memrsv = fdt_num_mem_rsv(fdt); 794 + if (num_memrsv < 0) 795 + return num_memrsv; 796 + 797 + while (1) { 798 + offset = nextoffset; 799 + tag = fdt_next_tag(fdt, offset, &nextoffset); 800 + 801 + if (nextoffset < 0) 802 + return nextoffset; 803 + 804 + switch (tag) { 805 + case FDT_NOP: 806 + break; 807 + 808 + case FDT_END: 809 + if (depth != 0) 810 + return -FDT_ERR_BADSTRUCTURE; 811 + return 0; 812 + 813 + case FDT_BEGIN_NODE: 814 + depth++; 815 + if (depth > INT_MAX) 816 + return -FDT_ERR_BADSTRUCTURE; 817 + break; 818 + 819 + case FDT_END_NODE: 820 + if (depth == 0) 821 + return -FDT_ERR_BADSTRUCTURE; 822 + depth--; 823 + break; 824 + 825 + case FDT_PROP: 826 + prop = fdt_getprop_by_offset(fdt, offset, &propname, 827 + &err); 828 + if (!prop) 829 + return err; 830 + break; 831 + 832 + default: 833 + return -FDT_ERR_INTERNAL; 834 + } 835 + } 859 836 }
+14 -14
scripts/dtc/libfdt/fdt_rw.c
··· 67 67 (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt))); 68 68 } 69 69 70 - static int fdt_rw_check_header_(void *fdt) 70 + static int fdt_rw_probe_(void *fdt) 71 71 { 72 - FDT_CHECK_HEADER(fdt); 72 + FDT_RO_PROBE(fdt); 73 73 74 74 if (fdt_version(fdt) < 17) 75 75 return -FDT_ERR_BADVERSION; ··· 82 82 return 0; 83 83 } 84 84 85 - #define FDT_RW_CHECK_HEADER(fdt) \ 85 + #define FDT_RW_PROBE(fdt) \ 86 86 { \ 87 87 int err_; \ 88 - if ((err_ = fdt_rw_check_header_(fdt)) != 0) \ 88 + if ((err_ = fdt_rw_probe_(fdt)) != 0) \ 89 89 return err_; \ 90 90 } 91 91 ··· 176 176 struct fdt_reserve_entry *re; 177 177 int err; 178 178 179 - FDT_RW_CHECK_HEADER(fdt); 179 + FDT_RW_PROBE(fdt); 180 180 181 181 re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt)); 182 182 err = fdt_splice_mem_rsv_(fdt, re, 0, 1); ··· 192 192 { 193 193 struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n); 194 194 195 - FDT_RW_CHECK_HEADER(fdt); 195 + FDT_RW_PROBE(fdt); 196 196 197 197 if (n >= fdt_num_mem_rsv(fdt)) 198 198 return -FDT_ERR_NOTFOUND; ··· 252 252 int oldlen, newlen; 253 253 int err; 254 254 255 - FDT_RW_CHECK_HEADER(fdt); 255 + FDT_RW_PROBE(fdt); 256 256 257 257 namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen); 258 258 if (!namep) ··· 275 275 struct fdt_property *prop; 276 276 int err; 277 277 278 - FDT_RW_CHECK_HEADER(fdt); 278 + FDT_RW_PROBE(fdt); 279 279 280 280 err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop); 281 281 if (err == -FDT_ERR_NOTFOUND) ··· 308 308 struct fdt_property *prop; 309 309 int err, oldlen, newlen; 310 310 311 - FDT_RW_CHECK_HEADER(fdt); 311 + FDT_RW_PROBE(fdt); 312 312 313 313 prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); 314 314 if (prop) { ··· 334 334 struct fdt_property *prop; 335 335 int len, proplen; 336 336 337 - FDT_RW_CHECK_HEADER(fdt); 337 + FDT_RW_PROBE(fdt); 338 338 339 339 prop = fdt_get_property_w(fdt, nodeoffset, name, &len); 340 340 if (!prop) ··· 354 354 uint32_t tag; 355 355 fdt32_t *endtag; 356 356 357 - FDT_RW_CHECK_HEADER(fdt); 357 + FDT_RW_PROBE(fdt); 358 358 359 359 offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen); 360 360 if (offset >= 0) ··· 394 394 { 395 395 int endoffset; 396 396 397 - FDT_RW_CHECK_HEADER(fdt); 397 + FDT_RW_PROBE(fdt); 398 398 399 399 endoffset = fdt_node_end_offset_(fdt, nodeoffset); 400 400 if (endoffset < 0) ··· 435 435 const char *fdtend = fdtstart + fdt_totalsize(fdt); 436 436 char *tmp; 437 437 438 - FDT_CHECK_HEADER(fdt); 438 + FDT_RO_PROBE(fdt); 439 439 440 440 mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) 441 441 * sizeof(struct fdt_reserve_entry); ··· 494 494 { 495 495 int mem_rsv_size; 496 496 497 - FDT_RW_CHECK_HEADER(fdt); 497 + FDT_RW_PROBE(fdt); 498 498 499 499 mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) 500 500 * sizeof(struct fdt_reserve_entry);
+87 -22
scripts/dtc/libfdt/fdt_sw.c
··· 55 55 56 56 #include "libfdt_internal.h" 57 57 58 - static int fdt_sw_check_header_(void *fdt) 58 + static int fdt_sw_probe_(void *fdt) 59 59 { 60 - if (fdt_magic(fdt) != FDT_SW_MAGIC) 60 + if (fdt_magic(fdt) == FDT_MAGIC) 61 + return -FDT_ERR_BADSTATE; 62 + else if (fdt_magic(fdt) != FDT_SW_MAGIC) 61 63 return -FDT_ERR_BADMAGIC; 62 - /* FIXME: should check more details about the header state */ 63 64 return 0; 64 65 } 65 66 66 - #define FDT_SW_CHECK_HEADER(fdt) \ 67 + #define FDT_SW_PROBE(fdt) \ 67 68 { \ 68 69 int err; \ 69 - if ((err = fdt_sw_check_header_(fdt)) != 0) \ 70 + if ((err = fdt_sw_probe_(fdt)) != 0) \ 70 71 return err; \ 71 72 } 73 + 74 + /* 'memrsv' state: Initial state after fdt_create() 75 + * 76 + * Allowed functions: 77 + * fdt_add_reservmap_entry() 78 + * fdt_finish_reservemap() [moves to 'struct' state] 79 + */ 80 + static int fdt_sw_probe_memrsv_(void *fdt) 81 + { 82 + int err = fdt_sw_probe_(fdt); 83 + if (err) 84 + return err; 85 + 86 + if (fdt_off_dt_strings(fdt) != 0) 87 + return -FDT_ERR_BADSTATE; 88 + return 0; 89 + } 90 + 91 + #define FDT_SW_PROBE_MEMRSV(fdt) \ 92 + { \ 93 + int err; \ 94 + if ((err = fdt_sw_probe_memrsv_(fdt)) != 0) \ 95 + return err; \ 96 + } 97 + 98 + /* 'struct' state: Enter this state after fdt_finish_reservemap() 99 + * 100 + * Allowed functions: 101 + * fdt_begin_node() 102 + * fdt_end_node() 103 + * fdt_property*() 104 + * fdt_finish() [moves to 'complete' state] 105 + */ 106 + static int fdt_sw_probe_struct_(void *fdt) 107 + { 108 + int err = fdt_sw_probe_(fdt); 109 + if (err) 110 + return err; 111 + 112 + if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt)) 113 + return -FDT_ERR_BADSTATE; 114 + return 0; 115 + } 116 + 117 + #define FDT_SW_PROBE_STRUCT(fdt) \ 118 + { \ 119 + int err; \ 120 + if ((err = fdt_sw_probe_struct_(fdt)) != 0) \ 121 + return err; \ 122 + } 123 + 124 + /* 'complete' state: Enter this state after fdt_finish() 125 + * 126 + * Allowed functions: none 127 + */ 72 128 73 129 static void *fdt_grab_space_(void *fdt, size_t len) 74 130 { ··· 143 87 144 88 int fdt_create(void *buf, int bufsize) 145 89 { 90 + const size_t hdrsize = FDT_ALIGN(sizeof(struct fdt_header), 91 + sizeof(struct fdt_reserve_entry)); 146 92 void *fdt = buf; 147 93 148 - if (bufsize < sizeof(struct fdt_header)) 94 + if (bufsize < hdrsize) 149 95 return -FDT_ERR_NOSPACE; 150 96 151 97 memset(buf, 0, bufsize); ··· 157 99 fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); 158 100 fdt_set_totalsize(fdt, bufsize); 159 101 160 - fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header), 161 - sizeof(struct fdt_reserve_entry))); 102 + fdt_set_off_mem_rsvmap(fdt, hdrsize); 162 103 fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt)); 163 - fdt_set_off_dt_strings(fdt, bufsize); 104 + fdt_set_off_dt_strings(fdt, 0); 164 105 165 106 return 0; 166 107 } ··· 169 112 size_t headsize, tailsize; 170 113 char *oldtail, *newtail; 171 114 172 - FDT_SW_CHECK_HEADER(fdt); 115 + FDT_SW_PROBE(fdt); 173 116 174 - headsize = fdt_off_dt_struct(fdt); 117 + headsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); 175 118 tailsize = fdt_size_dt_strings(fdt); 119 + 120 + if ((headsize + tailsize) > fdt_totalsize(fdt)) 121 + return -FDT_ERR_INTERNAL; 176 122 177 123 if ((headsize + tailsize) > bufsize) 178 124 return -FDT_ERR_NOSPACE; ··· 193 133 memmove(buf, fdt, headsize); 194 134 } 195 135 196 - fdt_set_off_dt_strings(buf, bufsize); 197 136 fdt_set_totalsize(buf, bufsize); 137 + if (fdt_off_dt_strings(buf)) 138 + fdt_set_off_dt_strings(buf, bufsize); 198 139 199 140 return 0; 200 141 } ··· 205 144 struct fdt_reserve_entry *re; 206 145 int offset; 207 146 208 - FDT_SW_CHECK_HEADER(fdt); 209 - 210 - if (fdt_size_dt_struct(fdt)) 211 - return -FDT_ERR_BADSTATE; 147 + FDT_SW_PROBE_MEMRSV(fdt); 212 148 213 149 offset = fdt_off_dt_struct(fdt); 214 150 if ((offset + sizeof(*re)) > fdt_totalsize(fdt)) ··· 222 164 223 165 int fdt_finish_reservemap(void *fdt) 224 166 { 225 - return fdt_add_reservemap_entry(fdt, 0, 0); 167 + int err = fdt_add_reservemap_entry(fdt, 0, 0); 168 + 169 + if (err) 170 + return err; 171 + 172 + fdt_set_off_dt_strings(fdt, fdt_totalsize(fdt)); 173 + return 0; 226 174 } 227 175 228 176 int fdt_begin_node(void *fdt, const char *name) 229 177 { 230 178 struct fdt_node_header *nh; 231 - int namelen = strlen(name) + 1; 179 + int namelen; 232 180 233 - FDT_SW_CHECK_HEADER(fdt); 181 + FDT_SW_PROBE_STRUCT(fdt); 234 182 183 + namelen = strlen(name) + 1; 235 184 nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); 236 185 if (! nh) 237 186 return -FDT_ERR_NOSPACE; ··· 252 187 { 253 188 fdt32_t *en; 254 189 255 - FDT_SW_CHECK_HEADER(fdt); 190 + FDT_SW_PROBE_STRUCT(fdt); 256 191 257 192 en = fdt_grab_space_(fdt, FDT_TAGSIZE); 258 193 if (! en) ··· 290 225 struct fdt_property *prop; 291 226 int nameoff; 292 227 293 - FDT_SW_CHECK_HEADER(fdt); 228 + FDT_SW_PROBE_STRUCT(fdt); 294 229 295 230 nameoff = fdt_find_add_string_(fdt, name); 296 231 if (nameoff == 0) ··· 327 262 uint32_t tag; 328 263 int offset, nextoffset; 329 264 330 - FDT_SW_CHECK_HEADER(fdt); 265 + FDT_SW_PROBE_STRUCT(fdt); 331 266 332 267 /* Add terminator */ 333 268 end = fdt_grab_space_(fdt, sizeof(*end));
+67 -9
scripts/dtc/libfdt/libfdt.h
··· 90 90 91 91 /* Error codes: codes for bad device tree blobs */ 92 92 #define FDT_ERR_TRUNCATED 8 93 - /* FDT_ERR_TRUNCATED: Structure block of the given device tree 94 - * ends without an FDT_END tag. */ 93 + /* FDT_ERR_TRUNCATED: FDT or a sub-block is improperly 94 + * terminated (overflows, goes outside allowed bounds, or 95 + * isn't properly terminated). */ 95 96 #define FDT_ERR_BADMAGIC 9 96 97 /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a 97 98 * device tree at all - it is missing the flattened device ··· 154 153 155 154 uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); 156 155 156 + /* 157 + * Alignment helpers: 158 + * These helpers access words from a device tree blob. They're 159 + * built to work even with unaligned pointers on platforms (ike 160 + * ARM) that don't like unaligned loads and stores 161 + */ 162 + 163 + static inline uint32_t fdt32_ld(const fdt32_t *p) 164 + { 165 + fdt32_t v; 166 + 167 + memcpy(&v, p, sizeof(v)); 168 + return fdt32_to_cpu(v); 169 + } 170 + 171 + static inline uint64_t fdt64_ld(const fdt64_t *p) 172 + { 173 + fdt64_t v; 174 + 175 + memcpy(&v, p, sizeof(v)); 176 + return fdt64_to_cpu(v); 177 + } 178 + 157 179 /**********************************************************************/ 158 180 /* Traversal functions */ 159 181 /**********************************************************************/ ··· 237 213 /* General functions */ 238 214 /**********************************************************************/ 239 215 #define fdt_get_header(fdt, field) \ 240 - (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) 216 + (fdt32_ld(&((const struct fdt_header *)(fdt))->field)) 241 217 #define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 242 218 #define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) 243 219 #define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) ··· 268 244 #undef fdt_set_hdr_ 269 245 270 246 /** 271 - * fdt_check_header - sanity check a device tree or possible device tree 247 + * fdt_header_size - return the size of the tree's header 248 + * @fdt: pointer to a flattened device tree 249 + */ 250 + size_t fdt_header_size_(uint32_t version); 251 + static inline size_t fdt_header_size(const void *fdt) 252 + { 253 + return fdt_header_size_(fdt_version(fdt)); 254 + } 255 + 256 + /** 257 + * fdt_check_header - sanity check a device tree header 258 + 272 259 * @fdt: pointer to data which might be a flattened device tree 273 260 * 274 261 * fdt_check_header() checks that the given buffer contains what 275 - * appears to be a flattened device tree with sane information in its 276 - * header. 262 + * appears to be a flattened device tree, and that the header contains 263 + * valid information (to the extent that can be determined from the 264 + * header alone). 277 265 * 278 266 * returns: 279 267 * 0, if the buffer appears to contain a valid device tree 280 268 * -FDT_ERR_BADMAGIC, 281 269 * -FDT_ERR_BADVERSION, 282 - * -FDT_ERR_BADSTATE, standard meanings, as above 270 + * -FDT_ERR_BADSTATE, 271 + * -FDT_ERR_TRUNCATED, standard meanings, as above 283 272 */ 284 273 int fdt_check_header(const void *fdt); 285 274 ··· 321 284 /* Read-only functions */ 322 285 /**********************************************************************/ 323 286 287 + int fdt_check_full(const void *fdt, size_t bufsize); 288 + 289 + /** 290 + * fdt_get_string - retrieve a string from the strings block of a device tree 291 + * @fdt: pointer to the device tree blob 292 + * @stroffset: offset of the string within the strings block (native endian) 293 + * @lenp: optional pointer to return the string's length 294 + * 295 + * fdt_get_string() retrieves a pointer to a single string from the 296 + * strings block of the device tree blob at fdt, and optionally also 297 + * returns the string's length in *lenp. 298 + * 299 + * returns: 300 + * a pointer to the string, on success 301 + * NULL, if stroffset is out of bounds, or doesn't point to a valid string 302 + */ 303 + const char *fdt_get_string(const void *fdt, int stroffset, int *lenp); 304 + 324 305 /** 325 306 * fdt_string - retrieve a string from the strings block of a device tree 326 307 * @fdt: pointer to the device tree blob ··· 349 294 * 350 295 * returns: 351 296 * a pointer to the string, on success 352 - * NULL, if stroffset is out of bounds 297 + * NULL, if stroffset is out of bounds, or doesn't point to a valid string 353 298 */ 354 299 const char *fdt_string(const void *fdt, int stroffset); 355 300 ··· 1145 1090 * 1146 1091 * returns: 1147 1092 * 0 <= n < FDT_MAX_NCELLS, on success 1148 - * 2, if the node has no #address-cells property 1093 + * 2, if the node has no #size-cells property 1149 1094 * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid 1150 1095 * #size-cells property 1151 1096 * -FDT_ERR_BADMAGIC, ··· 1368 1313 fdt64_t tmp = cpu_to_fdt64(val); 1369 1314 return fdt_property(fdt, name, &tmp, sizeof(tmp)); 1370 1315 } 1316 + 1317 + #ifndef SWIG /* Not available in Python */ 1371 1318 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) 1372 1319 { 1373 1320 return fdt_property_u32(fdt, name, val); 1374 1321 } 1322 + #endif 1375 1323 1376 1324 /** 1377 1325 * fdt_property_placeholder - add a new property and return a ptr to its value
+1
scripts/dtc/libfdt/libfdt_env.h
··· 56 56 #include <stdint.h> 57 57 #include <stdlib.h> 58 58 #include <string.h> 59 + #include <limits.h> 59 60 60 61 #ifdef __CHECKER__ 61 62 #define FDT_FORCE __attribute__((force))
+3 -2
scripts/dtc/libfdt/libfdt_internal.h
··· 55 55 #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 56 56 #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) 57 57 58 - #define FDT_CHECK_HEADER(fdt) \ 58 + int fdt_ro_probe_(const void *fdt); 59 + #define FDT_RO_PROBE(fdt) \ 59 60 { \ 60 61 int err_; \ 61 - if ((err_ = fdt_check_header(fdt)) != 0) \ 62 + if ((err_ = fdt_ro_probe_(fdt)) != 0) \ 62 63 return err_; \ 63 64 } 64 65
+6 -6
scripts/dtc/livetree.c
··· 594 594 cell_t get_node_phandle(struct node *root, struct node *node) 595 595 { 596 596 static cell_t phandle = 1; /* FIXME: ick, static local */ 597 + struct data d = empty_data; 597 598 598 599 if ((node->phandle != 0) && (node->phandle != -1)) 599 600 return node->phandle; ··· 604 603 605 604 node->phandle = phandle; 606 605 606 + d = data_add_marker(d, TYPE_UINT32, NULL); 607 + d = data_append_cell(d, phandle); 608 + 607 609 if (!get_property(node, "linux,phandle") 608 610 && (phandle_format & PHANDLE_LEGACY)) 609 - add_property(node, 610 - build_property("linux,phandle", 611 - data_append_cell(empty_data, phandle))); 611 + add_property(node, build_property("linux,phandle", d)); 612 612 613 613 if (!get_property(node, "phandle") 614 614 && (phandle_format & PHANDLE_EPAPR)) 615 - add_property(node, 616 - build_property("phandle", 617 - data_append_cell(empty_data, phandle))); 615 + add_property(node, build_property("phandle", d)); 618 616 619 617 /* If the node *does* have a phandle property, we must 620 618 * be dealing with a self-referencing phandle, which will be
+138 -93
scripts/dtc/treesource.c
··· 61 61 || strchr("\a\b\t\n\v\f\r", c)); 62 62 } 63 63 64 - static void write_propval_string(FILE *f, struct data val) 64 + static void write_propval_string(FILE *f, const char *s, size_t len) 65 65 { 66 - const char *str = val.val; 67 - int i; 68 - struct marker *m = val.markers; 66 + const char *end = s + len - 1; 67 + assert(*end == '\0'); 69 68 70 - assert(str[val.len-1] == '\0'); 71 - 72 - while (m && (m->offset == 0)) { 73 - if (m->type == LABEL) 74 - fprintf(f, "%s: ", m->ref); 75 - m = m->next; 76 - } 77 69 fprintf(f, "\""); 78 - 79 - for (i = 0; i < (val.len-1); i++) { 80 - char c = str[i]; 81 - 70 + while (s < end) { 71 + char c = *s++; 82 72 switch (c) { 83 73 case '\a': 84 74 fprintf(f, "\\a"); ··· 98 108 fprintf(f, "\\\""); 99 109 break; 100 110 case '\0': 101 - fprintf(f, "\", "); 102 - while (m && (m->offset <= (i + 1))) { 103 - if (m->type == LABEL) { 104 - assert(m->offset == (i+1)); 105 - fprintf(f, "%s: ", m->ref); 106 - } 107 - m = m->next; 108 - } 109 - fprintf(f, "\""); 111 + fprintf(f, "\\0"); 110 112 break; 111 113 default: 112 114 if (isprint((unsigned char)c)) 113 115 fprintf(f, "%c", c); 114 116 else 115 - fprintf(f, "\\x%02hhx", c); 117 + fprintf(f, "\\x%02"PRIx8, c); 116 118 } 117 119 } 118 120 fprintf(f, "\""); 119 - 120 - /* Wrap up any labels at the end of the value */ 121 - for_each_marker_of_type(m, LABEL) { 122 - assert (m->offset == val.len); 123 - fprintf(f, " %s:", m->ref); 124 - } 125 121 } 126 122 127 - static void write_propval_cells(FILE *f, struct data val) 123 + static void write_propval_int(FILE *f, const char *p, size_t len, size_t width) 128 124 { 129 - void *propend = val.val + val.len; 130 - fdt32_t *cp = (fdt32_t *)val.val; 131 - struct marker *m = val.markers; 125 + const char *end = p + len; 126 + assert(len % width == 0); 132 127 133 - fprintf(f, "<"); 134 - for (;;) { 135 - while (m && (m->offset <= ((char *)cp - val.val))) { 136 - if (m->type == LABEL) { 137 - assert(m->offset == ((char *)cp - val.val)); 138 - fprintf(f, "%s: ", m->ref); 139 - } 140 - m = m->next; 141 - } 142 - 143 - fprintf(f, "0x%x", fdt32_to_cpu(*cp++)); 144 - if ((void *)cp >= propend) 128 + for (; p < end; p += width) { 129 + switch (width) { 130 + case 1: 131 + fprintf(f, " %02"PRIx8, *(const uint8_t*)p); 145 132 break; 146 - fprintf(f, " "); 133 + case 2: 134 + fprintf(f, " 0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p)); 135 + break; 136 + case 4: 137 + fprintf(f, " 0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p)); 138 + break; 139 + case 8: 140 + fprintf(f, " 0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p)); 141 + break; 142 + } 147 143 } 148 - 149 - /* Wrap up any labels at the end of the value */ 150 - for_each_marker_of_type(m, LABEL) { 151 - assert (m->offset == val.len); 152 - fprintf(f, " %s:", m->ref); 153 - } 154 - fprintf(f, ">"); 155 144 } 156 145 157 - static void write_propval_bytes(FILE *f, struct data val) 146 + static bool has_data_type_information(struct marker *m) 158 147 { 159 - void *propend = val.val + val.len; 160 - const char *bp = val.val; 161 - struct marker *m = val.markers; 162 - 163 - fprintf(f, "["); 164 - for (;;) { 165 - while (m && (m->offset == (bp-val.val))) { 166 - if (m->type == LABEL) 167 - fprintf(f, "%s: ", m->ref); 168 - m = m->next; 169 - } 170 - 171 - fprintf(f, "%02hhx", (unsigned char)(*bp++)); 172 - if ((const void *)bp >= propend) 173 - break; 174 - fprintf(f, " "); 175 - } 176 - 177 - /* Wrap up any labels at the end of the value */ 178 - for_each_marker_of_type(m, LABEL) { 179 - assert (m->offset == val.len); 180 - fprintf(f, " %s:", m->ref); 181 - } 182 - fprintf(f, "]"); 148 + return m->type >= TYPE_UINT8; 183 149 } 184 150 185 - static void write_propval(FILE *f, struct property *prop) 151 + static struct marker *next_type_marker(struct marker *m) 152 + { 153 + while (m && !has_data_type_information(m)) 154 + m = m->next; 155 + return m; 156 + } 157 + 158 + size_t type_marker_length(struct marker *m) 159 + { 160 + struct marker *next = next_type_marker(m->next); 161 + 162 + if (next) 163 + return next->offset - m->offset; 164 + return 0; 165 + } 166 + 167 + static const char *delim_start[] = { 168 + [TYPE_UINT8] = "[", 169 + [TYPE_UINT16] = "/bits/ 16 <", 170 + [TYPE_UINT32] = "<", 171 + [TYPE_UINT64] = "/bits/ 64 <", 172 + [TYPE_STRING] = "", 173 + }; 174 + static const char *delim_end[] = { 175 + [TYPE_UINT8] = " ]", 176 + [TYPE_UINT16] = " >", 177 + [TYPE_UINT32] = " >", 178 + [TYPE_UINT64] = " >", 179 + [TYPE_STRING] = "", 180 + }; 181 + 182 + static enum markertype guess_value_type(struct property *prop) 186 183 { 187 184 int len = prop->val.len; 188 185 const char *p = prop->val.val; ··· 177 200 int nnotstring = 0, nnul = 0; 178 201 int nnotstringlbl = 0, nnotcelllbl = 0; 179 202 int i; 180 - 181 - if (len == 0) { 182 - fprintf(f, ";\n"); 183 - return; 184 - } 185 203 186 204 for (i = 0; i < len; i++) { 187 205 if (! isstring(p[i])) ··· 192 220 nnotcelllbl++; 193 221 } 194 222 195 - fprintf(f, " = "); 196 223 if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul)) 197 224 && (nnotstringlbl == 0)) { 198 - write_propval_string(f, prop->val); 225 + return TYPE_STRING; 199 226 } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { 200 - write_propval_cells(f, prop->val); 201 - } else { 202 - write_propval_bytes(f, prop->val); 227 + return TYPE_UINT32; 203 228 } 204 229 205 - fprintf(f, ";\n"); 230 + return TYPE_UINT8; 231 + } 232 + 233 + static void write_propval(FILE *f, struct property *prop) 234 + { 235 + size_t len = prop->val.len; 236 + struct marker *m = prop->val.markers; 237 + struct marker dummy_marker; 238 + enum markertype emit_type = TYPE_NONE; 239 + 240 + if (len == 0) { 241 + fprintf(f, ";\n"); 242 + return; 243 + } 244 + 245 + fprintf(f, " = "); 246 + 247 + if (!next_type_marker(m)) { 248 + /* data type information missing, need to guess */ 249 + dummy_marker.type = guess_value_type(prop); 250 + dummy_marker.next = prop->val.markers; 251 + dummy_marker.offset = 0; 252 + dummy_marker.ref = NULL; 253 + m = &dummy_marker; 254 + } 255 + 256 + struct marker *m_label = prop->val.markers; 257 + for_each_marker(m) { 258 + size_t chunk_len; 259 + const char *p = &prop->val.val[m->offset]; 260 + 261 + if (!has_data_type_information(m)) 262 + continue; 263 + 264 + chunk_len = type_marker_length(m); 265 + if (!chunk_len) 266 + chunk_len = len - m->offset; 267 + 268 + if (emit_type != TYPE_NONE) 269 + fprintf(f, "%s, ", delim_end[emit_type]); 270 + emit_type = m->type; 271 + 272 + for_each_marker_of_type(m_label, LABEL) { 273 + if (m_label->offset > m->offset) 274 + break; 275 + fprintf(f, "%s: ", m_label->ref); 276 + } 277 + 278 + fprintf(f, "%s", delim_start[emit_type]); 279 + 280 + if (chunk_len <= 0) 281 + continue; 282 + 283 + switch(emit_type) { 284 + case TYPE_UINT16: 285 + write_propval_int(f, p, chunk_len, 2); 286 + break; 287 + case TYPE_UINT32: 288 + write_propval_int(f, p, chunk_len, 4); 289 + break; 290 + case TYPE_UINT64: 291 + write_propval_int(f, p, chunk_len, 8); 292 + break; 293 + case TYPE_STRING: 294 + write_propval_string(f, p, chunk_len); 295 + break; 296 + default: 297 + write_propval_int(f, p, chunk_len, 1); 298 + } 299 + } 300 + 301 + /* Wrap up any labels at the end of the value */ 302 + for_each_marker_of_type(m_label, LABEL) { 303 + assert (m_label->offset == len); 304 + fprintf(f, " %s:", m_label->ref); 305 + } 306 + 307 + fprintf(f, "%s;\n", delim_end[emit_type] ? : ""); 206 308 } 207 309 208 310 static void write_tree_source_node(FILE *f, struct node *tree, int level) ··· 327 281 328 282 write_tree_source_node(f, dti->dt, 0); 329 283 } 330 -
+1 -1
scripts/dtc/update-dtc-source.sh
··· 32 32 DTC_LINUX_PATH=`pwd`/scripts/dtc 33 33 34 34 DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ 35 - srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ 35 + srcpos.h treesource.c util.c util.h version_gen.h yamltree.c Makefile.dtc \ 36 36 dtc-lexer.l dtc-parser.y" 37 37 LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ 38 38 fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \
+6 -17
scripts/dtc/util.c
··· 227 227 return val; 228 228 } 229 229 230 - int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len) 230 + int utilfdt_read_err(const char *filename, char **buffp, size_t *len) 231 231 { 232 232 int fd = 0; /* assume stdin */ 233 233 char *buf = NULL; 234 - off_t bufsize = 1024, offset = 0; 234 + size_t bufsize = 1024, offset = 0; 235 235 int ret = 0; 236 236 237 237 *buffp = NULL; ··· 264 264 free(buf); 265 265 else 266 266 *buffp = buf; 267 - *len = bufsize; 267 + if (len) 268 + *len = bufsize; 268 269 return ret; 269 270 } 270 271 271 - int utilfdt_read_err(const char *filename, char **buffp) 272 - { 273 - off_t len; 274 - return utilfdt_read_err_len(filename, buffp, &len); 275 - } 276 - 277 - char *utilfdt_read_len(const char *filename, off_t *len) 272 + char *utilfdt_read(const char *filename, size_t *len) 278 273 { 279 274 char *buff; 280 - int ret = utilfdt_read_err_len(filename, &buff, len); 275 + int ret = utilfdt_read_err(filename, &buff, len); 281 276 282 277 if (ret) { 283 278 fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, ··· 281 286 } 282 287 /* Successful read */ 283 288 return buff; 284 - } 285 - 286 - char *utilfdt_read(const char *filename) 287 - { 288 - off_t len; 289 - return utilfdt_read_len(filename, &len); 290 289 } 291 290 292 291 int utilfdt_write_err(const char *filename, const void *blob)
+4 -16
scripts/dtc/util.h
··· 98 98 * stderr. 99 99 * 100 100 * @param filename The filename to read, or - for stdin 101 + * @param len If non-NULL, the amount of data we managed to read 101 102 * @return Pointer to allocated buffer containing fdt, or NULL on error 102 103 */ 103 - char *utilfdt_read(const char *filename); 104 - 105 - /** 106 - * Like utilfdt_read(), but also passes back the size of the file read. 107 - * 108 - * @param len If non-NULL, the amount of data we managed to read 109 - */ 110 - char *utilfdt_read_len(const char *filename, off_t *len); 104 + char *utilfdt_read(const char *filename, size_t *len); 111 105 112 106 /** 113 107 * Read a device tree file into a buffer. Does not report errors, but only ··· 110 116 * 111 117 * @param filename The filename to read, or - for stdin 112 118 * @param buffp Returns pointer to buffer containing fdt 119 + * @param len If non-NULL, the amount of data we managed to read 113 120 * @return 0 if ok, else an errno value representing the error 114 121 */ 115 - int utilfdt_read_err(const char *filename, char **buffp); 116 - 117 - /** 118 - * Like utilfdt_read_err(), but also passes back the size of the file read. 119 - * 120 - * @param len If non-NULL, the amount of data we managed to read 121 - */ 122 - int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len); 122 + int utilfdt_read_err(const char *filename, char **buffp, size_t *len); 123 123 124 124 /** 125 125 * Write a device tree buffer to a file. This will report any errors on
+1 -1
scripts/dtc/version_gen.h
··· 1 - #define DTC_VERSION "DTC 1.4.6-g84e414b0" 1 + #define DTC_VERSION "DTC 1.4.7-gc86da84d"
+247
scripts/dtc/yamltree.c
··· 1 + /* 2 + * (C) Copyright Linaro, Ltd. 2018 3 + * (C) Copyright Arm Holdings. 2017 4 + * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation; either version 2 of the 9 + * License, or (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 + * General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 + * USA 20 + */ 21 + 22 + #include <stdlib.h> 23 + #include <yaml.h> 24 + #include "dtc.h" 25 + #include "srcpos.h" 26 + 27 + char *yaml_error_name[] = { 28 + [YAML_NO_ERROR] = "no error", 29 + [YAML_MEMORY_ERROR] = "memory error", 30 + [YAML_READER_ERROR] = "reader error", 31 + [YAML_SCANNER_ERROR] = "scanner error", 32 + [YAML_PARSER_ERROR] = "parser error", 33 + [YAML_COMPOSER_ERROR] = "composer error", 34 + [YAML_WRITER_ERROR] = "writer error", 35 + [YAML_EMITTER_ERROR] = "emitter error", 36 + }; 37 + 38 + #define yaml_emitter_emit_or_die(emitter, event) ( \ 39 + { \ 40 + if (!yaml_emitter_emit(emitter, event)) \ 41 + die("yaml '%s': %s in %s, line %i\n", \ 42 + yaml_error_name[(emitter)->error], \ 43 + (emitter)->problem, __func__, __LINE__); \ 44 + }) 45 + 46 + static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, char *data, int len, int width) 47 + { 48 + yaml_event_t event; 49 + void *tag; 50 + int off, start_offset = markers->offset; 51 + 52 + switch(width) { 53 + case 1: tag = "!u8"; break; 54 + case 2: tag = "!u16"; break; 55 + case 4: tag = "!u32"; break; 56 + case 8: tag = "!u64"; break; 57 + default: 58 + die("Invalid width %i", width); 59 + } 60 + assert(len % width == 0); 61 + 62 + yaml_sequence_start_event_initialize(&event, NULL, 63 + (yaml_char_t *)tag, width == 4, YAML_FLOW_SEQUENCE_STYLE); 64 + yaml_emitter_emit_or_die(emitter, &event); 65 + 66 + for (off = 0; off < len; off += width) { 67 + char buf[32]; 68 + struct marker *m; 69 + bool is_phandle = false; 70 + 71 + switch(width) { 72 + case 1: 73 + sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off)); 74 + break; 75 + case 2: 76 + sprintf(buf, "0x%"PRIx16, fdt16_to_cpu(*(fdt16_t*)(data + off))); 77 + break; 78 + case 4: 79 + sprintf(buf, "0x%"PRIx32, fdt32_to_cpu(*(fdt32_t*)(data + off))); 80 + m = markers; 81 + is_phandle = false; 82 + for_each_marker_of_type(m, REF_PHANDLE) { 83 + if (m->offset == (start_offset + off)) { 84 + is_phandle = true; 85 + break; 86 + } 87 + } 88 + break; 89 + case 8: 90 + sprintf(buf, "0x%"PRIx64, fdt64_to_cpu(*(fdt64_t*)(data + off))); 91 + break; 92 + } 93 + 94 + if (is_phandle) 95 + yaml_scalar_event_initialize(&event, NULL, 96 + (yaml_char_t*)"!phandle", (yaml_char_t *)buf, 97 + strlen(buf), 0, 0, YAML_PLAIN_SCALAR_STYLE); 98 + else 99 + yaml_scalar_event_initialize(&event, NULL, 100 + (yaml_char_t*)YAML_INT_TAG, (yaml_char_t *)buf, 101 + strlen(buf), 1, 1, YAML_PLAIN_SCALAR_STYLE); 102 + yaml_emitter_emit_or_die(emitter, &event); 103 + } 104 + 105 + yaml_sequence_end_event_initialize(&event); 106 + yaml_emitter_emit_or_die(emitter, &event); 107 + } 108 + 109 + static void yaml_propval_string(yaml_emitter_t *emitter, char *str, int len) 110 + { 111 + yaml_event_t event; 112 + int i; 113 + 114 + assert(str[len-1] == '\0'); 115 + 116 + /* Make sure the entire string is in the lower 7-bit ascii range */ 117 + for (i = 0; i < len; i++) 118 + assert(isascii(str[i])); 119 + 120 + yaml_scalar_event_initialize(&event, NULL, 121 + (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)str, 122 + len-1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); 123 + yaml_emitter_emit_or_die(emitter, &event); 124 + } 125 + 126 + static void yaml_propval(yaml_emitter_t *emitter, struct property *prop) 127 + { 128 + yaml_event_t event; 129 + int len = prop->val.len; 130 + struct marker *m = prop->val.markers; 131 + 132 + /* Emit the property name */ 133 + yaml_scalar_event_initialize(&event, NULL, 134 + (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)prop->name, 135 + strlen(prop->name), 1, 1, YAML_PLAIN_SCALAR_STYLE); 136 + yaml_emitter_emit_or_die(emitter, &event); 137 + 138 + /* Boolean properties are easiest to deal with. Length is zero, so just emit 'true' */ 139 + if (len == 0) { 140 + yaml_scalar_event_initialize(&event, NULL, 141 + (yaml_char_t *)YAML_BOOL_TAG, 142 + (yaml_char_t*)"true", 143 + strlen("true"), 1, 0, YAML_PLAIN_SCALAR_STYLE); 144 + yaml_emitter_emit_or_die(emitter, &event); 145 + return; 146 + } 147 + 148 + if (!m) 149 + die("No markers present in property '%s' value\n", prop->name); 150 + 151 + yaml_sequence_start_event_initialize(&event, NULL, 152 + (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE); 153 + yaml_emitter_emit_or_die(emitter, &event); 154 + 155 + for_each_marker(m) { 156 + int chunk_len; 157 + char *data = &prop->val.val[m->offset]; 158 + 159 + if (m->type < TYPE_UINT8) 160 + continue; 161 + 162 + chunk_len = type_marker_length(m) ? : len; 163 + assert(chunk_len > 0); 164 + len -= chunk_len; 165 + 166 + switch(m->type) { 167 + case TYPE_UINT16: 168 + yaml_propval_int(emitter, m, data, chunk_len, 2); 169 + break; 170 + case TYPE_UINT32: 171 + yaml_propval_int(emitter, m, data, chunk_len, 4); 172 + break; 173 + case TYPE_UINT64: 174 + yaml_propval_int(emitter, m, data, chunk_len, 8); 175 + break; 176 + case TYPE_STRING: 177 + yaml_propval_string(emitter, data, chunk_len); 178 + break; 179 + default: 180 + yaml_propval_int(emitter, m, data, chunk_len, 1); 181 + break; 182 + } 183 + } 184 + 185 + yaml_sequence_end_event_initialize(&event); 186 + yaml_emitter_emit_or_die(emitter, &event); 187 + } 188 + 189 + 190 + static void yaml_tree(struct node *tree, yaml_emitter_t *emitter) 191 + { 192 + struct property *prop; 193 + struct node *child; 194 + yaml_event_t event; 195 + 196 + if (tree->deleted) 197 + return; 198 + 199 + yaml_mapping_start_event_initialize(&event, NULL, 200 + (yaml_char_t *)YAML_MAP_TAG, 1, YAML_ANY_MAPPING_STYLE); 201 + yaml_emitter_emit_or_die(emitter, &event); 202 + 203 + for_each_property(tree, prop) 204 + yaml_propval(emitter, prop); 205 + 206 + /* Loop over all the children, emitting them into the map */ 207 + for_each_child(tree, child) { 208 + yaml_scalar_event_initialize(&event, NULL, 209 + (yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)child->name, 210 + strlen(child->name), 1, 0, YAML_PLAIN_SCALAR_STYLE); 211 + yaml_emitter_emit_or_die(emitter, &event); 212 + yaml_tree(child, emitter); 213 + } 214 + 215 + yaml_mapping_end_event_initialize(&event); 216 + yaml_emitter_emit_or_die(emitter, &event); 217 + } 218 + 219 + void dt_to_yaml(FILE *f, struct dt_info *dti) 220 + { 221 + yaml_emitter_t emitter; 222 + yaml_event_t event; 223 + 224 + yaml_emitter_initialize(&emitter); 225 + yaml_emitter_set_output_file(&emitter, f); 226 + yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); 227 + yaml_emitter_emit_or_die(&emitter, &event); 228 + 229 + yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); 230 + yaml_emitter_emit_or_die(&emitter, &event); 231 + 232 + yaml_sequence_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_ANY_SEQUENCE_STYLE); 233 + yaml_emitter_emit_or_die(&emitter, &event); 234 + 235 + yaml_tree(dti->dt, &emitter); 236 + 237 + yaml_sequence_end_event_initialize(&event); 238 + yaml_emitter_emit_or_die(&emitter, &event); 239 + 240 + yaml_document_end_event_initialize(&event, 0); 241 + yaml_emitter_emit_or_die(&emitter, &event); 242 + 243 + yaml_stream_end_event_initialize(&event); 244 + yaml_emitter_emit_or_die(&emitter, &event); 245 + 246 + yaml_emitter_delete(&emitter); 247 + }