* [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
@ 2026-05-14 10:51 Chen-Yu Tsai
2026-05-14 17:40 ` Brian Norris
2026-05-14 18:31 ` sashiko-bot
0 siblings, 2 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2026-05-14 10:51 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 patterns include:
- usb[0-9a-f]{1,4},[0-9a-f]{1,4}
- pci[0-9a-f]{2,4},[0-9a-f]{1,4}
- pciclass,[01][0-9a-f]{3}([0-9a-f]{2})?
These are not real vendor prefixes. Don't emit warnings for them.
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
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.
Hopefully everyone likes this version.
This is based on next-20260508.
[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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3727156e4cca..ccedf152acfd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3795,6 +3795,9 @@ sub process {
next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
my $vendor = $1;
+ next if $vendor eq "pciclass";
+ next if $vendor =~ /^pci[a-f0-9]{2,4}$/;
+ next if $vendor =~ /^usb(if)?[a-f0-9]{1,4}$/;
`grep -Eq "\\"\\^\Q$vendor\E,\\.\\*\\":" $vp_file`;
if ( $? >> 8 ) {
WARN("UNDOCUMENTED_DT_STRING",
--
2.54.0.563.g4f69b47b94-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
2026-05-14 10:51 [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes Chen-Yu Tsai
@ 2026-05-14 17:40 ` Brian Norris
2026-05-14 18:10 ` Joe Perches
2026-05-14 18:31 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Brian Norris @ 2026-05-14 17:40 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Whitcroft,
Joe Perches, Dwaipayan Ray, Lukas Bulwahn, devicetree,
linux-kernel, Yingying Tang
Hi Chen-Yu,
On Thu, May 14, 2026 at 06:51:50PM +0800, Chen-Yu Tsai wrote:
> 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 patterns include:
>
> - usb[0-9a-f]{1,4},[0-9a-f]{1,4}
> - pci[0-9a-f]{2,4},[0-9a-f]{1,4}
> - pciclass,[01][0-9a-f]{3}([0-9a-f]{2})?
>
> These are not real vendor prefixes. Don't emit warnings for them.
>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
> This is a simplified version of what Brian Norris previously posted [1],
Wow, almost forgot about that one. Thanks for the blast from the past.
> but more comprehensive and more perl-y than what Yingying Tang posted
Is "perl-y" a good thing? :)
> [2], which only covered the second pattern.
>
> Hopefully everyone likes this version.
I like any version that eliminates obvious false positives!
But one thing that can be improved: your version still requires that the
full ID string be documented explicitly. For example, this still gives a
false warning:
$ git format-patch -1 --stdout 24af105962c8004edb9f5bf84bc587cbb30e52de | scripts/checkpatch.pl
[...]
WARNING: DT compatible string "pci0014,7a24.0" appears un-documented -- check ./Documentation/devicetree/bindings/
#234: FILE: arch/mips/boot/dts/loongson/ls7a-pch.dtsi:37:
+ compatible = "pci0014,7a24.0",
WARNING: DT compatible string "pci0014,7a14.0" appears un-documented -- check ./Documentation/devicetree/bindings/
#245: FILE: arch/mips/boot/dts/loongson/ls7a-pch.dtsi:48:
+ compatible = "pci0014,7a14.0",
[...]
The dtschema is clear that anything matching the pci pattern is OK, and
we don't need to list every possible variation in a yaml file.
> This is based on next-20260508.
>
> [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 | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3727156e4cca..ccedf152acfd 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3795,6 +3795,9 @@ sub process {
>
> next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
> my $vendor = $1;
> + next if $vendor eq "pciclass";
> + next if $vendor =~ /^pci[a-f0-9]{2,4}$/;
> + next if $vendor =~ /^usb(if)?[a-f0-9]{1,4}$/;
Maybe we can move this "skip pciclass/pci/usb" stuff up a few lines?
Brian
> `grep -Eq "\\"\\^\Q$vendor\E,\\.\\*\\":" $vp_file`;
> if ( $? >> 8 ) {
> WARN("UNDOCUMENTED_DT_STRING",
> --
> 2.54.0.563.g4f69b47b94-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
2026-05-14 17:40 ` Brian Norris
@ 2026-05-14 18:10 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2026-05-14 18:10 UTC (permalink / raw)
To: Brian Norris, Chen-Yu Tsai
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Whitcroft,
Dwaipayan Ray, Lukas Bulwahn, devicetree, linux-kernel,
Yingying Tang
On Thu, 2026-05-14 at 10:40 -0700, Brian Norris wrote:
> Hi Chen-Yu,
> On Thu, May 14, 2026 at 06:51:50PM +0800, Chen-Yu Tsai wrote:
> 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 patterns include:
> >
> > - usb[0-9a-f]{1,4},[0-9a-f]{1,4}
> > - pci[0-9a-f]{2,4},[0-9a-f]{1,4}
> > - pciclass,[01][0-9a-f]{3}([0-9a-f]{2})?
> >
> > These are not real vendor prefixes. Don't emit warnings for them.
> >
> > Signed-off-by: Chen-Yu Tsai <[wenst@chromium.org](mailto:wenst@chromium.org)>
> > ---
> > This is a simplified version of what Brian Norris previously posted [1],
>
> Wow, almost forgot about that one. Thanks for the blast from the past.
You know Brian, you're different than me.
I completely forgot about that one.
> > but more comprehensive and more perl-y than what Yingying Tang posted
> Is "perl-y" a good thing? :)
My sweet wife thinks so. It's spelled differently though.
> > Hopefully everyone likes this version.
> I like any version that eliminates obvious false positives!
>
> But one thing that can be improved: your version still requires that the
> full ID string be documented explicitly. For example, this still gives a
> false warning:
>
> $ git format-patch -1 --stdout 24af105962c8004edb9f5bf84bc587cbb30e52de | scripts/checkpatch.pl
> [...]
> WARNING: DT compatible string "pci0014,7a24.0" appears un-documented -- check ./Documentation/devicetree/bindings/
> #234: FILE: arch/mips/boot/dts/loongson/ls7a-pch.dtsi:37:
> + compatible = "pci0014,7a24.0",
> The dtschema is clear that anything matching the pci pattern is OK, and
> we don't need to list every possible variation in a yaml file.
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > @@ -3795,6 +3795,9 @@ sub process {
> >
> > next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
> > my $vendor = $1;
> > + next if $vendor eq "pciclass";
> > + next if $vendor =~ /^pci[a-f0-9]{2,4}$/;
Maybe
+ next if $vendor =~ /^pci[a-f0-9]{2,4}/;
?
> > + next if $vendor =~ /^usb(if)?[a-f0-9]{1,4}$/;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
2026-05-14 10:51 [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes Chen-Yu Tsai
2026-05-14 17:40 ` Brian Norris
@ 2026-05-14 18:31 ` sashiko-bot
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-05-14 18:31 UTC (permalink / raw)
To: Chen-Yu Tsai; +Cc: devicetree, robh, krzk+dt, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The commit introduces a hardcoded bypass for `pciclass` based on a false premise, masking an underlying bug in checkpatch.pl.
- [Medium] The code implementation silently supports the `usbif` prefix, introducing a meaningful mismatch with the commit message.
--
commit 771fab4f035f631c7cd034c709f25afb0f1dc11b
Author: Chen-Yu Tsai <wenst@chromium.org>
checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
The USB and PCI device bindings define some compatible patterns based
on device IDs that use the comma to separate vendor and product IDs.
This commit skips these prefixes when checking vendor prefixes in
checkpatch.pl.
> These patterns include:
>
> - usb[0-9a-f]{1,4},[0-9a-f]{1,4}
> - pci[0-9a-f]{2,4},[0-9a-f]{1,4}
> - pciclass,[01][0-9a-f]{3}([0-9a-f]{2})?
>
> These are not real vendor prefixes. Don't emit warnings for them.
Is this description accurate regarding pciclass? The commit message assumes
pciclass is not a real vendor prefix. However, looking at
vendor-prefixes.yaml, it is actually defined as part of a grouped regex:
"^(pciclass|pinctrl-single|#pinctrl-single|PowerPC),.*": true
The reason the check fails in checkpatch.pl isn't because it is a fake prefix,
but because the grep command below uses a literal match:
grep -Eq "\"^\Q$vendor\E,\.*\":" $vp_file;
Does this workaround paper over the underlying issue with the grep
command not matching grouped regexes, which would also affect other valid
prefixes like pinctrl-single or exynos?
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3727156e4ccad..ccedf152acfd7 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3795,6 +3795,9 @@ sub process {
>
> next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
> my $vendor = $1;
> + next if $vendor eq "pciclass";
> + next if $vendor =~ /^pci[a-f0-9]{2,4}$/;
> + next if $vendor =~ /^usb(if)?[a-f0-9]{1,4}$/;
The commit message explicitly lists usb[0-9a-f]{1,4},[0-9a-f]{1,4} as the
supported pattern for USB, but the implementation here silently supports the
usbif prefix as well.
While usbif is a valid prefix for USB interface bindings, could the commit
message be updated to reflect its undocumented inclusion in this regex?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260514105151.2771474-1-wenst@chromium.org?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-14 18:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 10:51 [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes Chen-Yu Tsai
2026-05-14 17:40 ` Brian Norris
2026-05-14 18:10 ` Joe Perches
2026-05-14 18:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox