Skip to content

Commit

Permalink
dt: dt-extract-compatibles: Extract compatibles from function parameters
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
robherring committed Sep 5, 2024
1 parent 000f6d5 commit 4c72715
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/dtc/dt-extract-compatibles
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand All @@ -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

Expand Down

0 comments on commit 4c72715

Please sign in to comment.