Skip to contentSkip to conversation

dt: dt-check-compatible: Find struct of_device_id instances with compiler annotations

PATCH In review Rob Herring 2 participants 2 messages Aug 4, 2023 – Aug 5, 2023 Device tree

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 dt: dt-check-compatible: Find struct of_device_id instances with compiler annotations

The regex search for declarations of struct of_device_id was missing cases that had a compiler annotation such as "__maybe_unused". Improve the regex to allow for these. Use '\S' instead of specific characters to shorten the regex. That also finds some more compatibles using '.' characters.

Unfortunately, these changes add ~400 more compatibles without a schema.

---
 scripts/dtc/dt-extract-compatibles | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/dtc/dt-extract-compatibles +2 -2
index a1119762ed08..9df9f1face83 100755
@@ -25,8 +25,8 @@ def parse_of_declare_macros(data):
 def parse_of_device_id(data):
 	""" Find all compatible strings in of_device_id structs """
 	compat_list = []
-	for m in re.finditer(r'of_device_id\s+[a-zA-Z0-9_]+\[\]\s*=\s*({.*?);', data):
-		compat_list += re.findall(r'\.compatible\s+=\s+"([a-zA-Z0-9_\-,]+)"', m[1])
+	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])
 
 	return compat_list
 
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Rob Herring

The regex search for declarations of struct of_device_id was missing cases that had a compiler annotation such as "__maybe_unused". Improve the regex to allow for these. Use '\S' instead of specific characters to shorten the regex. That also finds some more compatibles using '.' characters.

Unfortunately, these changes add ~400 more compatibles without a schema.

Thanks,
Conor.

Quoted 22 lines
---
 scripts/dtc/dt-extract-compatibles | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/dtc/dt-extract-compatibles +2 -2
index a1119762ed08..9df9f1face83 100755
@@ -25,8 +25,8 @@ def parse_of_declare_macros(data):
 def parse_of_device_id(data):
 	""" Find all compatible strings in of_device_id structs """
 	compat_list = []
-	for m in re.finditer(r'of_device_id\s+[a-zA-Z0-9_]+\[\]\s*=\s*({.*?);', data):
-		compat_list += re.findall(r'\.compatible\s+=\s+"([a-zA-Z0-9_\-,]+)"', m[1])
+	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])
 
 	return compat_list
 
Signature · 1 line
2.40.1