Commit graph

108 commits

Author SHA1 Message Date
Qun-Wei Lin
2022bb1087 checks: Update #{size,address}-cells check for 'dma-ranges'
The "dma-ranges" property value is a sequence of
	child-address  parent-address  child-size

The size of each field is determined by taking the child's
"#address-cells" value, the parent's "#address-cells" value,
and the child's "#size-cells" value.

However, in the following example, it gives a false alarm:
+-----------------------------------+---------------------------------------+
| ranges.dts                        | dma-ranges.dts                        |
+-----------------------------------+---------------------------------------+
| /dts-v1/;                         | /dts-v1/;                             |
|                                   |                                       |
| /{                                | /{                                    |
|   #address-cells = <1>;           |   #address-cells = <1>;               |
|                                   |                                       |
|   parent {                        |   parent {                            |
|     #address-cells = <1>;         |     #address-cells = <1>;             |
|     #size-cells = <1>;            |     #size-cells = <1>;                |
|     ranges = <0x0 0xe000 0x1000>; |     dma-ranges = <0x0 0xe000 0x1000>; |
|     child {                       |     child {                           |
|       ...                         |       ...                             |
|     };                            |     };                                |
|   };                              |   };                                  |
| };                                | };                                    |
+-----------------------------------+---------------------------------------+
| no warning                        | Warning (avoid_unnecessary_addr_size) |
+-----------------------------------+---------------------------------------+

Same as "ranges", it should not be reported in this check.

Signed-off-by: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Message-Id: <20230112125654.13390-1-qun-wei.lin@mediatek.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-02-02 17:46:54 +11:00
David Gibson
ff5afb96d0 Handle integer overflow in check_property_phandle_args()
If the corresponding '#xxx-cells' value is much too large, an integer
overflow can prevent the checks in check_property_phandle_args() from
correctly determining that the checked property is too short for the
given cells value.  This leads to an infinite loops.

This patch fixes the bug, and adds a testcase for it.  Further
information in https://github.com/dgibson/dtc/issues/64

Reported-by: Anciety <anciety@pku.edu.cn>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-29 17:04:18 +11:00
Rob Herring
0a3a9d3449 checks: Add an interrupt-map check
Add a check for parsing 'interrupt-map' properties. The check primarily
tests parsing 'interrupt-map' properties which depends on and the parent
interrupt controller (or another map) node.

Note that this does not require '#address-cells' in the interrupt-map
parent, but treats missing '#address-cells' as 0 which is how the Linux
kernel parses it. There's numerous cases that expect this behavior.

Cc: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20211015213527.2237774-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-10-21 15:48:41 +11:00
Rob Herring
8fd24744e3 checks: Ensure '#interrupt-cells' only exists in interrupt providers
The interrupt provider check currently checks if an interrupt provider
has #interrupt-cells, but not whether #interrupt-cells is present
outside of interrupt-providers. Rework the check to cover the latter
case.

Cc: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20211011191245.1009682-4-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-10-14 14:46:17 +11:00
Rob Herring
d8d1a9a778 checks: Drop interrupt provider '#address-cells' check
'#address-cells' is only needed when parsing 'interrupt-map' properties, so
remove it from the common interrupt-provider test.

Cc: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20211011191245.1009682-3-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-10-14 14:45:22 +11:00
Rob Herring
52a16fd728 checks: Make interrupt_provider check dependent on interrupts_extended_is_cell
If '#interrupt-cells' doesn't pass checks, no reason to run interrupt
provider check.

Cc: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20211011191245.1009682-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-10-14 14:35:45 +11:00
Thierry Reding
69595a167f checks: Fix bus-range check
The upper limit of the bus-range is specified by the second cell of the
bus-range property.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Message-Id: <20210629114304.2451114-1-thierry.reding@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-30 10:32:13 +10:00
Andre Przywara
b587787ef3 checks: Fix signedness comparisons warnings
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in various parts in checks.c.

Fix those by making all affected variables unsigned. This covers return
values of the (unsigned) size_t type, phandles, variables holding sizes
in general and loop counters only ever counting positives values.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20210618172030.9684-5-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-21 15:34:05 +10:00
Andre Przywara
69bed6c241 dtc: Wrap phandle validity check
In several places we check for a returned phandle value to be valid,
for that it must not be 0 or "-1".

Wrap this check in a static inline function in dtc.h, and use ~0U instead
of -1 on the way, to keep everything in the unsigned realm.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20210618172030.9684-4-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-21 15:28:21 +10:00
David Gibson
4c2ef8f4d1 checks: Introduce is_multiple_of()
In a number of places we check if one number is a multiple of another,
using a modulus.  In some of those cases the divisor is potentially zero,
which needs special handling or we could trigger a divide by zero.

Introduce an is_multiple_of() helper to safely handle this case, and use
it in a bunch of places.  This should close Coverity issue 1501687, maybe
others as well.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-08 15:17:11 +10:00
Rob Herring
0c3fd9b6ac checks: Drop interrupt_cells_is_cell check
With the prior commit, this check is now redundant.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20210526010335.860787-4-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-08 11:58:43 +10:00
Rob Herring
6b3081abc4 checks: Add check_is_cell() for all phandle+arg properties
There's already a check for '#.*-cells' properties, so let's enable it for
all the ones we already know about.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20210526010335.860787-3-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-06-08 11:57:04 +10:00
Ilya Lipnitskiy
ad4abfadb6 checks: replace strstr and strrchr with strends
Makes the logic more clear

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Message-Id: <20210504035944.8453-4-ilya.lipnitskiy@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-05-04 14:45:20 +10:00
Ilya Lipnitskiy
9bb9b8d0b4 checks: tigthen up nr-gpios prop exception
There are no instances of nr-gpio in the Linux kernel tree, only
"[<vendor>,]nr-gpios", so make the check stricter.

nr-gpios without a "vendor," prefix is also invalid, according to the DT
spec[0], and there are no DT files in the Linux kernel tree with
non-vendor nr-gpios. There are some drivers, but they are not DT spec
compliant, so don't suppress the check for them.

[0]:
Link: cb53a16a1e/schemas/gpio/gpio-consumer.yaml (L20)

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Message-Id: <20210504035944.8453-2-ilya.lipnitskiy@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-05-04 14:45:20 +10:00
Kumar Gala
88875268c0 checks: Warn on node-name and property name being the same
Treat a node-name and property name at the same level of tree as
a warning

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Message-Id: <20210210193912.799544-1-kumar.gala@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-02-15 17:17:36 +11:00
Kumar Gala
9d2279e7e6 checks: Change node-name check to match devicetree spec
The devicetree spec limits the valid character set to:
  A-Z
  a-z
  0-9
  ,._+-

while property can additionally have '?#'.  Change the check to match
the spec.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Message-Id: <20210209184641.63052-1-kumar.gala@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-02-10 16:29:21 +11:00
Rob Herring
cbca977ea1 checks: Allow PCI bridge child nodes without an address
Some PCI bridge nodes have child nodes such as an interrupt controller
which are not PCI devices. Allow these nodes which don't have a
unit-address.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20200928201942.3242124-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 13:30:24 +10:00
Joel Stanley
8259d59f59 checks: Improve i2c reg property checking
The i2c bindings in the kernel tree describe support for 10 bit
addressing, which must be indicated with the I2C_TEN_BIT_ADDRESS flag.
When this is set the address can be up to 10 bits. When it is not set
the address is a maximum of 7 bits.

See Documentation/devicetree/bindings/i2c/i2c.txt.

Take into account this flag when checking the address is valid.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-Id: <20200622031005.1890039-3-joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-22 17:52:50 +10:00
Joel Stanley
fdabcf2980 checks: Remove warning for I2C_OWN_SLAVE_ADDRESS
dtc does a sanity check on reg properties that they are within the 10
bit address range for i2c slave addresses. In the case of multi-master
buses or devices that act as a slave, the binding may describe an
address that the bus will listen on as a device. Do not warn when this
flag is set.

See Documentation/devicetree/bindings/i2c/i2c.txt.

This fixes the following build warnings reported by Stephen and by Arnd:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
  Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
    I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
  Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:
    I2C address must be less than 10-bits, got "0x40000010"

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-Id: <20200622031005.1890039-2-joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-22 17:52:50 +10:00
Andre Przywara
81e0919a3e checks: Add interrupt provider test
An interrupt provider (an actual interrupt-controller node or an
interrupt nexus) should have both #address-cells and #interrupt-cells
properties explicitly defined.

Add an extra test for this. We check for the #interrupt-cells property
already, but this does not cover every controller so far, only those that
get referenced by an interrupts property in some node. Also we miss
interrupt nexus nodes.

A missing #address-cells property is less critical, but creates
ambiguities when used in interrupt-map properties, so warn about this as
well now.
This removes the now redundant warning in the existing interrupts test.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200515141827.27957-2-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-05-18 14:26:12 +10:00
Arkadiusz Drabczyk
87a656ae5f check: Inform about missing ranges
In check_unit_address_vs_reg() warning message already says 'reg _or_
ranges' when reg or ranges are present but unit name is missing.  Add
this message for compatibility to say "reg _or_ ranges" when unit name
is present but neither reg nor ranges are present.

Signed-off-by: Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
Message-Id: <20200308165643.19281-1-arkadiusz@drabczyk.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-10 11:44:23 +11:00
Rob Herring
76b43dcbd1 checks: Add 'dma-ranges' check
Generalize the existing 'ranges' check to also work for 'dma-ranges'
which has the same parsing requirements.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20200303193931.1653-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04 10:30:12 +11:00
David Gibson
60e0db3d65 Ignore phandle properties in /aliases
The 'alias_paths' check verifies that each property in /aliases is a valid
path to another node.  However this can cans false positives trees where
the /aliases node has a phandle property, which isn't in this format but
is allowed.  In particular this situation can be common with trees dumped
from some real OF systems (which typically generate a phandle for every
node).

Special case this to avoid the spurious error.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-04 14:58:28 +10:00
Rob Herring
acfe84f2c4 dtc: Replace GPLv2 boilerplate/reference with SPDX tags
Replace instances of GPLv2 or later boilerplate with SPDX tags.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-2-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00
David Gibson
8f69567622 Avoid assertion in check_interrupts_property()
If running on a tree with an 'interrupt-parent' property which contains
an invalid phandle (0 or -1, not merely for a node which doesn't exist),
then check_interrupts_property() will trip the assertion in
get_node_by_phandle().

There's logic that almost detects this, but it only handles the overlay
case, where we can't fully check because the links will be fixed up later.

For the non-overlay case, this is definitely a bad property, but we
shouldn't crash.  Fix it by failing the check early.

Fixes: c1e55a5513 ("checks: fix handling of unresolved phandles for dts plugins")
Fixes: ee3d26f696 ("checks: add interrupts property check")
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-05-06 17:00:07 +10:00
Chen-Yu Tsai
ae795b2db7 checks: Do not omit nodes with labels if symbol generation is requested
Commit 4038fd9005 ("dtc: add ability to make nodes conditional on them
being referenced") added the new /omit-if-no-ref/ directive to mark
nodes as eligible to be discarded if not referenced. The mechanism to
process this happens before the symbol generation phase. This means even
if symbol generation is requested and the node has a label, it will be
discarded if there are no references to it within the same file.

This is probably not what people expect. When using symbol generation to
compile base device trees for applying overlays, nodes with labels could
be referenced by the overlays, and therefore should be preserved.

Check if the node has a label and symbol generation was requested before
dropping the node.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Message-Id: <20190327035352.24036-1-wens@csie.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-27 17:02:54 +11:00
Leonard Crestez
4762ad051e checks: Fix spelling in check_graph_endpoint
Should be "endpoint" rather than "endpont"

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Message-Id: <6fcb6e160163467b706c312ffe307ee8a5d9255d.1552328099.git.leonard.crestez@nxp.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-12 19:16:14 +11:00
Kumar Gala
7cbc550f90 checks: Add unit address check if node is enabled
There are various SoCs that have 2 different peripheral blocks at the
same register offset.  However, we might have one block marked as
status = "disabled" and the other status = "ok".  In such cases we
shouldn't warn about duplicate unit-address.

Here's a cut down example that we would warning about before:

/dts-v1/;

/ {
	#address-cells = <0x01>;
	#size-cells = <0x01>;

	soc {
		#address-cells = <0x01>;
		#size-cells = <0x01>;
		compatible = "simple-bus";
		ranges;

		i2c0: i2c@40003000 {
			compatible = "nordic,nrf-i2c";
			reg = <0x40003000 0x1000>;
			status = "ok";
		};

		spi0: spi@40003000 {
			compatible = "nordic,nrf-spi";
			reg = <0x40003000 0x1000>;
			status = "disabled";
		};
	};
};

We introduce 'unique_unit_address_if_enabled' check that is disabled by
default.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-12-15 18:47:55 +11:00
Rob Herring
f267e674d1 checks: Fix crash with multiple source annotations
Commit 3616b9a811 ("checks: Use source position information for check
failures") causes crashes when there's a check message with multiple
source annotations. Drop the errant addition to the str pointer left
over from the previous version.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-28 09:35:13 +11:00
Rob Herring
3616b9a811 checks: Use source position information for check failures
Now that we retain source position information of nodes and properties,
make that the preferred file name (and position) to print out in check
failures. This will greatly simplify finding and fixing check errors
because most errors are in included source .dtsi files and they get
duplicated every time the source file is included.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25 18:24:00 +11:00
Rob Herring
2bdbd07a12 checks: Make each message output atomic
Printing to stderr as we build up the check message results in
interleaving of messages when multiple instances of dtc are running.
Change the message output to use an intermediate buffer for constructing
the message and then output the message to stderr with a single fputs.

While perhaps there is no guarantee that fputs will be atomic, this gets
rid of any interleaved output that previously occurred on Linux.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25 18:23:31 +11:00
Rob Herring
86a288a736 checks: Restructure check_msg to decrease indentation
The entire check_msg function is under the if condition except for
va_start/va_end. Move these and invert the if condition saving a level
of indentation.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-22 17:14:19 +11:00
Kumar Gala
403cc79f06 checks: Update SPI bus check for 'spi-slave'
If the SPI bus controller is being used for 'spi-slave' mode some of the
checks we have need to change:

In 'spi-slave' mode #address-cells should be 0, as any children don't
have a reg property.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14 14:25:43 +11:00
Rob Herring
e84742aa7b checks: fix simple-bus compatible matching
Since commit 7975f64222 ("Fix widespread incorrect use of strneq(),
replace with new strprefixeq()") simple-bus checks have been silently
skipped. The problem was 'end - str' is one more than the string length
and the strnlen in strprefixeq fails. This can't be fixed simply by
subtracting one as it is possible to have multiple '\0' at the end of
the property. Fix this by making the 'compatible' property string list
check a dependency, and then we can assume the property is null
terminated and we can just use streq() for comparisons.

Add some tests so the problem doesn't happen again.

Fixes: 7975f64222 ("Fix widespread incorrect use of strneq(), replace with new strprefixeq()")
Reported-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-21 11:31:16 +10:00
Rob Herring
90a190eb04 checks: add SPI bus checks
Add SPI bus type detection and checks. The node name is the
preferred way to find SPI buses as there is no common compatible or
property which can be used. There are a few common properties used in
child nodes, so they can be used as a fallback detection method. This
lets us warn if the SPI controller is not properly named 'spi@...'.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-07-27 13:42:50 +10:00
Rob Herring
53a1bd5469 checks: add I2C bus checks
Add I2C bus type detection and checks. The node name is used to find I2C
buses as there is no common compatible or property which can be used to
identify I2C controllers/buses. There are some common I2C properties,
but they are not used frequently enough to match on.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-07-27 13:42:50 +10:00
Maxime Ripard
4038fd9005 dtc: add ability to make nodes conditional on them being referenced
A number of platforms have a need to reduce the number of DT nodes,
mostly because of two similar constraints: the size of the DT blob, and
the time it takes to parse it.

As the DT is used in more and more SoCs, and by more projects, some
constraints start to appear in bootloaders running from SRAM with an
order of magnitude of 10kB. A typical DT is in the same order of
magnitude, so any effort to reduce the blob size is welcome in such an
environment.

Some platforms also want to reach very fast boot time, and the time it
takes to parse a typical DT starts to be noticeable.

Both of these issues can be mitigated by reducing the number of nodes in
the DT. The biggest provider of nodes is usually the pin controller and
its subnodes, usually one for each valid pin configuration in a given
SoC.

Obviously, a single, fixed, set of these nodes will be used by a given
board, so we can introduce a node property that will tell the DT
compiler to drop the nodes when they are not referenced in the tree, and
as such wouldn't be useful in the targetted system.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-05-04 11:48:46 +10:00
Rob Herring
e1f139ea49 checks: drop warning for missing PCI bridge bus-range
Having a 'bus-range' property for PCI bridges should not be required,
so remove the warning when missing. There was some confusion with the
Linux kernel printing a message that no property is present and the OS
assigned the bus number. This message was intended to be informational
rather than a warning.

When the firmware doesn't enumerate the PCI bus and leaves it up to the
OS to do, then it is perfectly fine for the OS to assign bus numbers
and bus-range is not necessary.

There are a few cases where bus-range is needed or useful as Arnd
Bergmann summarized:

- Traditionally Linux avoided using multiple PCI domains, but instead
  configured separate PCI host bridges to have non-overlapping
  bus ranges so we can present them to user space as a single
  domain, and run the kernel without CONFIG_PCI_DOMAINS.
  Specifying the bus ranges this way would and give stable bus
  numbers across boots when the probe order is not fixed.

- On certain ARM64 systems, we must only use the first
  128 bus numbers based on the way the IOMMU identifies
  the device with truncated bus/dev/fn number. There are probably
  others like this, with various limitations.

- To leave some room for hotplugged devices, each slot on
  a host bridge can in theory get a range of bus numbers
  that are available when assigning bus numbers at boot time

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-04-22 14:13:28 +10:00
Geert Uytterhoeven
f4eba68d89 checks: Print duplicate node name instead of parent name
When refactoring node path printing, the code checking for duplicate
node names was accidentally changed to print the name of the parent
node, instead of the name of the duplicated child node.

Fixes: 88960e3989 ("checks: centralize printing of node path in check_msg")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-28 10:13:15 +11:00
Rob Herring
df536831d0 checks: add graph binding checks
Add checks for DT graph bindings. These checks check node names,
unit-addresses and link connections on ports, port, and endpoint nodes.

The graph nodes are matched by finding nodes named 'endpoint' or with a
'remote-endpoint' property. We can't match on 'ports' or 'port' nodes
because those names are used for non-graph nodes. While the graph nodes
aren't really buses, using the bus pointer to tag matched nodes is
convenient.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-07 14:55:39 +11:00
Rob Herring
2347c96edc checks: add a check for duplicate unit-addresses of child nodes
Child nodes with the same unit-address (and different node names) are
either an error or just bad DT design. Typical errors are the unit-address
is just wrong (i.e. doesn't match reg value) or multiple children using the
same overlapping area. Overlapping regions are considered an error in new
bindings, but do exist in some existing trees. This check should flag
most but not all of those errors. Finding all cases would require doing
address translations and creating a full map of address spaces.

Mixing more than one address/number space at a level is bad design. It only
works if both spaces can use the same #address-cells and #size-cells sizes.
It also complicates parsing have a mixture of types of child nodes. The
best practice in this case is adding child container nodes for each
address/number space or using additional address bits/cells to encode
different address spaces.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-07 14:32:28 +11:00
David Gibson
afbddcd418 Suppress warnings on overlay fragments
Overlay fragments are traditionally named "fragment@NNN" but don't have
have a 'reg' property, amongst other differences from normal nodes.  Really
we should treat overlay fragments fundamentally differently, but for the
moment, suppress the common warnings about the fragment names with this
simple hack.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-03-06 14:45:50 +11:00
Rob Herring
aadd0b65c9 checks: centralize printing of property names in failure messages
Some failure messages apply to a specific property. Add a FAIL_PROP()
macro for failure messages which are specific to a property. With that,
failure messages can print the property name in a standard way. Once
source line numbers are supported, then the file and line number of the
property can be used instead of the node file and line number.

Convert the existing messages related to properties to use the FAIL_PROP
macro and reword the messages as necessary.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-02-10 12:09:12 +11:00
Rob Herring
88960e3989 checks: centralize printing of node path in check_msg
Most error/warning messages print the node path as part of their error
message. Move printing of the node path into check_msg() so the
formatting can be standardized to the form:

<output file>: (ERROR|warning) (<check name>): <full node name>: <check message>

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-02-09 17:53:02 +11:00
Rob Herring
c81d389a10 checks: add chosen node checks
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-15 13:26:57 +11:00
Rob Herring
e671852042 checks: add aliases node checks
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-13 21:28:11 +11:00
Rob Herring
d0c44ebe3f checks: check for #{size,address}-cells without child nodes
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-13 21:03:29 +11:00
Rob Herring
18a3d84bb8 checks: add string list check for *-names properties
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-13 20:27:36 +11:00
Rob Herring
8fe94fd6f1 checks: add string list check
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-13 20:22:56 +11:00
Rob Herring
6c57308196 checks: add a string check for 'label' property
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-13 20:18:30 +11:00