aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-01-03dtc: Bump version to v1.4.6v1.4.6David Gibson1-1/+1
We've accumulated a number of bugfixes since v1.4.5, so prepare for another release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-01-03fdtoverlay: Switch from using alloca to mallockevans@FreeBSD.org1-2/+2
alloca entails a complicated header situation when using other platforms, where some split it out in alloca.h while others include it as a standard part of stdlib.h. The cons don't seem to outweigh the pros, so switch it to malloc. Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-01-03tests: Improve compatibility with other platformskevans@FreeBSD.org1-4/+9
stat -c %s's equivalent on FreeBSD is stat -f %Uz; these differ enough, allow STATSZ in the environment to specify local replacement for a stat that outputs size in bytes of an argument. Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-15checks: add chosen node checksRob Herring3-0/+64
Add some checks for /chosen node. These check that chosen is located at the root level and that bootargs and stdout-path properties are strings. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-13checks: add aliases node checksRob Herring1-0/+24
Add checks for aliases node that all properties follow alias naming convention and the values are a valid path. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-13checks: check for #{size,address}-cells without child nodesRob Herring1-0/+26
Add a check for unnecessary "#{size,address}-cells" when there's neither a 'ranges' property nor child nodes with a 'reg' property. An exception may be an overlay that adds nodes, but this case would need "#{size,address}-cells" in the overlay to properly compile already. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-13checks: add string list check for *-names propertiesRob Herring3-2/+19
Add a string list check for common properties ending in "-names" such as reg-names or interrupt-names. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-13checks: add string list checkRob Herring3-1/+40
Add a check for string list properties with compatible being the first check. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-13checks: add a string check for 'label' propertyRob Herring3-1/+4
Add a string property check for 'label' property. 'label' is a human readable string typically used to identify connectors or ports on devices. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-12-05checks: fix sound-dai phandle with arg property checkPeter Rosin1-2/+2
The property is named "sound-dai", not "sound-dais". Fixes: b3bbac02d5e3 ("checks: add phandle with arg property checks") Signed-off-by: Peter Rosin <peda@axentia.se> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-11-21Fix ambiguous grammar for devicetree ruleGrant Likely3-8/+14
Commit 737b2df3, "overlay: Add syntactic sugar version of overlays" introduced an empty rule for "devicetree" that created ambiguities in the grammar and causes the following warning: BISON dtc-parser.tab.c dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] Fix the grammar by explicitly testing for the condition the new overlay grammar wants to use. This means duplicating a very small amount of grammar processing code, but the alternative seems to be a more invasive reorganization of the devicetree rule. Better to fix it this way now and save the reorg for a separate patch. Signed-off-by: Grant Likely <grant.likely@arm.com> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-11-11tests: Add some basic tests for the pci_bridge checksDavid Gibson4-0/+61
This adds some simple tests for the checks of correctly formatted PCI bridge nodes. Doesn't test all that much, but it's a start. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-11-11Fix widespread incorrect use of strneq(), replace with new strprefixeq()David Gibson3-5/+5
Every remaining usage of strneq() is, in fact, incorrect. They're trying to check that the first n characters of one string exactly match another string. But, they fall into the classic trap of strncmp() on which strneq() is based. If n is less than the length of the second string, they only check that the first string matches the start of the second, not the whole of it. To fix this, remove strneq() and replace it with a strprefixeq() function which does what we want here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-11-11Add strstarts() helper functionDavid Gibson2-1/+2
nodename_from_path() in flattree.c uses strneq() to test that one string starts with another. This is, in fact, the only correct usage of strneq() in the entire tree. To make things harder to confuse, add a strstarts() function for this purpose. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-30tests: Check non-matching cases for fdt_node_check_compatible()David Gibson1-0/+19
The current tests for fdt_node_check_compatible() test that it returns true on several matching cases, but don't test that it actually returns false on some non-matching cases, which isn't great coverage. Add some basic tests to address that. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-27livetree: avoid assertion of orphan phandles with overlaysTero Kristo2-2/+6
Right now, check_interrupts_property fails with overlays, as the phandle for the interrupt-parent can be orphan. Avoid this by allowing the orphan node to pass the assert check. The process_checks() call is also moved later during init sequence, so that we can use the global variable generate_fixups to check if we are compiling an overlay. Signed-off-by: Tero Kristo <t-kristo@ti.com> [dwg: Shortcut handling of invalid phandles] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-27implement strnlen for systems that need itJohn Arbuckle1-0/+27
Prior the Mac OS 10.7, the function strnlen() was not available. This patch implements strnlen() on Mac OS X versions that are below 10.7. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26libfdt: Remove leading underscores from identifiersDavid Gibson9-120/+120
In a lot of places libfdt uses a leading _ character to mark an identifier as "internal" (not part of the published libfdt API). This is a bad idea, because identifiers with a leading _ are generally reserved by the C library or system. It's particularly dangerous for libfdt, because it's designed to be able to be integrated into lots of different environments. In some cases the leading _ has no purpose, so we simply drop it. In most cases we move it to the end, as our new convention for marking internal identifiers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26Remove leading underscores from identifiersDavid Gibson10-43/+41
In a number of places, dtc and associated tools and test code use leading _ characters on identifiers to flag them as "internal", an idiom taken from the Linux kernel. This is a bad idea in a userspace program, because identifiers with a leading _ are reserved for the C library / system. In some cases, the extra _ served no real purpose, so simply drop it. In others move to the end of the identifier, which is a convention we're free to use for our own purposes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26Replace FDT_VERSION() with stringify()David Gibson2-3/+4
The FDT_VERSION() and _FDT_VERSION() macros don't really have anything specific to do with the fdt version. Rather, they're the common CPP "stringify" idiom. Move to util.h and rename to stringify() to reflect this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26Fix some errors in commentsDavid Gibson2-5/+6
A comment in tests/stringlist.c refers to fdt_get_string(), which is not a function that exists. From the content, it's supposed to be referring to fdt_getprop_string(). A comment in libfdt.h has an extraneous space in a function name. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26tests: Correct warning in sw_tree1.cDavid Gibson1-0/+2
At least some clang versions (correctly) warn that 'size' is used unititialized, if sw_tree1 is invoked with argc > 2. This corrects the warning. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-19checks: fix handling of unresolved phandles for dts pluginsRob Herring1-0/+9
In dts plugins, it is valid to have unresolved phandle values. The check_property_phandle_args and check_interrupts_property checks failed to account for this resulting in spurious warnings or asserts, respectively. Fix this by bailing from the checks if we're checking a dts plugin as there is no way to further validate the properties. Fixes: ee3d26f6960b ("checks: add interrupts property check") Fixes: b3bbac02d5e3 ("checks: add phandle with arg property checks") Reported-by: Alan Tull <atull@kernel.org> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-06tests: Avoid 64-bit arithmetic in assemblerDavid Gibson2-25/+28
For testing we (ab)use the assembler to build us a sample dtb, independent of the other tools (dtc and libfdt) that we're trying to test. In a few places this uses 64-bit arithmetic to decompose 64-bit constants into the individual bytes in the blob. Unfortunately, it seems that some builds of GNU as don't support >32 bit arithmetic, though it's not entirely clear to me which do and which don't (Fedora i386 does support 64-bit, Debian arm32 doesn't). Anyway, to be safe, this avoids 64-bit arithmetic in assembler at the cost of some extra awkwardness because we have to define the values in 32-bit halves. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-05libfdt: add stringlist functions to linker scriptReiner Huober1-0/+3
The fdt_stringlist_count, fdt_stringslist_search, and fdt_stringlist_get are added to the libfdt linker script as global symbols Signed-off-by: Reiner Huober <reiner.huober@nokia.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-28tests: Add a test for overlays syntactic sugarPantelis Antoniou1-0/+6
Add a single test makeing sure the &foo { }; syntax works. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-28overlay: Add syntactic sugar version of overlaysPantelis Antoniou3-3/+40
For simple overlays that use a single target there exists a simpler syntax version. &foo { }; generates an overlay with a single target at foo. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-28checks: Use proper format modifier for size_tThierry Reding1-2/+2
The size of size_t can vary between architectures, so using %ld isn't going to work on 32-bit builds. Use the %zu modifier to make sure it is always correct. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-27dtc: Bump version to v1.4.5v1.4.5David Gibson1-1/+1
Preparing for another release. No particular trigger for this, just a number of accumulated enhancements since v1.4.4. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-27Add fdtoverlay to .gitignoreDavid Gibson1-0/+1
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-27fdtoverlay: Sanity check blob sizeDavid Gibson1-0/+7
The fdtoverlay utility reads in the base fdt blob, then expands it to make room for all the overlays requested. However, it uses the totalsize field of the base blob without verifying that it actually read all of it in (it's possible the blob file could have been truncated). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-27pylibfdt: Use Python2 explicitlyDavid Gibson2-2/+2
The pylibfdt code is written for Python2, not Python3. So, it's safer to explicitly request Python2 in our scripts and when checking pkg-config. On Arch Linux at least, there isn't actually a plain "python" link, just "python2" and "python3", so the current setup won't work at all. According to https://www.python.org/dev/peps/pep-0394/ using "python2" should work, and is preferred. Updating pylibfdt to work with Python3 would be nice, but is a problem for another day. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-22checks: add interrupts property checkRob Herring3-0/+94
Add a check for nodes with interrupts property that they have a valid parent, the parent has #interrupt-cells property, and the size is a valid multiple of #interrupt-cells. This may not handle every possible case and doesn't deal with translation thru interrupt-map properties, but should be enough for modern dts files. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-22checks: add gpio binding properties checkRob Herring3-0/+88
The GPIO binding is different compared to other phandle plus args properties in that the property name has a variable, optional prefix. The format of the property name is [<name>-]gpio{s} where <name> can be any legal property string. Therefore, custom matching of property names is needed, but the common check_property_phandle_args() function can still be used. It's possible that there are property names matching which are not GPIO binding specifiers. There's only been one case found in testing which is "[<vendor>,]nr-gpio{s}". This property has been blacklisted and the same should be done to any others we find. This check will prevent getting any more of these, too. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-09-22checks: add phandle with arg property checksRob Herring5-0/+145
Many common bindings follow the same pattern of client properties containing a phandle and N arg cells where N is defined in the provider with a '#<specifier>-cells' property such as: intc0: interrupt-controller@0 { #interrupt-cells = <3>; }; intc1: interrupt-controller@1 { #interrupt-cells = <2>; }; node { interrupts-extended = <&intc0 1 2 3>, <&intc1 4 5>; }; Add checks for properties following this pattern. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21fdtget: Split out cell list display into a new functionSimon Glass1-15/+34
The show_data() function is quite long. Split out the part that loops through the values. This makes it easier to add new features. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21README: Add a note about test_tree1.dtsSimon Glass1-0/+11
Add a little note in the README about something which confused me. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Add support for fdt_subnode_offset()Simon Glass2-0/+29
Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Add support for fdt_node_offset_by_phandle()Simon Glass2-0/+24
Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Add support for fdt_parent_offset()Simon Glass2-0/+28
Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Add support for fdt_get_phandle()Simon Glass2-0/+18
Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21tests: Return a failure code when any tests failSimon Glass1-0/+1
At present 'make check' succeeds even if some tests fail. Adjust this so that we can use things like 'git bisect run make check' to find a failure. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Use local pylibfdt moduleSimon Glass1-2/+2
Some systems may have the Python libfdt.py library installed. Adjust the tests to prepend the local libfdt path so that we test the local version instead of the system version. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-21pylibfdt: Add a test for use of uint32_tSimon Glass1-0/+5
Using the libfdt function without going through the Python Fdt class requires use of the uint32_t type. Add a test that this works correctly. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-15pylibfdt: Add stdint include to fix uint32_tSimon Glass1-0/+2
Some types used by libfdt.h are not understood the Python module since they are defined outside it. An example is an attempt to do this: import libfdt result = libfdt.fdt_node_offset_by_phandle(fdt, phandle) This results in: TypeError: in method 'fdt_node_offset_by_phandle', argument 2 of type 'uint32_t' Include the standard integer header file to fix this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-09tests: Add stacked overlay tests on fdtoverlayPantelis Antoniou4-0/+47
Add a stacked overlay unit test, piggybacking on fdtoverlay. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-09fdt: Allow stacked overlays phandle referencesPantelis Antoniou1-22/+206
This patch enables an overlay to refer to a previous overlay's labels by performing a merge of symbol information at application time. In a nutshell it allows an overlay to refer to a symbol that a previous overlay has defined. It requires both the base and all the overlays to be compiled with the -@ command line switch so that symbol information is included. base.dts -------- /dts-v1/; / { foo: foonode { foo-property; }; }; $ dtc -@ -I dts -O dtb -o base.dtb base.dts bar.dts ------- /dts-v1/; /plugin/; / { fragment@1 { target = <&foo>; __overlay__ { overlay-1-property; bar: barnode { bar-property; }; }; }; }; $ dtc -@ -I dts -O dtb -o bar.dtb bar.dts baz.dts ------- /dts-v1/; /plugin/; / { fragment@1 { target = <&bar>; __overlay__ { overlay-2-property; baz: baznode { baz-property; }; }; }; }; $ dtc -@ -I dts -O dtb -o baz.dtb baz.dts Applying the overlays: $ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb Dumping: $ fdtdump target.dtb / { foonode { overlay-1-property; foo-property; linux,phandle = <0x00000001>; phandle = <0x00000001>; barnode { overlay-2-property; phandle = <0x00000002>; linux,phandle = <0x00000002>; bar-property; baznode { phandle = <0x00000003>; linux,phandle = <0x00000003>; baz-property; }; }; }; __symbols__ { baz = "/foonode/barnode/baznode"; bar = "/foonode/barnode"; foo = "/foonode"; }; }; Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-07-28Introduce fdt_setprop_placeholder() methodPantelis Antoniou2-3/+48
In some cases you need to add a property but the contents of it are not known at creation time, merely the extend of it. This method allows you to create a property of a given size (filled with garbage) while a pointer to the property data will be provided. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [dwg: Corrected commit message] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-07-13dtc: change default phandles to ePAPR style instead of bothRob Herring2-2/+2
Currently, both legacy (linux,phandle) and ePAPR (phandle) properties are inserted into dtbs by default. The newer ePAPR style has been supported in dtc and Linux kernel for 7 years. That should be a long enough transition period. We can save a little space by not putting both into the dtb. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-06-15tests: fdtoverlay unit testPantelis Antoniou3-1/+67
Add an fdtoverlay unit test. Applies applies overlay(s) and then retrieves an inserted property to verify. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>