summaryrefslogtreecommitdiff
path: root/scripts/dtc
AgeCommit message (Collapse)Author
2026-09-16dtc: dt-check-style: Handle multiple blank lines in continued propertiesKrzysztof Kozlowski
Properly ignore comments and report duplicated blank lines in multi-line properties. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260911-dts-style-checker-blank-lines-v1-2-85e779600d98@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Re-work classifying property continuationsKrzysztof Kozlowski
Script has an enumeration of DTS Line types (LineType) and one type is a continuation of multi-line property. This has limitations, because it basically hides true type of a continued line which makes certain checks difficult. For example detecting consecutive blank lines (LineType.BLANK) will fail if the type is continuation. clock-names = "foo", /* Comment */ "bar"; Above code not only fails check_blank_lines() rule, but also messes up how DtsLine array is constructed - the two middle continued lines are not put under the DtsLine.continuations array. The concepts of type of line (blank, preprocessor, property etc) and actual continuation are orthogonal to most of the checks - the checks need to know what sort of continued line it is. Fixing this solves false positives of continued properties with blank lines and comments: arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi:135: [blank-lines] consecutive blank lines arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi:135: [blank-lines] blank line at end of node body Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260911-dts-style-checker-blank-lines-v1-1-85e779600d98@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Relax property ordering rules (drop alphabetical)Krzysztof Kozlowski
Existing rules checked whether properties follow DTS Coding Style guidelines in respect of common properties and standard vs vendor properties, plus additionally it enforced alphabetical order within each of such group. The in-tree DTS does not follow such style at all, so this lead to many warnings. There is little value in fixing these warnings, because DTS with non-alphabetical order of properties is exactly the same readable, even though DTS Coding Style mentions natural order. Actually groupping properties logically, e.g. all supplies together regardless of their name, is more readable than pure natural sort. Relax the property order rules to the most important aspects (device_type, reg/reg-names, ranges, standard properties, vendor properties, status) and skip the alphabetical sorting completely. Assisted-by: LLM Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-7-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Properly detect comments in multi-line propertiesKrzysztof Kozlowski
Code classifying given line exits on first condition match, thus a line consisting only of a comment in a continued (multi-line) property, like: interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, /* Performance counter interrupts */ <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>; was treated as a comment-line line, not as continuation, leading to false positive warnings of invalid indentation: arch/arm64/boot/dts/tesla/fsd.dtsi:456: [indent-consistent] indent mismatch (expected depth 3 * '\t') This needs two related fixes: 1. Move the judgment as a LineType.CONTINUATION earlier before one classifying as a comment 2. Check the comment-stripped DtsLine.code, not DtsLine.stripped, to verify if it is a continuation. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-6-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Right strip whitespaces, leftovers before commentsKrzysztof Kozlowski
Stripping a comment from a line to get the code leads trailing whitespace (e.g. in a line like "enable-active-high; /* comment */") which will break DtsLine.code.endswith() checks. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-5-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Unduplicate checks in check_mixed_indent_chars()Krzysztof Kozlowski
Code checking each DtsLine and continuations is the same, so split it to separate function to avoid duplicated code. This has a positive side effect - if DtsLine did not have indentation, then check continued to next one, but now it will still go through the continued lines in the second loop. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-4-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Handle continued lines in check_trailing_whitespace()Krzysztof Kozlowski
Continued lines are not separate DtsLine items in ctx.lines, so they need own iteration. Rule for trailing white-space is applicable to continued values as well. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-3-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Handle continued lines in check_line_length()Krzysztof Kozlowski
Continued lines are not separate DtsLine items in ctx.lines, so they need own iteration. Rule for length of line is applicable to continued values as well. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-2-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-09-16dtc: dt-check-style: Handle continued lines in check_hex_case()Krzysztof Kozlowski
Continued lines are not separate DtsLine items in ctx.lines, so they need own iteration. Rule for hex case is applicable to continued values as well. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260915-b4-dts-style-checker-continued-lines-v4-1-5b8e09b11ef2@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Check for indentation also in continued lines of ↵Krzysztof Kozlowski
bindings example Add missing code in check_tab_in_yaml_example() for example in the bindings to apply the same rule of discouraged tab character also for continued lines (iterating over all DtsLines is not enough). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-6-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Check for indentation also in continued lines of DTSKrzysztof Kozlowski
Add missing code in check_mixed_indent_chars() for DTS to apply the same rule of too many spaces for indentation also for continued lines (iterating over all DtsLines is not enough). Reported-by: sashiko-bot@kernel.org Closes: https://lore.kernel.org/all/20260709180118.6935B1F000E9@smtp.kernel.org/ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-5-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Add test for node and property name stylesKrzysztof Kozlowski
Common style violation is usage of underscores in node or property names, so add rules for following recommended names. There is plenty of legacy approach, so add the rules only for 'strict' mode of checking. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-4-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Process property names with a question markKrzysztof Kozlowski
Devicetree spec allows question mark '?' in property names and such code is also accepted by DTC, thus catch such properties as a valid code, even if discouraged. Otherwise certain rules checking for property names would ignore that line. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-3-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Sort rule functions by nameKrzysztof Kozlowski
Sort all the functions implementing style rules by name, so managing this will be at bit easier and simultaneous addons of new rules less conflict-prone. No functional changes, except adding underscore to _detect_indent_unit() to match other helpers used by the rules. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-2-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Sort rule directory by nameKrzysztof Kozlowski
Sort the array with all the rules, so managing this will be at bit easier and simultaneous addons of new rules less conflict-prone. No functional changes. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260829-dts-style-checker-sort-v1-1-6693a37d7ae1@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Add warning for redundant white-spacesKrzysztof Kozlowski
Show warnings of too many spaces around '=', after ':', before '{' and ';' characters, or using tabs for these. Both in-tree DTS and DT bindings have many warnings for the first case (too mant spaces around '='), thus keep this one only for 'strict' mode. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-9-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Add test for trailing white-space in DTSKrzysztof Kozlowski
Add unit tests for expected warnings for trailing white-spaces in DTS (there is only one for YAML files). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-8-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Call _strip_strings_and_comments() only onceKrzysztof Kozlowski
More than one rule evaluates pure code - stripped from comments and indentation - thus store this pure code in DtsLine class for better performance. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-7-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Replace Test User email with Rob HerringKrzysztof Kozlowski
scripts/get_maintainer.pl reports email from the example binding fixtures, so let's spare someone at @example.com from receiving bunch of odd emails. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-6-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Introduce 'stricter' modeKrzysztof Kozlowski
Two rules, which are enabled in 'strict' mode make little sense for DTS: 1. line-length, limiting length of line to 80 characters: DTS often has a bit longer lines, especially for interconnects or heavily nested opp-level. Checkpatch already does not warn for exceeding 80 characters. 2. unused-labels, discouraging unused labels in DTS or YAML (not DTSI or DTSO): while not harming this leads to many false positives, e.g. unused PMIC regulators in DTS. Introduce another 'mode' of running beside existing relaxed and strict: a 'stricter' one where these two rules are moved for DTS. Intention is to have in-tree DTS passing 'strict' mode. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-5-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Consistently call 'kind' as 'file_type'Krzysztof Kozlowski
Script was using different names for variables or attributes with the same meaning: the type of file (YAML, DTS, DTSI, DTSO). Unify 'kind', 'input_kind' and function input_kind() to consistent 'file_type'. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-4-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Fix alignment of values in continued property linesKrzysztof Kozlowski
Continued lines in property assignments should be indented to opening '<' or '"' if they also start with that character, e.g.: reg = <0x1000 0x100>, <0x2000 0x100>; If the continued line is part of previous phandle, then alignment should be to inner values to make it more readable, e.g.: reg = <0x1000 0x100 0x2000 0x100>; Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-3-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Drop stray backslash before quote for ↵Krzysztof Kozlowski
continuation-alignment Drop stray backslash before the quote character in a warning for continuation-alignment rule: (under "<" or \"). Since the '"' character has no quotes, drop the quotes also from '<'. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-2-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-31dtc: dt-check-style: Handle sorting of top-level nodes and propertiesKrzysztof Kozlowski
Top-level DTS (but not example in the bindings) has only two nodes with unit-addresses: memory@ and soc@. There are two special cases here, in terms of coding style: 1. The unit-address of memory is often not known thus set to @0, because it is filled up by bootloader. 2. There is mixture of non-unit-address and unit-address nodes. Therefore usually the DTS chooses for the top-level part sorting by the node name, not the unit address. Also the properties have one exception: 'model' property is supposed to be before the 'compatible'. This cannot be applied to the entire DTS, because sound cards have also 'model' where it is supposed to follow standard rules (after the 'compatible'). Root node is just special. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260826-n-dts-style-checker-continued-v6-1-f270b1e81f8e@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-14dtc: dt-check-style: Simplify setting depth of DtsLineKrzysztof Kozlowski
When creating new DtsLine object, pass expected indentation depth as constructor, instead of assigning it immediately after, so the code will be easier to read and explicit (depth is not supposed to change during DtsLine lifetime). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260803-n-dts-style-checker-continued-v3-2-6c9776928cea@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-08-14dtc: dt-check-style: Add missing /dts-v1/ to few test casesKrzysztof Kozlowski
The selftest DTS should still look like a real DTS, so it needs '/dts-v1/' marking. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260803-n-dts-style-checker-continued-v3-1-6c9776928cea@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Add more DTS test casesKrzysztof Kozlowski
Add a few more test cases for valid and incorrect DTS for dt-check-style. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-7-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Print proper line number of indentation detection placeKrzysztof Kozlowski
Script judges the indentation however always suggests it is the first line which is wrong, e.g.: sigmastar/mstar-infinity2m.dtsi:1: [indent-unit-dts] indent unit must be 1 tab in DTS, got '\t\t' Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-6-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Handle properly DTC-style includesKrzysztof Kozlowski
dt-check-style was not properly handling DTC directives (starting with '/', e.g. /dts-v1/ or /include/), thus a few DTS files had false positive like: apm/apm-merlin.dts:1: [indent-unit-dts] indent unit must be 1 tab in DTS, got '\t\t' Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-5-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Expect first device_typeKrzysztof Kozlowski
A few nodes do have "device_type" property which is mostly, but not always, the first property in a device node, when applicable. Adjust the DTS coding style rules to actually expect the device_type first and improve the dt-check-style to handle this correctly. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-4-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Rework handling YAML/DTS in rulesKrzysztof Kozlowski
Individual rules behave differently depending whether they handle bindings (YAML) or DTS, but the code was focusing on type of indentation (spaces vs tabs). That indentation is actually irrelevant in some rules, so differentiate based on file type. This will be more relevant in the future when more rules act differently on DTS, than on bindings. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-3-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Allow space-aligning indentation in DTSKrzysztof Kozlowski
DTS often have spaces after tabs in indentation for aligning continued lines of comments or list properties, thus allow such cases to avoid many false positives. What we can easily detect is a space followed by tab or too many spaces (more than alignment). OTOH, DTS example in YAML files does not have tabs at all and there is already rule for that, thus there is no point to check for mixed indentation there. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-2-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-07-20dtc: dt-check-style: Narrow disallowing of tab in DTS only to YAMLKrzysztof Kozlowski
DTS in the bindings (example in a YAML file) does not have tabs at all, but regular DTS do, therefore entire check check_tab_in_dts() has confusing name and should apply only to YAML files. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260709-dts-style-checker-v5-1-fcc147cb697d@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-06-10dt-bindings: add self-test fixtures for style checkerDaniel Golle
Provide good/ and bad/ DTS and YAML fixtures plus a small runner that feeds them to dt-check-style and diffs the output against expected text files. Wired into a new top-level dt_style_selftest make target so the suite can be exercised independently of the full tree. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Link: https://patch.msgid.link/80fec5d2cfcdee0f9c5e2d4921ebbd4115d392b7.1779908995.git.daniel@makrotopia.org Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-06-10dt-bindings: add DTS style checkerDaniel Golle
Add a Python tool that checks DTS coding style on examples in YAML binding files and on .dts/.dtsi/.dtso source files. Rules are kept in a small declarative registry, each tagged 'relaxed' (default; must be zero-violation on the current tree) or 'strict' (opt-in for new submissions). Promoting a rule from strict to relaxed is a one-line edit once the tree is clean. Relaxed mode covers trailing whitespace, tab characters in YAML examples, mixed tab+space indents, and missing tabs in .dts files. Strict adds indent unit and consistency checks, blank-line placement, sibling address ordering, "compatible" and "reg" ordering, and unused labels. The tool reads file paths from @argfile and parallelises across CPUs via -j N. With no -j given it picks up $PARALLELISM (set by scripts/jobserver-exec from the GNU make jobserver) and falls back to os.cpu_count() otherwise. Running as one Python invocation amortises the ruamel.yaml import across the whole tree -- ~2s on a 32-CPU host vs ~28s sequential. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/224923f3d1c73ff55cebb3e0796f119e32c1bb43.1779908995.git.daniel@makrotopia.org Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-04-07scripts/dtc: Update to upstream version v1.7.2-69-g53373d135579Rob Herring (Arm)
This adds the following commits from upstream: 53373d135579 dtc: Remove unused dts_version in dtc-lexer.l caf7465c5d60 libfdt: fdt_check_full: Handle FDT_NOP when FDT_END is expected 5976c4a66098 libfdt: fdt_rw: Introduce fdt_downgrade_version() 5bb5bedd347d fdtdump: Return an error code on wrong tag value 68b960e299f7 fdtdump: Remove dtb version check adba02caf554 dtc: Use a consistent type for basenamelen 8d15a63e84ff libfdt: Verify alignment of sub-blocks in dtb Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-02-03of: Add for_each_compatible_node_scoped() helperKrzysztof Kozlowski
Just like looping through children and available children, add a scoped helper for for_each_compatible_node() so error paths can drop of_node_put() leading to simpler code. Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20260109-of-for-each-compatible-scoped-v3-1-c22fa2c0749a@oss.qualcomm.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2026-02-03scripts/dtc: Update to upstream version v1.7.2-62-ga26ef6400bd8Rob Herring (Arm)
This adds the following commits from upstream: a26ef6400bd8 Restore phandle references from __fixups__ node 05c524db44ff Restore phandle references from __local_fixups__ node db65a3a3f4f0 Restore labels from __symbols__ node 64330c682cac Improve type guessing when compiling to dts format cbb48690c697 Set DTSF_PLUGIN if needed when compiling from dtb ef3b1baf6370 Emit /plugin/ when compiling to .dts with DTSF_PLUGIN set 7c78c8542d73 Added empty node name check 14dd76b96732 fdtdump: Change FDT_PROP prob handling to ease future addition 9a1c801a1a3c Fix discarded const qualifiers 194ac9422ac9 libfdt: fdt_get_name: Add can_assume(VALID_DTB) check 39cae0bd0031 libfdt: Improve size savings in FDT_RO_PROBE slightly b12692473298 libfdt: libfdt_internal.h correct final comment in ASSUME block 7f3184a6c550 libfdt: Remove old MacOS strnlen workaround 9197f1ccd95c checks: Do not check overlays for alias paths e1284ee5dc20 livetree: Add only new data to fixup nodes instead of complete regeneration cba90ce82064 checks: Remove check for graph child addresses 763c6ab4189c livetree: Simplify append_to_property() 739403f22242 libfdt: Drop including string.h from libfdt_internal.h 1c6c51e51b29 Consider drive letters when checking for absolute paths on Windows. 617f3d9b60f7 ci: Add Cirrus CI configuration for FreeBSD testing 04f948e83fef ci: Add GitLab CI configuration for Linux builds e89680263137 ci: Tweaks to GitHub Actions setup 2ad738722b79 build: Add FreeBSD and non-GNU linker compatibility 4132ac08ba95 libfdt: Document most remaining functions 33e66ec845b8 tests: Add compatibility with uutils a0dd7b608102 fdtput: Use strtol() in preference to sscanf() 5b71660724d7 tests: Work around limitation in FreeBSD's printf(1) The graph_child_address check has been removed from upstream. Drop it from the makefiles. Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2025-09-26scripts: dt_to_config: fix grammar and a typo in --help textMarkus Heidelberg
- grammar: singular/plural inconsistency - typo: "of" -> "or" Signed-off-by: Markus Heidelberg <m.heidelberg@cab.de> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2025-08-11scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47cRob Herring (Arm)
This adds the following commits from upstream: 52f07dcca47c dtc: Add informative error for stray identifier 9cabae6b0351 checks: Fix detection of 'i2c-bus' node 605dc044c3fe New helper to add markers 7da5d106c740 fdtput: Fix documentation about existing nodes 53c63dd421d7 dtdiff: Use input format dtb for dtbo files 84d9dd2fcbc8 dtc: Add data_insert_data function 97011d1f4e98 meson: use override_find_program/override_dependency b841391bbd08 srcpos: Define srcpos_free e0b7749c26a9 Add alloc_marker ecb21febfdd3 meson: port python bindings to build natively via meson and meson-python 7ebfcac8520e Makefile: deprecate in favor of Meson f4c53f4ebf78 Use __ASSEMBLER__ instead of __ASSEMBLY__ 205fbef17b7b Fix some typos da85f91931e5 Remove duplicated words in documentation and comments dd1b3e532d22 meson: support building libfdt without static library 1ccd232709d4 meson: don't build test programs by default ce1d8588880a tests: When building .so from -O asm output mark as non-executable stack 915daadbb62d Start with empty __local_fixups__ and __fixups__ nodes 4ea851f5a44d Let get_subnode() not return deleted nodes 175d2a564c47 Use build_root_node() instead of open-coding it 18f4f305fdd7 build: fix -Dtools=false build 267efc7d4694 checks: Warn about missing #address-cells for interrupt parents 755db115355b libfdt: Add fdt_setprop_namelen_string() bdca8612009e libfdt: Add fdt_setprop_namelen() 0f69cedc08fc libfdt_internal: fdt_find_string_len_() 56b2b30c5bd0 libfdt: add fdt_get_property_namelen_w() 1e8c5f60e127 Add clang-format config 6f183c7d9246 checks: Relax avoid_unnecessary_addr_size check to allow child ranges properties 66c7d0e6f4f3 tests/sw_tree1.c: fix unitialized saveptr 9a969f3b70b0 pylibfdt/libfdt.i: fix backwards compatibility of return values 4292b072a23a .github/workflows: update ubuntu runner to supported version 1c745a9bd169 libfdt: Remove fdt parameter from overlay_fixup_one_phandle b3bbee6b1242 libfdt: Move the SBOM authors section d1656730abfb Add a SBOM file in CycloneDX format b75515af4576 libfdt: Remove extra semi-colons outside functions 2d10aa2afe35 Bump version to v1.7.2 48795c82bdb6 pylibfdt: Don't emit warnings from swig generate C code 838f11e830e3 fdtoverlay: provide better error message for missing `/__symbols__` d1e2384185c5 pylibfdt/libfdt.i: Use SWIG_AppendOutput 18aa49a9f68d Escape spaces in depfile with backslashes. f9968fa06921 libfdt.h: whitespace consistency fixups 9b5f65fb3d8d libfdt.h: typo and consistency fixes 99031e3a4a6e Bump version to v1.7.1 3d5e376925fd setup: Move setting of srcdir down to the bottom e277553b9880 setup: Collect top-level code together 7e5a88984081 setup: Move version and full_description into a function 78b6a85c113b Tidy up some pylint warnings 3501d373f0a2 Require Python 3 The added include of string.h in libfdt_internal.h breaks the kernel overriding libfdt_env.h with its own string functions, so it is dropped. An upstream fix is pending. Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2024-09-05dt: dt-extract-compatibles: Extract compatibles from function parametersRob Herring (Arm)
Various DT and fwnode functions take a compatible string as a parameter. These are often used in cases which don't have a driver, so they've been missed. The additional checks add about 400 more undocumented compatible strings. Link: https://lore.kernel.org/all/20240903200753.2097911-1-robh@kernel.org/ Acked-by: Saravana Kannan <saravanak@google.com> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2024-08-15scripts/dtc: Update to upstream version v1.7.0-95-gbcd02b523429Rob Herring (Arm)
Some pending overlay additions need the graph check fix. This adds the following commits from upstream: bcd02b523429 fdtoverlay: remove wrong singular article in a comment 84b056a89d3c checks: relax graph checks for overlays Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2024-07-17Merge tag 'devicetree-for-6.11' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "DT Bindings: - Convert and add a bunch of IBM FSI related bindings - Add a new schema listing legacy compatibles which will (probably) never be documented. This will silence various checks warning about them. - Add bindings for Sierra Wireless mangOH Green SPI IoT interface, new Arm 2024 Cortex and Neoverse CPUs, QCom sc8180x PDC, QCom SDX75 GPI DMA, imx8mp/imx8qxp fsl,irqsteer, and Renesas RZ/G2UL CRU and CSI-2 blocks - Convert Spreadtrum sprd-timer, FSL cpm_qe, FSL fsl,ls-scfg-msi, FSL q(b)man-*, FSL qoriq-mc, and img,pdc-wdt bindings to DT schema - Drop obsolete stericsson,abx500.txt DT core: - Update dtc to upstream version v1.7.0-93-g1df7b047fe43 - Add support to run DT validation on DTs with applied overlays - Add helper for creating boolean properties in dynamic nodes and use that for dynamic PCI nodes - Clean-up early parsing of '#{address,size}-cells'" * tag 'devicetree-for-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (39 commits) dt-bindings: timer: sprd-timer: convert to YAML dt-bindings: incomplete-devices: document devices without bindings dt-bindings: trivial-devices: document the Sierra Wireless mangOH Green SPI IoT interface scripts/dtc: Update to upstream version v1.7.0-93-g1df7b047fe43 dt-bindings: soc: fsl: Add fsl,ls1028a-reset for reset syscon node dt-bindings: soc: fsl: cpm_qe: convert to yaml format dt-bindings: i2c: i2c-fsi: Convert to json-schema dt-bindings: fsi: Document the FSI Hub Controller dt-bindings: fsi: Document the AST2700 FSI controller dt-bindings: fsi: ast2600-fsi-master: Convert to json-schema dt-bindings: fsi: ibm,i2cr-fsi-master: Reference common FSI controller dt-bindings: fsi: Document the FSI controller common properties dt-bindings: fsi: Document the IBM SBEFIFO engine dt-bindings: fsi: p9-occ: Convert to json-schema dt-bindings: fsi: Document the IBM SCOM engine dt-bindings: fsi: fsi2spi: Document SPI controller child nodes dt-bindings: interrupt-controller: convert fsl,ls-scfg-msi to yaml dt-bindings: soc: fsl: Convert q(b)man-* to yaml format dt-bindings: misc: fsl,qoriq-mc: convert to yaml format dt-bindings: drop stale Anson Huang from maintainers ...
2024-07-09scripts/dtc: Update to upstream version v1.7.0-93-g1df7b047fe43Rob Herring (Arm)
This adds the following commits from upstream: 1df7b047fe43 pylibfdt/Makefile.pylibfdt: use project's flags to compile the extension 61e88fdcec52 libfdt: overlay: Fix phandle overwrite check for new subtrees 49d30894466e meson: fix installation with meson-python d54aaf93673c pylibfdt: clean up python build directory ab86f1e9fda8 pylibfdt: add VERSION.txt to Python sdist 7b8a30eceabe pylibfdt: fix Python version ff4f17eb5865 pylibfdt/Makefile.pylibfdt: fix Python library being rebuild during install 9e313b14e684 pylibfdt/meson.build: fix Python library being rebuilt during install d598fc3648ec tests/run_tests.sh: fix Meson library path being dropped b98239da2f18 tests/meson.build: fix python and yaml tests not running c17d76ab5e84 checks: Check the overall length of "interrupt-map" ae26223a056e libfdt: overlay: Refactor overlay_fixup_phandle 4dd831affd01 libfdt: tests: Update test case for overlay_bad_fixup e6d294200837 tests: Remove two_roots and named_root from LIBTREE_TESTS_L and add all dtb filenames generated by dumptrees to TESTS_TREES_L in Makefile.tests 855c934e26ae tests: fix tests broken under Meson 4fd3f4f0a95d github: enforce testing pylibfdt and yaml support 9ca7d62dbf0b meson: split run-tests by type bb51223083a4 meson: fix dependencies of tests e81900635c95 meson: fix pylibfdt missing dependency on libfdt 822123856980 pylibfdt: fix get_mem_rsv for newer Python versions 1fad065080e6 libfdt: overlay: ensure that existing phandles are not overwritten b0aacd0a7735 github: add windows/msys CI build ae97d9745862 github: Don't accidentally suppress test errors 057a7dbbb777 github: Display meson test logs on failure 92b5d4e91678 pylibfdt: Remove some apparently deprecated options from setup.py 417e3299dbd1 github: Update to newer checkout action 5e6cefa17e2d fix MinGW format attribute 24f60011fd43 libfdt: Simplify adjustment of values for local fixups da39ee0e68b6 libfdt: rework shared/static libraries a669223f7a60 Makefile: do not hardcode the `install` program path 3fbfdd08afd2 libfdt: fix duplicate meson target dcef5f834ea3 tests: use correct pkg-config when cross compiling 0b8026ff254f meson: allow building from shallow clones 95c74d71f090 treesource: Restore string list output when no type markers 2283dd78eff5 libfdt: fdt_path_offset_namelen: Reject empty path 79b9e326a162 libfdt: fdt_get_alias_namelen: Validate aliases 52157f13ef3d pylibfdt: Support boolean properties d77433727566 dtc: fix missing string in usage_opts_help ad8bf9f9aa39 libfdt: Fix fdt_appendprop_addrrange documentation 6c5e189fb952 github: add workflow for Meson builds a3dc9f006a78 libfdt: rename libfdt-X.Y.Z.so to libfdt.so.X.Y.Z 35019949c4c7 workflows: build: remove setuptools_scm hack cd3e2304f4a9 pylibfdt: use fallback version in tarballs 0f5864567745 move release version into VERSION.txt 38165954c13b libfdt: add missing version symbols 5e98b5979354 editorconfig: use tab indentation for version.lds d030a893be25 tests: generate dtbs in Meson build directory 8d8372b13706 tests: fix use of deprecated meson methods 761114effaf7 pylibtfdt: fix use of deprecated meson method bf6377a98d97 meson: set minimum Meson version to 0.56.0 4c68e4b16b22 libfdt: fix library version to match project version bdc5c8793a13 meson: allow disabling tests f088e381f29e Makefile: allow to install libfdt without building executables 6df5328a902c Fix use of <ctype.h> functions ccf1f62d59ad libfdt: Fix a typo in libfdt.h 71a8b8ef0adf libfdt: meson: Fix linking on macOS linker 589d8c7653c7 dtc: Add an option to generate __local_fixups__ and __fixups__ e8364666d5ac CI: Add build matrix with multiple Linux distributions 3b02a94b486f dtc: Correct invalid dts output with mixed phandles and integers d4888958d64b tests: Add additional tests for device graph checks ea3b9a1d2c5a checks: Fix crash in graph_child_address if 'reg' cell size != 1 b2b9671583e9 livetree: fix off-by-one in propval_cell_n() bounds check ab481e483061 Add definition for a GitHub Actions CI job c88038c9b8ca Drop obsolete/broken CI definitions 0ac8b30ba5a1 yaml: Depend on libyaml >= 0.2.3 f1657b2fb5be tests: Add test cases for bad endpoint node and remote-endpoint prop checks 44bb89cafd3d checks: Fix segmentation fault in check_graph_node 60bcf1cde1a8 improve documentation for fdt_path_offset() a6f997bc77d4 add fdt_get_symbol() and fdt_get_symbol_namelen() functions 18f5ec12a10e use fdt_path_getprop_namelen() in fdt_get_alias_namelen() df093279282c add fdt_path_getprop_namelen() helper 129bb4b78bc6 doc: dt-object-internal: Fix a typo 390f481521c3 fdtoverlay: Drop a a repeated article 9f8b382ed45e manual: Fix and improve documentation about -@ 2cdf93a6d402 fdtoverlay: Fix usage string to not mention "<type>" 72fc810c3025 build-sys: add -Wwrite-strings 083ab26da83b tests: fix leaks spotted by ASAN 6f8b28f49609 livetree: fix leak spotted by ASAN fd68bb8c5658 Make name_node() xstrdup its name argument 4718189c4ca8 Delay xstrdup() of node and property names coming from a flat tree 0b842c3c8199 Make build_property() xstrdup its name argument 9cceabea1ee0 checks: correct I2C 10-bit address check 0d56145938fe yamltree.c: fix -Werror=discarded-qualifiers & -Werror=cast-qual 61fa22b05f69 checks: make check.data const 7a1d72a788e0 checks.c: fix check_msg() leak ee5799938697 checks.c: fix heap-buffer-overflow 44c9b73801c1 tests: fix -Wwrite-strings 5b60f5104fcc srcpos.c: fix -Wwrite-strings 32174a66efa4 meson: Fix cell overflow tests when running from meson 64a907f08b9b meson.build: bump version to 1.7.0 e3cde0613bfd Add -Wsuggest-attribute=format warning, correct warnings thus generated 41821821101a Use #ifdef NO_VALGRIND 71c19f20b3ef Do not redefine _GNU_SOURCE if already set 039a99414e77 Bump version to v1.7.0 9b62ec84bb2d Merge remote-tracking branch 'gitlab/main' 3f29d6d85c24 pylibfdt: add size_hint parameter for get_path 2022bb10879d checks: Update #{size,address}-cells check for 'dma-ranges' Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2024-05-30dt-bindings: kbuild: Fix dt_binding_check on unconfigured buildRob Herring (Arm)
The 'dt_binding_check' target shouldn't depend on the kernel configuration, but it has since commit 604a57ba9781 ("dt-bindings: kbuild: Add separate target/dependency for processed-schema.json"). That is because CHECK_DT_BINDING make variable was dropped, but scripts/dtc/Makefile was missed. The CHECK_DTBS variable can be used instead. Reported-by: Francesco Dolcini <francesco.dolcini@toradex.com> Fixes: 604a57ba9781 ("dt-bindings: kbuild: Add separate target/dependency for processed-schema.json") Signed-off-by: "Rob Herring (Arm)" <robh@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-05-10kbuild: use $(src) instead of $(srctree)/$(src) for source directoryMasahiro Yamada
Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for checked-in source files. It is merely a convention without any functional difference. In fact, $(obj) and $(src) are exactly the same, as defined in scripts/Makefile.build: src := $(obj) When the kernel is built in a separate output directory, $(src) does not accurately reflect the source directory location. While Kbuild resolves this discrepancy by specifying VPATH=$(srctree) to search for source files, it does not cover all cases. For example, when adding a header search path for local headers, -I$(srctree)/$(src) is typically passed to the compiler. This introduces inconsistency between upstream and downstream Makefiles because $(src) is used instead of $(srctree)/$(src) for the latter. To address this inconsistency, this commit changes the semantics of $(src) so that it always points to the directory in the source tree. Going forward, the variables used in Makefiles will have the following meanings: $(obj) - directory in the object tree $(src) - directory in the source tree (changed by this commit) $(objtree) - the top of the kernel object tree $(srctree) - the top of the kernel source tree Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced with $(src). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2023-11-09dt: dt-extract-compatibles: Don't follow symlinks when walking treeNícolas F. R. A. Prado
The iglob function, which we use to find C source files in the kernel tree, always follows symbolic links. This can cause unintentional recursions whenever a symbolic link points to a parent directory. A common scenario is building the kernel with the output set to a directory inside the kernel tree, which will contain such a symlink. Instead of using the iglob function, use os.walk to traverse the directory tree, which by default doesn't follow symbolic links. fnmatch is then used to match the glob on the filename, as well as ignore hidden files (which were ignored by default with iglob). This approach runs just as fast as using iglob. Fixes: b6acf8073517 ("dt: Add a check for undocumented compatible strings in kernel") Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com> Closes: https://lore.kernel.org/all/e90cb52f-d55b-d3ba-3933-6cc7b43fcfbc@arm.com Signed-off-by: "Nícolas F. R. A. Prado" <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20231107225624.9811-1-nfraprado@collabora.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-09-20dt: dt-extract-compatibles: Add flag for driver matching compatiblesNícolas F. R. A. Prado
Add a new flag, '--driver-match', to the dt-extract-compatibles script that causes it to only print out compatibles that are expected to match a driver. This output can then be used by tests to detect device probe failures. In order to filter the compatibles down to only ones that will match to a driver, the following is considered: - A compatible needs to show up in a driver's of_match_table for it to be matched to a driver - Compatibles that are used in both of_match_table and OF_DECLARE type macros can't be expected to match to a driver and so are ignored. One exception is CLK_OF_DECLARE_DRIVER, since it indicates that a driver will also later probe, so compatibles in this macro are not ignored. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230828211424.2964562-3-nfraprado@collabora.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-09-20dt: dt-extract-compatibles: Handle cfile arguments in generator functionNícolas F. R. A. Prado
Move the handling of the cfile arguments to a separate generator function to avoid redundancy. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230828211424.2964562-2-nfraprado@collabora.com Signed-off-by: Rob Herring <robh@kernel.org>
2023-08-17dt: dt-check-compatible: Find struct of_device_id instances with compiler ↵Rob Herring
annotations The regex search for declarations of struct of_device_id was missing cases that had a compiler annotation such as "__maybe_unused". Improve the regex to allow for these. Use '\S' instead of specific characters to shorten the regex. That also finds some more compatibles using '.' characters. Unfortunately, these changes add ~400 more compatibles without a schema. Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230804190130.1936566-1-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>