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

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

Pull DeviceTree updates from Rob Herring:

- fix sparse warnings in drivers/of/

- add more overlay unittests

- update dtc to v1.4.4-8-g756ffc4f52f6. This adds more checks on dts
files such as unit-address formatting and stricter character sets for
node and property names

- add a common DT modalias function

- move trivial-devices.txt up and out of i2c dir

- ARM NVIC interrupt controller binding

- vendor prefixes for Sensirion, Dioo, Nordic, ROHM

- correct some binding file locations

* tag 'devicetree-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (24 commits)
of: fix sparse warnings in fdt, irq, reserved mem, and resolver code
of: fix sparse warning in of_pci_range_parser_one
of: fix sparse warnings in of_find_next_cache_node
of/unittest: Missing unlocks on error
of: fix uninitialized variable warning for overlay test
of: fix unittest build without CONFIG_OF_OVERLAY
of: Add unit tests for applying overlays
of: per-file dtc compiler flags
fpga: region: add missing DT documentation for config complete timeout
of: Add vendor prefix for ROHM Semiconductor
of: fix "/cpus" reference leak in of_numa_parse_cpu_nodes()
of: Add vendor prefix for Nordic Semiconductor
dt-bindings: arm,nvic: Binding for ARM NVIC interrupt controller on Cortex-M
dtc: update warning settings for new bus and node/property name checks
scripts/dtc: Update to upstream version v1.4.4-8-g756ffc4f52f6
scripts/dtc: automate getting dtc version and log in update script
of: Add function for generating a DT modalias with a newline
of: fix of_device_get_modalias returned length when truncating buffers
Documentation: devicetree: move trivial-devices out of I2C realm
dt-bindings: add vendor prefix for Dioo
..

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