summaryrefslogtreecommitdiff
path: root/scripts/dtc
diff options
context:
space:
mode:
authorRob Herring (Arm) <robh@kernel.org>2024-07-17 08:39:55 -0600
committerRob Herring (Arm) <robh@kernel.org>2024-09-05 10:17:03 -0500
commit4c727150a629a59933cbd12ab4230a30789e4c90 (patch)
tree257bd863ea487baf7b73f64e724c311dc256426b /scripts/dtc
parent000f6d588a8f3d128f89351058dc04d38e54a327 (diff)
dt: dt-extract-compatibles: Extract compatibles from function parameters
Various DT and fwnode functions take a compatible string as a parameter. These are often used in cases which don't have a driver, so they've been missed. The additional checks add about 400 more undocumented compatible strings. Link: https://lore.kernel.org/all/20240903200753.2097911-1-robh@kernel.org/ Acked-by: Saravana Kannan <saravanak@google.com> Reviewed-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Diffstat (limited to 'scripts/dtc')
-rwxr-xr-xscripts/dtc/dt-extract-compatibles13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles
index 5ffb2364409b..6570efabaa64 100755
--- a/scripts/dtc/dt-extract-compatibles
+++ b/scripts/dtc/dt-extract-compatibles
@@ -46,6 +46,15 @@ def parse_of_match_table(data):
return match_table_list
+def parse_of_functions(data, func_name):
+ """ Find all compatibles in the last argument of a given function """
+ compat_list = []
+ for m in re.finditer(rf'{func_name}\(([a-zA-Z0-9_>\(\)"\-]+,\s)*"([a-zA-Z0-9_,-]+)"\)', data):
+ compat_list.append(m[2])
+
+ return compat_list
+
+
def parse_compatibles(file, compat_ignore_list):
with open(file, 'r', encoding='utf-8') as f:
data = f.read().replace('\n', '')
@@ -60,6 +69,10 @@ def parse_compatibles(file, compat_ignore_list):
else:
compat_list = parse_of_declare_macros(data)
compat_list += parse_of_device_id(data)
+ compat_list += parse_of_functions(data, "_is_compatible")
+ compat_list += parse_of_functions(data, "of_find_compatible_node")
+ compat_list += parse_of_functions(data, "for_each_compatible_node")
+ compat_list += parse_of_functions(data, "of_get_compatible_child")
return compat_list