diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-10-31 18:50:13 -1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-10-31 18:50:13 -1000 |
commit | 8bc9e6515183935fa0cccaf67455c439afe4982b (patch) | |
tree | 55e65055ce529ac13b3d2f081541a5c91f50a812 /scripts | |
parent | f9ae180416e04bcee4d3cd216a6264a50f9299e6 (diff) | |
parent | fe612629746cf5cc7040529f780d46929605d0a6 (diff) | |
download | linux-stable-8bc9e6515183935fa0cccaf67455c439afe4982b.tar.gz linux-stable-8bc9e6515183935fa0cccaf67455c439afe4982b.tar.bz2 linux-stable-8bc9e6515183935fa0cccaf67455c439afe4982b.zip |
Merge tag 'devicetree-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull devicetree updates from Rob Herring:
- Add a kselftest to check for unprobed DT devices
- Fix address translation for some 3 address cells cases
- Refactor firmware node refcounting for AMBA bus
- Add bindings for qcom,sm4450-pdc, Qualcomm Kryo 465 CPU, and
Freescale QMC HDLC
- Add Marantec vendor prefix
- Convert qcom,pm8921-keypad, cnxt,cx92755-wdt, da9062-wdt, and
atmel,at91rm9200-wdt bindings to DT schema
- Several additionalProperties/unevaluatedProperties on child node
schemas fixes
- Drop reserved-memory bindings which now live in dtschema project
- Fix a reference to rockchip,inno-usb2phy.yaml
- Remove backlight nodes from display panel examples
- Expand example for using DT_SCHEMA_FILES
- Merge simple LVDS panel bindings to one binding doc
* tag 'devicetree-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (34 commits)
dt-bindings: soc: fsl: cpm_qe: cpm1-scc-qmc: Add support for QMC HDLC
dt-bindings: soc: fsl: cpm_qe: cpm1-scc-qmc: Add 'additionalProperties: false' in child nodes
dt-bindings: soc: fsl: cpm_qe: cpm1-scc-qmc: Fix example property name
dt-bindings: arm,coresight-cti: Add missing additionalProperties on child nodes
dt-bindings: arm,coresight-cti: Drop type for 'cpu' property
dt-bindings: soundwire: Add reference to soundwire-controller.yaml schema
dt-bindings: input: syna,rmi4: Make "additionalProperties: true" explicit
media: dt-bindings: ti,ds90ub960: Add missing type for "i2c-alias"
dt-bindings: input: qcom,pm8921-keypad: convert to YAML format
of: overlay: unittest: overlay_bad_unresolved: Spelling s/ok/okay/
of: address: Consolidate bus .map() functions
of: address: Store number of bus flag cells rather than bool
of: unittest: Add tests for address translations
of: address: Remove duplicated functions
of: address: Fix address translation when address-size is greater than 2
dt-bindings: watchdog: cnxt,cx92755-wdt: convert txt to yaml
dt-bindings: watchdog: da9062-wdt: convert txt to yaml
dt-bindings: watchdog: fsl,scu-wdt: Document imx8dl
dt-bindings: watchdog: atmel,at91rm9200-wdt: convert txt to yaml
dt-bindings: usb: rockchip,dwc3: update inno usb2 phy binding name
...
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dtc/dt-extract-compatibles | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles index 9df9f1face83..bd07477dd144 100755 --- a/scripts/dtc/dt-extract-compatibles +++ b/scripts/dtc/dt-extract-compatibles @@ -7,11 +7,15 @@ import re import argparse -def parse_of_declare_macros(data): +def parse_of_declare_macros(data, include_driver_macros=True): """ Find all compatible strings in OF_DECLARE() style macros """ compat_list = [] # CPU_METHOD_OF_DECLARE does not have a compatible string - for m in re.finditer(r'(?<!CPU_METHOD_)(IRQCHIP|OF)_(DECLARE|MATCH)(_DRIVER)?\(.*?\)', data): + if include_driver_macros: + re_macros = r'(?<!CPU_METHOD_)(IRQCHIP|OF)_(DECLARE|MATCH)(_DRIVER)?\(.*?\)' + else: + re_macros = r'(?<!CPU_METHOD_)(IRQCHIP|OF)_(DECLARE|MATCH)\(.*?\)' + for m in re.finditer(re_macros, data): try: compat = re.search(r'"(.*?)"', m[0])[1] except: @@ -22,24 +26,52 @@ def parse_of_declare_macros(data): return compat_list -def parse_of_device_id(data): +def parse_of_device_id(data, match_table_list=None): """ Find all compatible strings in of_device_id structs """ compat_list = [] - for m in re.finditer(r'of_device_id(\s+\S+)?\s+\S+\[\](\s+\S+)?\s*=\s*({.*?);', data): - compat_list += re.findall(r'\.compatible\s+=\s+"(\S+)"', m[3]) + for m in re.finditer(r'of_device_id(\s+\S+)?\s+(\S+)\[\](\s+\S+)?\s*=\s*({.*?);', data): + if match_table_list is not None and m[2] not in match_table_list: + continue + compat_list += re.findall(r'\.compatible\s+=\s+"(\S+)"', m[4]) return compat_list -def parse_compatibles(file): +def parse_of_match_table(data): + """ Find all driver's of_match_table """ + match_table_list = [] + for m in re.finditer(r'\.of_match_table\s+=\s+(of_match_ptr\()?([a-zA-Z0-9_-]+)', data): + match_table_list.append(m[2]) + + return match_table_list + + +def parse_compatibles(file, compat_ignore_list): with open(file, 'r', encoding='utf-8') as f: data = f.read().replace('\n', '') - compat_list = parse_of_declare_macros(data) - compat_list += parse_of_device_id(data) + if compat_ignore_list is not None: + # For a compatible in the DT to be matched to a driver it needs to show + # up in a driver's of_match_table + match_table_list = parse_of_match_table(data) + compat_list = parse_of_device_id(data, match_table_list) + + compat_list = [compat for compat in compat_list if compat not in compat_ignore_list] + else: + compat_list = parse_of_declare_macros(data) + compat_list += parse_of_device_id(data) return compat_list +def parse_compatibles_to_ignore(file): + with open(file, 'r', encoding='utf-8') as f: + data = f.read().replace('\n', '') + + # Compatibles that show up in OF_DECLARE macros can't be expected to + # match a driver, except for the _DRIVER ones. + return parse_of_declare_macros(data, include_driver_macros=False) + + def print_compat(filename, compatibles): if not compatibles: return @@ -49,21 +81,31 @@ def print_compat(filename, compatibles): else: print(*compatibles, sep='\n') +def files_to_parse(path_args): + for f in path_args: + if os.path.isdir(f): + for filename in glob.iglob(f + "/**/*.c", recursive=True): + yield filename + else: + yield f + show_filename = False if __name__ == "__main__": ap = argparse.ArgumentParser() ap.add_argument("cfile", type=str, nargs='*', help="C source files or directories to parse") ap.add_argument('-H', '--with-filename', help="Print filename with compatibles", action="store_true") + ap.add_argument('-d', '--driver-match', help="Only print compatibles that should match to a driver", action="store_true") args = ap.parse_args() show_filename = args.with_filename + compat_ignore_list = None - for f in args.cfile: - if os.path.isdir(f): - for filename in glob.iglob(f + "/**/*.c", recursive=True): - compat_list = parse_compatibles(filename) - print_compat(filename, compat_list) - else: - compat_list = parse_compatibles(f) - print_compat(f, compat_list) + if args.driver_match: + compat_ignore_list = [] + for f in files_to_parse(args.cfile): + compat_ignore_list.extend(parse_compatibles_to_ignore(f)) + + for f in files_to_parse(args.cfile): + compat_list = parse_compatibles(f, compat_ignore_list) + print_compat(f, compat_list) |