Devicetree
 help / color / mirror / Atom feed
From: "Rob Herring (Arm)" <robh@kernel.org>
To: Saravana Kannan <saravanak@google.com>
Cc: "Nícolas F . R . A . Prado" <nfraprado@collabora.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] dt: dt-extract-compatibles: Extract compatibles from function parameters
Date: Tue,  3 Sep 2024 15:07:52 -0500	[thread overview]
Message-ID: <20240903200753.2097911-1-robh@kernel.org> (raw)

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.

Cc: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 scripts/dtc/dt-extract-compatibles | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles
index 5ffb2364409b..13ea66d49e6c 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 (device|machine)_is_compatible() arguments """
+	match_table_list = []
+	for m in re.finditer(rf'{func_name}\(([a-zA-Z0-9_>\(\)"\-]+,\s)*"([a-zA-Z0-9_,-]+)"\)', data):
+		match_table_list.append(m[2])
+
+	return match_table_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
 
-- 
2.45.2


             reply	other threads:[~2024-09-03 20:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03 20:07 Rob Herring (Arm) [this message]
2024-09-03 20:34 ` [PATCH] dt: dt-extract-compatibles: Extract compatibles from function parameters Saravana Kannan
2024-09-04 20:42 ` Nícolas F. R. A. Prado
2024-09-04 21:53   ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240903200753.2097911-1-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfraprado@collabora.com \
    --cc=saravanak@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox