[PATCH 7/9] dtc: dt-check-style: Consistently call 'kind' as 'file_type'
From: Krzysztof Kozlowski
Date: Sun Jul 26 2026 - 11:52:00 EST
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@xxxxxxxxxxxxxxxx>
---
scripts/dtc/dt-check-style | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index 171a5e12fcbd..8c049c04b865 100755
--- a/scripts/dtc/dt-check-style
+++ b/scripts/dtc/dt-check-style
@@ -314,13 +314,13 @@ def collect_labels_and_refs(text):
class Ctx:
"""Context passed to each rule check. Carries the parsed lines,
- raw text, mode and kind."""
+ raw text, mode and file_type."""
- def __init__(self, lines, text, mode, kind):
+ def __init__(self, lines, text, mode, file_type):
self.lines = lines
self.text = text
self.mode = mode # 'relaxed' or 'strict'
- if kind in DTS_FAMILY:
+ if file_type in DTS_FAMILY:
self.file_type = 'dts'
else:
self.file_type = 'yaml'
@@ -519,7 +519,7 @@ def _walk_bodies(lines):
def _natural_sort_key(s):
- """Split a string into a tuple of (kind, value) pairs that compares
+ """Split a string into a tuple of (file_type, value) pairs that compares
numeric runs as ints, so 'foo10' sorts after 'foo2'."""
parts = []
for part in re.split(r'(\d+)', s):
@@ -1053,14 +1053,14 @@ RULES = [
]
-def select_rules(mode, input_kind):
+def select_rules(mode, file_type):
"""Return rules that apply to the given mode and input type."""
rank = {'relaxed': 0, 'strict': 1}
out = []
for r in RULES:
if rank[r.mode] > rank[mode]:
continue
- if input_kind not in r.applies_to:
+ if file_type not in r.applies_to:
continue
out.append(r)
return out
@@ -1132,7 +1132,7 @@ def iter_dts_file(filepath):
# Top-level processing
# ---------------------------------------------------------------------------
-def input_kind(filepath):
+def get_file_type(filepath):
p = filepath.lower()
if p.endswith('.yaml') or p.endswith('.yml'):
return 'yaml'
@@ -1152,17 +1152,17 @@ DTS_FAMILY = ('dts', 'dtsi', 'dtso')
def collect_findings(filepath, mode):
"""Return a (lines, count) pair for filepath. lines is a list of
formatted output strings; count is the number of findings."""
- kind = input_kind(filepath)
- if kind == 'yaml':
+ file_type = get_file_type(filepath)
+ if file_type == 'yaml':
iterator = iter_yaml_examples(filepath)
- elif kind in DTS_FAMILY:
+ elif file_type in DTS_FAMILY:
iterator = iter_dts_file(filepath)
else:
return (['%s: unknown file type, skipping' % filepath], 0)
out = []
for text, base, idx in iterator:
- for lineno, rule, msg in check_block(text, mode, kind):
+ for lineno, rule, msg in check_block(text, mode, file_type):
abs_line = base + lineno - 1
ex_tag = '' if idx is None else ' example %d' % idx
out.append('%s:%d:%s [%s] %s' %
--
2.53.0