Devicetree
 help / color / mirror / Atom feed
* [PATCH v2] checkpatch: Don't emit warnings for ID-base USB & PCI DT compatibles
@ 2026-05-20  8:44 Chen-Yu Tsai
  2026-05-20 22:26 ` Brian Norris
  0 siblings, 1 reply; 2+ messages in thread
From: Chen-Yu Tsai @ 2026-05-20  8:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Whitcroft,
	Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: Chen-Yu Tsai, devicetree, linux-kernel, Brian Norris,
	Yingying Tang

The USB and PCI device bindings define some compatible patterns based
on device IDs that use the comma to separate vendor and product IDs.

These prefix patterns include:

  - ^usb(if)?[0-9a-f]{1,4},
  - ^pci[0-9a-f]{2,4},
  - ^pciclass,

These are not real vendor prefixes. Don't emit warnings for them.
Instead just skip over the DT compatible check altogether, and leave
the real check to the DT validator. This avoids false positive warnings
about undocumented DT vendor prefixes and compatibles.

Note that the script mostly only checks the first compatible string of
each node, as it processes the source file line-by-line, and the check
only matches on the line with 'compatible = "..."'. Otherwise there
would be more warnings from arch/mips/boot/dts/loongson/ls7a-pch.dtsi
since that file also includes compatibles like "pciclass0c0310" and
"pciclass0c03" which are not accepted either. "pci0014,7a24.0" is not
valid either, but this patch leaves the real check to the DT validator.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
Changes since v1:
- Moved check earlier and match against full compatible string to avoid
  false positives for undocumented compatibles as well
- Added comma to patterns as they are now matched against the full
  compatible string
- Fixed patterns in commit message to just cover the prefix portion

This is a simplified version of what Brian Norris previously posted [1],
but more comprehensive and more perl-y than what Yingying Tang posted
[2], which only covered the second pattern.

This is based on next-20260519.

Also, odd observation: the other regex patterns in this script escape
the comma ',', but AFAIK this is not needed.

[1] https://lore.kernel.org/all/20190223022440.146915-1-briannorris@chromium.org/
[2] https://lore.kernel.org/all/20251210073812.1380803-1-yingying.tang@oss.qualcomm.com/
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0d18771f1b01..d4ee9d88ad07 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3783,6 +3783,12 @@ sub process {
 			my $vp_file = $dt_path . "vendor-prefixes.yaml";
 
 			foreach my $compat (@compats) {
+				# Skip ID-based PCI and USB compatible patterns.
+				# DT validation will check them properly.
+				next if $compat =~ /^pciclass,/;
+				next if $compat =~ /^pci[a-f0-9]{2,4},/;
+				next if $compat =~ /^usb(if)?[a-f0-9]{1,4},/;
+
 				my $compat2 = $compat;
 				$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
 				my $compat3 = $compat;
-- 
2.54.0.631.ge1b05301d1-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-20 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20  8:44 [PATCH v2] checkpatch: Don't emit warnings for ID-base USB & PCI DT compatibles Chen-Yu Tsai
2026-05-20 22:26 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox