summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>2026-08-26 13:15:56 +0200
committerRob Herring (Arm) <robh@kernel.org>2026-08-31 08:23:17 -0500
commita3b23ea1e3bbc17b1d974dce82ff16d5def368fe (patch)
tree5da744703cba96cc72a4ff411ab2b54f237e8b3d /scripts
parent98d3da8dc2cc5699a8f39426907cff694acb4aaf (diff)
dtc: dt-check-style: Consistently call 'kind' as 'file_type'
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dtc/dt-check-style26
1 files changed, 13 insertions, 13 deletions
diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style
index eb5045f0ad9e..17332018d70b 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'
@@ -1071,14 +1071,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
@@ -1088,12 +1088,12 @@ def select_rules(mode, input_kind):
# Block runner
# ---------------------------------------------------------------------------
-def check_block(text, mode, input_type):
+def check_block(text, mode, file_type):
"""Run all selected rules on a single block of DTS text. Returns a
list of (lineno, rule_name, message) tuples."""
lines = classify_lines(text)
- ctx = Ctx(lines, text, mode, input_type)
- rules = select_rules(mode, input_type)
+ ctx = Ctx(lines, text, mode, file_type)
+ rules = select_rules(mode, file_type)
findings = []
for r in rules:
for lineno, msg in r.check(ctx):
@@ -1150,7 +1150,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'
@@ -1170,17 +1170,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' %