[PATCH v3 07/11] dtc: dt-check-style: Consistently call 'kind' as 'file_type'
Krzysztof Kozlowski <[email protected]>
| Newsgroups | org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260803-n-dts-style-checker-continued-v3-7-6c9776928cea@oss.qualcomm.com> |
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 <[email protected]> --- scripts/dtc/dt-check-style | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/dtc/dt-check-style b/scripts/dtc/dt-check-style index 1c67348fb526..e3adaad1be63 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' @@ -1069,14 +1069,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 @@ -1086,12 +1086,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): @@ -1148,7 +1148,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' @@ -1168,17 +1168,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