Skip to content

Commit 4c72715

Browse files
committed
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/[email protected]/ Acked-by: Saravana Kannan <[email protected]> Reviewed-by: Nícolas F. R. A. Prado <[email protected]> Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 000f6d5 commit 4c72715

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scripts/dtc/dt-extract-compatibles

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def parse_of_match_table(data):
4646
return match_table_list
4747

4848

49+
def parse_of_functions(data, func_name):
50+
""" Find all compatibles in the last argument of a given function """
51+
compat_list = []
52+
for m in re.finditer(rf'{func_name}\(([a-zA-Z0-9_>\(\)"\-]+,\s)*"([a-zA-Z0-9_,-]+)"\)', data):
53+
compat_list.append(m[2])
54+
55+
return compat_list
56+
57+
4958
def parse_compatibles(file, compat_ignore_list):
5059
with open(file, 'r', encoding='utf-8') as f:
5160
data = f.read().replace('\n', '')
@@ -60,6 +69,10 @@ def parse_compatibles(file, compat_ignore_list):
6069
else:
6170
compat_list = parse_of_declare_macros(data)
6271
compat_list += parse_of_device_id(data)
72+
compat_list += parse_of_functions(data, "_is_compatible")
73+
compat_list += parse_of_functions(data, "of_find_compatible_node")
74+
compat_list += parse_of_functions(data, "for_each_compatible_node")
75+
compat_list += parse_of_functions(data, "of_get_compatible_child")
6376

6477
return compat_list
6578

0 commit comments

Comments
 (0)