* [PATCH v2 1/2] dtc: dt-check-style: Narrow disallowing of tab in DTS only to YAML
@ 2026-07-06 10:24 Krzysztof Kozlowski
2026-07-06 10:24 ` [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS Krzysztof Kozlowski
0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-06 10:24 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, devicetree, linux-kernel
Cc: Krzysztof 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>
---
Changes in v2:
1. New patch
---
scripts/dtc/dt-check-style | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 2d5723d41ea3..34e0f7e2a57a 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -340,7 +340,7 @@ def check_trailing_whitespace(ctx):
yield (dl.lineno, 'trailing whitespace')
-def check_tab_in_dts(ctx):
+def check_tab_in_yaml_example(ctx):
"""Reject literal tabs in DTS lines when input is YAML.
For YAML examples, indent and content must use spaces. Tabs inside
@@ -929,7 +929,7 @@ RULES = [
check_trailing_whitespace),
Rule('tab-in-dts', 'relaxed',
'YAML examples may not contain tab characters',
- check_tab_in_dts, applies_to=('yaml',)),
+ check_tab_in_yaml_example, applies_to=('yaml',)),
Rule('mixed-indent-chars', 'relaxed',
'indent must not mix tabs and spaces',
check_mixed_indent_chars),
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS
2026-07-06 10:24 [PATCH v2 1/2] dtc: dt-check-style: Narrow disallowing of tab in DTS only to YAML Krzysztof Kozlowski
@ 2026-07-06 10:24 ` Krzysztof Kozlowski
2026-07-06 10:31 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-06 10:24 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, devicetree, linux-kernel
Cc: Krzysztof 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>
---
Changes in v2:
1. Rework idea.
2. Adjust function doc/comment.
v1: https://lore.kernel.org/all/20260706071446.87669-2-krzysztof.kozlowski@oss.qualcomm.com/
---
scripts/dtc/dt-check-style | 9 ++++++---
.../expected/yaml-mixed-indent.yaml.txt | 1 -
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 34e0f7e2a57a..e49b7446a2f7 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -359,14 +359,17 @@ def check_tab_in_yaml_example(ctx):
def check_mixed_indent_chars(ctx):
- """Indent must be all-spaces or all-tabs, never mixed on one line."""
+ """Indent must be all-tabs, except for aligning indentation (comments
+ or continued lines)."""
for dl in ctx.lines:
if not dl.indent_str:
continue
if dl.linetype == LineType.PREPROCESSOR:
continue
- if ' ' in dl.indent_str and '\t' in dl.indent_str:
+ if re.match(r' \t', dl.indent_str):
yield (dl.lineno, 'mixed tabs and spaces in indent')
+ if dl.indent_str.count(' ') > 7:
+ yield (dl.lineno, 'too many space characters in indent (more than 7)')
def detect_indent_unit(ctx):
@@ -932,7 +935,7 @@ RULES = [
check_tab_in_yaml_example, applies_to=('yaml',)),
Rule('mixed-indent-chars', 'relaxed',
'indent must not mix tabs and spaces',
- check_mixed_indent_chars),
+ check_mixed_indent_chars, applies_to=('dts', 'dtsi', 'dtso')),
Rule('unclosed-block-comment', 'relaxed',
'every /* block comment must close with */',
check_unclosed_block_comment),
diff --git a/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt b/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
index c989f8f19853..0089c62963f5 100644
--- a/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
+++ b/scripts/dtc/dt-style-selftest/expected/yaml-mixed-indent.yaml.txt
@@ -1,3 +1,2 @@
# mode=relaxed
-bad/yaml-mixed-indent.yaml:27: example 0 [mixed-indent-chars] mixed tabs and spaces in indent
bad/yaml-mixed-indent.yaml:27: example 0 [tab-in-dts] tab character not allowed in DTS example
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS
2026-07-06 10:24 ` [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS Krzysztof Kozlowski
@ 2026-07-06 10:31 ` sashiko-bot
2026-07-06 15:32 ` Krzysztof Kozlowski
0 siblings, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-07-06 10:31 UTC (permalink / raw)
To: Krzysztof Kozlowski; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The use of `re.match()` instead of `re.search()` or the `in` operator causes the script to only detect a space followed by a tab if it occurs at the very beginning of the indentation string.
--
commit b4c995f24f81e6a677f411361809325fa7fa3599
Author: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
dtc: dt-check-style: Allow space-aligning indentation in DTS
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).
> diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
> index 34e0f7e2a57a4..e49b7446a2f72 100755
> --- a/scripts/dtc/dt-check-style
> +++ b/scripts/dtc/dt-check-style
> @@ -359,14 +359,17 @@ def check_tab_in_yaml_example(ctx):
>
>
> def check_mixed_indent_chars(ctx):
> - """Indent must be all-spaces or all-tabs, never mixed on one line."""
> + """Indent must be all-tabs, except for aligning indentation (comments
> + or continued lines)."""
> for dl in ctx.lines:
> if not dl.indent_str:
> continue
> if dl.linetype == LineType.PREPROCESSOR:
> continue
> - if ' ' in dl.indent_str and '\t' in dl.indent_str:
> + if re.match(r' \t', dl.indent_str):
[Severity: Low]
Because Python's re.match() enforces an implicit string-start anchor, does
this condition in check_mixed_indent_chars() fail to detect mixed
indentation if a space precedes a tab but doesn't occur at the very
beginning of the line?
For example, an indentation sequence like tab-space-tab would be ignored.
Would re.search() or checking ' \t' in dl.indent_str be more effective here?
> yield (dl.lineno, 'mixed tabs and spaces in indent')
> + if dl.indent_str.count(' ') > 7:
> + yield (dl.lineno, 'too many space characters in indent (more than 7)')
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706102421.343639-3-krzysztof.kozlowski@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS
2026-07-06 10:31 ` sashiko-bot
@ 2026-07-06 15:32 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-06 15:32 UTC (permalink / raw)
To: sashiko-reviews; +Cc: robh, conor+dt, devicetree
On 06/07/2026 12:31, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] The use of `re.match()` instead of `re.search()` or the `in` operator causes the script to only detect a space followed by a tab if it occurs at the very beginning of the indentation string.
> --
Ack. I have also few more fixes, so v3.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-06 15:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 10:24 [PATCH v2 1/2] dtc: dt-check-style: Narrow disallowing of tab in DTS only to YAML Krzysztof Kozlowski
2026-07-06 10:24 ` [PATCH v2 2/2] dtc: dt-check-style: Allow space-aligning indentation in DTS Krzysztof Kozlowski
2026-07-06 10:31 ` sashiko-bot
2026-07-06 15:32 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox