aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/display/atmel/hlcdc-dc.txt2
-rw-r--r--Documentation/devicetree/bindings/fpga/fpga-region.txt2
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/arm,nvic.txt36
-rw-r--r--Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt2
-rw-r--r--Documentation/devicetree/bindings/net/faraday,ftmac.txt (renamed from Documentation/devicetree/bindings/net/moxa,moxart-mac.txt)7
-rw-r--r--Documentation/devicetree/bindings/trivial-devices.txt (renamed from Documentation/devicetree/bindings/i2c/trivial-devices.txt)0
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt3
-rw-r--r--arch/powerpc/platforms/pseries/ibmebus.c5
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/macintosh/macio_sysfs.c7
-rw-r--r--drivers/of/address.c2
-rw-r--r--drivers/of/base.c13
-rw-r--r--drivers/of/device.c20
-rw-r--r--drivers/of/fdt.c18
-rw-r--r--drivers/of/irq.c2
-rw-r--r--drivers/of/of_numa.c2
-rw-r--r--drivers/of/of_private.h12
-rw-r--r--drivers/of/of_reserved_mem.c2
-rw-r--r--drivers/of/resolver.c2
-rw-r--r--drivers/of/unittest-data/Makefile17
-rw-r--r--drivers/of/unittest-data/overlay.dts53
-rw-r--r--drivers/of/unittest-data/overlay_bad_phandle.dts20
-rw-r--r--drivers/of/unittest-data/overlay_base.dts80
-rw-r--r--drivers/of/unittest.c321
-rw-r--r--drivers/tty/serdev/core.c5
-rw-r--r--drivers/usb/common/ulpi.c2
-rw-r--r--include/linux/of_device.h7
-rw-r--r--include/linux/of_irq.h2
-rw-r--r--scripts/Makefile.lib14
-rw-r--r--scripts/dtc/checks.c361
-rw-r--r--scripts/dtc/data.c16
-rw-r--r--scripts/dtc/dtc-lexer.l3
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped77
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped6
-rw-r--r--scripts/dtc/dtc-parser.y6
-rw-r--r--scripts/dtc/dtc.c9
-rw-r--r--scripts/dtc/dtc.h11
-rw-r--r--scripts/dtc/flattree.c58
-rw-r--r--scripts/dtc/libfdt/fdt_rw.c3
-rw-r--r--scripts/dtc/libfdt/libfdt.h51
-rw-r--r--scripts/dtc/libfdt/libfdt_env.h26
-rw-r--r--scripts/dtc/livetree.c22
-rw-r--r--scripts/dtc/srcpos.c2
-rw-r--r--scripts/dtc/srcpos.h11
-rw-r--r--scripts/dtc/treesource.c6
-rwxr-xr-xscripts/dtc/update-dtc-source.sh20
-rw-r--r--scripts/dtc/util.c11
-rw-r--r--scripts/dtc/util.h24
-rw-r--r--scripts/dtc/version_gen.h2
49 files changed, 1152 insertions, 233 deletions
diff --git a/Documentation/devicetree/bindings/display/atmel/hlcdc-dc.txt b/Documentation/devicetree/bindings/display/atmel/hlcdc-dc.txt
index ebc1a914bda3..ec94468b35be 100644
--- a/Documentation/devicetree/bindings/display/atmel/hlcdc-dc.txt
+++ b/Documentation/devicetree/bindings/display/atmel/hlcdc-dc.txt
@@ -1,7 +1,7 @@
1Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver 1Device-Tree bindings for Atmel's HLCDC (High LCD Controller) DRM driver
2 2
3The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD device. 3The Atmel HLCDC Display Controller is subdevice of the HLCDC MFD device.
4See ../mfd/atmel-hlcdc.txt for more details. 4See ../../mfd/atmel-hlcdc.txt for more details.
5 5
6Required properties: 6Required properties:
7 - compatible: value should be "atmel,hlcdc-display-controller" 7 - compatible: value should be "atmel,hlcdc-display-controller"
diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt b/Documentation/devicetree/bindings/fpga/fpga-region.txt
index 81bf3adba24b..6db8aeda461a 100644
--- a/Documentation/devicetree/bindings/fpga/fpga-region.txt
+++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt
@@ -193,6 +193,8 @@ Optional properties:
193- region-freeze-timeout-us : The maximum time in microseconds to wait for 193- region-freeze-timeout-us : The maximum time in microseconds to wait for
194 bridges to successfully become disabled before the region has been 194 bridges to successfully become disabled before the region has been
195 programmed. 195 programmed.
196- config-complete-timeout-us : The maximum time in microseconds time for the
197 FPGA to go to operating mode after the region has been programmed.
196- child nodes : devices in the FPGA after programming. 198- child nodes : devices in the FPGA after programming.
197 199
198In the example below, when an overlay is applied targeting fpga-region0, 200In the example below, when an overlay is applied targeting fpga-region0,
diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,nvic.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,nvic.txt
new file mode 100644
index 000000000000..386ab37a383f
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,nvic.txt
@@ -0,0 +1,36 @@
1* ARM Nested Vector Interrupt Controller (NVIC)
2
3The NVIC provides an interrupt controller that is tightly coupled to
4Cortex-M based processor cores. The NVIC implemented on different SoCs
5vary in the number of interrupts and priority bits per interrupt.
6
7Main node required properties:
8
9- compatible : should be one of:
10 "arm,v6m-nvic"
11 "arm,v7m-nvic"
12 "arm,v8m-nvic"
13- interrupt-controller : Identifies the node as an interrupt controller
14- #interrupt-cells : Specifies the number of cells needed to encode an
15 interrupt source. The type shall be a <u32> and the value shall be 2.
16
17 The 1st cell contains the interrupt number for the interrupt type.
18
19 The 2nd cell is the priority of the interrupt.
20
21- reg : Specifies base physical address(s) and size of the NVIC registers.
22 This is at a fixed address (0xe000e100) and size (0xc00).
23
24- arm,num-irq-priority-bits: The number of priority bits implemented by the
25 given SoC
26
27Example:
28
29 intc: interrupt-controller@e000e100 {
30 compatible = "arm,v7m-nvic";
31 #interrupt-cells = <2>;
32 #address-cells = <1>;
33 interrupt-controller;
34 reg = <0xe000e100 0xc00>;
35 arm,num-irq-priority-bits = <4>;
36 };
diff --git a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
index 670831b29565..eec40be7f79a 100644
--- a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
+++ b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
@@ -15,7 +15,7 @@ Required properties:
15 15
16The HLCDC IP exposes two subdevices: 16The HLCDC IP exposes two subdevices:
17 - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt 17 - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt
18 - a Display Controller: see ../display/atmel-hlcdc-dc.txt 18 - a Display Controller: see ../display/atmel/hlcdc-dc.txt
19 19
20Example: 20Example:
21 21
diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/faraday,ftmac.txt
index 583418b2c127..be4f55e23bf7 100644
--- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
+++ b/Documentation/devicetree/bindings/net/faraday,ftmac.txt
@@ -1,8 +1,11 @@
1MOXA ART Ethernet Controller 1Faraday Ethernet Controller
2 2
3Required properties: 3Required properties:
4 4
5- compatible : Must be "moxa,moxart-mac" 5- compatible : Must contain "faraday,ftmac", as well as one of
6 the SoC specific identifiers:
7 "andestech,atmac100"
8 "moxa,moxart-mac"
6- reg : Should contain register location and length 9- reg : Should contain register location and length
7- interrupts : Should contain the mac interrupt number 10- interrupts : Should contain the mac interrupt number
8 11
diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt
index ad10fbe61562..ad10fbe61562 100644
--- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/trivial-devices.txt
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 257ec07cbaa0..ee558477e164 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -80,6 +80,7 @@ denx Denx Software Engineering
80devantech Devantech, Ltd. 80devantech Devantech, Ltd.
81digi Digi International Inc. 81digi Digi International Inc.
82digilent Diglent, Inc. 82digilent Diglent, Inc.
83dioo Dioo Microcircuit Co., Ltd
83dlg Dialog Semiconductor 84dlg Dialog Semiconductor
84dlink D-Link Corporation 85dlink D-Link Corporation
85dmo Data Modul AG 86dmo Data Modul AG
@@ -215,6 +216,7 @@ newhaven Newhaven Display International
215ni National Instruments 216ni National Instruments
216nintendo Nintendo 217nintendo Nintendo
217nokia Nokia 218nokia Nokia
219nordic Nordic Semiconductor
218nuvoton Nuvoton Technology Corporation 220nuvoton Nuvoton Technology Corporation
219nvd New Vision Display 221nvd New Vision Display
220nvidia NVIDIA 222nvidia NVIDIA
@@ -261,6 +263,7 @@ richtek Richtek Technology Corporation
261ricoh Ricoh Co. Ltd. 263ricoh Ricoh Co. Ltd.
262rikomagic Rikomagic Tech Corp. Ltd 264rikomagic Rikomagic Tech Corp. Ltd
263rockchip Fuzhou Rockchip Electronics Co., Ltd 265rockchip Fuzhou Rockchip Electronics Co., Ltd
266rohm ROHM Semiconductor Co., Ltd
264samsung Samsung Semiconductor 267samsung Samsung Semiconductor
265samtec Samtec/Softing company 268samtec Samtec/Softing company
266sandisk Sandisk Corporation 269sandisk Sandisk Corporation
diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index 99a6bf7f3bcf..b363e439ddb9 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -410,10 +410,7 @@ static ssize_t name_show(struct device *dev,
410static ssize_t modalias_show(struct device *dev, 410static ssize_t modalias_show(struct device *dev,
411 struct device_attribute *attr, char *buf) 411 struct device_attribute *attr, char *buf)
412{ 412{
413 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); 413 return of_device_modalias(dev, buf, PAGE_SIZE);
414 buf[len] = '\n';
415 buf[len+1] = 0;
416 return len+1;
417} 414}
418 415
419static struct device_attribute ibmebus_bus_device_attrs[] = { 416static struct device_attribute ibmebus_bus_device_attrs[] = {
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index c2456839214a..a102152301c8 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -847,7 +847,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
847 struct platform_device *pdev = to_platform_device(dev); 847 struct platform_device *pdev = to_platform_device(dev);
848 int len; 848 int len;
849 849
850 len = of_device_get_modalias(dev, buf, PAGE_SIZE -1); 850 len = of_device_modalias(dev, buf, PAGE_SIZE);
851 if (len != -ENODEV) 851 if (len != -ENODEV)
852 return len; 852 return len;
853 853
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 8eb40afbd0f5..0b1f9c76c68d 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -41,12 +41,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
41static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, 41static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
42 char *buf) 42 char *buf)
43{ 43{
44 int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); 44 return of_device_modalias(dev, buf, PAGE_SIZE);
45
46 buf[len] = '\n';
47 buf[len+1] = 0;
48
49 return len+1;
50} 45}
51 46
52static ssize_t devspec_show(struct device *dev, 47static ssize_t devspec_show(struct device *dev,
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 02b2903fe9d2..72914cdfce2a 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -263,7 +263,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
263 if (!parser->range || parser->range + parser->np > parser->end) 263 if (!parser->range || parser->range + parser->np > parser->end)
264 return NULL; 264 return NULL;
265 265
266 range->pci_space = parser->range[0]; 266 range->pci_space = be32_to_cpup(parser->range);
267 range->flags = of_bus_pci_get_flags(parser->range); 267 range->flags = of_bus_pci_get_flags(parser->range);
268 range->pci_addr = of_read_number(parser->range + 1, ns); 268 range->pci_addr = of_read_number(parser->range + 1, ns);
269 range->cpu_addr = of_translate_address(parser->node, 269 range->cpu_addr = of_translate_address(parser->node,
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0ea16bd3c8f1..28d5f53bc631 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2281,15 +2281,14 @@ EXPORT_SYMBOL_GPL(of_console_check);
2281 */ 2281 */
2282struct device_node *of_find_next_cache_node(const struct device_node *np) 2282struct device_node *of_find_next_cache_node(const struct device_node *np)
2283{ 2283{
2284 struct device_node *child; 2284 struct device_node *child, *cache_node;
2285 const phandle *handle;
2286 2285
2287 handle = of_get_property(np, "l2-cache", NULL); 2286 cache_node = of_parse_phandle(np, "l2-cache", 0);
2288 if (!handle) 2287 if (!cache_node)
2289 handle = of_get_property(np, "next-level-cache", NULL); 2288 cache_node = of_parse_phandle(np, "next-level-cache", 0);
2290 2289
2291 if (handle) 2290 if (cache_node)
2292 return of_find_node_by_phandle(be32_to_cpup(handle)); 2291 return cache_node;
2293 2292
2294 /* OF on pmac has nodes instead of properties named "l2-cache" 2293 /* OF on pmac has nodes instead of properties named "l2-cache"
2295 * beneath CPU nodes. 2294 * beneath CPU nodes.
diff --git a/drivers/of/device.c b/drivers/of/device.c
index b1e6bebda3f3..6e2f9113b1b7 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -176,7 +176,7 @@ const void *of_device_get_match_data(const struct device *dev)
176} 176}
177EXPORT_SYMBOL(of_device_get_match_data); 177EXPORT_SYMBOL(of_device_get_match_data);
178 178
179ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) 179static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
180{ 180{
181 const char *compat; 181 const char *compat;
182 int cplen, i; 182 int cplen, i;
@@ -223,9 +223,8 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
223 str[i] = '_'; 223 str[i] = '_';
224 } 224 }
225 225
226 return tsize; 226 return repend;
227} 227}
228EXPORT_SYMBOL_GPL(of_device_get_modalias);
229 228
230int of_device_request_module(struct device *dev) 229int of_device_request_module(struct device *dev)
231{ 230{
@@ -251,6 +250,21 @@ int of_device_request_module(struct device *dev)
251EXPORT_SYMBOL_GPL(of_device_request_module); 250EXPORT_SYMBOL_GPL(of_device_request_module);
252 251
253/** 252/**
253 * of_device_modalias - Fill buffer with newline terminated modalias string
254 */
255ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
256{
257 ssize_t sl = of_device_get_modalias(dev, str, len - 2);
258 if (sl < 0)
259 return sl;
260
261 str[sl++] = '\n';
262 str[sl] = 0;
263 return sl;
264}
265EXPORT_SYMBOL_GPL(of_device_modalias);
266
267/**
254 * of_device_uevent - Display OF related uevent information 268 * of_device_uevent - Display OF related uevent information
255 */ 269 */
256void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) 270void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e5ce4b59e162..a0972219ccfc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -31,6 +31,8 @@
31#include <asm/setup.h> /* for COMMAND_LINE_SIZE */ 31#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
32#include <asm/page.h> 32#include <asm/page.h>
33 33
34#include "of_private.h"
35
34/* 36/*
35 * of_fdt_limit_memory - limit the number of regions in the /memory node 37 * of_fdt_limit_memory - limit the number of regions in the /memory node
36 * @limit: maximum entries 38 * @limit: maximum entries
@@ -46,8 +48,8 @@ void of_fdt_limit_memory(int limit)
46 const void *val; 48 const void *val;
47 int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; 49 int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
48 int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; 50 int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
49 const uint32_t *addr_prop; 51 const __be32 *addr_prop;
50 const uint32_t *size_prop; 52 const __be32 *size_prop;
51 int root_offset; 53 int root_offset;
52 int cell_size; 54 int cell_size;
53 55
@@ -469,11 +471,11 @@ static int unflatten_dt_nodes(const void *blob,
469 * Returns NULL on failure or the memory chunk containing the unflattened 471 * Returns NULL on failure or the memory chunk containing the unflattened
470 * device tree on success. 472 * device tree on success.
471 */ 473 */
472static void *__unflatten_device_tree(const void *blob, 474void *__unflatten_device_tree(const void *blob,
473 struct device_node *dad, 475 struct device_node *dad,
474 struct device_node **mynodes, 476 struct device_node **mynodes,
475 void *(*dt_alloc)(u64 size, u64 align), 477 void *(*dt_alloc)(u64 size, u64 align),
476 bool detached) 478 bool detached)
477{ 479{
478 int size; 480 int size;
479 void *mem; 481 void *mem;
@@ -1261,6 +1263,8 @@ void __init unflatten_device_tree(void)
1261 1263
1262 /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */ 1264 /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
1263 of_alias_scan(early_init_dt_alloc_memory_arch); 1265 of_alias_scan(early_init_dt_alloc_memory_arch);
1266
1267 unittest_unflatten_overlay_base();
1264} 1268}
1265 1269
1266/** 1270/**
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 7c56b72d1dc6..d11437cb1187 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -102,7 +102,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq)
102 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; 102 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
103 __be32 initial_match_array[MAX_PHANDLE_ARGS]; 103 __be32 initial_match_array[MAX_PHANDLE_ARGS];
104 const __be32 *match_array = initial_match_array; 104 const __be32 *match_array = initial_match_array;
105 const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; 105 const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
106 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; 106 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
107 int imaplen, match, i, rc = -EINVAL; 107 int imaplen, match, i, rc = -EINVAL;
108 108
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index a53982a330ea..2db1f7a04baf 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -57,6 +57,8 @@ static void __init of_numa_parse_cpu_nodes(void)
57 else 57 else
58 node_set(nid, numa_nodes_parsed); 58 node_set(nid, numa_nodes_parsed);
59 } 59 }
60
61 of_node_put(cpus);
60} 62}
61 63
62static int __init of_numa_parse_memory_nodes(void) 64static int __init of_numa_parse_memory_nodes(void)
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 18bbb4517e25..4ebb0149d118 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -55,6 +55,18 @@ static inline int of_property_notify(int action, struct device_node *np,
55} 55}
56#endif /* CONFIG_OF_DYNAMIC */ 56#endif /* CONFIG_OF_DYNAMIC */
57 57
58#if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
59extern void __init unittest_unflatten_overlay_base(void);
60#else
61static inline void unittest_unflatten_overlay_base(void) {};
62#endif
63
64extern void *__unflatten_device_tree(const void *blob,
65 struct device_node *dad,
66 struct device_node **mynodes,
67 void *(*dt_alloc)(u64 size, u64 align),
68 bool detached);
69
58/** 70/**
59 * General utilities for working with live trees. 71 * General utilities for working with live trees.
60 * 72 *
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index d507c3569a88..4dec07ea510f 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -197,7 +197,7 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem)
197 const struct of_device_id *i; 197 const struct of_device_id *i;
198 198
199 for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) { 199 for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) {
200 reservedmem_of_init_fn initfn = i->data; 200 int const (*initfn)(struct reserved_mem *rmem) = i->data;
201 const char *compat = i->compatible; 201 const char *compat = i->compatible;
202 202
203 if (!of_flat_dt_is_compatible(rmem->fdt_node, compat)) 203 if (!of_flat_dt_is_compatible(rmem->fdt_node, compat))
diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 7ae9863cb0a4..771f4844c781 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -92,7 +92,7 @@ static void adjust_overlay_phandles(struct device_node *overlay,
92 if (phandle == OF_PHANDLE_ILLEGAL) 92 if (phandle == OF_PHANDLE_ILLEGAL)
93 continue; 93 continue;
94 94
95 *(uint32_t *)prop->value = cpu_to_be32(overlay->phandle); 95 *(__be32 *)prop->value = cpu_to_be32(overlay->phandle);
96 } 96 }
97 97
98 for_each_child_of_node(overlay, child) 98 for_each_child_of_node(overlay, child)
diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
index 1ac5cc01d627..6e00a9c69e58 100644
--- a/drivers/of/unittest-data/Makefile
+++ b/drivers/of/unittest-data/Makefile
@@ -1,7 +1,18 @@
1obj-y += testcases.dtb.o 1obj-y += testcases.dtb.o
2obj-y += overlay.dtb.o
3obj-y += overlay_bad_phandle.dtb.o
4obj-y += overlay_base.dtb.o
2 5
3targets += testcases.dtb testcases.dtb.S 6targets += testcases.dtb testcases.dtb.S
7targets += overlay.dtb overlay.dtb.S
8targets += overlay_bad_phandle.dtb overlay_bad_phandle.dtb.S
9targets += overlay_base.dtb overlay_base.dtb.S
4 10
5.SECONDARY: \ 11.PRECIOUS: \
6 $(obj)/testcases.dtb.S \ 12 $(obj)/%.dtb.S \
7 $(obj)/testcases.dtb 13 $(obj)/%.dtb
14
15# enable creation of __symbols__ node
16DTC_FLAGS_overlay := -@
17DTC_FLAGS_overlay_bad_phandle := -@
18DTC_FLAGS_overlay_base := -@
diff --git a/drivers/of/unittest-data/overlay.dts b/drivers/of/unittest-data/overlay.dts
new file mode 100644
index 000000000000..6cd7e6a0c13e
--- /dev/null
+++ b/drivers/of/unittest-data/overlay.dts
@@ -0,0 +1,53 @@
1/dts-v1/;
2/plugin/;
3
4/ {
5
6 fragment@0 {
7 target = <&electric_1>;
8
9 __overlay__ {
10 status = "ok";
11
12 hvac_2: hvac-large-1 {
13 compatible = "ot,hvac-large";
14 heat-range = < 40 75 >;
15 cool-range = < 65 80 >;
16 };
17 };
18 };
19
20 fragment@1 {
21 target = <&rides_1>;
22
23 __overlay__ {
24 #address-cells = <1>;
25 #size-cells = <1>;
26 status = "ok";
27
28 ride@200 {
29 compatible = "ot,ferris-wheel";
30 reg = < 0x00000200 0x100 >;
31 hvac-provider = < &hvac_2 >;
32 hvac-thermostat = < 27 32 > ;
33 hvac-zones = < 12 5 >;
34 hvac-zone-names = "operator", "snack-bar";
35 spin-controller = < &spin_ctrl_1 3 >;
36 spin-rph = < 30 >;
37 gondolas = < 16 >;
38 gondola-capacity = < 6 >;
39 };
40 };
41 };
42
43 fragment@2 {
44 target = <&lights_2>;
45
46 __overlay__ {
47 status = "ok";
48 color = "purple", "white", "red", "green";
49 rate = < 3 256 >;
50 };
51 };
52
53};
diff --git a/drivers/of/unittest-data/overlay_bad_phandle.dts b/drivers/of/unittest-data/overlay_bad_phandle.dts
new file mode 100644
index 000000000000..270ee885a623
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_bad_phandle.dts
@@ -0,0 +1,20 @@
1/dts-v1/;
2/plugin/;
3
4/ {
5
6 fragment@0 {
7 target = <&electric_1>;
8
9 __overlay__ {
10
11 // This label should cause an error when the overlay
12 // is applied. There is already a phandle value
13 // in the base tree for motor-1.
14 spin_ctrl_1_conflict: motor-1 {
15 accelerate = < 3 >;
16 decelerate = < 5 >;
17 };
18 };
19 };
20};
diff --git a/drivers/of/unittest-data/overlay_base.dts b/drivers/of/unittest-data/overlay_base.dts
new file mode 100644
index 000000000000..5566b27fb61a
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_base.dts
@@ -0,0 +1,80 @@
1/dts-v1/;
2/plugin/;
3
4/*
5 * Base device tree that overlays will be applied against.
6 *
7 * Do not add any properties in node "/".
8 * Do not add any nodes other than "/testcase-data-2" in node "/".
9 * Do not add anything that would result in dtc creating node "/__fixups__".
10 * dtc will create nodes "/__symbols__" and "/__local_fixups__".
11 */
12
13/ {
14 testcase-data-2 {
15 #address-cells = <1>;
16 #size-cells = <1>;
17
18 electric_1: substation@100 {
19 compatible = "ot,big-volts-control";
20 reg = < 0x00000100 0x100 >;
21 status = "disabled";
22
23 hvac_1: hvac-medium-1 {
24 compatible = "ot,hvac-medium";
25 heat-range = < 50 75 >;
26 cool-range = < 60 80 >;
27 };
28
29 spin_ctrl_1: motor-1 {
30 compatible = "ot,ferris-wheel-motor";
31 spin = "clockwise";
32 };
33
34 spin_ctrl_2: motor-8 {
35 compatible = "ot,roller-coaster-motor";
36 };
37 };
38
39 rides_1: fairway-1 {
40 #address-cells = <1>;
41 #size-cells = <1>;
42 compatible = "ot,rides";
43 status = "disabled";
44 orientation = < 127 >;
45
46 ride@100 {
47 compatible = "ot,roller-coaster";
48 reg = < 0x00000100 0x100 >;
49 hvac-provider = < &hvac_1 >;
50 hvac-thermostat = < 29 > ;
51 hvac-zones = < 14 >;
52 hvac-zone-names = "operator";
53 spin-controller = < &spin_ctrl_2 5 &spin_ctrl_2 7 >;
54 spin-controller-names = "track_1", "track_2";
55 queues = < 2 >;
56 };
57 };
58
59 lights_1: lights@30000 {
60 compatible = "ot,work-lights";
61 reg = < 0x00030000 0x1000 >;
62 status = "disabled";
63 };
64
65 lights_2: lights@40000 {
66 compatible = "ot,show-lights";
67 reg = < 0x00040000 0x1000 >;
68 status = "disabled";
69 rate = < 13 138 >;
70 };
71
72 retail_1: vending@50000 {
73 reg = < 0x00050000 0x1000 >;
74 compatible = "ot,tickets";
75 status = "disabled";
76 };
77
78 };
79};
80
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 62db55b97c10..987a1530282a 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -8,6 +8,7 @@
8#include <linux/err.h> 8#include <linux/err.h>
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/hashtable.h> 10#include <linux/hashtable.h>
11#include <linux/libfdt.h>
11#include <linux/of.h> 12#include <linux/of.h>
12#include <linux/of_fdt.h> 13#include <linux/of_fdt.h>
13#include <linux/of_irq.h> 14#include <linux/of_irq.h>
@@ -1925,6 +1926,324 @@ out:
1925static inline void __init of_unittest_overlay(void) { } 1926static inline void __init of_unittest_overlay(void) { }
1926#endif 1927#endif
1927 1928
1929/*
1930 * __dtb_ot_begin[] and __dtb_ot_end[] are created by cmd_dt_S_dtb
1931 * in scripts/Makefile.lib
1932 */
1933
1934#define OVERLAY_INFO_EXTERN(name) \
1935 extern uint8_t __dtb_##name##_begin[]; \
1936 extern uint8_t __dtb_##name##_end[]
1937
1938#define OVERLAY_INFO(name, expected) \
1939{ .dtb_begin = __dtb_##name##_begin, \
1940 .dtb_end = __dtb_##name##_end, \
1941 .expected_result = expected, \
1942}
1943
1944struct overlay_info {
1945 uint8_t *dtb_begin;
1946 uint8_t *dtb_end;
1947 void *data;
1948 struct device_node *np_overlay;
1949 int expected_result;
1950 int overlay_id;
1951};
1952
1953OVERLAY_INFO_EXTERN(overlay_base);
1954OVERLAY_INFO_EXTERN(overlay);
1955OVERLAY_INFO_EXTERN(overlay_bad_phandle);
1956
1957#ifdef CONFIG_OF_OVERLAY
1958
1959/* order of entries is hard-coded into users of overlays[] */
1960static struct overlay_info overlays[] = {
1961 OVERLAY_INFO(overlay_base, -9999),
1962 OVERLAY_INFO(overlay, 0),
1963 OVERLAY_INFO(overlay_bad_phandle, -EINVAL),
1964 {}
1965};
1966
1967static struct device_node *overlay_base_root;
1968
1969/*
1970 * Create base device tree for the overlay unittest.
1971 *
1972 * This is called from very early boot code.
1973 *
1974 * Do as much as possible the same way as done in __unflatten_device_tree
1975 * and other early boot steps for the normal FDT so that the overlay base
1976 * unflattened tree will have the same characteristics as the real tree
1977 * (such as having memory allocated by the early allocator). The goal
1978 * is to test "the real thing" as much as possible, and test "test setup
1979 * code" as little as possible.
1980 *
1981 * Have to stop before resolving phandles, because that uses kmalloc.
1982 */
1983void __init unittest_unflatten_overlay_base(void)
1984{
1985 struct overlay_info *info;
1986 u32 data_size;
1987 u32 size;
1988
1989 info = &overlays[0];
1990
1991 if (info->expected_result != -9999) {
1992 pr_err("No dtb 'overlay_base' to attach\n");
1993 return;
1994 }
1995
1996 data_size = info->dtb_end - info->dtb_begin;
1997 if (!data_size) {
1998 pr_err("No dtb 'overlay_base' to attach\n");
1999 return;
2000 }
2001
2002 size = fdt_totalsize(info->dtb_begin);
2003 if (size != data_size) {
2004 pr_err("dtb 'overlay_base' header totalsize != actual size");
2005 return;
2006 }
2007
2008 info->data = early_init_dt_alloc_memory_arch(size,
2009 roundup_pow_of_two(FDT_V17_SIZE));
2010 if (!info->data) {
2011 pr_err("alloc for dtb 'overlay_base' failed");
2012 return;
2013 }
2014
2015 memcpy(info->data, info->dtb_begin, size);
2016
2017 __unflatten_device_tree(info->data, NULL, &info->np_overlay,
2018 early_init_dt_alloc_memory_arch, true);
2019 overlay_base_root = info->np_overlay;
2020}
2021
2022/*
2023 * The purpose of of_unittest_overlay_data_add is to add an
2024 * overlay in the normal fashion. This is a test of the whole
2025 * picture, instead of testing individual elements.
2026 *
2027 * A secondary purpose is to be able to verify that the contents of
2028 * /proc/device-tree/ contains the updated structure and values from
2029 * the overlay. That must be verified separately in user space.
2030 *
2031 * Return 0 on unexpected error.
2032 */
2033static int __init overlay_data_add(int onum)
2034{
2035 struct overlay_info *info;
2036 int k;
2037 int ret;
2038 u32 size;
2039 u32 size_from_header;
2040
2041 for (k = 0, info = overlays; info; info++, k++) {
2042 if (k == onum)
2043 break;
2044 }
2045 if (onum > k)
2046 return 0;
2047
2048 size = info->dtb_end - info->dtb_begin;
2049 if (!size) {
2050 pr_err("no overlay to attach, %d\n", onum);
2051 ret = 0;
2052 }
2053
2054 size_from_header = fdt_totalsize(info->dtb_begin);
2055 if (size_from_header != size) {
2056 pr_err("overlay header totalsize != actual size, %d", onum);
2057 return 0;
2058 }
2059
2060 /*
2061 * Must create permanent copy of FDT because of_fdt_unflatten_tree()
2062 * will create pointers to the passed in FDT in the EDT.
2063 */
2064 info->data = kmemdup(info->dtb_begin, size, GFP_KERNEL);
2065 if (!info->data) {
2066 pr_err("unable to allocate memory for data, %d\n", onum);
2067 return 0;
2068 }
2069
2070 of_fdt_unflatten_tree(info->data, NULL, &info->np_overlay);
2071 if (!info->np_overlay) {
2072 pr_err("unable to unflatten overlay, %d\n", onum);
2073 ret = 0;
2074 goto out_free_data;
2075 }
2076 of_node_set_flag(info->np_overlay, OF_DETACHED);
2077
2078 ret = of_resolve_phandles(info->np_overlay);
2079 if (ret) {
2080 pr_err("resolve ot phandles (ret=%d), %d\n", ret, onum);
2081 goto out_free_np_overlay;
2082 }
2083
2084 ret = of_overlay_create(info->np_overlay);
2085 if (ret < 0) {
2086 pr_err("of_overlay_create() (ret=%d), %d\n", ret, onum);
2087 goto out_free_np_overlay;
2088 } else {
2089 info->overlay_id = ret;
2090 ret = 0;
2091 }
2092
2093 pr_debug("__dtb_overlay_begin applied, overlay id %d\n", ret);
2094
2095 goto out;
2096
2097out_free_np_overlay:
2098 /*
2099 * info->np_overlay is the unflattened device tree
2100 * It has not been spliced into the live tree.
2101 */
2102
2103 /* todo: function to free unflattened device tree */
2104
2105out_free_data:
2106 kfree(info->data);
2107
2108out:
2109 return (ret == info->expected_result);
2110}
2111
2112/*
2113 * The purpose of of_unittest_overlay_high_level is to add an overlay
2114 * in the normal fashion. This is a test of the whole picture,
2115 * instead of individual elements.
2116 *
2117 * The first part of the function is _not_ normal overlay usage; it is
2118 * finishing splicing the base overlay device tree into the live tree.
2119 */
2120static __init void of_unittest_overlay_high_level(void)
2121{
2122 struct device_node *last_sibling;
2123 struct device_node *np;
2124 struct device_node *of_symbols;
2125 struct device_node *overlay_base_symbols;
2126 struct device_node **pprev;
2127 struct property *prop;
2128 int ret;
2129
2130 if (!overlay_base_root) {
2131 unittest(0, "overlay_base_root not initialized\n");
2132 return;
2133 }
2134
2135 /*
2136 * Could not fixup phandles in unittest_unflatten_overlay_base()
2137 * because kmalloc() was not yet available.
2138 */
2139 of_resolve_phandles(overlay_base_root);
2140
2141 /*
2142 * do not allow overlay_base to duplicate any node already in
2143 * tree, this greatly simplifies the code
2144 */
2145
2146 /*
2147 * remove overlay_base_root node "__local_fixups", after
2148 * being used by of_resolve_phandles()
2149 */
2150 pprev = &overlay_base_root->child;
2151 for (np = overlay_base_root->child; np; np = np->sibling) {
2152 if (!of_node_cmp(np->name, "__local_fixups__")) {
2153 *pprev = np->sibling;
2154 break;
2155 }
2156 pprev = &np->sibling;
2157 }
2158
2159 /* remove overlay_base_root node "__symbols__" if in live tree */
2160 of_symbols = of_get_child_by_name(of_root, "__symbols__");
2161 if (of_symbols) {
2162 /* will have to graft properties from node into live tree */
2163 pprev = &overlay_base_root->child;
2164 for (np = overlay_base_root->child; np; np = np->sibling) {
2165 if (!of_node_cmp(np->name, "__symbols__")) {
2166 overlay_base_symbols = np;
2167 *pprev = np->sibling;
2168 break;
2169 }
2170 pprev = &np->sibling;
2171 }
2172 }
2173
2174 for (np = overlay_base_root->child; np; np = np->sibling) {
2175 if (of_get_child_by_name(of_root, np->name)) {
2176 unittest(0, "illegal node name in overlay_base %s",
2177 np->name);
2178 return;
2179 }
2180 }
2181
2182 /*
2183 * overlay 'overlay_base' is not allowed to have root
2184 * properties, so only need to splice nodes into main device tree.
2185 *
2186 * root node of *overlay_base_root will not be freed, it is lost
2187 * memory.
2188 */
2189
2190 for (np = overlay_base_root->child; np; np = np->sibling)
2191 np->parent = of_root;
2192
2193 mutex_lock(&of_mutex);
2194
2195 for (last_sibling = np = of_root->child; np; np = np->sibling)
2196 last_sibling = np;
2197
2198 if (last_sibling)
2199 last_sibling->sibling = overlay_base_root->child;
2200 else
2201 of_root->child = overlay_base_root->child;
2202
2203 for_each_of_allnodes_from(overlay_base_root, np)
2204 __of_attach_node_sysfs(np);
2205
2206 if (of_symbols) {
2207 for_each_property_of_node(overlay_base_symbols, prop) {
2208 ret = __of_add_property(of_symbols, prop);
2209 if (ret) {
2210 unittest(0,
2211 "duplicate property '%s' in overlay_base node __symbols__",
2212 prop->name);
2213 goto err_unlock;
2214 }
2215 ret = __of_add_property_sysfs(of_symbols, prop);
2216 if (ret) {
2217 unittest(0,
2218 "unable to add property '%s' in overlay_base node __symbols__ to sysfs",
2219 prop->name);
2220 goto err_unlock;
2221 }
2222 }
2223 }
2224
2225 mutex_unlock(&of_mutex);
2226
2227
2228 /* now do the normal overlay usage test */
2229
2230 unittest(overlay_data_add(1),
2231 "Adding overlay 'overlay' failed\n");
2232
2233 unittest(overlay_data_add(2),
2234 "Adding overlay 'overlay_bad_phandle' failed\n");
2235 return;
2236
2237err_unlock:
2238 mutex_unlock(&of_mutex);
2239}
2240
2241#else
2242
2243static inline __init void of_unittest_overlay_high_level(void) {}
2244
2245#endif
2246
1928static int __init of_unittest(void) 2247static int __init of_unittest(void)
1929{ 2248{
1930 struct device_node *np; 2249 struct device_node *np;
@@ -1962,6 +2281,8 @@ static int __init of_unittest(void)
1962 /* Double check linkage after removing testcase data */ 2281 /* Double check linkage after removing testcase data */
1963 of_unittest_check_tree_linkage(); 2282 of_unittest_check_tree_linkage();
1964 2283
2284 of_unittest_overlay_high_level();
2285
1965 pr_info("end of unittest - %i passed, %i failed\n", 2286 pr_info("end of unittest - %i passed, %i failed\n",
1966 unittest_results.passed, unittest_results.failed); 2287 unittest_results.passed, unittest_results.failed);
1967 2288
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 1e1cbae3a0ea..1c4829a56351 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -224,10 +224,7 @@ static int serdev_drv_remove(struct device *dev)
224static ssize_t modalias_show(struct device *dev, 224static ssize_t modalias_show(struct device *dev,
225 struct device_attribute *attr, char *buf) 225 struct device_attribute *attr, char *buf)
226{ 226{
227 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); 227 return of_device_modalias(dev, buf, PAGE_SIZE);
228 buf[len] = '\n';
229 buf[len+1] = 0;
230 return len+1;
231} 228}
232 229
233static struct device_attribute serdev_device_attrs[] = { 230static struct device_attribute serdev_device_attrs[] = {
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index c9480d77810c..930e8f35f8df 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -107,7 +107,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
107 int len; 107 int len;
108 struct ulpi *ulpi = to_ulpi_dev(dev); 108 struct ulpi *ulpi = to_ulpi_dev(dev);
109 109
110 len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1); 110 len = of_device_modalias(dev, buf, PAGE_SIZE);
111 if (len != -ENODEV) 111 if (len != -ENODEV)
112 return len; 112 return len;
113 113
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index c12dace043f3..169ea0bd8eb4 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -34,8 +34,7 @@ extern void of_device_unregister(struct platform_device *ofdev);
34 34
35extern const void *of_device_get_match_data(const struct device *dev); 35extern const void *of_device_get_match_data(const struct device *dev);
36 36
37extern ssize_t of_device_get_modalias(struct device *dev, 37extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
38 char *str, ssize_t len);
39extern int of_device_request_module(struct device *dev); 38extern int of_device_request_module(struct device *dev);
40 39
41extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env); 40extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
@@ -72,8 +71,8 @@ static inline const void *of_device_get_match_data(const struct device *dev)
72 return NULL; 71 return NULL;
73} 72}
74 73
75static inline int of_device_get_modalias(struct device *dev, 74static inline int of_device_modalias(struct device *dev,
76 char *str, ssize_t len) 75 char *str, ssize_t len)
77{ 76{
78 return -ENODEV; 77 return -ENODEV;
79} 78}
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 1e0deb8e8494..ec6b11deb773 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -8,7 +8,7 @@
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/of.h> 9#include <linux/of.h>
10 10
11typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *); 11typedef int const (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
12 12
13/* 13/*
14 * Workarounds only applied to 32bit powermac machines 14 * Workarounds only applied to 32bit powermac machines
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 7234e61e7ce3..c9f975ab9840 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -280,9 +280,21 @@ DTC ?= $(objtree)/scripts/dtc/dtc
280 280
281# Disable noisy checks by default 281# Disable noisy checks by default
282ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) 282ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
283DTC_FLAGS += -Wno-unit_address_vs_reg 283DTC_FLAGS += -Wno-unit_address_vs_reg \
284 -Wno-simple_bus_reg \
285 -Wno-unit_address_format \
286 -Wno-pci_bridge \
287 -Wno-pci_device_bus_num \
288 -Wno-pci_device_reg
284endif 289endif
285 290
291ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),2)
292DTC_FLAGS += -Wnode_name_chars_strict \
293 -Wproperty_name_chars_strict
294endif
295
296DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
297
286# Generate an assembly file to wrap the output of the device tree compiler 298# Generate an assembly file to wrap the output of the device tree compiler
287quiet_cmd_dt_S_dtb= DTB $@ 299quiet_cmd_dt_S_dtb= DTB $@
288cmd_dt_S_dtb= \ 300cmd_dt_S_dtb= \
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 3d18e45374c8..5adfc8f52b4f 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -72,17 +72,16 @@ struct check {
72#define CHECK(_nm, _fn, _d, ...) \ 72#define CHECK(_nm, _fn, _d, ...) \
73 CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) 73 CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
74 74
75#ifdef __GNUC__ 75static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,
76static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); 76 const char *fmt, ...)
77#endif
78static inline void check_msg(struct check *c, const char *fmt, ...)
79{ 77{
80 va_list ap; 78 va_list ap;
81 va_start(ap, fmt); 79 va_start(ap, fmt);
82 80
83 if ((c->warn && (quiet < 1)) 81 if ((c->warn && (quiet < 1))
84 || (c->error && (quiet < 2))) { 82 || (c->error && (quiet < 2))) {
85 fprintf(stderr, "%s (%s): ", 83 fprintf(stderr, "%s: %s (%s): ",
84 strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
86 (c->error) ? "ERROR" : "Warning", c->name); 85 (c->error) ? "ERROR" : "Warning", c->name);
87 vfprintf(stderr, fmt, ap); 86 vfprintf(stderr, fmt, ap);
88 fprintf(stderr, "\n"); 87 fprintf(stderr, "\n");
@@ -90,11 +89,11 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
90 va_end(ap); 89 va_end(ap);
91} 90}
92 91
93#define FAIL(c, ...) \ 92#define FAIL(c, dti, ...) \
94 do { \ 93 do { \
95 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ 94 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
96 (c)->status = FAILED; \ 95 (c)->status = FAILED; \
97 check_msg((c), __VA_ARGS__); \ 96 check_msg((c), dti, __VA_ARGS__); \
98 } while (0) 97 } while (0)
99 98
100static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) 99static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
@@ -127,7 +126,7 @@ static bool run_check(struct check *c, struct dt_info *dti)
127 error = error || run_check(prq, dti); 126 error = error || run_check(prq, dti);
128 if (prq->status != PASSED) { 127 if (prq->status != PASSED) {
129 c->status = PREREQ; 128 c->status = PREREQ;
130 check_msg(c, "Failed prerequisite '%s'", 129 check_msg(c, dti, "Failed prerequisite '%s'",
131 c->prereq[i]->name); 130 c->prereq[i]->name);
132 } 131 }
133 } 132 }
@@ -157,7 +156,7 @@ out:
157static inline void check_always_fail(struct check *c, struct dt_info *dti, 156static inline void check_always_fail(struct check *c, struct dt_info *dti,
158 struct node *node) 157 struct node *node)
159{ 158{
160 FAIL(c, "always_fail check"); 159 FAIL(c, dti, "always_fail check");
161} 160}
162CHECK(always_fail, check_always_fail, NULL); 161CHECK(always_fail, check_always_fail, NULL);
163 162
@@ -172,7 +171,7 @@ static void check_is_string(struct check *c, struct dt_info *dti,
172 return; /* Not present, assumed ok */ 171 return; /* Not present, assumed ok */
173 172
174 if (!data_is_one_string(prop->val)) 173 if (!data_is_one_string(prop->val))
175 FAIL(c, "\"%s\" property in %s is not a string", 174 FAIL(c, dti, "\"%s\" property in %s is not a string",
176 propname, node->fullpath); 175 propname, node->fullpath);
177} 176}
178#define WARNING_IF_NOT_STRING(nm, propname) \ 177#define WARNING_IF_NOT_STRING(nm, propname) \
@@ -191,7 +190,7 @@ static void check_is_cell(struct check *c, struct dt_info *dti,
191 return; /* Not present, assumed ok */ 190 return; /* Not present, assumed ok */
192 191
193 if (prop->val.len != sizeof(cell_t)) 192 if (prop->val.len != sizeof(cell_t))
194 FAIL(c, "\"%s\" property in %s is not a single cell", 193 FAIL(c, dti, "\"%s\" property in %s is not a single cell",
195 propname, node->fullpath); 194 propname, node->fullpath);
196} 195}
197#define WARNING_IF_NOT_CELL(nm, propname) \ 196#define WARNING_IF_NOT_CELL(nm, propname) \
@@ -213,7 +212,7 @@ static void check_duplicate_node_names(struct check *c, struct dt_info *dti,
213 child2; 212 child2;
214 child2 = child2->next_sibling) 213 child2 = child2->next_sibling)
215 if (streq(child->name, child2->name)) 214 if (streq(child->name, child2->name))
216 FAIL(c, "Duplicate node name %s", 215 FAIL(c, dti, "Duplicate node name %s",
217 child->fullpath); 216 child->fullpath);
218} 217}
219ERROR(duplicate_node_names, check_duplicate_node_names, NULL); 218ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
@@ -228,7 +227,7 @@ static void check_duplicate_property_names(struct check *c, struct dt_info *dti,
228 if (prop2->deleted) 227 if (prop2->deleted)
229 continue; 228 continue;
230 if (streq(prop->name, prop2->name)) 229 if (streq(prop->name, prop2->name))
231 FAIL(c, "Duplicate property name %s in %s", 230 FAIL(c, dti, "Duplicate property name %s in %s",
232 prop->name, node->fullpath); 231 prop->name, node->fullpath);
233 } 232 }
234 } 233 }
@@ -239,6 +238,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
239#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 238#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
240#define DIGITS "0123456789" 239#define DIGITS "0123456789"
241#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" 240#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
241#define PROPNODECHARSSTRICT LOWERCASE UPPERCASE DIGITS ",-"
242 242
243static void check_node_name_chars(struct check *c, struct dt_info *dti, 243static void check_node_name_chars(struct check *c, struct dt_info *dti,
244 struct node *node) 244 struct node *node)
@@ -246,16 +246,27 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti,
246 int n = strspn(node->name, c->data); 246 int n = strspn(node->name, c->data);
247 247
248 if (n < strlen(node->name)) 248 if (n < strlen(node->name))
249 FAIL(c, "Bad character '%c' in node %s", 249 FAIL(c, dti, "Bad character '%c' in node %s",
250 node->name[n], node->fullpath); 250 node->name[n], node->fullpath);
251} 251}
252ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); 252ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
253 253
254static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
255 struct node *node)
256{
257 int n = strspn(node->name, c->data);
258
259 if (n < node->basenamelen)
260 FAIL(c, dti, "Character '%c' not recommended in node %s",
261 node->name[n], node->fullpath);
262}
263CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT);
264
254static void check_node_name_format(struct check *c, struct dt_info *dti, 265static void check_node_name_format(struct check *c, struct dt_info *dti,
255 struct node *node) 266 struct node *node)
256{ 267{
257 if (strchr(get_unitname(node), '@')) 268 if (strchr(get_unitname(node), '@'))
258 FAIL(c, "Node %s has multiple '@' characters in name", 269 FAIL(c, dti, "Node %s has multiple '@' characters in name",
259 node->fullpath); 270 node->fullpath);
260} 271}
261ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); 272ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
@@ -274,11 +285,11 @@ static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti,
274 285
275 if (prop) { 286 if (prop) {
276 if (!unitname[0]) 287 if (!unitname[0])
277 FAIL(c, "Node %s has a reg or ranges property, but no unit name", 288 FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name",
278 node->fullpath); 289 node->fullpath);
279 } else { 290 } else {
280 if (unitname[0]) 291 if (unitname[0])
281 FAIL(c, "Node %s has a unit name, but no reg property", 292 FAIL(c, dti, "Node %s has a unit name, but no reg property",
282 node->fullpath); 293 node->fullpath);
283 } 294 }
284} 295}
@@ -293,12 +304,44 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti,
293 int n = strspn(prop->name, c->data); 304 int n = strspn(prop->name, c->data);
294 305
295 if (n < strlen(prop->name)) 306 if (n < strlen(prop->name))
296 FAIL(c, "Bad character '%c' in property name \"%s\", node %s", 307 FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s",
297 prop->name[n], prop->name, node->fullpath); 308 prop->name[n], prop->name, node->fullpath);
298 } 309 }
299} 310}
300ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); 311ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
301 312
313static void check_property_name_chars_strict(struct check *c,
314 struct dt_info *dti,
315 struct node *node)
316{
317 struct property *prop;
318
319 for_each_property(node, prop) {
320 const char *name = prop->name;
321 int n = strspn(name, c->data);
322
323 if (n == strlen(prop->name))
324 continue;
325
326 /* Certain names are whitelisted */
327 if (streq(name, "device_type"))
328 continue;
329
330 /*
331 * # is only allowed at the beginning of property names not counting
332 * the vendor prefix.
333 */
334 if (name[n] == '#' && ((n == 0) || (name[n-1] == ','))) {
335 name += n + 1;
336 n = strspn(name, c->data);
337 }
338 if (n < strlen(name))
339 FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s",
340 name[n], prop->name, node->fullpath);
341 }
342}
343CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT);
344
302#define DESCLABEL_FMT "%s%s%s%s%s" 345#define DESCLABEL_FMT "%s%s%s%s%s"
303#define DESCLABEL_ARGS(node,prop,mark) \ 346#define DESCLABEL_ARGS(node,prop,mark) \
304 ((mark) ? "value of " : ""), \ 347 ((mark) ? "value of " : ""), \
@@ -327,7 +370,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
327 return; 370 return;
328 371
329 if ((othernode != node) || (otherprop != prop) || (othermark != mark)) 372 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
330 FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT 373 FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT
331 " and " DESCLABEL_FMT, 374 " and " DESCLABEL_FMT,
332 label, DESCLABEL_ARGS(node, prop, mark), 375 label, DESCLABEL_ARGS(node, prop, mark),
333 DESCLABEL_ARGS(othernode, otherprop, othermark)); 376 DESCLABEL_ARGS(othernode, otherprop, othermark));
@@ -367,7 +410,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti,
367 return 0; 410 return 0;
368 411
369 if (prop->val.len != sizeof(cell_t)) { 412 if (prop->val.len != sizeof(cell_t)) {
370 FAIL(c, "%s has bad length (%d) %s property", 413 FAIL(c, dti, "%s has bad length (%d) %s property",
371 node->fullpath, prop->val.len, prop->name); 414 node->fullpath, prop->val.len, prop->name);
372 return 0; 415 return 0;
373 } 416 }
@@ -379,7 +422,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti,
379 /* "Set this node's phandle equal to some 422 /* "Set this node's phandle equal to some
380 * other node's phandle". That's nonsensical 423 * other node's phandle". That's nonsensical
381 * by construction. */ { 424 * by construction. */ {
382 FAIL(c, "%s in %s is a reference to another node", 425 FAIL(c, dti, "%s in %s is a reference to another node",
383 prop->name, node->fullpath); 426 prop->name, node->fullpath);
384 } 427 }
385 /* But setting this node's phandle equal to its own 428 /* But setting this node's phandle equal to its own
@@ -393,7 +436,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti,
393 phandle = propval_cell(prop); 436 phandle = propval_cell(prop);
394 437
395 if ((phandle == 0) || (phandle == -1)) { 438 if ((phandle == 0) || (phandle == -1)) {
396 FAIL(c, "%s has bad value (0x%x) in %s property", 439 FAIL(c, dti, "%s has bad value (0x%x) in %s property",
397 node->fullpath, phandle, prop->name); 440 node->fullpath, phandle, prop->name);
398 return 0; 441 return 0;
399 } 442 }
@@ -420,7 +463,7 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti,
420 return; 463 return;
421 464
422 if (linux_phandle && phandle && (phandle != linux_phandle)) 465 if (linux_phandle && phandle && (phandle != linux_phandle))
423 FAIL(c, "%s has mismatching 'phandle' and 'linux,phandle'" 466 FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'"
424 " properties", node->fullpath); 467 " properties", node->fullpath);
425 468
426 if (linux_phandle && !phandle) 469 if (linux_phandle && !phandle)
@@ -428,7 +471,7 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti,
428 471
429 other = get_node_by_phandle(root, phandle); 472 other = get_node_by_phandle(root, phandle);
430 if (other && (other != node)) { 473 if (other && (other != node)) {
431 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", 474 FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)",
432 node->fullpath, phandle, other->fullpath); 475 node->fullpath, phandle, other->fullpath);
433 return; 476 return;
434 } 477 }
@@ -453,7 +496,7 @@ static void check_name_properties(struct check *c, struct dt_info *dti,
453 496
454 if ((prop->val.len != node->basenamelen+1) 497 if ((prop->val.len != node->basenamelen+1)
455 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { 498 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
456 FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead" 499 FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead"
457 " of base node name)", node->fullpath, prop->val.val); 500 " of base node name)", node->fullpath, prop->val.val);
458 } else { 501 } else {
459 /* The name property is correct, and therefore redundant. 502 /* The name property is correct, and therefore redundant.
@@ -488,16 +531,16 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
488 refnode = get_node_by_ref(dt, m->ref); 531 refnode = get_node_by_ref(dt, m->ref);
489 if (! refnode) { 532 if (! refnode) {
490 if (!(dti->dtsflags & DTSF_PLUGIN)) 533 if (!(dti->dtsflags & DTSF_PLUGIN))
491 FAIL(c, "Reference to non-existent node or " 534 FAIL(c, dti, "Reference to non-existent node or "
492 "label \"%s\"\n", m->ref); 535 "label \"%s\"\n", m->ref);
493 else /* mark the entry as unresolved */ 536 else /* mark the entry as unresolved */
494 *((cell_t *)(prop->val.val + m->offset)) = 537 *((fdt32_t *)(prop->val.val + m->offset)) =
495 cpu_to_fdt32(0xffffffff); 538 cpu_to_fdt32(0xffffffff);
496 continue; 539 continue;
497 } 540 }
498 541
499 phandle = get_node_phandle(dt, refnode); 542 phandle = get_node_phandle(dt, refnode);
500 *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); 543 *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
501 } 544 }
502 } 545 }
503} 546}
@@ -520,7 +563,7 @@ static void fixup_path_references(struct check *c, struct dt_info *dti,
520 563
521 refnode = get_node_by_ref(dt, m->ref); 564 refnode = get_node_by_ref(dt, m->ref);
522 if (!refnode) { 565 if (!refnode) {
523 FAIL(c, "Reference to non-existent node or label \"%s\"\n", 566 FAIL(c, dti, "Reference to non-existent node or label \"%s\"\n",
524 m->ref); 567 m->ref);
525 continue; 568 continue;
526 } 569 }
@@ -579,19 +622,19 @@ static void check_reg_format(struct check *c, struct dt_info *dti,
579 return; /* No "reg", that's fine */ 622 return; /* No "reg", that's fine */
580 623
581 if (!node->parent) { 624 if (!node->parent) {
582 FAIL(c, "Root node has a \"reg\" property"); 625 FAIL(c, dti, "Root node has a \"reg\" property");
583 return; 626 return;
584 } 627 }
585 628
586 if (prop->val.len == 0) 629 if (prop->val.len == 0)
587 FAIL(c, "\"reg\" property in %s is empty", node->fullpath); 630 FAIL(c, dti, "\"reg\" property in %s is empty", node->fullpath);
588 631
589 addr_cells = node_addr_cells(node->parent); 632 addr_cells = node_addr_cells(node->parent);
590 size_cells = node_size_cells(node->parent); 633 size_cells = node_size_cells(node->parent);
591 entrylen = (addr_cells + size_cells) * sizeof(cell_t); 634 entrylen = (addr_cells + size_cells) * sizeof(cell_t);
592 635
593 if (!entrylen || (prop->val.len % entrylen) != 0) 636 if (!entrylen || (prop->val.len % entrylen) != 0)
594 FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) " 637 FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) "
595 "(#address-cells == %d, #size-cells == %d)", 638 "(#address-cells == %d, #size-cells == %d)",
596 node->fullpath, prop->val.len, addr_cells, size_cells); 639 node->fullpath, prop->val.len, addr_cells, size_cells);
597} 640}
@@ -608,7 +651,7 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
608 return; 651 return;
609 652
610 if (!node->parent) { 653 if (!node->parent) {
611 FAIL(c, "Root node has a \"ranges\" property"); 654 FAIL(c, dti, "Root node has a \"ranges\" property");
612 return; 655 return;
613 } 656 }
614 657
@@ -620,17 +663,17 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
620 663
621 if (prop->val.len == 0) { 664 if (prop->val.len == 0) {
622 if (p_addr_cells != c_addr_cells) 665 if (p_addr_cells != c_addr_cells)
623 FAIL(c, "%s has empty \"ranges\" property but its " 666 FAIL(c, dti, "%s has empty \"ranges\" property but its "
624 "#address-cells (%d) differs from %s (%d)", 667 "#address-cells (%d) differs from %s (%d)",
625 node->fullpath, c_addr_cells, node->parent->fullpath, 668 node->fullpath, c_addr_cells, node->parent->fullpath,
626 p_addr_cells); 669 p_addr_cells);
627 if (p_size_cells != c_size_cells) 670 if (p_size_cells != c_size_cells)
628 FAIL(c, "%s has empty \"ranges\" property but its " 671 FAIL(c, dti, "%s has empty \"ranges\" property but its "
629 "#size-cells (%d) differs from %s (%d)", 672 "#size-cells (%d) differs from %s (%d)",
630 node->fullpath, c_size_cells, node->parent->fullpath, 673 node->fullpath, c_size_cells, node->parent->fullpath,
631 p_size_cells); 674 p_size_cells);
632 } else if ((prop->val.len % entrylen) != 0) { 675 } else if ((prop->val.len % entrylen) != 0) {
633 FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) " 676 FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) "
634 "(parent #address-cells == %d, child #address-cells == %d, " 677 "(parent #address-cells == %d, child #address-cells == %d, "
635 "#size-cells == %d)", node->fullpath, prop->val.len, 678 "#size-cells == %d)", node->fullpath, prop->val.len,
636 p_addr_cells, c_addr_cells, c_size_cells); 679 p_addr_cells, c_addr_cells, c_size_cells);
@@ -638,6 +681,229 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
638} 681}
639WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); 682WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
640 683
684static const struct bus_type pci_bus = {
685 .name = "PCI",
686};
687
688static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node)
689{
690 struct property *prop;
691 cell_t *cells;
692
693 prop = get_property(node, "device_type");
694 if (!prop || !streq(prop->val.val, "pci"))
695 return;
696
697 node->bus = &pci_bus;
698
699 if (!strneq(node->name, "pci", node->basenamelen) &&
700 !strneq(node->name, "pcie", node->basenamelen))
701 FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"",
702 node->fullpath);
703
704 prop = get_property(node, "ranges");
705 if (!prop)
706 FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)",
707 node->fullpath);
708
709 if (node_addr_cells(node) != 3)
710 FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge",
711 node->fullpath);
712 if (node_size_cells(node) != 2)
713 FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge",
714 node->fullpath);
715
716 prop = get_property(node, "bus-range");
717 if (!prop) {
718 FAIL(c, dti, "Node %s missing bus-range for PCI bridge",
719 node->fullpath);
720 return;
721 }
722 if (prop->val.len != (sizeof(cell_t) * 2)) {
723 FAIL(c, dti, "Node %s bus-range must be 2 cells",
724 node->fullpath);
725 return;
726 }
727 cells = (cell_t *)prop->val.val;
728 if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1]))
729 FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell",
730 node->fullpath);
731 if (fdt32_to_cpu(cells[1]) > 0xff)
732 FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256",
733 node->fullpath);
734}
735WARNING(pci_bridge, check_pci_bridge, NULL,
736 &device_type_is_string, &addr_size_cells);
737
738static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node)
739{
740 struct property *prop;
741 unsigned int bus_num, min_bus, max_bus;
742 cell_t *cells;
743
744 if (!node->parent || (node->parent->bus != &pci_bus))
745 return;
746
747 prop = get_property(node, "reg");
748 if (!prop)
749 return;
750
751 cells = (cell_t *)prop->val.val;
752 bus_num = (fdt32_to_cpu(cells[0]) & 0x00ff0000) >> 16;
753
754 prop = get_property(node->parent, "bus-range");
755 if (!prop) {
756 min_bus = max_bus = 0;
757 } else {
758 cells = (cell_t *)prop->val.val;
759 min_bus = fdt32_to_cpu(cells[0]);
760 max_bus = fdt32_to_cpu(cells[0]);
761 }
762 if ((bus_num < min_bus) || (bus_num > max_bus))
763 FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)",
764 node->fullpath, bus_num, min_bus, max_bus);
765}
766WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, &reg_format, &pci_bridge);
767
768static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node)
769{
770 struct property *prop;
771 const char *unitname = get_unitname(node);
772 char unit_addr[5];
773 unsigned int dev, func, reg;
774 cell_t *cells;
775
776 if (!node->parent || (node->parent->bus != &pci_bus))
777 return;
778
779 prop = get_property(node, "reg");
780 if (!prop) {
781 FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath);
782 return;
783 }
784
785 cells = (cell_t *)prop->val.val;
786 if (cells[1] || cells[2])
787 FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0",
788 node->fullpath);
789
790 reg = fdt32_to_cpu(cells[0]);
791 dev = (reg & 0xf800) >> 11;
792 func = (reg & 0x700) >> 8;
793
794 if (reg & 0xff000000)
795 FAIL(c, dti, "Node %s PCI reg address is not configuration space",
796 node->fullpath);
797 if (reg & 0x000000ff)
798 FAIL(c, dti, "Node %s PCI reg config space address register number must be 0",
799 node->fullpath);
800
801 if (func == 0) {
802 snprintf(unit_addr, sizeof(unit_addr), "%x", dev);
803 if (streq(unitname, unit_addr))
804 return;
805 }
806
807 snprintf(unit_addr, sizeof(unit_addr), "%x,%x", dev, func);
808 if (streq(unitname, unit_addr))
809 return;
810
811 FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"",
812 node->fullpath, unit_addr);
813}
814WARNING(pci_device_reg, check_pci_device_reg, NULL, &reg_format, &pci_bridge);
815
816static const struct bus_type simple_bus = {
817 .name = "simple-bus",
818};
819
820static bool node_is_compatible(struct node *node, const char *compat)
821{
822 struct property *prop;
823 const char *str, *end;
824
825 prop = get_property(node, "compatible");
826 if (!prop)
827 return false;
828
829 for (str = prop->val.val, end = str + prop->val.len; str < end;
830 str += strnlen(str, end - str) + 1) {
831 if (strneq(str, compat, end - str))
832 return true;
833 }
834 return false;
835}
836
837static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
838{
839 if (node_is_compatible(node, "simple-bus"))
840 node->bus = &simple_bus;
841}
842WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL, &addr_size_cells);
843
844static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
845{
846 struct property *prop;
847 const char *unitname = get_unitname(node);
848 char unit_addr[17];
849 unsigned int size;
850 uint64_t reg = 0;
851 cell_t *cells = NULL;
852
853 if (!node->parent || (node->parent->bus != &simple_bus))
854 return;
855
856 prop = get_property(node, "reg");
857 if (prop)
858 cells = (cell_t *)prop->val.val;
859 else {
860 prop = get_property(node, "ranges");
861 if (prop && prop->val.len)
862 /* skip of child address */
863 cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
864 }
865
866 if (!cells) {
867 if (node->parent->parent && !(node->bus == &simple_bus))
868 FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath);
869 return;
870 }
871
872 size = node_addr_cells(node->parent);
873 while (size--)
874 reg = (reg << 32) | fdt32_to_cpu(*(cells++));
875
876 snprintf(unit_addr, sizeof(unit_addr), "%lx", reg);
877 if (!streq(unitname, unit_addr))
878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
879 node->fullpath, unit_addr);
880}
881WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge);
882
883static void check_unit_address_format(struct check *c, struct dt_info *dti,
884 struct node *node)
885{
886 const char *unitname = get_unitname(node);
887
888 if (node->parent && node->parent->bus)
889 return;
890
891 if (!unitname[0])
892 return;
893
894 if (!strncmp(unitname, "0x", 2)) {
895 FAIL(c, dti, "Node %s unit name should not have leading \"0x\"",
896 node->fullpath);
897 /* skip over 0x for next test */
898 unitname += 2;
899 }
900 if (unitname[0] == '0' && isxdigit(unitname[1]))
901 FAIL(c, dti, "Node %s unit name should not have leading 0s",
902 node->fullpath);
903}
904WARNING(unit_address_format, check_unit_address_format, NULL,
905 &node_name_format, &pci_bridge, &simple_bus_bridge);
906
641/* 907/*
642 * Style checks 908 * Style checks
643 */ 909 */
@@ -656,11 +922,11 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
656 return; 922 return;
657 923
658 if (node->parent->addr_cells == -1) 924 if (node->parent->addr_cells == -1)
659 FAIL(c, "Relying on default #address-cells value for %s", 925 FAIL(c, dti, "Relying on default #address-cells value for %s",
660 node->fullpath); 926 node->fullpath);
661 927
662 if (node->parent->size_cells == -1) 928 if (node->parent->size_cells == -1)
663 FAIL(c, "Relying on default #size-cells value for %s", 929 FAIL(c, dti, "Relying on default #size-cells value for %s",
664 node->fullpath); 930 node->fullpath);
665} 931}
666WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, 932WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
@@ -684,7 +950,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
684 950
685 prop = get_property(chosen, "interrupt-controller"); 951 prop = get_property(chosen, "interrupt-controller");
686 if (prop) 952 if (prop)
687 FAIL(c, "/chosen has obsolete \"interrupt-controller\" " 953 FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" "
688 "property"); 954 "property");
689} 955}
690WARNING(obsolete_chosen_interrupt_controller, 956WARNING(obsolete_chosen_interrupt_controller,
@@ -703,9 +969,20 @@ static struct check *check_table[] = {
703 &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, 969 &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
704 &device_type_is_string, &model_is_string, &status_is_string, 970 &device_type_is_string, &model_is_string, &status_is_string,
705 971
972 &property_name_chars_strict,
973 &node_name_chars_strict,
974
706 &addr_size_cells, &reg_format, &ranges_format, 975 &addr_size_cells, &reg_format, &ranges_format,
707 976
708 &unit_address_vs_reg, 977 &unit_address_vs_reg,
978 &unit_address_format,
979
980 &pci_bridge,
981 &pci_device_reg,
982 &pci_device_bus_num,
983
984 &simple_bus_bridge,
985 &simple_bus_reg,
709 986
710 &avoid_default_addr_size, 987 &avoid_default_addr_size,
711 &obsolete_chosen_interrupt_controller, 988 &obsolete_chosen_interrupt_controller,
diff --git a/scripts/dtc/data.c b/scripts/dtc/data.c
index 8cae23746882..aa37a16c8891 100644
--- a/scripts/dtc/data.c
+++ b/scripts/dtc/data.c
@@ -171,9 +171,9 @@ struct data data_merge(struct data d1, struct data d2)
171struct data data_append_integer(struct data d, uint64_t value, int bits) 171struct data data_append_integer(struct data d, uint64_t value, int bits)
172{ 172{
173 uint8_t value_8; 173 uint8_t value_8;
174 uint16_t value_16; 174 fdt16_t value_16;
175 uint32_t value_32; 175 fdt32_t value_32;
176 uint64_t value_64; 176 fdt64_t value_64;
177 177
178 switch (bits) { 178 switch (bits) {
179 case 8: 179 case 8:
@@ -197,14 +197,14 @@ struct data data_append_integer(struct data d, uint64_t value, int bits)
197 } 197 }
198} 198}
199 199
200struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) 200struct data data_append_re(struct data d, uint64_t address, uint64_t size)
201{ 201{
202 struct fdt_reserve_entry bere; 202 struct fdt_reserve_entry re;
203 203
204 bere.address = cpu_to_fdt64(re->address); 204 re.address = cpu_to_fdt64(address);
205 bere.size = cpu_to_fdt64(re->size); 205 re.size = cpu_to_fdt64(size);
206 206
207 return data_append_data(d, &bere, sizeof(bere)); 207 return data_append_data(d, &re, sizeof(re));
208} 208}
209 209
210struct data data_append_cell(struct data d, cell_t word) 210struct data data_append_cell(struct data d, cell_t word)
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index c600603044f3..fd825ebba69c 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -62,7 +62,8 @@ static int dts_version = 1;
62 62
63static void push_input_file(const char *filename); 63static void push_input_file(const char *filename);
64static bool pop_input_file(void); 64static bool pop_input_file(void);
65static void lexical_error(const char *fmt, ...); 65static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
66
66%} 67%}
67 68
68%% 69%%
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index 2c862bc86ad0..64c243772398 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -655,8 +655,9 @@ static int dts_version = 1;
655 655
656static void push_input_file(const char *filename); 656static void push_input_file(const char *filename);
657static bool pop_input_file(void); 657static bool pop_input_file(void);
658static void lexical_error(const char *fmt, ...); 658static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
659#line 660 "dtc-lexer.lex.c" 659
660#line 661 "dtc-lexer.lex.c"
660 661
661#define INITIAL 0 662#define INITIAL 0
662#define BYTESTRING 1 663#define BYTESTRING 1
@@ -878,9 +879,9 @@ YY_DECL
878 } 879 }
879 880
880 { 881 {
881#line 68 "dtc-lexer.l" 882#line 69 "dtc-lexer.l"
882 883
883#line 884 "dtc-lexer.lex.c" 884#line 885 "dtc-lexer.lex.c"
884 885
885 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ 886 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
886 { 887 {
@@ -937,7 +938,7 @@ do_action: /* This label is used only to access EOF actions. */
937case 1: 938case 1:
938/* rule 1 can match eol */ 939/* rule 1 can match eol */
939YY_RULE_SETUP 940YY_RULE_SETUP
940#line 69 "dtc-lexer.l" 941#line 70 "dtc-lexer.l"
941{ 942{
942 char *name = strchr(yytext, '\"') + 1; 943 char *name = strchr(yytext, '\"') + 1;
943 yytext[yyleng-1] = '\0'; 944 yytext[yyleng-1] = '\0';
@@ -947,7 +948,7 @@ YY_RULE_SETUP
947case 2: 948case 2:
948/* rule 2 can match eol */ 949/* rule 2 can match eol */
949YY_RULE_SETUP 950YY_RULE_SETUP
950#line 75 "dtc-lexer.l" 951#line 76 "dtc-lexer.l"
951{ 952{
952 char *line, *fnstart, *fnend; 953 char *line, *fnstart, *fnend;
953 struct data fn; 954 struct data fn;
@@ -981,7 +982,7 @@ case YY_STATE_EOF(INITIAL):
981case YY_STATE_EOF(BYTESTRING): 982case YY_STATE_EOF(BYTESTRING):
982case YY_STATE_EOF(PROPNODENAME): 983case YY_STATE_EOF(PROPNODENAME):
983case YY_STATE_EOF(V1): 984case YY_STATE_EOF(V1):
984#line 104 "dtc-lexer.l" 985#line 105 "dtc-lexer.l"
985{ 986{
986 if (!pop_input_file()) { 987 if (!pop_input_file()) {
987 yyterminate(); 988 yyterminate();
@@ -991,7 +992,7 @@ case YY_STATE_EOF(V1):
991case 3: 992case 3:
992/* rule 3 can match eol */ 993/* rule 3 can match eol */
993YY_RULE_SETUP 994YY_RULE_SETUP
994#line 110 "dtc-lexer.l" 995#line 111 "dtc-lexer.l"
995{ 996{
996 DPRINT("String: %s\n", yytext); 997 DPRINT("String: %s\n", yytext);
997 yylval.data = data_copy_escape_string(yytext+1, 998 yylval.data = data_copy_escape_string(yytext+1,
@@ -1001,7 +1002,7 @@ YY_RULE_SETUP
1001 YY_BREAK 1002 YY_BREAK
1002case 4: 1003case 4:
1003YY_RULE_SETUP 1004YY_RULE_SETUP
1004#line 117 "dtc-lexer.l" 1005#line 118 "dtc-lexer.l"
1005{ 1006{
1006 DPRINT("Keyword: /dts-v1/\n"); 1007 DPRINT("Keyword: /dts-v1/\n");
1007 dts_version = 1; 1008 dts_version = 1;
@@ -1011,7 +1012,7 @@ YY_RULE_SETUP
1011 YY_BREAK 1012 YY_BREAK
1012case 5: 1013case 5:
1013YY_RULE_SETUP 1014YY_RULE_SETUP
1014#line 124 "dtc-lexer.l" 1015#line 125 "dtc-lexer.l"
1015{ 1016{
1016 DPRINT("Keyword: /plugin/\n"); 1017 DPRINT("Keyword: /plugin/\n");
1017 return DT_PLUGIN; 1018 return DT_PLUGIN;
@@ -1019,7 +1020,7 @@ YY_RULE_SETUP
1019 YY_BREAK 1020 YY_BREAK
1020case 6: 1021case 6:
1021YY_RULE_SETUP 1022YY_RULE_SETUP
1022#line 129 "dtc-lexer.l" 1023#line 130 "dtc-lexer.l"
1023{ 1024{
1024 DPRINT("Keyword: /memreserve/\n"); 1025 DPRINT("Keyword: /memreserve/\n");
1025 BEGIN_DEFAULT(); 1026 BEGIN_DEFAULT();
@@ -1028,7 +1029,7 @@ YY_RULE_SETUP
1028 YY_BREAK 1029 YY_BREAK
1029case 7: 1030case 7:
1030YY_RULE_SETUP 1031YY_RULE_SETUP
1031#line 135 "dtc-lexer.l" 1032#line 136 "dtc-lexer.l"
1032{ 1033{
1033 DPRINT("Keyword: /bits/\n"); 1034 DPRINT("Keyword: /bits/\n");
1034 BEGIN_DEFAULT(); 1035 BEGIN_DEFAULT();
@@ -1037,7 +1038,7 @@ YY_RULE_SETUP
1037 YY_BREAK 1038 YY_BREAK
1038case 8: 1039case 8:
1039YY_RULE_SETUP 1040YY_RULE_SETUP
1040#line 141 "dtc-lexer.l" 1041#line 142 "dtc-lexer.l"
1041{ 1042{
1042 DPRINT("Keyword: /delete-property/\n"); 1043 DPRINT("Keyword: /delete-property/\n");
1043 DPRINT("<PROPNODENAME>\n"); 1044 DPRINT("<PROPNODENAME>\n");
@@ -1047,7 +1048,7 @@ YY_RULE_SETUP
1047 YY_BREAK 1048 YY_BREAK
1048case 9: 1049case 9:
1049YY_RULE_SETUP 1050YY_RULE_SETUP
1050#line 148 "dtc-lexer.l" 1051#line 149 "dtc-lexer.l"
1051{ 1052{
1052 DPRINT("Keyword: /delete-node/\n"); 1053 DPRINT("Keyword: /delete-node/\n");
1053 DPRINT("<PROPNODENAME>\n"); 1054 DPRINT("<PROPNODENAME>\n");
@@ -1057,7 +1058,7 @@ YY_RULE_SETUP
1057 YY_BREAK 1058 YY_BREAK
1058case 10: 1059case 10:
1059YY_RULE_SETUP 1060YY_RULE_SETUP
1060#line 155 "dtc-lexer.l" 1061#line 156 "dtc-lexer.l"
1061{ 1062{
1062 DPRINT("Label: %s\n", yytext); 1063 DPRINT("Label: %s\n", yytext);
1063 yylval.labelref = xstrdup(yytext); 1064 yylval.labelref = xstrdup(yytext);
@@ -1067,7 +1068,7 @@ YY_RULE_SETUP
1067 YY_BREAK 1068 YY_BREAK
1068case 11: 1069case 11:
1069YY_RULE_SETUP 1070YY_RULE_SETUP
1070#line 162 "dtc-lexer.l" 1071#line 163 "dtc-lexer.l"
1071{ 1072{
1072 char *e; 1073 char *e;
1073 DPRINT("Integer Literal: '%s'\n", yytext); 1074 DPRINT("Integer Literal: '%s'\n", yytext);
@@ -1093,7 +1094,7 @@ YY_RULE_SETUP
1093case 12: 1094case 12:
1094/* rule 12 can match eol */ 1095/* rule 12 can match eol */
1095YY_RULE_SETUP 1096YY_RULE_SETUP
1096#line 184 "dtc-lexer.l" 1097#line 185 "dtc-lexer.l"
1097{ 1098{
1098 struct data d; 1099 struct data d;
1099 DPRINT("Character literal: %s\n", yytext); 1100 DPRINT("Character literal: %s\n", yytext);
@@ -1117,7 +1118,7 @@ YY_RULE_SETUP
1117 YY_BREAK 1118 YY_BREAK
1118case 13: 1119case 13:
1119YY_RULE_SETUP 1120YY_RULE_SETUP
1120#line 205 "dtc-lexer.l" 1121#line 206 "dtc-lexer.l"
1121{ /* label reference */ 1122{ /* label reference */
1122 DPRINT("Ref: %s\n", yytext+1); 1123 DPRINT("Ref: %s\n", yytext+1);
1123 yylval.labelref = xstrdup(yytext+1); 1124 yylval.labelref = xstrdup(yytext+1);
@@ -1126,7 +1127,7 @@ YY_RULE_SETUP
1126 YY_BREAK 1127 YY_BREAK
1127case 14: 1128case 14:
1128YY_RULE_SETUP 1129YY_RULE_SETUP
1129#line 211 "dtc-lexer.l" 1130#line 212 "dtc-lexer.l"
1130{ /* new-style path reference */ 1131{ /* new-style path reference */
1131 yytext[yyleng-1] = '\0'; 1132 yytext[yyleng-1] = '\0';
1132 DPRINT("Ref: %s\n", yytext+2); 1133 DPRINT("Ref: %s\n", yytext+2);
@@ -1136,7 +1137,7 @@ YY_RULE_SETUP
1136 YY_BREAK 1137 YY_BREAK
1137case 15: 1138case 15:
1138YY_RULE_SETUP 1139YY_RULE_SETUP
1139#line 218 "dtc-lexer.l" 1140#line 219 "dtc-lexer.l"
1140{ 1141{
1141 yylval.byte = strtol(yytext, NULL, 16); 1142 yylval.byte = strtol(yytext, NULL, 16);
1142 DPRINT("Byte: %02x\n", (int)yylval.byte); 1143 DPRINT("Byte: %02x\n", (int)yylval.byte);
@@ -1145,7 +1146,7 @@ YY_RULE_SETUP
1145 YY_BREAK 1146 YY_BREAK
1146case 16: 1147case 16:
1147YY_RULE_SETUP 1148YY_RULE_SETUP
1148#line 224 "dtc-lexer.l" 1149#line 225 "dtc-lexer.l"
1149{ 1150{
1150 DPRINT("/BYTESTRING\n"); 1151 DPRINT("/BYTESTRING\n");
1151 BEGIN_DEFAULT(); 1152 BEGIN_DEFAULT();
@@ -1154,7 +1155,7 @@ YY_RULE_SETUP
1154 YY_BREAK 1155 YY_BREAK
1155case 17: 1156case 17:
1156YY_RULE_SETUP 1157YY_RULE_SETUP
1157#line 230 "dtc-lexer.l" 1158#line 231 "dtc-lexer.l"
1158{ 1159{
1159 DPRINT("PropNodeName: %s\n", yytext); 1160 DPRINT("PropNodeName: %s\n", yytext);
1160 yylval.propnodename = xstrdup((yytext[0] == '\\') ? 1161 yylval.propnodename = xstrdup((yytext[0] == '\\') ?
@@ -1165,7 +1166,7 @@ YY_RULE_SETUP
1165 YY_BREAK 1166 YY_BREAK
1166case 18: 1167case 18:
1167YY_RULE_SETUP 1168YY_RULE_SETUP
1168#line 238 "dtc-lexer.l" 1169#line 239 "dtc-lexer.l"
1169{ 1170{
1170 DPRINT("Binary Include\n"); 1171 DPRINT("Binary Include\n");
1171 return DT_INCBIN; 1172 return DT_INCBIN;
@@ -1174,64 +1175,64 @@ YY_RULE_SETUP
1174case 19: 1175case 19:
1175/* rule 19 can match eol */ 1176/* rule 19 can match eol */
1176YY_RULE_SETUP 1177YY_RULE_SETUP
1177#line 243 "dtc-lexer.l" 1178#line 244 "dtc-lexer.l"
1178/* eat whitespace */ 1179/* eat whitespace */
1179 YY_BREAK 1180 YY_BREAK
1180case 20: 1181case 20:
1181/* rule 20 can match eol */ 1182/* rule 20 can match eol */
1182YY_RULE_SETUP 1183YY_RULE_SETUP
1183#line 244 "dtc-lexer.l" 1184#line 245 "dtc-lexer.l"
1184/* eat C-style comments */ 1185/* eat C-style comments */
1185 YY_BREAK 1186 YY_BREAK
1186case 21: 1187case 21:
1187/* rule 21 can match eol */ 1188/* rule 21 can match eol */
1188YY_RULE_SETUP 1189YY_RULE_SETUP
1189#line 245 "dtc-lexer.l" 1190#line 246 "dtc-lexer.l"
1190/* eat C++-style comments */ 1191/* eat C++-style comments */
1191 YY_BREAK 1192 YY_BREAK
1192case 22: 1193case 22:
1193YY_RULE_SETUP 1194YY_RULE_SETUP
1194#line 247 "dtc-lexer.l" 1195#line 248 "dtc-lexer.l"
1195{ return DT_LSHIFT; }; 1196{ return DT_LSHIFT; };
1196 YY_BREAK 1197 YY_BREAK
1197case 23: 1198case 23:
1198YY_RULE_SETUP 1199YY_RULE_SETUP
1199#line 248 "dtc-lexer.l" 1200#line 249 "dtc-lexer.l"
1200{ return DT_RSHIFT; }; 1201{ return DT_RSHIFT; };
1201 YY_BREAK 1202 YY_BREAK
1202case 24: 1203case 24:
1203YY_RULE_SETUP 1204YY_RULE_SETUP
1204#line 249 "dtc-lexer.l" 1205#line 250 "dtc-lexer.l"
1205{ return DT_LE; }; 1206{ return DT_LE; };
1206 YY_BREAK 1207 YY_BREAK
1207case 25: 1208case 25:
1208YY_RULE_SETUP 1209YY_RULE_SETUP
1209#line 250 "dtc-lexer.l" 1210#line 251 "dtc-lexer.l"
1210{ return DT_GE; }; 1211{ return DT_GE; };
1211 YY_BREAK 1212 YY_BREAK
1212case 26: 1213case 26:
1213YY_RULE_SETUP 1214YY_RULE_SETUP
1214#line 251 "dtc-lexer.l" 1215#line 252 "dtc-lexer.l"
1215{ return DT_EQ; }; 1216{ return DT_EQ; };
1216 YY_BREAK 1217 YY_BREAK
1217case 27: 1218case 27:
1218YY_RULE_SETUP 1219YY_RULE_SETUP
1219#line 252 "dtc-lexer.l" 1220#line 253 "dtc-lexer.l"
1220{ return DT_NE; }; 1221{ return DT_NE; };
1221 YY_BREAK 1222 YY_BREAK
1222case 28: 1223case 28:
1223YY_RULE_SETUP 1224YY_RULE_SETUP
1224#line 253 "dtc-lexer.l" 1225#line 254 "dtc-lexer.l"
1225{ return DT_AND; }; 1226{ return DT_AND; };
1226 YY_BREAK 1227 YY_BREAK
1227case 29: 1228case 29:
1228YY_RULE_SETUP 1229YY_RULE_SETUP
1229#line 254 "dtc-lexer.l" 1230#line 255 "dtc-lexer.l"
1230{ return DT_OR; }; 1231{ return DT_OR; };
1231 YY_BREAK 1232 YY_BREAK
1232case 30: 1233case 30:
1233YY_RULE_SETUP 1234YY_RULE_SETUP
1234#line 256 "dtc-lexer.l" 1235#line 257 "dtc-lexer.l"
1235{ 1236{
1236 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 1237 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
1237 (unsigned)yytext[0]); 1238 (unsigned)yytext[0]);
@@ -1249,10 +1250,10 @@ YY_RULE_SETUP
1249 YY_BREAK 1250 YY_BREAK
1250case 31: 1251case 31:
1251YY_RULE_SETUP 1252YY_RULE_SETUP
1252#line 271 "dtc-lexer.l" 1253#line 272 "dtc-lexer.l"
1253ECHO; 1254ECHO;
1254 YY_BREAK 1255 YY_BREAK
1255#line 1256 "dtc-lexer.lex.c" 1256#line 1257 "dtc-lexer.lex.c"
1256 1257
1257 case YY_END_OF_BUFFER: 1258 case YY_END_OF_BUFFER:
1258 { 1259 {
@@ -2218,7 +2219,7 @@ void yyfree (void * ptr )
2218 2219
2219#define YYTABLES_NAME "yytables" 2220#define YYTABLES_NAME "yytables"
2220 2221
2221#line 271 "dtc-lexer.l" 2222#line 272 "dtc-lexer.l"
2222 2223
2223 2224
2224 2225
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 2965227a1b4a..0a7a5ed86f04 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1557,10 +1557,10 @@ yyreduce:
1557 { 1557 {
1558 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); 1558 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
1559 1559
1560 add_label(&target->labels, (yyvsp[-2].labelref)); 1560 if (target) {
1561 if (target) 1561 add_label(&target->labels, (yyvsp[-2].labelref));
1562 merge_nodes(target, (yyvsp[0].node)); 1562 merge_nodes(target, (yyvsp[0].node));
1563 else 1563 } else
1564 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); 1564 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
1565 (yyval.node) = (yyvsp[-3].node); 1565 (yyval.node) = (yyvsp[-3].node);
1566 } 1566 }
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index b2fd4d155839..ca3f5003427c 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -171,10 +171,10 @@ devicetree:
171 { 171 {
172 struct node *target = get_node_by_ref($1, $3); 172 struct node *target = get_node_by_ref($1, $3);
173 173
174 add_label(&target->labels, $2); 174 if (target) {
175 if (target) 175 add_label(&target->labels, $2);
176 merge_nodes(target, $4); 176 merge_nodes(target, $4);
177 else 177 } else
178 ERROR(&@3, "Label or path %s not found", $3); 178 ERROR(&@3, "Label or path %s not found", $3);
179 $$ = $1; 179 $$ = $1;
180 } 180 }
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index a4edf4c7aebf..f5eed9d72c02 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -138,7 +138,7 @@ static const char *guess_type_by_name(const char *fname, const char *fallback)
138static const char *guess_input_format(const char *fname, const char *fallback) 138static const char *guess_input_format(const char *fname, const char *fallback)
139{ 139{
140 struct stat statbuf; 140 struct stat statbuf;
141 uint32_t magic; 141 fdt32_t magic;
142 FILE *f; 142 FILE *f;
143 143
144 if (stat(fname, &statbuf) != 0) 144 if (stat(fname, &statbuf) != 0)
@@ -159,8 +159,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)
159 } 159 }
160 fclose(f); 160 fclose(f);
161 161
162 magic = fdt32_to_cpu(magic); 162 if (fdt32_to_cpu(magic) == FDT_MAGIC)
163 if (magic == FDT_MAGIC)
164 return "dtb"; 163 return "dtb";
165 164
166 return guess_type_by_name(fname, fallback); 165 return guess_type_by_name(fname, fallback);
@@ -216,7 +215,7 @@ int main(int argc, char *argv[])
216 alignsize = strtol(optarg, NULL, 0); 215 alignsize = strtol(optarg, NULL, 0);
217 if (!is_power_of_2(alignsize)) 216 if (!is_power_of_2(alignsize))
218 die("Invalid argument \"%d\" to -a option\n", 217 die("Invalid argument \"%d\" to -a option\n",
219 optarg); 218 alignsize);
220 break; 219 break;
221 case 'f': 220 case 'f':
222 force = true; 221 force = true;
@@ -309,6 +308,8 @@ int main(int argc, char *argv[])
309 else 308 else
310 die("Unknown input format \"%s\"\n", inform); 309 die("Unknown input format \"%s\"\n", inform);
311 310
311 dti->outname = outname;
312
312 if (depfile) { 313 if (depfile) {
313 fputc('\n', depfile); 314 fputc('\n', depfile);
314 fclose(depfile); 315 fclose(depfile);
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index c6f125c68ba8..fc24e17510fd 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -43,7 +43,6 @@
43#define debug(...) 43#define debug(...)
44#endif 44#endif
45 45
46
47#define DEFAULT_FDT_VERSION 17 46#define DEFAULT_FDT_VERSION 17
48 47
49/* 48/*
@@ -114,7 +113,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m,
114struct data data_merge(struct data d1, struct data d2); 113struct data data_merge(struct data d1, struct data d2);
115struct data data_append_cell(struct data d, cell_t word); 114struct data data_append_cell(struct data d, cell_t word);
116struct data data_append_integer(struct data d, uint64_t word, int bits); 115struct data data_append_integer(struct data d, uint64_t word, int bits);
117struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); 116struct data data_append_re(struct data d, uint64_t address, uint64_t size);
118struct data data_append_addr(struct data d, uint64_t addr); 117struct data data_append_addr(struct data d, uint64_t addr);
119struct data data_append_byte(struct data d, uint8_t byte); 118struct data data_append_byte(struct data d, uint8_t byte);
120struct data data_append_zeroes(struct data d, int len); 119struct data data_append_zeroes(struct data d, int len);
@@ -136,6 +135,10 @@ struct label {
136 struct label *next; 135 struct label *next;
137}; 136};
138 137
138struct bus_type {
139 const char *name;
140};
141
139struct property { 142struct property {
140 bool deleted; 143 bool deleted;
141 char *name; 144 char *name;
@@ -162,6 +165,7 @@ struct node {
162 int addr_cells, size_cells; 165 int addr_cells, size_cells;
163 166
164 struct label *labels; 167 struct label *labels;
168 const struct bus_type *bus;
165}; 169};
166 170
167#define for_each_label_withdel(l0, l) \ 171#define for_each_label_withdel(l0, l) \
@@ -227,7 +231,7 @@ uint32_t guess_boot_cpuid(struct node *tree);
227/* Boot info (tree plus memreserve information */ 231/* Boot info (tree plus memreserve information */
228 232
229struct reserve_info { 233struct reserve_info {
230 struct fdt_reserve_entry re; 234 uint64_t address, size;
231 235
232 struct reserve_info *next; 236 struct reserve_info *next;
233 237
@@ -246,6 +250,7 @@ struct dt_info {
246 struct reserve_info *reservelist; 250 struct reserve_info *reservelist;
247 uint32_t boot_cpuid_phys; 251 uint32_t boot_cpuid_phys;
248 struct node *dt; /* the device tree */ 252 struct node *dt; /* the device tree */
253 const char *outname; /* filename being written to, "-" for stdout */
249}; 254};
250 255
251/* DTS version flags definitions */ 256/* DTS version flags definitions */
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c
index ebac548b3fa8..fcf71541d8a7 100644
--- a/scripts/dtc/flattree.c
+++ b/scripts/dtc/flattree.c
@@ -49,7 +49,7 @@ static struct version_info {
49 49
50struct emitter { 50struct emitter {
51 void (*cell)(void *, cell_t); 51 void (*cell)(void *, cell_t);
52 void (*string)(void *, char *, int); 52 void (*string)(void *, const char *, int);
53 void (*align)(void *, int); 53 void (*align)(void *, int);
54 void (*data)(void *, struct data); 54 void (*data)(void *, struct data);
55 void (*beginnode)(void *, struct label *labels); 55 void (*beginnode)(void *, struct label *labels);
@@ -64,7 +64,7 @@ static void bin_emit_cell(void *e, cell_t val)
64 *dtbuf = data_append_cell(*dtbuf, val); 64 *dtbuf = data_append_cell(*dtbuf, val);
65} 65}
66 66
67static void bin_emit_string(void *e, char *str, int len) 67static void bin_emit_string(void *e, const char *str, int len)
68{ 68{
69 struct data *dtbuf = e; 69 struct data *dtbuf = e;
70 70
@@ -144,22 +144,14 @@ static void asm_emit_cell(void *e, cell_t val)
144 (val >> 8) & 0xff, val & 0xff); 144 (val >> 8) & 0xff, val & 0xff);
145} 145}
146 146
147static void asm_emit_string(void *e, char *str, int len) 147static void asm_emit_string(void *e, const char *str, int len)
148{ 148{
149 FILE *f = e; 149 FILE *f = e;
150 char c = 0;
151 150
152 if (len != 0) { 151 if (len != 0)
153 /* XXX: ewww */ 152 fprintf(f, "\t.string\t\"%.*s\"\n", len, str);
154 c = str[len]; 153 else
155 str[len] = '\0'; 154 fprintf(f, "\t.string\t\"%s\"\n", str);
156 }
157
158 fprintf(f, "\t.string\t\"%s\"\n", str);
159
160 if (len != 0) {
161 str[len] = c;
162 }
163} 155}
164 156
165static void asm_emit_align(void *e, int a) 157static void asm_emit_align(void *e, int a)
@@ -179,7 +171,7 @@ static void asm_emit_data(void *e, struct data d)
179 emit_offset_label(f, m->ref, m->offset); 171 emit_offset_label(f, m->ref, m->offset);
180 172
181 while ((d.len - off) >= sizeof(uint32_t)) { 173 while ((d.len - off) >= sizeof(uint32_t)) {
182 asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); 174 asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off))));
183 off += sizeof(uint32_t); 175 off += sizeof(uint32_t);
184 } 176 }
185 177
@@ -318,17 +310,16 @@ static struct data flatten_reserve_list(struct reserve_info *reservelist,
318{ 310{
319 struct reserve_info *re; 311 struct reserve_info *re;
320 struct data d = empty_data; 312 struct data d = empty_data;
321 static struct fdt_reserve_entry null_re = {0,0};
322 int j; 313 int j;
323 314
324 for (re = reservelist; re; re = re->next) { 315 for (re = reservelist; re; re = re->next) {
325 d = data_append_re(d, &re->re); 316 d = data_append_re(d, re->address, re->size);
326 } 317 }
327 /* 318 /*
328 * Add additional reserved slots if the user asked for them. 319 * Add additional reserved slots if the user asked for them.
329 */ 320 */
330 for (j = 0; j < reservenum; j++) { 321 for (j = 0; j < reservenum; j++) {
331 d = data_append_re(d, &null_re); 322 d = data_append_re(d, 0, 0);
332 } 323 }
333 324
334 return d; 325 return d;
@@ -544,11 +535,11 @@ void dt_to_asm(FILE *f, struct dt_info *dti, int version)
544 fprintf(f, "\t.globl\t%s\n", l->label); 535 fprintf(f, "\t.globl\t%s\n", l->label);
545 fprintf(f, "%s:\n", l->label); 536 fprintf(f, "%s:\n", l->label);
546 } 537 }
547 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32)); 538 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->address >> 32));
548 ASM_EMIT_BELONG(f, "0x%08x", 539 ASM_EMIT_BELONG(f, "0x%08x",
549 (unsigned int)(re->re.address & 0xffffffff)); 540 (unsigned int)(re->address & 0xffffffff));
550 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32)); 541 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size >> 32));
551 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff)); 542 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size & 0xffffffff));
552 } 543 }
553 for (i = 0; i < reservenum; i++) { 544 for (i = 0; i < reservenum; i++) {
554 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); 545 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -609,7 +600,7 @@ static void flat_read_chunk(struct inbuf *inb, void *p, int len)
609 600
610static uint32_t flat_read_word(struct inbuf *inb) 601static uint32_t flat_read_word(struct inbuf *inb)
611{ 602{
612 uint32_t val; 603 fdt32_t val;
613 604
614 assert(((inb->ptr - inb->base) % sizeof(val)) == 0); 605 assert(((inb->ptr - inb->base) % sizeof(val)) == 0);
615 606
@@ -718,13 +709,15 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb)
718 * First pass, count entries. 709 * First pass, count entries.
719 */ 710 */
720 while (1) { 711 while (1) {
712 uint64_t address, size;
713
721 flat_read_chunk(inb, &re, sizeof(re)); 714 flat_read_chunk(inb, &re, sizeof(re));
722 re.address = fdt64_to_cpu(re.address); 715 address = fdt64_to_cpu(re.address);
723 re.size = fdt64_to_cpu(re.size); 716 size = fdt64_to_cpu(re.size);
724 if (re.size == 0) 717 if (size == 0)
725 break; 718 break;
726 719
727 new = build_reserve_entry(re.address, re.size); 720 new = build_reserve_entry(address, size);
728 reservelist = add_reserve_entry(reservelist, new); 721 reservelist = add_reserve_entry(reservelist, new);
729 } 722 }
730 723
@@ -817,6 +810,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
817struct dt_info *dt_from_blob(const char *fname) 810struct dt_info *dt_from_blob(const char *fname)
818{ 811{
819 FILE *f; 812 FILE *f;
813 fdt32_t magic_buf, totalsize_buf;
820 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; 814 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
821 uint32_t off_dt, off_str, off_mem_rsvmap; 815 uint32_t off_dt, off_str, off_mem_rsvmap;
822 int rc; 816 int rc;
@@ -833,7 +827,7 @@ struct dt_info *dt_from_blob(const char *fname)
833 827
834 f = srcfile_relative_open(fname, NULL); 828 f = srcfile_relative_open(fname, NULL);
835 829
836 rc = fread(&magic, sizeof(magic), 1, f); 830 rc = fread(&magic_buf, sizeof(magic_buf), 1, f);
837 if (ferror(f)) 831 if (ferror(f))
838 die("Error reading DT blob magic number: %s\n", 832 die("Error reading DT blob magic number: %s\n",
839 strerror(errno)); 833 strerror(errno));
@@ -844,11 +838,11 @@ struct dt_info *dt_from_blob(const char *fname)
844 die("Mysterious short read reading magic number\n"); 838 die("Mysterious short read reading magic number\n");
845 } 839 }
846 840
847 magic = fdt32_to_cpu(magic); 841 magic = fdt32_to_cpu(magic_buf);
848 if (magic != FDT_MAGIC) 842 if (magic != FDT_MAGIC)
849 die("Blob has incorrect magic number\n"); 843 die("Blob has incorrect magic number\n");
850 844
851 rc = fread(&totalsize, sizeof(totalsize), 1, f); 845 rc = fread(&totalsize_buf, sizeof(totalsize_buf), 1, f);
852 if (ferror(f)) 846 if (ferror(f))
853 die("Error reading DT blob size: %s\n", strerror(errno)); 847 die("Error reading DT blob size: %s\n", strerror(errno));
854 if (rc < 1) { 848 if (rc < 1) {
@@ -858,7 +852,7 @@ struct dt_info *dt_from_blob(const char *fname)
858 die("Mysterious short read reading blob size\n"); 852 die("Mysterious short read reading blob size\n");
859 } 853 }
860 854
861 totalsize = fdt32_to_cpu(totalsize); 855 totalsize = fdt32_to_cpu(totalsize_buf);
862 if (totalsize < FDT_V1_SIZE) 856 if (totalsize < FDT_V1_SIZE)
863 die("DT blob size (%d) is too small\n", totalsize); 857 die("DT blob size (%d) is too small\n", totalsize);
864 858
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c
index 2eed4f58387c..3fd5847377c9 100644
--- a/scripts/dtc/libfdt/fdt_rw.c
+++ b/scripts/dtc/libfdt/fdt_rw.c
@@ -283,7 +283,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
283 if (err) 283 if (err)
284 return err; 284 return err;
285 285
286 memcpy(prop->data, val, len); 286 if (len)
287 memcpy(prop->data, val, len);
287 return 0; 288 return 0;
288} 289}
289 290
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index b842b156fa17..ba86caa73d01 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -143,7 +143,9 @@
143/* Low-level functions (you probably don't need these) */ 143/* Low-level functions (you probably don't need these) */
144/**********************************************************************/ 144/**********************************************************************/
145 145
146#ifndef SWIG /* This function is not useful in Python */
146const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); 147const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
148#endif
147static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) 149static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
148{ 150{
149 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); 151 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
@@ -210,7 +212,6 @@ int fdt_next_subnode(const void *fdt, int offset);
210/**********************************************************************/ 212/**********************************************************************/
211/* General functions */ 213/* General functions */
212/**********************************************************************/ 214/**********************************************************************/
213
214#define fdt_get_header(fdt, field) \ 215#define fdt_get_header(fdt, field) \
215 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) 216 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
216#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 217#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
@@ -354,8 +355,10 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
354 * useful for finding subnodes based on a portion of a larger string, 355 * useful for finding subnodes based on a portion of a larger string,
355 * such as a full path. 356 * such as a full path.
356 */ 357 */
358#ifndef SWIG /* Not available in Python */
357int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, 359int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
358 const char *name, int namelen); 360 const char *name, int namelen);
361#endif
359/** 362/**
360 * fdt_subnode_offset - find a subnode of a given node 363 * fdt_subnode_offset - find a subnode of a given node
361 * @fdt: pointer to the device tree blob 364 * @fdt: pointer to the device tree blob
@@ -391,7 +394,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
391 * Identical to fdt_path_offset(), but only consider the first namelen 394 * Identical to fdt_path_offset(), but only consider the first namelen
392 * characters of path as the path name. 395 * characters of path as the path name.
393 */ 396 */
397#ifndef SWIG /* Not available in Python */
394int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); 398int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
399#endif
395 400
396/** 401/**
397 * fdt_path_offset - find a tree node by its full path 402 * fdt_path_offset - find a tree node by its full path
@@ -550,10 +555,12 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
550 * Identical to fdt_get_property(), but only examine the first namelen 555 * Identical to fdt_get_property(), but only examine the first namelen
551 * characters of name for matching the property name. 556 * characters of name for matching the property name.
552 */ 557 */
558#ifndef SWIG /* Not available in Python */
553const struct fdt_property *fdt_get_property_namelen(const void *fdt, 559const struct fdt_property *fdt_get_property_namelen(const void *fdt,
554 int nodeoffset, 560 int nodeoffset,
555 const char *name, 561 const char *name,
556 int namelen, int *lenp); 562 int namelen, int *lenp);
563#endif
557 564
558/** 565/**
559 * fdt_get_property - find a given property in a given node 566 * fdt_get_property - find a given property in a given node
@@ -624,8 +631,10 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
624 * -FDT_ERR_BADSTRUCTURE, 631 * -FDT_ERR_BADSTRUCTURE,
625 * -FDT_ERR_TRUNCATED, standard meanings 632 * -FDT_ERR_TRUNCATED, standard meanings
626 */ 633 */
634#ifndef SWIG /* This function is not useful in Python */
627const void *fdt_getprop_by_offset(const void *fdt, int offset, 635const void *fdt_getprop_by_offset(const void *fdt, int offset,
628 const char **namep, int *lenp); 636 const char **namep, int *lenp);
637#endif
629 638
630/** 639/**
631 * fdt_getprop_namelen - get property value based on substring 640 * fdt_getprop_namelen - get property value based on substring
@@ -638,6 +647,7 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
638 * Identical to fdt_getprop(), but only examine the first namelen 647 * Identical to fdt_getprop(), but only examine the first namelen
639 * characters of name for matching the property name. 648 * characters of name for matching the property name.
640 */ 649 */
650#ifndef SWIG /* Not available in Python */
641const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, 651const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
642 const char *name, int namelen, int *lenp); 652 const char *name, int namelen, int *lenp);
643static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset, 653static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
@@ -647,6 +657,7 @@ static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
647 return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name, 657 return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
648 namelen, lenp); 658 namelen, lenp);
649} 659}
660#endif
650 661
651/** 662/**
652 * fdt_getprop - retrieve the value of a given property 663 * fdt_getprop - retrieve the value of a given property
@@ -707,8 +718,10 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
707 * Identical to fdt_get_alias(), but only examine the first namelen 718 * Identical to fdt_get_alias(), but only examine the first namelen
708 * characters of name for matching the alias name. 719 * characters of name for matching the alias name.
709 */ 720 */
721#ifndef SWIG /* Not available in Python */
710const char *fdt_get_alias_namelen(const void *fdt, 722const char *fdt_get_alias_namelen(const void *fdt,
711 const char *name, int namelen); 723 const char *name, int namelen);
724#endif
712 725
713/** 726/**
714 * fdt_get_alias - retrieve the path referenced by a given alias 727 * fdt_get_alias - retrieve the path referenced by a given alias
@@ -1106,10 +1119,12 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
1106 * of the name. It is useful when you want to manipulate only one value of 1119 * of the name. It is useful when you want to manipulate only one value of
1107 * an array and you have a string that doesn't end with \0. 1120 * an array and you have a string that doesn't end with \0.
1108 */ 1121 */
1122#ifndef SWIG /* Not available in Python */
1109int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, 1123int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1110 const char *name, int namelen, 1124 const char *name, int namelen,
1111 uint32_t idx, const void *val, 1125 uint32_t idx, const void *val,
1112 int len); 1126 int len);
1127#endif
1113 1128
1114/** 1129/**
1115 * fdt_setprop_inplace - change a property's value, but not its size 1130 * fdt_setprop_inplace - change a property's value, but not its size
@@ -1139,8 +1154,10 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1139 * -FDT_ERR_BADSTRUCTURE, 1154 * -FDT_ERR_BADSTRUCTURE,
1140 * -FDT_ERR_TRUNCATED, standard meanings 1155 * -FDT_ERR_TRUNCATED, standard meanings
1141 */ 1156 */
1157#ifndef SWIG /* Not available in Python */
1142int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 1158int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
1143 const void *val, int len); 1159 const void *val, int len);
1160#endif
1144 1161
1145/** 1162/**
1146 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property 1163 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
@@ -1527,6 +1544,36 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
1527#define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1544#define fdt_setprop_string(fdt, nodeoffset, name, str) \
1528 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1545 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1529 1546
1547
1548/**
1549 * fdt_setprop_empty - set a property to an empty value
1550 * @fdt: pointer to the device tree blob
1551 * @nodeoffset: offset of the node whose property to change
1552 * @name: name of the property to change
1553 *
1554 * fdt_setprop_empty() sets the value of the named property in the
1555 * given node to an empty (zero length) value, or creates a new empty
1556 * property if it does not already exist.
1557 *
1558 * This function may insert or delete data from the blob, and will
1559 * therefore change the offsets of some existing nodes.
1560 *
1561 * returns:
1562 * 0, on success
1563 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1564 * contain the new property value
1565 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1566 * -FDT_ERR_BADLAYOUT,
1567 * -FDT_ERR_BADMAGIC,
1568 * -FDT_ERR_BADVERSION,
1569 * -FDT_ERR_BADSTATE,
1570 * -FDT_ERR_BADSTRUCTURE,
1571 * -FDT_ERR_BADLAYOUT,
1572 * -FDT_ERR_TRUNCATED, standard meanings
1573 */
1574#define fdt_setprop_empty(fdt, nodeoffset, name) \
1575 fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
1576
1530/** 1577/**
1531 * fdt_appendprop - append to or create a property 1578 * fdt_appendprop - append to or create a property
1532 * @fdt: pointer to the device tree blob 1579 * @fdt: pointer to the device tree blob
@@ -1704,8 +1751,10 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name);
1704 * creating subnodes based on a portion of a larger string, such as a 1751 * creating subnodes based on a portion of a larger string, such as a
1705 * full path. 1752 * full path.
1706 */ 1753 */
1754#ifndef SWIG /* Not available in Python */
1707int fdt_add_subnode_namelen(void *fdt, int parentoffset, 1755int fdt_add_subnode_namelen(void *fdt, int parentoffset,
1708 const char *name, int namelen); 1756 const char *name, int namelen);
1757#endif
1709 1758
1710/** 1759/**
1711 * fdt_add_subnode - creates a new node 1760 * fdt_add_subnode - creates a new node
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h
index 99f936dacc60..952056cddf09 100644
--- a/scripts/dtc/libfdt/libfdt_env.h
+++ b/scripts/dtc/libfdt/libfdt_env.h
@@ -58,16 +58,16 @@
58#include <string.h> 58#include <string.h>
59 59
60#ifdef __CHECKER__ 60#ifdef __CHECKER__
61#define __force __attribute__((force)) 61#define FDT_FORCE __attribute__((force))
62#define __bitwise __attribute__((bitwise)) 62#define FDT_BITWISE __attribute__((bitwise))
63#else 63#else
64#define __force 64#define FDT_FORCE
65#define __bitwise 65#define FDT_BITWISE
66#endif 66#endif
67 67
68typedef uint16_t __bitwise fdt16_t; 68typedef uint16_t FDT_BITWISE fdt16_t;
69typedef uint32_t __bitwise fdt32_t; 69typedef uint32_t FDT_BITWISE fdt32_t;
70typedef uint64_t __bitwise fdt64_t; 70typedef uint64_t FDT_BITWISE fdt64_t;
71 71
72#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) 72#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
73#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) 73#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
@@ -80,29 +80,29 @@ typedef uint64_t __bitwise fdt64_t;
80 80
81static inline uint16_t fdt16_to_cpu(fdt16_t x) 81static inline uint16_t fdt16_to_cpu(fdt16_t x)
82{ 82{
83 return (__force uint16_t)CPU_TO_FDT16(x); 83 return (FDT_FORCE uint16_t)CPU_TO_FDT16(x);
84} 84}
85static inline fdt16_t cpu_to_fdt16(uint16_t x) 85static inline fdt16_t cpu_to_fdt16(uint16_t x)
86{ 86{
87 return (__force fdt16_t)CPU_TO_FDT16(x); 87 return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x);
88} 88}
89 89
90static inline uint32_t fdt32_to_cpu(fdt32_t x) 90static inline uint32_t fdt32_to_cpu(fdt32_t x)
91{ 91{
92 return (__force uint32_t)CPU_TO_FDT32(x); 92 return (FDT_FORCE uint32_t)CPU_TO_FDT32(x);
93} 93}
94static inline fdt32_t cpu_to_fdt32(uint32_t x) 94static inline fdt32_t cpu_to_fdt32(uint32_t x)
95{ 95{
96 return (__force fdt32_t)CPU_TO_FDT32(x); 96 return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x);
97} 97}
98 98
99static inline uint64_t fdt64_to_cpu(fdt64_t x) 99static inline uint64_t fdt64_to_cpu(fdt64_t x)
100{ 100{
101 return (__force uint64_t)CPU_TO_FDT64(x); 101 return (FDT_FORCE uint64_t)CPU_TO_FDT64(x);
102} 102}
103static inline fdt64_t cpu_to_fdt64(uint64_t x) 103static inline fdt64_t cpu_to_fdt64(uint64_t x)
104{ 104{
105 return (__force fdt64_t)CPU_TO_FDT64(x); 105 return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x);
106} 106}
107#undef CPU_TO_FDT64 107#undef CPU_TO_FDT64
108#undef CPU_TO_FDT32 108#undef CPU_TO_FDT32
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index afa2f67b142a..3673de07e4e5 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -242,7 +242,7 @@ void delete_property_by_name(struct node *node, char *name)
242 struct property *prop = node->proplist; 242 struct property *prop = node->proplist;
243 243
244 while (prop) { 244 while (prop) {
245 if (!strcmp(prop->name, name)) { 245 if (streq(prop->name, name)) {
246 delete_property(prop); 246 delete_property(prop);
247 return; 247 return;
248 } 248 }
@@ -275,7 +275,7 @@ void delete_node_by_name(struct node *parent, char *name)
275 struct node *node = parent->children; 275 struct node *node = parent->children;
276 276
277 while (node) { 277 while (node) {
278 if (!strcmp(node->name, name)) { 278 if (streq(node->name, name)) {
279 delete_node(node); 279 delete_node(node);
280 return; 280 return;
281 } 281 }
@@ -319,8 +319,8 @@ struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
319 319
320 memset(new, 0, sizeof(*new)); 320 memset(new, 0, sizeof(*new));
321 321
322 new->re.address = address; 322 new->address = address;
323 new->re.size = size; 323 new->size = size;
324 324
325 return new; 325 return new;
326} 326}
@@ -393,7 +393,7 @@ struct property *get_property(struct node *node, const char *propname)
393cell_t propval_cell(struct property *prop) 393cell_t propval_cell(struct property *prop)
394{ 394{
395 assert(prop->val.len == sizeof(cell_t)); 395 assert(prop->val.len == sizeof(cell_t));
396 return fdt32_to_cpu(*((cell_t *)prop->val.val)); 396 return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
397} 397}
398 398
399struct property *get_property_by_label(struct node *tree, const char *label, 399struct property *get_property_by_label(struct node *tree, const char *label,
@@ -599,13 +599,13 @@ static int cmp_reserve_info(const void *ax, const void *bx)
599 a = *((const struct reserve_info * const *)ax); 599 a = *((const struct reserve_info * const *)ax);
600 b = *((const struct reserve_info * const *)bx); 600 b = *((const struct reserve_info * const *)bx);
601 601
602 if (a->re.address < b->re.address) 602 if (a->address < b->address)
603 return -1; 603 return -1;
604 else if (a->re.address > b->re.address) 604 else if (a->address > b->address)
605 return 1; 605 return 1;
606 else if (a->re.size < b->re.size) 606 else if (a->size < b->size)
607 return -1; 607 return -1;
608 else if (a->re.size > b->re.size) 608 else if (a->size > b->size)
609 return 1; 609 return 1;
610 else 610 else
611 return 0; 611 return 0;
@@ -847,6 +847,8 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
847 xasprintf(&entry, "%s:%s:%u", 847 xasprintf(&entry, "%s:%s:%u",
848 node->fullpath, prop->name, m->offset); 848 node->fullpath, prop->name, m->offset);
849 append_to_property(fn, m->ref, entry, strlen(entry) + 1); 849 append_to_property(fn, m->ref, entry, strlen(entry) + 1);
850
851 free(entry);
850} 852}
851 853
852static void generate_fixups_tree_internal(struct dt_info *dti, 854static void generate_fixups_tree_internal(struct dt_info *dti,
@@ -900,7 +902,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
900 struct node *refnode) 902 struct node *refnode)
901{ 903{
902 struct node *wn, *nwn; /* local fixup node, walk node, new */ 904 struct node *wn, *nwn; /* local fixup node, walk node, new */
903 uint32_t value_32; 905 fdt32_t value_32;
904 char **compp; 906 char **compp;
905 int i, depth; 907 int i, depth;
906 908
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c
index aa3aad04cec4..9d38459902f3 100644
--- a/scripts/dtc/srcpos.c
+++ b/scripts/dtc/srcpos.c
@@ -252,7 +252,7 @@ srcpos_string(struct srcpos *pos)
252 const char *fname = "<no-file>"; 252 const char *fname = "<no-file>";
253 char *pos_str; 253 char *pos_str;
254 254
255 if (pos) 255 if (pos->file && pos->file->name)
256 fname = pos->file->name; 256 fname = pos->file->name;
257 257
258 258
diff --git a/scripts/dtc/srcpos.h b/scripts/dtc/srcpos.h
index 2cdfcd82e95e..7caca8257c6d 100644
--- a/scripts/dtc/srcpos.h
+++ b/scripts/dtc/srcpos.h
@@ -22,6 +22,7 @@
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <stdbool.h> 24#include <stdbool.h>
25#include "util.h"
25 26
26struct srcfile_state { 27struct srcfile_state {
27 FILE *f; 28 FILE *f;
@@ -106,12 +107,10 @@ extern void srcpos_update(struct srcpos *pos, const char *text, int len);
106extern struct srcpos *srcpos_copy(struct srcpos *pos); 107extern struct srcpos *srcpos_copy(struct srcpos *pos);
107extern char *srcpos_string(struct srcpos *pos); 108extern char *srcpos_string(struct srcpos *pos);
108 109
109extern void srcpos_verror(struct srcpos *pos, const char *prefix, 110extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix,
110 const char *fmt, va_list va) 111 const char *fmt, va_list va);
111 __attribute__((format(printf, 3, 0))); 112extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix,
112extern void srcpos_error(struct srcpos *pos, const char *prefix, 113 const char *fmt, ...);
113 const char *fmt, ...)
114 __attribute__((format(printf, 3, 4)));
115 114
116extern void srcpos_set_line(char *f, int l); 115extern void srcpos_set_line(char *f, int l);
117 116
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
index c9d8967969f9..2461a3d068a0 100644
--- a/scripts/dtc/treesource.c
+++ b/scripts/dtc/treesource.c
@@ -137,7 +137,7 @@ static void write_propval_string(FILE *f, struct data val)
137static void write_propval_cells(FILE *f, struct data val) 137static void write_propval_cells(FILE *f, struct data val)
138{ 138{
139 void *propend = val.val + val.len; 139 void *propend = val.val + val.len;
140 cell_t *cp = (cell_t *)val.val; 140 fdt32_t *cp = (fdt32_t *)val.val;
141 struct marker *m = val.markers; 141 struct marker *m = val.markers;
142 142
143 fprintf(f, "<"); 143 fprintf(f, "<");
@@ -275,8 +275,8 @@ void dt_to_source(FILE *f, struct dt_info *dti)
275 for_each_label(re->labels, l) 275 for_each_label(re->labels, l)
276 fprintf(f, "%s: ", l->label); 276 fprintf(f, "%s: ", l->label);
277 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", 277 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
278 (unsigned long long)re->re.address, 278 (unsigned long long)re->address,
279 (unsigned long long)re->re.size); 279 (unsigned long long)re->size);
280 } 280 }
281 281
282 write_tree_source_node(f, dti->dt, 0); 282 write_tree_source_node(f, dti->dt, 0);
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh
index f5cde799db03..b8ebcc6722d2 100755
--- a/scripts/dtc/update-dtc-source.sh
+++ b/scripts/dtc/update-dtc-source.sh
@@ -36,10 +36,19 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c
36DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" 36DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
37LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" 37LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
38 38
39get_last_dtc_version() {
40 git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/'
41}
42
43last_dtc_ver=$(get_last_dtc_version)
44
39# Build DTC 45# Build DTC
40cd $DTC_UPSTREAM_PATH 46cd $DTC_UPSTREAM_PATH
41make clean 47make clean
42make check 48make check
49dtc_version=$(git describe HEAD)
50dtc_log=$(git log --oneline ${last_dtc_ver}..)
51
43 52
44# Copy the files into the Linux tree 53# Copy the files into the Linux tree
45cd $DTC_LINUX_PATH 54cd $DTC_LINUX_PATH
@@ -60,4 +69,13 @@ sed -i -- 's/#include <libfdt_env.h>/#include "libfdt_env.h"/g' ./libfdt/libfdt.
60sed -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h 69sed -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h
61git add ./libfdt/libfdt.h 70git add ./libfdt/libfdt.h
62 71
63git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]" 72commit_msg=$(cat << EOF
73scripts/dtc: Update to upstream version ${dtc_version}
74
75This adds the following commits from upstream:
76
77${dtc_log}
78EOF
79)
80
81git commit -e -v -s -m "${commit_msg}"
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index 3550f86bd6df..9953c32a0244 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -396,7 +396,7 @@ void utilfdt_print_data(const char *data, int len)
396 } while (s < data + len); 396 } while (s < data + len);
397 397
398 } else if ((len % 4) == 0) { 398 } else if ((len % 4) == 0) {
399 const uint32_t *cell = (const uint32_t *)data; 399 const fdt32_t *cell = (const fdt32_t *)data;
400 400
401 printf(" = <"); 401 printf(" = <");
402 for (i = 0, len /= 4; i < len; i++) 402 for (i = 0, len /= 4; i < len; i++)
@@ -412,15 +412,16 @@ void utilfdt_print_data(const char *data, int len)
412 } 412 }
413} 413}
414 414
415void util_version(void) 415void NORETURN util_version(void)
416{ 416{
417 printf("Version: %s\n", DTC_VERSION); 417 printf("Version: %s\n", DTC_VERSION);
418 exit(0); 418 exit(0);
419} 419}
420 420
421void util_usage(const char *errmsg, const char *synopsis, 421void NORETURN util_usage(const char *errmsg, const char *synopsis,
422 const char *short_opts, struct option const long_opts[], 422 const char *short_opts,
423 const char * const opts_help[]) 423 struct option const long_opts[],
424 const char * const opts_help[])
424{ 425{
425 FILE *fp = errmsg ? stderr : stdout; 426 FILE *fp = errmsg ? stderr : stdout;
426 const char a_arg[] = "<arg>"; 427 const char a_arg[] = "<arg>";
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h
index f5c4f1b50d30..ad5f41199edb 100644
--- a/scripts/dtc/util.h
+++ b/scripts/dtc/util.h
@@ -25,9 +25,17 @@
25 * USA 25 * USA
26 */ 26 */
27 27
28#ifdef __GNUC__
29#define PRINTF(i, j) __attribute__((format (printf, i, j)))
30#define NORETURN __attribute__((noreturn))
31#else
32#define PRINTF(i, j)
33#define NORETURN
34#endif
35
28#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
29 37
30static inline void __attribute__((noreturn)) die(const char *str, ...) 38static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
31{ 39{
32 va_list ap; 40 va_list ap;
33 41
@@ -53,13 +61,14 @@ static inline void *xrealloc(void *p, size_t len)
53 void *new = realloc(p, len); 61 void *new = realloc(p, len);
54 62
55 if (!new) 63 if (!new)
56 die("realloc() failed (len=%d)\n", len); 64 die("realloc() failed (len=%zd)\n", len);
57 65
58 return new; 66 return new;
59} 67}
60 68
61extern char *xstrdup(const char *s); 69extern char *xstrdup(const char *s);
62extern int xasprintf(char **strp, const char *fmt, ...); 70
71extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
63extern char *join_path(const char *path, const char *name); 72extern char *join_path(const char *path, const char *name);
64 73
65/** 74/**
@@ -188,7 +197,7 @@ void utilfdt_print_data(const char *data, int len);
188/** 197/**
189 * Show source version and exit 198 * Show source version and exit
190 */ 199 */
191void util_version(void) __attribute__((noreturn)); 200void NORETURN util_version(void);
192 201
193/** 202/**
194 * Show usage and exit 203 * Show usage and exit
@@ -202,9 +211,10 @@ void util_version(void) __attribute__((noreturn));
202 * @param long_opts The structure of long options 211 * @param long_opts The structure of long options
203 * @param opts_help An array of help strings (should align with long_opts) 212 * @param opts_help An array of help strings (should align with long_opts)
204 */ 213 */
205void util_usage(const char *errmsg, const char *synopsis, 214void NORETURN util_usage(const char *errmsg, const char *synopsis,
206 const char *short_opts, struct option const long_opts[], 215 const char *short_opts,
207 const char * const opts_help[]) __attribute__((noreturn)); 216 struct option const long_opts[],
217 const char * const opts_help[]);
208 218
209/** 219/**
210 * Show usage and exit 220 * Show usage and exit
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index 16c2e53a85e3..1229e07b4912 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
#define DTC_VERSION "DTC 1.4.2-g0931cea3" #define DTC_VERSION "DTC 1.4.4-g756ffc4f"