Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+13
+13
scripts/dtc/dt-extract-compatibles
··· 46 46 return match_table_list 47 47 48 48 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 + 49 58 def parse_compatibles(file, compat_ignore_list): 50 59 with open(file, 'r', encoding='utf-8') as f: 51 60 data = f.read().replace('\n', '') ··· 69 60 else: 70 61 compat_list = parse_of_declare_macros(data) 71 62 compat_list += parse_of_device_id(data) 63 + compat_list += parse_of_functions(data, "_is_compatible") 64 + compat_list += parse_of_functions(data, "of_find_compatible_node") 65 + compat_list += parse_of_functions(data, "for_each_compatible_node") 66 + compat_list += parse_of_functions(data, "of_get_compatible_child") 72 67 73 68 return compat_list 74 69